當前位置: 首頁>>代碼示例>>Java>>正文


Java ActionFilters.filters方法代碼示例

本文整理匯總了Java中org.elasticsearch.action.support.ActionFilters.filters方法的典型用法代碼示例。如果您正苦於以下問題:Java ActionFilters.filters方法的具體用法?Java ActionFilters.filters怎麽用?Java ActionFilters.filters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.action.support.ActionFilters的用法示例。


在下文中一共展示了ActionFilters.filters方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testClusterInfoServiceInformationClearOnError

import org.elasticsearch.action.support.ActionFilters; //導入方法依賴的package包/類
public void testClusterInfoServiceInformationClearOnError() throws InterruptedException, ExecutionException {
    internalCluster().startNodes(2,
            // manually control publishing
            Settings.builder().put(InternalClusterInfoService.INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING.getKey(), "60m").build());
    prepareCreate("test").setSettings(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1).get();
    ensureGreen("test");
    InternalTestCluster internalTestCluster = internalCluster();
    InternalClusterInfoService infoService = (InternalClusterInfoService) internalTestCluster.getInstance(ClusterInfoService.class, internalTestCluster.getMasterName());
    // get one healthy sample
    ClusterInfo info = infoService.refresh();
    assertNotNull("failed to collect info", info);
    assertThat("some usages are populated", info.getNodeLeastAvailableDiskUsages().size(), Matchers.equalTo(2));
    assertThat("some shard sizes are populated", info.shardSizes.size(), greaterThan(0));


    MockTransportService mockTransportService = (MockTransportService) internalCluster().getInstance(TransportService.class, internalTestCluster.getMasterName());

    final AtomicBoolean timeout = new AtomicBoolean(false);
    final Set<String> blockedActions = newHashSet(NodesStatsAction.NAME, NodesStatsAction.NAME + "[n]", IndicesStatsAction.NAME, IndicesStatsAction.NAME + "[n]");
    // drop all outgoing stats requests to force a timeout.
    for (DiscoveryNode node : internalTestCluster.clusterService().state().getNodes()) {
        mockTransportService.addDelegate(internalTestCluster.getInstance(TransportService.class, node.getName()), new MockTransportService.DelegateTransport(mockTransportService.original()) {
            @Override
            protected void sendRequest(Connection connection, long requestId, String action, TransportRequest request,
                                       TransportRequestOptions options) throws IOException {
                if (blockedActions.contains(action)) {
                    if (timeout.get()) {
                        logger.info("dropping [{}] to [{}]", action, node);
                        return;
                    }
                }
                super.sendRequest(connection, requestId, action, request, options);
            }
        });
    }

    // timeouts shouldn't clear the info
    timeout.set(true);
    info = infoService.refresh();
    assertNotNull("info should not be null", info);
    // node info will time out both on the request level on the count down latch. this means
    // it is likely to update the node disk usage based on the one response that came be from local
    // node.
    assertThat(info.getNodeLeastAvailableDiskUsages().size(), greaterThanOrEqualTo(1));
    assertThat(info.getNodeMostAvailableDiskUsages().size(), greaterThanOrEqualTo(1));
    // indices is guaranteed to time out on the latch, not updating anything.
    assertThat(info.shardSizes.size(), greaterThan(1));

    // now we cause an exception
    timeout.set(false);
    ActionFilters actionFilters = internalTestCluster.getInstance(ActionFilters.class, internalTestCluster.getMasterName());
    BlockingActionFilter blockingActionFilter = null;
    for (ActionFilter filter : actionFilters.filters()) {
        if (filter instanceof BlockingActionFilter) {
            blockingActionFilter = (BlockingActionFilter) filter;
            break;
        }
    }

    assertNotNull("failed to find BlockingActionFilter", blockingActionFilter);
    blockingActionFilter.blockActions(blockedActions.toArray(Strings.EMPTY_ARRAY));
    info = infoService.refresh();
    assertNotNull("info should not be null", info);
    assertThat(info.getNodeLeastAvailableDiskUsages().size(), equalTo(0));
    assertThat(info.getNodeMostAvailableDiskUsages().size(), equalTo(0));
    assertThat(info.shardSizes.size(), equalTo(0));

    // check we recover
    blockingActionFilter.blockActions();
    info = infoService.refresh();
    assertNotNull("info should not be null", info);
    assertThat(info.getNodeLeastAvailableDiskUsages().size(), equalTo(2));
    assertThat(info.getNodeMostAvailableDiskUsages().size(), equalTo(2));
    assertThat(info.shardSizes.size(), greaterThan(0));

}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:77,代碼來源:ClusterInfoServiceIT.java

