• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java EsRejectedExecutionException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: notifyNodeFailure

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
private void notifyNodeFailure(final DiscoveryNode node, final String reason) {
    try {
        threadPool.generic().execute(new Runnable() {
            @Override
            public void run() {
                for (Listener listener : listeners) {
                    listener.onNodeFailure(node, reason);
                }
            }
        });
    } catch (EsRejectedExecutionException ex) {
        logger.trace(
            (Supplier<?>) () -> new ParameterizedMessage(
                "[node  ] [{}] ignoring node failure (reason [{}]). Local node is shutting down",
                node,
                reason),
            ex);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:NodesFaultDetection.java


示例2: onNodeDisconnected

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
@Override
public void onNodeDisconnected(final DiscoveryNode node) {
    try {
        threadPool.generic().execute( () -> {
            for (final TransportConnectionListener connectionListener : connectionListeners) {
                connectionListener.onNodeDisconnected(node);
            }
        });
        for (Map.Entry<Long, RequestHolder> entry : clientHandlers.entrySet()) {
            RequestHolder holder = entry.getValue();
            if (holder.node().equals(node)) {
                final RequestHolder holderToNotify = clientHandlers.remove(entry.getKey());
                if (holderToNotify != null) {
                    // callback that an exception happened, but on a different thread since we don't
                    // want handlers to worry about stack overflows
                    threadPool.generic().execute(() -> holderToNotify.handler().handleException(new NodeDisconnectedException(node,
                        holderToNotify.action())));
                }
            }
        }
    } catch (EsRejectedExecutionException ex) {
        logger.debug("Rejected execution on NodeDisconnected", ex);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:TransportService.java


示例3: onMaster

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
@Override
public void onMaster() {
    this.isMaster = true;
    if (logger.isTraceEnabled()) {
        logger.trace("I have been elected master, scheduling a ClusterInfoUpdateJob");
    }
    try {
        // Submit a job that will start after DEFAULT_STARTING_INTERVAL, and reschedule itself after running
        threadPool.schedule(updateFrequency, executorName(), new SubmitReschedulingClusterInfoUpdatedJob());
        if (clusterService.state().getNodes().getDataNodes().size() > 1) {
            // Submit an info update job to be run immediately
            threadPool.executor(executorName()).execute(() -> maybeRefresh());
        }
    } catch (EsRejectedExecutionException ex) {
        if (logger.isDebugEnabled()) {
            logger.debug("Couldn't schedule cluster info update task - node might be shutting down", ex);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:InternalClusterInfoService.java


示例4: createAckListener

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
public Discovery.AckListener createAckListener(ThreadPool threadPool, ClusterState newClusterState) {
    ArrayList<Discovery.AckListener> ackListeners = new ArrayList<>();

    //timeout straightaway, otherwise we could wait forever as the timeout thread has not started
    nonFailedTasks.stream().filter(task -> task.listener instanceof AckedClusterStateTaskListener).forEach(task -> {
        final AckedClusterStateTaskListener ackedListener = (AckedClusterStateTaskListener) task.listener;
        if (ackedListener.ackTimeout() == null || ackedListener.ackTimeout().millis() == 0) {
            ackedListener.onAckTimeout();
        } else {
            try {
                ackListeners.add(new AckCountDownListener(ackedListener, newClusterState.version(), newClusterState.nodes(),
                    threadPool));
            } catch (EsRejectedExecutionException ex) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Couldn't schedule timeout thread - node might be shutting down", ex);
                }
                //timeout straightaway, otherwise we could wait forever as the timeout thread has not started
                ackedListener.onAckTimeout();
            }
        }
    });

    return new DelegetingAckListener(ackListeners);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:ClusterService.java


示例5: AbstractAsyncBulkByScrollAction

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
public AbstractAsyncBulkByScrollAction(WorkingBulkByScrollTask task, Logger logger, ParentTaskAssigningClient client,
        ThreadPool threadPool, Request mainRequest, ScriptService scriptService, ClusterState clusterState,
        ActionListener<BulkByScrollResponse> listener) {
    this.task = task;
    this.logger = logger;
    this.client = client;
    this.threadPool = threadPool;
    this.scriptService = scriptService;
    this.clusterState = clusterState;
    this.mainRequest = mainRequest;
    this.listener = listener;
    BackoffPolicy backoffPolicy = buildBackoffPolicy();
    bulkRetry = Retry.on(EsRejectedExecutionException.class).policy(BackoffPolicy.wrap(backoffPolicy, task::countBulkRetry));
    scrollSource = buildScrollableResultSource(backoffPolicy);
    scriptApplier = Objects.requireNonNull(buildScriptApplier(), "script applier must not be null");
    /*
     * Default to sorting by doc. We can't do this in the request itself because it is normal to *add* to the sorts rather than replace
     * them and if we add _doc as the first sort by default then sorts will never work.... So we add it here, only if there isn't
     * another sort.
     */
    List<SortBuilder<?>> sorts = mainRequest.getSearchRequest().source().sorts();
    if (sorts == null || sorts.isEmpty()) {
        mainRequest.getSearchRequest().source().sort(fieldSort("_doc"));
    }
    mainRequest.getSearchRequest().source().version(needsSourceDocumentVersions());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:AbstractAsyncBulkByScrollAction.java


示例6: testOnRejectionCausesCancellation

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
public void testOnRejectionCausesCancellation() throws Exception {
    final TimeValue delay = TimeValue.timeValueMillis(10L);
    terminate(threadPool);
    threadPool = new ThreadPool(Settings.builder().put(Node.NODE_NAME_SETTING.getKey(), "fixed delay tests").build()) {
        @Override
        public ScheduledFuture<?> schedule(TimeValue delay, String executor, Runnable command) {
            if (command instanceof ReschedulingRunnable) {
                ((ReschedulingRunnable) command).onRejection(new EsRejectedExecutionException());
            } else {
                fail("this should only be called with a rescheduling runnable in this test");
            }
            return null;
        }
    };
    Runnable runnable = () -> {};
    ReschedulingRunnable reschedulingRunnable = new ReschedulingRunnable(runnable, delay, Names.GENERIC, threadPool);
    assertTrue(reschedulingRunnable.isCancelled());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:ScheduleWithFixedDelayTests.java


示例7: testAsyncRetryFailsAfterBacksOff

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
public void testAsyncRetryFailsAfterBacksOff() throws Exception {
    BackoffPolicy backoff = BackoffPolicy.constantBackoff(DELAY, CALLS_TO_FAIL - 1);
    AssertingListener listener = new AssertingListener();

    BulkRequest bulkRequest = createBulkRequest();
    Retry.on(EsRejectedExecutionException.class)
            .policy(backoff)
            .withAsyncBackoff(bulkClient, bulkRequest, listener);

    listener.awaitCallbacksCalled();

    listener.assertOnResponseCalled();
    listener.assertResponseWithFailures();
    listener.assertResponseWithNumberOfItems(bulkRequest.numberOfActions());
    listener.assertOnFailureNeverCalled();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:RetryTests.java


示例8: testThreadPoolRejectionsAbortRequest

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
/**
 * Mimicks a ThreadPool rejecting execution of the task.
 */
public void testThreadPoolRejectionsAbortRequest() throws Exception {
    testTask.rethrottle(1);
    setupClient(new TestThreadPool(getTestName()) {
        @Override
        public ScheduledFuture<?> schedule(TimeValue delay, String name, Runnable command) {
            // While we're here we can check that the sleep made it through
            assertThat(delay.nanos(), greaterThan(0L));
            assertThat(delay.seconds(), lessThanOrEqualTo(10L));
            ((AbstractRunnable) command).onRejection(new EsRejectedExecutionException("test"));
            return null;
        }
    });
    ScrollableHitSource.Response response = new ScrollableHitSource.Response(false, emptyList(), 0, emptyList(), null);
    simulateScrollResponse(new DummyAsyncBulkByScrollAction(), timeValueNanos(System.nanoTime()), 10, response);
    ExecutionException e = expectThrows(ExecutionException.class, () -> listener.get());
    assertThat(e.getMessage(), equalTo("EsRejectedExecutionException[test]"));
    assertThat(client.scrollsCleared, contains(scrollId));

    // When the task is rejected we don't increment the throttled timer
    assertEquals(timeValueMillis(0), testTask.getStatus().getThrottled());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:AsyncBulkByScrollActionTests.java


示例9: run

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
@Override
public void run() {
    if (closed) {
        return;
    }
    if (keysToClean.isEmpty()) {
        schedule();
        return;
    }
    try {
        threadPool.executor(ThreadPool.Names.GENERIC).execute(new Runnable() {
            @Override
            public void run() {
                reap();
                schedule();
            }
        });
    } catch (EsRejectedExecutionException ex) {
        logger.debug("Can not run ReaderCleaner - execution rejected", ex);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:IndicesRequestCache.java


示例10: onMaster

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
@Override
public void onMaster() {
    this.isMaster = true;
    if (logger.isTraceEnabled()) {
        logger.trace("I have been elected master, scheduling a ClusterInfoUpdateJob");
    }
    try {
        // Submit a job that will start after DEFAULT_STARTING_INTERVAL, and reschedule itself after running
        threadPool.schedule(updateFrequency, executorName(), new SubmitReschedulingClusterInfoUpdatedJob());
        if (clusterService.state().getNodes().getDataNodes().size() > 1) {
            // Submit an info update job to be run immediately
            threadPool.executor(executorName()).execute(new Runnable() {
                @Override
                public void run() {
                    maybeRefresh();
                }
            });
        }
    } catch (EsRejectedExecutionException ex) {
        if (logger.isDebugEnabled()) {
            logger.debug("Couldn't schedule cluster info update task - node might be shutting down", ex);
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:InternalClusterInfoService.java


示例11: execute

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
@Override
public void execute(BulkRequest bulkRequest, long executionId) {
    boolean afterCalled = false;
    try {
        listener.beforeBulk(executionId, bulkRequest);
        BulkResponse bulkResponse = Retry
                .on(EsRejectedExecutionException.class)
                .policy(backoffPolicy)
                .withSyncBackoff(client, bulkRequest);
        afterCalled = true;
        listener.afterBulk(executionId, bulkRequest, bulkResponse);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        logger.info("Bulk request {} has been cancelled.", e, executionId);
        if (!afterCalled) {
            listener.afterBulk(executionId, bulkRequest, e);
        }
    } catch (Throwable t) {
        logger.warn("Failed to execute bulk request {}.", t, executionId);
        if (!afterCalled) {
            listener.afterBulk(executionId, bulkRequest, t);
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:BulkRequestHandler.java


示例12: schedule

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
private void schedule() {
    boolean success = false;
    while (!success) {
        if (closed) {
            break;
        }
        try {
            threadPool.schedule(cleanInterval, ThreadPool.Names.SAME,
                    this);
            success = true;
        } catch (final EsRejectedExecutionException ex) {
            logger.warn("Can not schedule Reaper - execution rejected",
                    ex);
            try {
                Thread.sleep(1000);
            } catch (final InterruptedException e) {
                // ignore
            }
        }
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-qrcache,代码行数:22,代码来源:QueryResultCache.java


示例13: insertDiscovery

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
@Override
public void insertDiscovery(List<Token> tokens) throws IOException {
    batchHistogram.update(tokens.size());
    if (tokens.size() == 0) return;

    Timer.Context ctx = writeTimer.time();
    try {

        BulkRequestBuilder bulk = client.prepareBulk();

        for (Token token : tokens) {
            bulk.add(createSingleRequest(token));
        }

        bulk.execute().actionGet();
    } catch (EsRejectedExecutionException esEx) {
        log.error(("Error during bulk insert to ES with status: [" + esEx.status() + "] " +
                "with message: [" + esEx.getDetailedMessage() + "]"));
        throw esEx;
    } finally {
        ctx.stop();
    }
}
 
开发者ID:rackerlabs,项目名称:blueflood,代码行数:24,代码来源:ElasticTokensIO.java


示例14: setUp

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    super.setUp();
    createIndex("source");
    // Build the test data. Don't use indexRandom because that won't work consistently with such small thread pools.
    BulkRequestBuilder bulk = client().prepareBulk();
    for (int i = 0; i < DOC_COUNT; i++) {
        bulk.add(client().prepareIndex("source", "test").setSource("foo", "bar " + i));
    }
    Retry retry = Retry.on(EsRejectedExecutionException.class).policy(BackoffPolicy.exponentialBackoff());
    BulkResponse response = retry.withSyncBackoff(client(), bulk.request());
    assertFalse(response.buildFailureMessage(), response.hasFailures());
    client().admin().indices().prepareRefresh("source").get();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:RetryTests.java


示例15: testParseRejection

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
public void testParseRejection() throws Exception {
    // The rejection comes through in the handler because the mocked http response isn't marked as an error
    AtomicBoolean called = new AtomicBoolean();
    // Handling a scroll rejection is the same as handling a search rejection so we reuse the verification code
    Consumer<Response> checkResponse = r -> {
        assertFalse(r.isTimedOut());
        assertEquals(FAKE_SCROLL_ID, r.getScrollId());
        assertEquals(4, r.getTotalHits());
        assertThat(r.getFailures(), hasSize(1));
        assertEquals("test", r.getFailures().get(0).getIndex());
        assertEquals((Integer) 0, r.getFailures().get(0).getShardId());
        assertEquals("87A7NvevQxSrEwMbtRCecg", r.getFailures().get(0).getNodeId());
        assertThat(r.getFailures().get(0).getReason(), instanceOf(EsRejectedExecutionException.class));
        assertEquals("rejected execution of [email protected] on "
                + "EsThreadPoolExecutor[search, queue capacity = 1000, org.elasticsearch.common.util.concurrent."
                + "[email protected][Running, pool size = 7, active threads = 7, queued tasks = 1000, "
                + "completed tasks = 4182]]", r.getFailures().get(0).getReason().getMessage());
        assertThat(r.getHits(), hasSize(1));
        assertEquals("test", r.getHits().get(0).getIndex());
        assertEquals("test", r.getHits().get(0).getType());
        assertEquals("AVToMiC250DjIiBO3yJ_", r.getHits().get(0).getId());
        assertEquals("{\"test\":\"test1\"}", r.getHits().get(0).getSource().utf8ToString());
        called.set(true);
    };
    sourceWithMockedRemoteCall("rejection.json").doStart(checkResponse);
    assertTrue(called.get());
    called.set(false);
    sourceWithMockedRemoteCall("rejection.json").doStartNextScroll("scroll", timeValueMillis(0), checkResponse);
    assertTrue(called.get());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:31,代码来源:RemoteScrollableHitSourceTests.java


示例16: notifyMasterFailure

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
private void notifyMasterFailure(final DiscoveryNode masterNode, final Throwable cause, final String reason) {
    if (notifiedMasterFailure.compareAndSet(false, true)) {
        try {
            threadPool.generic().execute(() -> {
                for (Listener listener : listeners) {
                    listener.onMasterFailure(masterNode, cause, reason);
                }
            });
        } catch (EsRejectedExecutionException e) {
            logger.error("master failure notification was rejected, it's highly likely the node is shutting down", e);
        }
        stop("master failure, " + reason);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:MasterFaultDetection.java


示例17: onAfterInLifecycle

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
@Override
protected void onAfterInLifecycle() {
    try {
        threadPool.schedule(pingSchedule, ThreadPool.Names.GENERIC, this);
    } catch (EsRejectedExecutionException ex) {
        if (ex.isExecutorShutdown()) {
            logger.debug("couldn't schedule new ping execution, executor is shutting down", ex);
        } else {
            throw ex;
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:TcpTransport.java


示例18: addTimeoutListener

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
/**
 * Adds a cluster state listener that is expected to be removed during a short period of time.
 * If provided, the listener will be notified once a specific time has elapsed.
 *
 * NOTE: the listener is not removed on timeout. This is the responsibility of the caller.
 */
public void addTimeoutListener(@Nullable final TimeValue timeout, final TimeoutClusterStateListener listener) {
    if (lifecycle.stoppedOrClosed()) {
        listener.onClose();
        return;
    }
    // call the post added notification on the same event thread
    try {
        threadPoolExecutor.execute(new SourcePrioritizedRunnable(Priority.HIGH, "_add_listener_") {
            @Override
            public void run() {
                if (timeout != null) {
                    NotifyTimeout notifyTimeout = new NotifyTimeout(listener, timeout);
                    notifyTimeout.future = threadPool.schedule(timeout, ThreadPool.Names.GENERIC, notifyTimeout);
                    onGoingTimeouts.add(notifyTimeout);
                }
                timeoutClusterStateListeners.add(listener);
                listener.postAdded();
            }
        });
    } catch (EsRejectedExecutionException e) {
        if (lifecycle.stoppedOrClosed()) {
            listener.onClose();
        } else {
            throw e;
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:ClusterService.java


示例19: onAfter

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
@Override
public void onAfter() {
    // if this has not been cancelled reschedule it to run again
    if (run) {
        try {
            threadPool.schedule(interval, executor, this);
        } catch (final EsRejectedExecutionException e) {
            onRejection(e);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:ThreadPool.java


示例20: testSyncRetryBacksOff

import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; //导入依赖的package包/类
public void testSyncRetryBacksOff() throws Exception {
    BackoffPolicy backoff = BackoffPolicy.constantBackoff(DELAY, CALLS_TO_FAIL);

    BulkRequest bulkRequest = createBulkRequest();
    BulkResponse response = Retry
            .on(EsRejectedExecutionException.class)
            .policy(backoff)
            .withSyncBackoff(bulkClient, bulkRequest);

    assertFalse(response.hasFailures());
    assertThat(response.getItems().length, equalTo(bulkRequest.numberOfActions()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:RetryTests.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileDirContext类代码示例发布时间:2022-05-22
下一篇:
Java Labels类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap