当前位置: 首页>>代码示例>>Java>>正文


Java ActionFilter类代码示例

本文整理汇总了Java中org.elasticsearch.action.support.ActionFilter的典型用法代码示例。如果您正苦于以下问题:Java ActionFilter类的具体用法?Java ActionFilter怎么用?Java ActionFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ActionFilter类属于org.elasticsearch.action.support包,在下文中一共展示了ActionFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.elasticsearch.action.support.ActionFilter; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    transport = new CapturingTransport();
    clusterService = createClusterService(THREAD_POOL);
    transportService = new TransportService(clusterService.getSettings(), transport, THREAD_POOL,
            TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
    transportService.start();
    transportService.acceptIncomingRequests();
    action = new TestTransportInstanceSingleOperationAction(
            Settings.EMPTY,
            "indices:admin/test",
            transportService,
            new ActionFilters(new HashSet<ActionFilter>()),
            new MyResolver(),
            Request::new
    );
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:TransportInstanceSingleOperationActionTests.java

示例2: configure

import org.elasticsearch.action.support.ActionFilter; //导入依赖的package包/类
@Override
protected void configure() {
    Multibinder<ActionFilter> actionFilterMultibinder = Multibinder.newSetBinder(binder(), ActionFilter.class);
    for (Class<? extends ActionFilter> actionFilter : actionFilters) {
        actionFilterMultibinder.addBinding().to(actionFilter);
    }
    bind(ActionFilters.class).asEagerSingleton();
    bind(DestructiveOperations.class).toInstance(destructiveOperations);

    if (false == transportClient) {
        // Supporting classes only used when not a transport client
        bind(AutoCreateIndex.class).toInstance(autoCreateIndex);
        bind(TransportLivenessAction.class).asEagerSingleton();

        // register GenericAction -> transportAction Map used by NodeClient
        @SuppressWarnings("rawtypes")
        MapBinder<GenericAction, TransportAction> transportActionsBinder
                = MapBinder.newMapBinder(binder(), GenericAction.class, TransportAction.class);
        for (ActionHandler<?, ?> action : actions.values()) {
            // bind the action as eager singleton, so the map binder one will reuse it
            bind(action.getTransportAction()).asEagerSingleton();
            transportActionsBinder.addBinding(action.getAction()).to(action.getTransportAction()).asEagerSingleton();
            for (Class<?> supportAction : action.getSupportTransportActions()) {
                bind(supportAction).asEagerSingleton();
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:ActionModule.java

示例3: getActionFilters

import org.elasticsearch.action.support.ActionFilter; //导入依赖的package包/类
@Override
public List<Class<? extends ActionFilter>> getActionFilters() {

	List<Class<? extends ActionFilter>> r = new ArrayList<>();
	r.add(SpActionFilter.class);
	return r;
}
 
开发者ID:psfu,项目名称:es-sp-tools,代码行数:8,代码来源:SpToolsPlugin.java

示例4: getActionFilters

import org.elasticsearch.action.support.ActionFilter; //导入依赖的package包/类
@Override
public List<ActionFilter> getActionFilters() {
    List<ActionFilter> filters = new ArrayList<>(1);
    if (!tribeNodeClient && !client && !disabled) {
        filters.add(Objects.requireNonNull(sgf));
    }
    return filters;
}
 
开发者ID:floragunncom,项目名称:search-guard,代码行数:9,代码来源:SearchGuardPlugin.java

示例5: DictionaryRestoreService

import org.elasticsearch.action.support.ActionFilter; //导入依赖的package包/类
@Inject
public DictionaryRestoreService(final Settings settings,
        final Client client, final Environment env,
        final ClusterService clusterService,
        final TransportService transportService,
        final RestoreService restoreService, final ActionFilters filters) {
    super(settings);
    this.client = client;
    this.env = env;
    this.clusterService = clusterService;
    this.transportService = transportService;
    this.restoreService = restoreService;

    dictionaryIndex = settings.get("dictionary.index", ".dictionary");
    masterNodeTimeout = settings.getAsTime(
            "dictionary.restore.master_node_timeout",
            TimeValue.timeValueSeconds(30));
    maxNumOfDictionaries = settings.getAsInt(
            "dictionary.restore.max_num_of_dictionaries", 100);

    for (final ActionFilter filter : filters.filters()) {
        if (filter instanceof RestoreSnapshotActionFilter) {
            ((RestoreSnapshotActionFilter) filter)
                    .setDictionaryRestoreService(this);
            if (logger.isDebugEnabled()) {
                logger.debug("Set DictionaryRestoreService to " + filter);
            }
        }
    }

    transportService.registerRequestHandler(ACTION_RESTORE_DICTIONERY,
            RestoreDictionaryRequest.class, ThreadPool.Names.SNAPSHOT,
            new RestoreDictionaryRequestHandler());
}
 
开发者ID:codelibs,项目名称:elasticsearch-dictionary,代码行数:35,代码来源:DictionaryRestoreService.java

示例6: DictionarySnapshotService

import org.elasticsearch.action.support.ActionFilter; //导入依赖的package包/类
@Inject
public DictionarySnapshotService(final Settings settings, final Client client, final Environment env,
        final ClusterService clusterService, final IndicesService indicesService, final TransportService transportService,
        final SnapshotsService snapshotsService, final ActionFilters filters) {
    super(settings);
    this.client = client;
    this.env = env;
    this.clusterService = clusterService;
    this.indicesService = indicesService;
    this.transportService = transportService;
    this.snapshotsService = snapshotsService;

    dictionaryIndex = settings.get("dictionary.index", ".dictionary");
    fileExtensions = settings.getAsArray("directory.file_extensions",
            new String[] { "txt" });
    masterNodeTimeout = settings.getAsTime(
            "dictionary.snapshot.master_node_timeout",
            TimeValue.timeValueSeconds(30));

    for (final ActionFilter filter : filters.filters()) {
        if (filter instanceof CreateSnapshotActionFilter) {
            ((CreateSnapshotActionFilter) filter)
                    .setDictionarySnapshotService(this);
            if (logger.isDebugEnabled()) {
                logger.debug("Set CreateSnapshotActionFilter to " + filter);
            }
        } else if (filter instanceof DeleteSnapshotActionFilter) {
            ((DeleteSnapshotActionFilter) filter)
                    .setDictionarySnapshotService(this);
            if (logger.isDebugEnabled()) {
                logger.debug("Set DeleteSnapshotActionFilter to " + filter);
            }
        }
    }

    transportService.registerRequestHandler(ACTION_DICTIONARY_SNAPSHOT_DELETE,
            DeleteDictionaryRequest.class, ThreadPool.Names.SNAPSHOT,
            new DeleteDictionaryRequestHandler());
}
 
开发者ID:codelibs,项目名称:elasticsearch-dictionary,代码行数:40,代码来源:DictionarySnapshotService.java

示例7: getActionFilters

import org.elasticsearch.action.support.ActionFilter; //导入依赖的package包/类
@Override
public List<Class<? extends ActionFilter>> getActionFilters() {
    return singletonList(ReindexFromRemoteWithAuthTests.TestFilter.class);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:ReindexFromRemoteWithAuthTests.java

示例8: getActionFilters

import org.elasticsearch.action.support.ActionFilter; //导入依赖的package包/类
@Override
public List<Class<? extends ActionFilter>> getActionFilters() {
    return singletonList(LoggingFilter.class);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:ContextAndHeaderTransportIT.java

示例9: setupActionFilters

import org.elasticsearch.action.support.ActionFilter; //导入依赖的package包/类
private List<Class<? extends ActionFilter>> setupActionFilters(List<ActionPlugin> actionPlugins) {
    return unmodifiableList(actionPlugins.stream().flatMap(p -> p.getActionFilters().stream()).collect(Collectors.toList()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:ActionModule.java

示例10: getActionFilters

import org.elasticsearch.action.support.ActionFilter; //导入依赖的package包/类
/**
 * Action filters added by this plugin.
 */
default List<Class<? extends ActionFilter>> getActionFilters() {
    return Collections.emptyList();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:ActionPlugin.java

示例11: getActionFilters

import org.elasticsearch.action.support.ActionFilter; //导入依赖的package包/类
@Override
public List<Class<? extends ActionFilter>> getActionFilters() {
    return singletonList(BlockingActionFilter.class);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:ClusterInfoServiceIT.java

示例12: testClusterInfoServiceInformationClearOnError

import org.elasticsearch.action.support.ActionFilter; //导入依赖的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

示例13: testBatchExecute

import org.elasticsearch.action.support.ActionFilter; //导入依赖的package包/类
public void testBatchExecute() throws Exception {
    // Initialize dependencies of TransportMultiSearchAction
    Settings settings = Settings.builder()
            .put("node.name", TransportMultiSearchActionTests.class.getSimpleName())
            .build();
    ActionFilters actionFilters = mock(ActionFilters.class);
    when(actionFilters.filters()).thenReturn(new ActionFilter[0]);
    ThreadPool threadPool = new ThreadPool(settings);
    TaskManager taskManager = mock(TaskManager.class);
    TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR,
        boundAddress -> DiscoveryNode.createLocal(settings, boundAddress.publishAddress(), UUIDs.randomBase64UUID()), null) {
        @Override
        public TaskManager getTaskManager() {
            return taskManager;
        }
    };
    ClusterService clusterService = mock(ClusterService.class);
    when(clusterService.state()).thenReturn(ClusterState.builder(new ClusterName("test")).build());
    IndexNameExpressionResolver resolver = new IndexNameExpressionResolver(Settings.EMPTY);

    // Keep track of the number of concurrent searches started by multi search api,
    // and if there are more searches than is allowed create an error and remember that.
    int maxAllowedConcurrentSearches = scaledRandomIntBetween(1, 16);
    AtomicInteger counter = new AtomicInteger();
    AtomicReference<AssertionError> errorHolder = new AtomicReference<>();
    // randomize whether or not requests are executed asynchronously
    final List<String> threadPoolNames = Arrays.asList(ThreadPool.Names.GENERIC, ThreadPool.Names.SAME);
    Randomness.shuffle(threadPoolNames);
    final ExecutorService commonExecutor = threadPool.executor(threadPoolNames.get(0));
    final ExecutorService rarelyExecutor = threadPool.executor(threadPoolNames.get(1));
    final Set<SearchRequest> requests = Collections.newSetFromMap(Collections.synchronizedMap(new IdentityHashMap<>()));
    TransportAction<SearchRequest, SearchResponse> searchAction = new TransportAction<SearchRequest, SearchResponse>
            (Settings.EMPTY, "action", threadPool, actionFilters, resolver, taskManager) {
        @Override
        protected void doExecute(SearchRequest request, ActionListener<SearchResponse> listener) {
            requests.add(request);
            int currentConcurrentSearches = counter.incrementAndGet();
            if (currentConcurrentSearches > maxAllowedConcurrentSearches) {
                errorHolder.set(new AssertionError("Current concurrent search [" + currentConcurrentSearches +
                        "] is higher than is allowed [" + maxAllowedConcurrentSearches + "]"));
            }
            final ExecutorService executorService = rarely() ? rarelyExecutor : commonExecutor;
            executorService.execute(() -> {
                counter.decrementAndGet();
                listener.onResponse(new SearchResponse());
            });
        }
    };
    TransportMultiSearchAction action =
            new TransportMultiSearchAction(threadPool, actionFilters, transportService, clusterService, searchAction, resolver, 10);

    // Execute the multi search api and fail if we find an error after executing:
    try {
        /*
         * Allow for a large number of search requests in a single batch as previous implementations could stack overflow if the number
         * of requests in a single batch was large
         */
        int numSearchRequests = scaledRandomIntBetween(1, 8192);
        MultiSearchRequest multiSearchRequest = new MultiSearchRequest();
        multiSearchRequest.maxConcurrentSearchRequests(maxAllowedConcurrentSearches);
        for (int i = 0; i < numSearchRequests; i++) {
            multiSearchRequest.add(new SearchRequest());
        }

        MultiSearchResponse response = action.execute(multiSearchRequest).actionGet();
        assertThat(response.getResponses().length, equalTo(numSearchRequests));
        assertThat(requests.size(), equalTo(numSearchRequests));
        assertThat(errorHolder.get(), nullValue());
    } finally {
        assertTrue(ESTestCase.terminate(threadPool));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:73,代码来源:TransportMultiSearchActionTests.java

示例14: IndexingProxyService

import org.elasticsearch.action.support.ActionFilter; //导入依赖的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

示例15: getActionFilters

import org.elasticsearch.action.support.ActionFilter; //导入依赖的package包/类
@Override
public List<Class<? extends ActionFilter>> getActionFilters() {
    return Arrays.asList(ProxyActionFilter.class);
}
 
开发者ID:codelibs,项目名称:elasticsearch-indexing-proxy,代码行数:5,代码来源:IndexingProxyPlugin.java


注:本文中的org.elasticsearch.action.support.ActionFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。