org.elasticsearch.indices.IndicesService Java Examples

The following examples show how to use org.elasticsearch.indices.IndicesService. 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: InternalTestCluster.java    From crate with Apache License 2.0 6 votes vote down vote up
synchronized String routingKeyForShard(Index index, int shard, Random random) {
    assertThat(shard, greaterThanOrEqualTo(0));
    assertThat(shard, greaterThanOrEqualTo(0));
    for (NodeAndClient n : nodes.values()) {
        Node node = n.node;
        IndicesService indicesService = getInstanceFromNode(IndicesService.class, node);
        ClusterService clusterService = getInstanceFromNode(ClusterService.class, node);
        IndexService indexService = indicesService.indexService(index);
        if (indexService != null) {
            assertThat(indexService.getIndexSettings().getSettings().getAsInt(IndexMetaData.SETTING_NUMBER_OF_SHARDS, -1),
                    greaterThan(shard));
            OperationRouting operationRouting = clusterService.operationRouting();
            while (true) {
                String routing = RandomStrings.randomAsciiOfLength(random, 10);
                final int targetShard = operationRouting
                        .indexShards(clusterService.state(), index.getName(), null, routing)
                        .shardId().getId();
                if (shard == targetShard) {
                    return routing;
                }
            }
        }
    }
    fail("Could not find a node that holds " + index);
    return null;
}
 
Example #2
Source File: TransportForceMergeAction.java    From crate with Apache License 2.0 6 votes vote down vote up
@Inject
public TransportForceMergeAction(ThreadPool threadPool,
                                 ClusterService clusterService,
                                 TransportService transportService,
                                 IndicesService indicesService,
                                 IndexNameExpressionResolver indexNameExpressionResolver) {
    super(
        ForceMergeAction.NAME,
        threadPool,
        clusterService,
        transportService,
        indexNameExpressionResolver,
        ForceMergeRequest::new,
        ThreadPool.Names.FORCE_MERGE,
        true
    );
    this.indicesService = indicesService;
}
 
Example #3
Source File: TransportShardUpsertAction.java    From crate with Apache License 2.0 6 votes vote down vote up
@Inject
public TransportShardUpsertAction(ThreadPool threadPool,
                                  ClusterService clusterService,
                                  TransportService transportService,
                                  SchemaUpdateClient schemaUpdateClient,
                                  TasksService tasksService,
                                  IndicesService indicesService,
                                  ShardStateAction shardStateAction,
                                  Functions functions,
                                  Schemas schemas,
                                  IndexNameExpressionResolver indexNameExpressionResolver) {
    super(
        ACTION_NAME,
        transportService,
        indexNameExpressionResolver,
        clusterService,
        indicesService,
        threadPool,
        shardStateAction,
        ShardUpsertRequest::new,
        schemaUpdateClient
    );
    this.schemas = schemas;
    this.functions = functions;
    tasksService.addListener(this);
}
 
Example #4
Source File: InternalTestCluster.java    From crate with Apache License 2.0 6 votes vote down vote up
private void assertNoPendingIndexOperations() throws Exception {
    assertBusy(() -> {
        for (NodeAndClient nodeAndClient : nodes.values()) {
            IndicesService indexServices = getInstance(IndicesService.class, nodeAndClient.name);
            for (IndexService indexService : indexServices) {
                for (IndexShard indexShard : indexService) {
                    List<String> operations = indexShard.getActiveOperations();
                    if (operations.size() > 0) {
                        throw new AssertionError(
                            "shard " + indexShard.shardId() + " on node [" + nodeAndClient.name + "] has pending operations:\n --> " +
                                String.join("\n --> ", operations)
                        );
                    }
                }
            }
        }
    });
}
 
Example #5
Source File: TransportWriteAction.java    From crate with Apache License 2.0 6 votes vote down vote up
protected TransportWriteAction(String actionName,
                               TransportService transportService,
                               ClusterService clusterService,
                               IndicesService indicesService,
                               ThreadPool threadPool,
                               ShardStateAction shardStateAction,
                               IndexNameExpressionResolver indexNameExpressionResolver,
                               Writeable.Reader<Request> reader,
                               Writeable.Reader<ReplicaRequest> replicaReader,
                               String executor) {
    super(
        actionName,
        transportService,
        clusterService,
        indicesService,
        threadPool,
        shardStateAction,
        indexNameExpressionResolver,
        reader,
        replicaReader,
        executor,
        true);
}
 
