org.elasticsearch.repositories.RepositoriesService Java Examples

The following examples show how to use org.elasticsearch.repositories.RepositoriesService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransportPutRepositoryAction.java    From crate with Apache License 2.0 6 votes vote down vote up
@Override
protected void masterOperation(final PutRepositoryRequest request, ClusterState state, final ActionListener<AcknowledgedResponse> listener) {
    repositoriesService.registerRepository(
        new RepositoriesService.RegisterRepositoryRequest(
            "put_repository [" + request.name() + "]",
            request.name(),
            request.type(),
            request.verify()
        )
        .settings(request.settings())
        .masterNodeTimeout(request.masterNodeTimeout())
        .ackTimeout(request.timeout()),
        new ActionListener<ClusterStateUpdateResponse>() {
            @Override
            public void onResponse(ClusterStateUpdateResponse response) {
                listener.onResponse(new AcknowledgedResponse(response.isAcknowledged()));
            }

            @Override
            public void onFailure(Exception e) {
                listener.onFailure(e);
            }
        }
    );
}
 
Example #2
Source File: TransportDeleteRepositoryAction.java    From crate with Apache License 2.0 6 votes vote down vote up
@Override
protected void masterOperation(final DeleteRepositoryRequest request, ClusterState state, final ActionListener<AcknowledgedResponse> listener) {
    repositoriesService.unregisterRepository(
            new RepositoriesService.UnregisterRepositoryRequest("delete_repository [" + request.name() + "]", request.name())
                    .masterNodeTimeout(request.masterNodeTimeout()).ackTimeout(request.timeout()),
            new ActionListener<ClusterStateUpdateResponse>() {
                @Override
                public void onResponse(ClusterStateUpdateResponse unregisterRepositoryResponse) {
                    listener.onResponse(new AcknowledgedResponse(unregisterRepositoryResponse.isAcknowledged()));
                }

                @Override
                public void onFailure(Exception e) {
                    listener.onFailure(e);
                }
            });
}
 
Example #3
Source File: TransportDeleteRepositoryAction.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
protected void masterOperation(final DeleteRepositoryRequest request, ClusterState state, final ActionListener<DeleteRepositoryResponse> listener) {
    repositoriesService.unregisterRepository(
            new RepositoriesService.UnregisterRepositoryRequest("delete_repository [" + request.name() + "]", request.name())
                    .masterNodeTimeout(request.masterNodeTimeout()).ackTimeout(request.timeout()),
            new ActionListener<ClusterStateUpdateResponse>() {
                @Override
                public void onResponse(ClusterStateUpdateResponse unregisterRepositoryResponse) {
                    listener.onResponse(new DeleteRepositoryResponse(unregisterRepositoryResponse.isAcknowledged()));
                }

                @Override
                public void onFailure(Throwable e) {
                    listener.onFailure(e);
                }
            });
}
 
Example #4
Source File: TransportPutRepositoryAction.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
protected void masterOperation(final PutRepositoryRequest request, ClusterState state, final ActionListener<PutRepositoryResponse> listener) {

    repositoriesService.registerRepository(
            new RepositoriesService.RegisterRepositoryRequest("put_repository [" + request.name() + "]",
                    request.name(), request.type(), request.verify())
            .settings(request.settings())
            .masterNodeTimeout(request.masterNodeTimeout())
            .ackTimeout(request.timeout()), new ActionListener<ClusterStateUpdateResponse>() {

        @Override
        public void onResponse(ClusterStateUpdateResponse response) {
            listener.onResponse(new PutRepositoryResponse(response.isAcknowledged()));
        }

        @Override
        public void onFailure(Throwable e) {
            listener.onFailure(e);
        }
    });
}
 
Example #5
Source File: SnapshotShardsService.java    From crate with Apache License 2.0 6 votes vote down vote up
@Inject
public SnapshotShardsService(Settings settings, ClusterService clusterService, RepositoriesService repositoriesService,
                             ThreadPool threadPool, TransportService transportService, IndicesService indicesService,
                             IndexNameExpressionResolver indexNameExpressionResolver) {
    this.indicesService = indicesService;
    this.repositoriesService = repositoriesService;
    this.transportService = transportService;
    this.clusterService = clusterService;
    this.threadPool = threadPool;
    if (DiscoveryNode.isDataNode(settings)) {
        // this is only useful on the nodes that can hold data
        clusterService.addListener(this);
    }

    // The constructor of UpdateSnapshotStatusAction will register itself to the TransportService.
    this.updateSnapshotStatusHandler =
        new UpdateSnapshotStatusAction(transportService, clusterService, threadPool, indexNameExpressionResolver);
}
 