示例2: IndexingProxyService

import org.elasticsearch.action.support.ActionFilters; //導入方法依賴的package包/類
@Inject
public IndexingProxyService(final Settings settings, final Environment env, final Client client, final ClusterService clusterService,
        final TransportService transportService, final NamedWriteableRegistry namedWriteableRegistry, final ThreadPool threadPool,
        final ActionFilters filters, final PluginComponent pluginComponent) {
    super(settings);
    this.client = client;
    this.clusterService = clusterService;
    this.transportService = transportService;
    this.namedWriteableRegistry = namedWriteableRegistry;
    this.threadPool = threadPool;

    final String dataPathStr = IndexingProxyPlugin.SETTING_INXPROXY_DATA_PATH.get(settings);
    if (dataPathStr == null || dataPathStr.length() == 0) {
        dataPath = env.dataFiles()[0];
    } else {
        dataPath = Paths.get(dataPathStr);
    }

    final String dataFileFormatStr = IndexingProxyPlugin.SETTING_INXPROXY_DATA_FILE_FORMAT.get(settings);
    if (dataFileFormatStr == null || dataFileFormatStr.length() == 0) {
        dataFileFormat = "%019d";
    } else {
        dataFileFormat = dataFileFormatStr;
    }

    dataFileSize = IndexingProxyPlugin.SETTING_INXPROXY_DATA_FILE_SIZE.get(settings).getBytes();
    targetIndexSet = IndexingProxyPlugin.SETTING_INXPROXY_TARGET_INDICES.get(settings).stream().collect(Collectors.toSet());
    flushPerDoc = IndexingProxyPlugin.SETTING_INXPROXY_FLUSH_PER_DOC.get(settings);
    monitorInterval = IndexingProxyPlugin.SETTING_INXPROXY_MONITOR_INTERVAL.get(settings);
    senderNodes = IndexingProxyPlugin.SETTING_INXPROXY_SENDER_NODES.get(settings);
    writerNodes = IndexingProxyPlugin.SETTING_INXPROXY_WRITE_NODES.get(settings);
    writerRetryCount = IndexingProxyPlugin.SETTING_INXPROXY_WRITER_RETRY_COUNT.get(settings);
    numberOfReplicas = IndexingProxyPlugin.SETTING_INXPROXY_NUMBER_OF_REPLICAS.get(settings);
    numberOfShards = IndexingProxyPlugin.SETTING_INXPROXY_NUMBER_OF_SHARDS.get(settings);
    renewActions = IndexingProxyPlugin.SETTING_INXPROXY_RENEW_ACTIONS.get(settings).stream().collect(Collectors.toSet());

    for (final ActionFilter filter : filters.filters()) {
        if (filter instanceof ProxyActionFilter) {
            ((ProxyActionFilter) filter).setIndexingProxyService(this);
        }
    }

    clusterService.addLocalNodeMasterListener(this);

    transportService.registerRequestHandler(IndexingProxyPlugin.ACTION_IDXPROXY_CREATE, CreateRequest::new, ThreadPool.Names.GENERIC,
            new CreateRequestHandler(this));
    transportService.registerRequestHandler(IndexingProxyPlugin.ACTION_IDXPROXY_PING, PingRequest::new, ThreadPool.Names.GENERIC,
            new PingRequestHandler(this));
    transportService.registerRequestHandler(IndexingProxyPlugin.ACTION_IDXPROXY_WRITE, WriteRequest::new, ThreadPool.Names.GENERIC,
            new WriteRequestHandler<>(this));

    pluginComponent.setIndexingProxyService(this);
}
 
開發者ID:codelibs,項目名稱:elasticsearch-indexing-proxy,代碼行數:54,代碼來源:IndexingProxyService.java


注:本文中的org.elasticsearch.action.support.ActionFilters.filters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。