Example #6
Source File: TransportStartBlobAction.java    From crate with Apache License 2.0 6 votes vote down vote up
@Inject
public TransportStartBlobAction(Settings settings,
                                TransportService transportService,
                                ClusterService clusterService,
                                IndicesService indicesService,
                                ThreadPool threadPool,
                                ShardStateAction shardStateAction,
                                BlobTransferTarget transferTarget,
                                IndexNameExpressionResolver indexNameExpressionResolver) {
    super(
        StartBlobAction.NAME,
        transportService,
        clusterService,
        indicesService,
        threadPool,
        shardStateAction,
        indexNameExpressionResolver,
        StartBlobRequest::new,
        StartBlobRequest::new,
        ThreadPool.Names.WRITE
    );
    this.transferTarget = transferTarget;
    logger.trace("Constructor");
}
 
Example #7
Source File: TransportStartBlobAction.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public TransportStartBlobAction(Settings settings,
                                TransportService transportService,
                                ClusterService clusterService,
                                IndicesService indicesService,
                                ThreadPool threadPool,
                                ShardStateAction shardStateAction,
                                BlobTransferTarget transferTarget,
                                MappingUpdatedAction mappingUpdatedAction,
                                ActionFilters actionFilters,
                                IndexNameExpressionResolver indexNameExpressionResolver) {
    super(settings, StartBlobAction.NAME, transportService, clusterService,
            indicesService, threadPool, shardStateAction, mappingUpdatedAction, actionFilters,
            indexNameExpressionResolver, StartBlobRequest.class, StartBlobRequest.class, ThreadPool.Names.INDEX);

    this.transferTarget = transferTarget;
    logger.trace("Constructor");
}
 
Example #8
Source File: BlobIndices.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public BlobIndices(Settings settings,
                   Provider<TransportCreateIndexAction> transportCreateIndexActionProvider,
                   Provider<TransportDeleteIndexAction> transportDeleteIndexActionProvider,
                   Provider<TransportUpdateSettingsAction> transportUpdateSettingsActionProvider,
                   IndicesService indicesService,
                   IndicesLifecycle indicesLifecycle,
                   BlobEnvironment blobEnvironment,
                   ClusterService clusterService) {
    super(settings);
    this.transportCreateIndexActionProvider = transportCreateIndexActionProvider;
    this.transportDeleteIndexActionProvider = transportDeleteIndexActionProvider;
    this.transportUpdateSettingsActionProvider = transportUpdateSettingsActionProvider;
    this.indicesService = indicesService;
    this.indicesLifecycle = indicesLifecycle;
    this.blobEnvironment = blobEnvironment;
    clusterService.addFirst(this);
    logger.setLevel("debug");
}
 
Example #9
Source File: TransportDeleteBlobAction.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public TransportDeleteBlobAction(Settings settings,
                                 TransportService transportService,
                                 ClusterService clusterService,
                                 IndicesService indicesService,
                                 ThreadPool threadPool,
                                 ShardStateAction shardStateAction,
                                 BlobIndices blobIndices,
                                 MappingUpdatedAction mappingUpdatedAction,
                                 ActionFilters actionFilters,
                                 IndexNameExpressionResolver indexNameExpressionResolver) {
    super(settings, DeleteBlobAction.NAME, transportService, clusterService, indicesService, threadPool, shardStateAction,
            mappingUpdatedAction, actionFilters, indexNameExpressionResolver, DeleteBlobRequest.class, DeleteBlobRequest.class, ThreadPool.Names.INDEX);
    this.blobIndices = blobIndices;
    logger.trace("Constructor");
}
 