Example #6
Source File: TransportVerifyRepositoryAction.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
protected void masterOperation(final VerifyRepositoryRequest request, ClusterState state, final ActionListener<VerifyRepositoryResponse> listener) {
    repositoriesService.verifyRepository(request.name(), new  ActionListener<RepositoriesService.VerifyResponse>() {
        @Override
        public void onResponse(RepositoriesService.VerifyResponse verifyResponse) {
            if (verifyResponse.failed()) {
                listener.onFailure(new RepositoryVerificationException(request.name(), verifyResponse.failureDescription()));
            } else {
                listener.onResponse(new VerifyRepositoryResponse(clusterName, verifyResponse.nodes()));
            }
        }

        @Override
        public void onFailure(Throwable e) {
            listener.onFailure(e);
        }
    });
}
 
Example #7
Source File: IndicesClusterStateService.java    From crate with Apache License 2.0 6 votes vote down vote up
@Inject
public IndicesClusterStateService(Settings settings,
                                  IndicesService indicesService,
                                  ClusterService clusterService,
                                  ThreadPool threadPool,
                                  PeerRecoveryTargetService recoveryTargetService,
                                  ShardStateAction shardStateAction,
                                  NodeMappingRefreshAction nodeMappingRefreshAction,
                                  RepositoriesService repositoriesService,
                                  SyncedFlushService syncedFlushService,
                                  PeerRecoverySourceService peerRecoverySourceService,
                                  SnapshotShardsService snapshotShardsService,
                                  PrimaryReplicaSyncer primaryReplicaSyncer,
                                  GlobalCheckpointSyncAction globalCheckpointSyncAction) {
    this(settings, (AllocatedIndices<? extends Shard, ? extends AllocatedIndex<? extends Shard>>) indicesService,
            clusterService, threadPool, recoveryTargetService, shardStateAction,
            nodeMappingRefreshAction, repositoriesService, syncedFlushService, peerRecoverySourceService,
            snapshotShardsService, primaryReplicaSyncer, globalCheckpointSyncAction::updateGlobalCheckpointForShard);
}
 
Example #8
Source File: IndicesService.java    From crate with Apache License 2.0 6 votes vote down vote up
@Override
public IndexShard createShard(ShardRouting shardRouting, RecoveryState recoveryState, PeerRecoveryTargetService recoveryTargetService,
                              PeerRecoveryTargetService.RecoveryListener recoveryListener, RepositoriesService repositoriesService,
                              Consumer<IndexShard.ShardFailure> onShardFailure,
                              Consumer<ShardId> globalCheckpointSyncer) throws IOException {
    ensureChangesAllowed();
    IndexService indexService = indexService(shardRouting.index());
    IndexShard indexShard = indexService.createShard(shardRouting, globalCheckpointSyncer);
    indexShard.addShardFailureCallback(onShardFailure);
    indexShard.startRecovery(recoveryState, recoveryTargetService, recoveryListener, repositoriesService,
        (type, mapping) -> {
            assert recoveryState.getRecoverySource().getType() == RecoverySource.Type.LOCAL_SHARDS :
                "mapping update consumer only required by local shards recovery";
            client.admin().indices().preparePutMapping()
                .setConcreteIndex(shardRouting.index()) // concrete index - no name clash, it uses uuid
                .setType(type)
                .setSource(mapping.source().string(), XContentType.JSON)
                .get();
        }, this);
    return indexShard;
}
 
Example #9
Source File: SnapshotsService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public SnapshotsService(Settings settings, ClusterService clusterService, IndexNameExpressionResolver indexNameExpressionResolver, RepositoriesService repositoriesService, ThreadPool threadPool) {
    super(settings);
    this.clusterService = clusterService;
    this.indexNameExpressionResolver = indexNameExpressionResolver;
    this.repositoriesService = repositoriesService;
    this.threadPool = threadPool;

    if (DiscoveryNode.masterNode(settings)) {
        // addLast to make sure that Repository will be created before snapshot
        clusterService.addLast(this);
    }
}
 
Example #10
Source File: SnapshotRestoreIntegrationTest.java    From crate with Apache License 2.0 5 votes vote down vote up
private RepositoryData getRepositoryData() throws Exception {
    RepositoriesService service = internalCluster().getInstance(RepositoriesService.class, internalCluster().getMasterName());
    Repository repository = service.repository(REPOSITORY_NAME);
    ThreadPool threadPool = internalCluster().getInstance(ThreadPool.class, internalCluster().getMasterName());
    final SetOnce<RepositoryData> repositoryData = new SetOnce<>();
    final CountDownLatch latch = new CountDownLatch(1);
    threadPool.executor(ThreadPool.Names.SNAPSHOT).execute(() -> {
        repositoryData.set(repository.getRepositoryData());
        latch.countDown();
    });
    latch.await();
    return repositoryData.get();
}
 