Example #10
Source File: ShardCollectSource.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public ShardCollectSource(Settings settings,
                          IndexNameExpressionResolver indexNameExpressionResolver,
                          IndicesService indicesService,
                          Functions functions,
                          ClusterService clusterService,
                          ThreadPool threadPool,
                          TransportActionProvider transportActionProvider,
                          BulkRetryCoordinatorPool bulkRetryCoordinatorPool,
                          RemoteCollectorFactory remoteCollectorFactory,
                          SystemCollectSource systemCollectSource,
                          NodeSysExpression nodeSysExpression) {
    this.settings = settings;
    this.indexNameExpressionResolver = indexNameExpressionResolver;
    this.indicesService = indicesService;
    this.functions = functions;
    this.clusterService = clusterService;
    this.threadPool = threadPool;
    this.remoteCollectorFactory = remoteCollectorFactory;
    this.systemCollectSource = systemCollectSource;
    this.executor = MoreExecutors.listeningDecorator((ExecutorService) threadPool.executor(ThreadPool.Names.SEARCH));
    this.transportActionProvider = transportActionProvider;
    this.bulkRetryCoordinatorPool = bulkRetryCoordinatorPool;
    this.nodeSysExpression = nodeSysExpression;
}
 
Example #11
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 #12
Source File: TransportNodesListShardStoreMetaData.java    From crate with Apache License 2.0 6 votes vote down vote up
@Inject
public TransportNodesListShardStoreMetaData(Settings settings,
                                            ThreadPool threadPool,
                                            ClusterService clusterService,
                                            TransportService transportService,
                                            IndicesService indicesService,
                                            NodeEnvironment nodeEnv,
                                            IndexNameExpressionResolver indexNameExpressionResolver,
                                            NamedXContentRegistry namedXContentRegistry) {
    super(ACTION_NAME, threadPool, clusterService, transportService, indexNameExpressionResolver,
        Request::new, NodeRequest::new, ThreadPool.Names.FETCH_SHARD_STORE, NodeStoreFilesMetaData.class);
    this.settings = settings;
    this.indicesService = indicesService;
    this.nodeEnv = nodeEnv;
    this.namedXContentRegistry = namedXContentRegistry;
}
 
Example #13
Source File: TransportPutChunkAction.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public TransportPutChunkAction(Settings settings,
                               TransportService transportService,
                               ClusterService clusterService,
                               IndicesService indicesService,
                               ThreadPool threadPool,
                               ShardStateAction shardStateAction,
                               BlobTransferTarget transferTarget,
                               MappingUpdatedAction mappingUpdatedAction,
                               ActionFilters actionFilters,
                               IndexNameExpressionResolver indexNameExpressionResolver) {
    super(settings, PutChunkAction.NAME, transportService, clusterService,
            indicesService, threadPool, shardStateAction, mappingUpdatedAction, actionFilters,
            indexNameExpressionResolver, PutChunkRequest.class, PutChunkReplicaRequest.class, ThreadPool.Names.INDEX);

    this.transferTarget = transferTarget;
}
 
Example #14
Source File: GlobalCheckpointSyncAction.java    From crate with Apache License 2.0 6 votes vote down vote up
@Inject
public GlobalCheckpointSyncAction(
        final TransportService transportService,
        final ClusterService clusterService,
        final IndicesService indicesService,
        final ThreadPool threadPool,
        final ShardStateAction shardStateAction,
        final IndexNameExpressionResolver indexNameExpressionResolver) {
    super(
            ACTION_NAME,
            transportService,
            clusterService,
            indicesService,
            threadPool,
            shardStateAction,
            indexNameExpressionResolver,
            Request::new,
            Request::new,
            ThreadPool.Names.MANAGEMENT);
}
 
Example #15
Source File: IndicesClusterStateService.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public IndicesClusterStateService(Settings settings, IndicesService indicesService, ClusterService clusterService,
                                  ThreadPool threadPool, RecoveryTarget recoveryTarget,
                                  ShardStateAction shardStateAction,
                                  NodeIndexDeletedAction nodeIndexDeletedAction,
                                  NodeMappingRefreshAction nodeMappingRefreshAction) {
    super(settings);
    this.indicesService = indicesService;
    this.clusterService = clusterService;
    this.threadPool = threadPool;
    this.recoveryTarget = recoveryTarget;
    this.shardStateAction = shardStateAction;
    this.nodeIndexDeletedAction = nodeIndexDeletedAction;
    this.nodeMappingRefreshAction = nodeMappingRefreshAction;

    this.sendRefreshMapping = this.settings.getAsBoolean("indices.cluster.send_refresh_mapping", true);
}
 