Example #11
Source File: TransportPutRepositoryAction.java    From crate with Apache License 2.0 5 votes vote down vote up
@Inject
public TransportPutRepositoryAction(TransportService transportService,
                                    ClusterService clusterService,
                                    RepositoriesService repositoriesService,
                                    ThreadPool threadPool,
                                    IndexNameExpressionResolver indexNameExpressionResolver) {
    super(PutRepositoryAction.NAME, transportService, clusterService, threadPool, PutRepositoryRequest::new, indexNameExpressionResolver);
    this.repositoriesService = repositoriesService;
}
 
Example #12
Source File: TransportDeleteRepositoryAction.java    From crate with Apache License 2.0 5 votes vote down vote up
@Inject
public TransportDeleteRepositoryAction(TransportService transportService,
                                       ClusterService clusterService,
                                       RepositoriesService repositoriesService,
                                       ThreadPool threadPool,
                                       IndexNameExpressionResolver indexNameExpressionResolver) {
    super(DeleteRepositoryAction.NAME, transportService, clusterService, threadPool, DeleteRepositoryRequest::new, indexNameExpressionResolver);
    this.repositoriesService = repositoriesService;
}
 
Example #13
Source File: RestoreService.java    From crate with Apache License 2.0 5 votes vote down vote up
@Inject
public RestoreService(ClusterService clusterService, RepositoriesService repositoriesService,
                      AllocationService allocationService, MetaDataCreateIndexService createIndexService,
                      MetaDataIndexUpgradeService metaDataIndexUpgradeService, ClusterSettings clusterSettings) {
    this.clusterService = clusterService;
    this.repositoriesService = repositoriesService;
    this.allocationService = allocationService;
    this.createIndexService = createIndexService;
    this.metaDataIndexUpgradeService = metaDataIndexUpgradeService;
    clusterService.addStateApplier(this);
    this.clusterSettings = clusterSettings;
    this.cleanRestoreStateTaskExecutor = new CleanRestoreStateTaskExecutor(LOGGER);
}
 
Example #14
Source File: SnapshotsService.java    From crate with Apache License 2.0 5 votes vote down vote up
@Inject
public SnapshotsService(Settings settings, ClusterService clusterService, IndexNameExpressionResolver indexNameExpressionResolver,
                        RepositoriesService repositoriesService, ThreadPool threadPool) {
    this.clusterService = clusterService;
    this.indexNameExpressionResolver = indexNameExpressionResolver;
    this.repositoriesService = repositoriesService;
    this.threadPool = threadPool;

    if (DiscoveryNode.isMasterNode(settings)) {
        // addLowPriorityApplier to make sure that Repository will be created before snapshot
        clusterService.addLowPriorityApplier(this);
    }
}
 
Example #15
Source File: IndicesClusterStateService.java    From crate with Apache License 2.0 5 votes vote down vote up
IndicesClusterStateService(Settings settings,
                           AllocatedIndices<? extends Shard, ? extends AllocatedIndex<? extends Shard>> indicesService,
                           ClusterService clusterService,
                           ThreadPool threadPool,
                           PeerRecoveryTargetService recoveryTargetService,
                           ShardStateAction shardStateAction,
                           NodeMappingRefreshAction nodeMappingRefreshAction,
                           RepositoriesService repositoriesService,
                           SyncedFlushService syncedFlushService,
                           PeerRecoverySourceService peerRecoverySourceService,
                           SnapshotShardsService snapshotShardsService,
                           PrimaryReplicaSyncer primaryReplicaSyncer,
                           Consumer<ShardId> globalCheckpointSyncer) {
    this.buildInIndexListener =
            Arrays.asList(
                    peerRecoverySourceService,
                    recoveryTargetService,
                    syncedFlushService,
                    snapshotShardsService);
    this.settings = settings;
    this.indicesService = indicesService;
    this.clusterService = clusterService;
    this.threadPool = threadPool;
    this.recoveryTargetService = recoveryTargetService;
    this.shardStateAction = shardStateAction;
    this.nodeMappingRefreshAction = nodeMappingRefreshAction;
    this.repositoriesService = repositoriesService;
    this.primaryReplicaSyncer = primaryReplicaSyncer;
    this.globalCheckpointSyncer = globalCheckpointSyncer;
    this.sendRefreshMapping = settings.getAsBoolean("indices.cluster.send_refresh_mapping", true);
}
 