Example #16
Source File: TransportIndicesStatsAction.java    From crate with Apache License 2.0 6 votes vote down vote up
@Inject
public TransportIndicesStatsAction(ThreadPool threadPool,
                                   ClusterService clusterService,
                                   TransportService transportService,
                                   IndicesService indicesService,
                                   IndexNameExpressionResolver indexNameExpressionResolver) {
    super(
        IndicesStatsAction.NAME,
        threadPool,
        clusterService,
        transportService,
        indexNameExpressionResolver,
        IndicesStatsRequest::new,
        ThreadPool.Names.MANAGEMENT,
        true
    );
    this.indicesService = indicesService;
}
 
Example #17
Source File: RecoverySource.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public RecoverySource(Settings settings, TransportService transportService, IndicesService indicesService,
                      RecoverySettings recoverySettings, ClusterService clusterService) {
    super(settings);
    this.transportService = transportService;
    this.indicesService = indicesService;
    this.clusterService = clusterService;
    this.indicesService.indicesLifecycle().addListener(new IndicesLifecycle.Listener() {
        @Override
        public void beforeIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard,
                                           Settings indexSettings) {
            if (indexShard != null) {
                ongoingRecoveries.cancel(indexShard, "shard is closed");
            }
        }
    });

    this.recoverySettings = recoverySettings;

    transportService.registerRequestHandler(Actions.START_RECOVERY, StartRecoveryRequest.class, ThreadPool.Names.GENERIC, new StartRecoveryTransportRequestHandler());
}
 
Example #18
Source File: InternalTestCluster.java    From crate with Apache License 2.0 6 votes vote down vote up
private void assertOpenTranslogReferences() throws Exception {
    assertBusy(() -> {
        for (NodeAndClient nodeAndClient : nodes.values()) {
            IndicesService indexServices = getInstance(IndicesService.class, nodeAndClient.name);
            for (IndexService indexService : indexServices) {
                for (IndexShard indexShard : indexService) {
                    try {
                        if (IndexShardTestCase.getEngine(indexShard) instanceof InternalEngine) {
                            IndexShardTestCase.getTranslog(indexShard).getDeletionPolicy().assertNoOpenTranslogRefs();
                        }
                    } catch (AlreadyClosedException ok) {
                        // all good
                    }
                }
            }
        }
    });
}
 
Example #19
Source File: PhasesTaskFactory.java    From crate with Apache License 2.0 6 votes vote down vote up
@Inject
public PhasesTaskFactory(ClusterService clusterService,
                         ThreadPool threadPool,
                         JobSetup jobSetup,
                         TasksService tasksService,
                         IndicesService indicesService,
                         TransportJobAction jobAction,
                         TransportKillJobsNodeAction killJobsNodeAction) {
    this.clusterService = clusterService;
    this.jobSetup = jobSetup;
    this.tasksService = tasksService;
    this.indicesService = indicesService;
    this.jobAction = jobAction;
    this.killJobsNodeAction = killJobsNodeAction;
    this.searchExecutor = threadPool.executor(ThreadPool.Names.SEARCH);
}
 
Example #20
Source File: TransportDeleteBlobAction.java    From crate with Apache License 2.0 6 votes vote down vote up
@Inject
public TransportDeleteBlobAction(TransportService transportService,
                                 ClusterService clusterService,
                                 IndicesService indicesService,
                                 ThreadPool threadPool,
                                 ShardStateAction shardStateAction,
                                 BlobIndicesService blobIndicesService,
                                 IndexNameExpressionResolver indexNameExpressionResolver) {
    super(
        DeleteBlobAction.NAME,
        transportService,
        clusterService,
        indicesService,
        threadPool,
        shardStateAction,
        indexNameExpressionResolver,
        DeleteBlobRequest::new,
        DeleteBlobRequest::new,
        ThreadPool.Names.WRITE
    );
    this.blobIndicesService = blobIndicesService;
    logger.trace("Constructor");
}
 