Example #16
Source File: TransportVerifyRepositoryAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public TransportVerifyRepositoryAction(Settings settings, ClusterName clusterName, TransportService transportService, ClusterService clusterService,
                                       RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters,
                                       IndexNameExpressionResolver indexNameExpressionResolver) {
    super(settings, VerifyRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, VerifyRepositoryRequest.class);
    this.repositoriesService = repositoriesService;
    this.clusterName = clusterName;
}
 
Example #17
Source File: TransportPutRepositoryAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public TransportPutRepositoryAction(Settings settings, TransportService transportService, ClusterService clusterService,
                                    RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters,
                                    IndexNameExpressionResolver indexNameExpressionResolver) {
    super(settings, PutRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, PutRepositoryRequest.class);
    this.repositoriesService = repositoriesService;
}
 
Example #18
Source File: TransportDeleteRepositoryAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public TransportDeleteRepositoryAction(Settings settings, TransportService transportService, ClusterService clusterService,
                                       RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters,
                                       IndexNameExpressionResolver indexNameExpressionResolver) {
    super(settings, DeleteRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, DeleteRepositoryRequest.class);
    this.repositoriesService = repositoriesService;
}
 
Example #19
Source File: RestoreService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public RestoreService(Settings settings, ClusterService clusterService, RepositoriesService repositoriesService, TransportService transportService,
                      AllocationService allocationService, MetaDataCreateIndexService createIndexService, @ClusterDynamicSettings DynamicSettings dynamicSettings,
                      MetaDataIndexUpgradeService metaDataIndexUpgradeService) {
    super(settings);
    this.clusterService = clusterService;
    this.repositoriesService = repositoriesService;
    this.transportService = transportService;
    this.allocationService = allocationService;
    this.createIndexService = createIndexService;
    this.dynamicSettings = dynamicSettings;
    this.metaDataIndexUpgradeService = metaDataIndexUpgradeService;
    transportService.registerRequestHandler(UPDATE_RESTORE_ACTION_NAME, UpdateIndexShardRestoreStatusRequest.class, ThreadPool.Names.SAME, new UpdateRestoreStateRequestHandler());
    clusterService.add(this);
}
 
Example #20
Source File: StoreRecoveryService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public StoreRecoveryService(ShardId shardId, IndexSettingsService indexSettingsService, ThreadPool threadPool,
                            MappingUpdatedAction mappingUpdatedAction, ClusterService clusterService, RepositoriesService repositoriesService, RestoreService restoreService) {
    super(shardId, indexSettingsService.getSettings());
    this.threadPool = threadPool;
    this.mappingUpdatedAction = mappingUpdatedAction;
    this.restoreService = restoreService;
    this.repositoriesService = repositoriesService;
    this.clusterService = clusterService;
    this.waitForMappingUpdatePostRecovery = indexSettings.getAsTime(SETTING_MAPPING_UPDATE_WAIT, indexSettings.getAsTime(SETTING_MAPPING_UPDATE_WAIT_LEGACY, TimeValue.timeValueSeconds(15)));
}
 
Example #21
Source File: IndicesClusterStateService.java    From crate with Apache License 2.0 4 votes vote down vote up
/**
 * Creates shard for the specified shard routing and starts recovery,
 */
T createShard(ShardRouting shardRouting, RecoveryState recoveryState, PeerRecoveryTargetService recoveryTargetService,
              PeerRecoveryTargetService.RecoveryListener recoveryListener, RepositoriesService repositoriesService,
              Consumer<IndexShard.ShardFailure> onShardFailure,
              Consumer<ShardId> globalCheckpointSyncer) throws IOException;
 
Example #22
Source File: SnapshotsService.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public RepositoriesService getRepositoriesService() {
    return repositoriesService;
}
 