Example #21
Source File: TransportShardDeleteActionTest.java    From crate with Apache License 2.0 6 votes vote down vote up
@Before
public void prepare() throws Exception {
    indexUUID = UUIDs.randomBase64UUID();
    IndicesService indicesService = mock(IndicesService.class);
    IndexService indexService = mock(IndexService.class);
    when(indicesService.indexServiceSafe(new Index(TABLE_IDENT.indexNameOrAlias(), indexUUID))).thenReturn(indexService);
    indexShard = mock(IndexShard.class);
    when(indexService.getShard(0)).thenReturn(indexShard);


    transportShardDeleteAction = new TransportShardDeleteAction(
        MockTransportService.createNewService(
            Settings.EMPTY, Version.CURRENT, THREAD_POOL, clusterService.getClusterSettings()),
        mock(IndexNameExpressionResolver.class),
        mock(ClusterService.class),
        indicesService,
        mock(ThreadPool.class),
        mock(ShardStateAction.class),
        mock(SchemaUpdateClient.class)
    );
}
 
Example #22
Source File: MetaDataCreateIndexService.java    From crate with Apache License 2.0 6 votes vote down vote up
public MetaDataCreateIndexService(
        final Settings settings,
        final ClusterService clusterService,
        final IndicesService indicesService,
        final AllocationService allocationService,
        final AliasValidator aliasValidator,
        final Environment env,
        final IndexScopedSettings indexScopedSettings,
        final ThreadPool threadPool,
        final NamedXContentRegistry xContentRegistry,
        final boolean forbidPrivateIndexSettings) {
    this.settings = settings;
    this.clusterService = clusterService;
    this.indicesService = indicesService;
    this.allocationService = allocationService;
    this.aliasValidator = aliasValidator;
    this.env = env;
    this.indexScopedSettings = indexScopedSettings;
    this.activeShardsObserver = new ActiveShardsObserver(clusterService, threadPool);
    this.xContentRegistry = xContentRegistry;
    this.forbidPrivateIndexSettings = forbidPrivateIndexSettings;
}
 
Example #23
Source File: SnapshotShardsService.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public SnapshotShardsService(Settings settings, ClusterService clusterService, SnapshotsService snapshotsService, ThreadPool threadPool,
                             TransportService transportService, IndicesService indicesService) {
    super(settings);
    this.indicesService = indicesService;
    this.snapshotsService = snapshotsService;
    this.transportService = transportService;
    this.clusterService = clusterService;
    this.threadPool = threadPool;
    if (DiscoveryNode.dataNode(settings)) {
        // this is only useful on the nodes that can hold data
        // addLast to make sure that Repository will be created before snapshot
        clusterService.addLast(this);
    }

    if (DiscoveryNode.masterNode(settings)) {
        // This needs to run only on nodes that can become masters
        transportService.registerRequestHandler(UPDATE_SNAPSHOT_ACTION_NAME, UpdateIndexShardSnapshotStatusRequest.class, ThreadPool.Names.SAME, new UpdateSnapshotStateRequestHandler());
    }

}
 
Example #24
Source File: NodeService.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public NodeService(Settings settings, ThreadPool threadPool, MonitorService monitorService, Discovery discovery,
                   TransportService transportService, IndicesService indicesService,
                   PluginsService pluginService, CircuitBreakerService circuitBreakerService,
                   Version version) {
    super(settings);
    this.threadPool = threadPool;
    this.monitorService = monitorService;
    this.transportService = transportService;
    this.indicesService = indicesService;
    this.discovery = discovery;
    discovery.setNodeService(this);
    this.version = version;
    this.pluginService = pluginService;
    this.circuitBreakerService = circuitBreakerService;
}
 
Example #25
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 #26
Source File: TransportRecoveryAction.java    From crate with Apache License 2.0 6 votes vote down vote up
@Inject
public TransportRecoveryAction(ThreadPool threadPool,
                               ClusterService clusterService,
                               TransportService transportService,
                               IndicesService indicesService,
                               IndexNameExpressionResolver indexNameExpressionResolver) {
    super(
        RecoveryAction.NAME,
        threadPool,
        clusterService,
        transportService,
        indexNameExpressionResolver,
        RecoveryRequest::new,
        ThreadPool.Names.MANAGEMENT,
        true
    );
    this.indicesService = indicesService;
}
 
Example #27
Source File: TransportShardAction.java    From crate with Apache License 2.0 6 votes vote down vote up
protected TransportShardAction(String actionName,
                               TransportService transportService,
                               IndexNameExpressionResolver indexNameExpressionResolver,
                               ClusterService clusterService,
                               IndicesService indicesService,
                               ThreadPool threadPool,
                               ShardStateAction shardStateAction,
                               Writeable.Reader<Request> reader,
                               SchemaUpdateClient schemaUpdateClient) {
    super(
        actionName,
        transportService,
        clusterService,
        indicesService,
        threadPool,
        shardStateAction,
        indexNameExpressionResolver,
        reader,
        reader,
        ThreadPool.Names.WRITE
    );
    this.mappingUpdate = (update, shardId, type) -> {
        validateMapping(update.root().iterator(), false);
        schemaUpdateClient.blockingUpdateOnMaster(shardId.getIndex(), update);
    };
}
 
Example #28
Source File: DocLevelCollectTest.java    From crate with Apache License 2.0 6 votes vote down vote up
private Bucket collect(RoutedCollectPhase collectNode) throws Throwable {
    JobSetup jobSetup = internalCluster().getDataNodeInstance(JobSetup.class);
    TasksService tasksService = internalCluster().getDataNodeInstance(TasksService.class);
    SharedShardContexts sharedShardContexts = new SharedShardContexts(
        internalCluster().getDataNodeInstance(IndicesService.class), UnaryOperator.identity());
    RootTask.Builder builder = tasksService.newBuilder(collectNode.jobId());
    NodeOperation nodeOperation = NodeOperation.withDirectResponse(collectNode, mock(ExecutionPhase.class), (byte) 0,
        "remoteNode");

    List<CompletableFuture<StreamBucket>> results = jobSetup.prepareOnRemote(
        DUMMY_SESSION_INFO,
        ImmutableList.of(nodeOperation),
        builder,
        sharedShardContexts
    );
    RootTask rootTask = tasksService.createTask(builder);
    rootTask.start();
    return results.get(0).get(2, TimeUnit.SECONDS);
}
 
Example #29
Source File: GraphiteService.java    From elasticsearch-graphite-plugin with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Inject public GraphiteService(Settings settings, ClusterService clusterService, IndicesService indicesService,
                               NodeService nodeService) {
    super(settings);
    this.clusterService = clusterService;
    this.indicesService = indicesService;
    this.nodeService = nodeService;
    graphiteRefreshInternal = settings.getAsTime("metrics.graphite.every", TimeValue.timeValueMinutes(1));
    graphiteHost = settings.get("metrics.graphite.host");
    graphitePort = settings.getAsInt("metrics.graphite.port", 2003);
    graphitePrefix = settings.get("metrics.graphite.prefix", "elasticsearch" + "." + settings.get("cluster.name"));
    String graphiteInclusionRegexString = settings.get("metrics.graphite.include");
    if (graphiteInclusionRegexString != null) {
        graphiteInclusionRegex = Pattern.compile(graphiteInclusionRegexString);
    }
    String graphiteExclusionRegexString = settings.get("metrics.graphite.exclude");
    if (graphiteExclusionRegexString != null) {
        graphiteExclusionRegex = Pattern.compile(graphiteExclusionRegexString);
    }
}
 
Example #30
Source File: GraphiteService.java    From elasticsearch-graphite-plugin with Do What The F*ck You Want To Public License 5 votes vote down vote up
private List<IndexShard> getIndexShards(IndicesService indicesService) {
    List<IndexShard> indexShards = Lists.newArrayList();
    Iterator<IndexService> indexServiceIterator = indicesService.iterator();
    while (indexServiceIterator.hasNext()) {
        IndexService indexService = indexServiceIterator.next();
        for (int shardId : indexService.shardIds()) {
            indexShards.add(indexService.shard(shardId));
        }
    }
    return indexShards;
}