Example #23
Source File: SysTableDefinitions.java    From crate with Apache License 2.0 4 votes vote down vote up
@Inject
public SysTableDefinitions(JobsLogs jobsLogs,
                           ClusterService clusterService,
                           SysSchemaInfo sysSchemaInfo,
                           Set<SysCheck> sysChecks,
                           SysNodeChecks sysNodeChecks,
                           RepositoriesService repositoriesService,
                           SysSnapshots sysSnapshots,
                           SysAllocations sysAllocations,
                           ShardSegments shardSegmentInfos,
                           TableHealthService tableHealthService) {
    Supplier<DiscoveryNode> localNode = clusterService::localNode;
    var sysClusterTableInfo = (SystemTable<Void>) sysSchemaInfo.getTableInfo(SysClusterTableInfo.IDENT.name());
    assert sysClusterTableInfo != null : "sys.cluster table must exist in sys schema";
    tableDefinitions.put(SysClusterTableInfo.IDENT, new StaticTableDefinition<>(
        () -> completedFuture(Collections.singletonList(null)),
        sysClusterTableInfo.expressions(),
        false
    ));
    var sysJobsTable = SysJobsTableInfo.create(localNode);
    tableDefinitions.put(SysJobsTableInfo.IDENT, new StaticTableDefinition<>(
        () -> completedFuture(jobsLogs.activeJobs()),
        sysJobsTable.expressions(),
        (user, jobCtx) -> user.isSuperUser() || user.name().equals(jobCtx.username()),
        false));
    var sysJobsLogTable = SysJobsLogTableInfo.create(localNode);
    tableDefinitions.put(SysJobsLogTableInfo.IDENT, new StaticTableDefinition<>(
        () -> completedFuture(jobsLogs.jobsLog()),
        sysJobsLogTable.expressions(),
        (user, jobCtx) -> user.isSuperUser() || user.name().equals(jobCtx.username()),
        false));
    tableDefinitions.put(SysOperationsTableInfo.IDENT, new StaticTableDefinition<>(
        () -> completedFuture(jobsLogs.activeOperations()),
        SysOperationsTableInfo.create(localNode).expressions(),
        false));
    tableDefinitions.put(SysOperationsLogTableInfo.IDENT, new StaticTableDefinition<>(
        () -> completedFuture(jobsLogs.operationsLog()),
        SysOperationsLogTableInfo.create().expressions(),
        false));

    SysChecker<SysCheck> sysChecker = new SysChecker<>(sysChecks);
    tableDefinitions.put(SysChecksTableInfo.IDENT, new StaticTableDefinition<>(
        sysChecker::computeResultAndGet,
        SysChecksTableInfo.create().expressions(),
        true));

    tableDefinitions.put(SysNodeChecksTableInfo.IDENT, new StaticTableDefinition<>(
        () -> completedFuture(sysNodeChecks),
        SysNodeChecksTableInfo.create().expressions(),
        true));
    tableDefinitions.put(SysRepositoriesTableInfo.IDENT, new StaticTableDefinition<>(
        () -> completedFuture(repositoriesService.getRepositoriesList()),
        SysRepositoriesTableInfo.create(clusterService.getClusterSettings().maskedSettings()).expressions(),
        false));
    tableDefinitions.put(SysSnapshotsTableInfo.IDENT, new StaticTableDefinition<>(
        () -> completedFuture(sysSnapshots.currentSnapshots()),
        SysSnapshotsTableInfo.create().expressions(),
        true));

    tableDefinitions.put(SysAllocationsTableInfo.IDENT, new StaticTableDefinition<>(
        () -> sysAllocations,
        (user, allocation) -> user.hasAnyPrivilege(Privilege.Clazz.TABLE, allocation.fqn()),
        SysAllocationsTableInfo.create().expressions()
    ));

    SummitsIterable summits = new SummitsIterable();
    tableDefinitions.put(SysSummitsTableInfo.IDENT, new StaticTableDefinition<>(
        () -> completedFuture(summits),
        SysSummitsTableInfo.create().expressions(),
        false));

    SystemTable<TableHealth> sysHealth = SysHealth.create();
    tableDefinitions.put(SysHealth.IDENT, new StaticTableDefinition<>(
        tableHealthService::computeResults,
        sysHealth.expressions(),
        (user, tableHealth) -> user.hasAnyPrivilege(Privilege.Clazz.TABLE, tableHealth.fqn()),
        true)
    );
    tableDefinitions.put(SysMetricsTableInfo.NAME, new StaticTableDefinition<>(
        () -> completedFuture(jobsLogs.metrics()),
        SysMetricsTableInfo.create(localNode).expressions(),
        false));
    tableDefinitions.put(SysSegmentsTableInfo.IDENT, new StaticTableDefinition<>(
        () -> completedFuture(shardSegmentInfos),
        SysSegmentsTableInfo.create(clusterService::localNode).expressions(),
        true));
}
 
Example #24
Source File: SysSnapshots.java    From crate with Apache License 2.0 4 votes vote down vote up
@Inject
public SysSnapshots(RepositoriesService repositoriesService) {
    this(repositoriesService::getRepositoriesList);
}
 
Example #25
Source File: BlobStoreRepositoryTest.java    From crate with Apache License 2.0 4 votes vote down vote up
protected BlobStoreRepository getRepository() throws Exception {
    RepositoriesService service = internalCluster().getInstance(RepositoriesService.class, internalCluster().getMasterName());
    return (BlobStoreRepository) service.repository(REPOSITORY_NAME);
}