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


Java ElasticsearchTimeoutException类代码示例

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


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

示例1: doRun

import org.elasticsearch.ElasticsearchTimeoutException; //导入依赖的package包/类
@Override
protected void doRun() throws Exception {
    RecoveryStatus status = onGoingRecoveries.get(recoveryId);
    if (status == null) {
        logger.trace("[monitor] no status found for [{}], shutting down", recoveryId);
        return;
    }
    long accessTime = status.lastAccessTime();
    if (accessTime == lastSeenAccessTime) {
        String message = "no activity after [" + checkInterval + "]";
        failRecovery(recoveryId,
                new RecoveryFailedException(status.state(), message, new ElasticsearchTimeoutException(message)),
                true // to be safe, we don't know what go stuck
        );
        return;
    }
    lastSeenAccessTime = accessTime;
    logger.trace("[monitor] rescheduling check for [{}]. last access time is [{}]", recoveryId, lastSeenAccessTime);
    threadPool.schedule(checkInterval, ThreadPool.Names.GENERIC, this);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:21,代码来源:RecoveriesCollection.java

示例2: doRun

import org.elasticsearch.ElasticsearchTimeoutException; //导入依赖的package包/类
@Override
protected void doRun() throws Exception {
    RecoveryTarget status = onGoingRecoveries.get(recoveryId);
    if (status == null) {
        logger.trace("[monitor] no status found for [{}], shutting down", recoveryId);
        return;
    }
    long accessTime = status.lastAccessTime();
    if (accessTime == lastSeenAccessTime) {
        String message = "no activity after [" + checkInterval + "]";
        failRecovery(recoveryId,
                new RecoveryFailedException(status.state(), message, new ElasticsearchTimeoutException(message)),
                true // to be safe, we don't know what go stuck
        );
        return;
    }
    lastSeenAccessTime = accessTime;
    logger.trace("[monitor] rescheduling check for [{}]. last access time is [{}]", recoveryId, lastSeenAccessTime);
    threadPool.schedule(checkInterval, ThreadPool.Names.GENERIC, this);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:RecoveriesCollection.java

示例3: startNodes

import org.elasticsearch.ElasticsearchTimeoutException; //导入依赖的package包/类
@Before
public void startNodes() {
    try {
        logger.info("starting");
        setClusterName();
        startNode("1");
        findNodeAddress();
        try {
            ClusterHealthResponse healthResponse = client("1").execute(ClusterHealthAction.INSTANCE,
                            new ClusterHealthRequest().waitForStatus(ClusterHealthStatus.GREEN).timeout(TimeValue.timeValueSeconds(30))).actionGet();
            if (healthResponse != null && healthResponse.isTimedOut()) {
                throw new IOException("cluster state is " + healthResponse.getStatus().name()
                        + ", from here on, everything will fail!");
            }
        } catch (ElasticsearchTimeoutException e) {
            throw new IOException("timeout, cluster does not respond to health request, cowardly refusing to continue with operations");
        }
    } catch (Throwable t) {
        logger.error("startNodes failed", t);
    }
}
 
开发者ID:jprante,项目名称:elasticsearch-client-http,代码行数:22,代码来源:NodeTestUtils.java

示例4: waitForCluster

import org.elasticsearch.ElasticsearchTimeoutException; //导入依赖的package包/类
public static void waitForCluster(Client client, ClusterHealthStatus statusThreshold,
    String timeout) throws UnableToStartException {
  try {
    ClusterHealthResponse healthResponse = (ClusterHealthResponse) client
        .execute(ClusterHealthAction.INSTANCE,
            new ClusterHealthRequest().waitForStatus(statusThreshold).timeout(timeout))
        .actionGet();
    if (healthResponse != null && healthResponse.isTimedOut()) {
      throw new UnableToStartException("cluster state is " + healthResponse.getStatus().name()
          + " and not " + statusThreshold.name()
          + ", from here on, everything will fail!");
    }
  } catch (ElasticsearchTimeoutException e) {
    throw new UnableToStartException(
        "timeout, cluster does not respond to health request, cowardly refusing to continue with operations");
  }
}
 
开发者ID:apache,项目名称:metron,代码行数:18,代码来源:ElasticSearchComponent.java

示例5: waitForCluster

import org.elasticsearch.ElasticsearchTimeoutException; //导入依赖的package包/类
public void waitForCluster(String statusString, TimeValue timeout) throws IOException {
    if (client() == null) {
        return;
    }
    try {
        ClusterHealthStatus status = ClusterHealthStatus.fromString(statusString);
        ClusterHealthResponse healthResponse =
                client().execute(ClusterHealthAction.INSTANCE, new ClusterHealthRequest().waitForStatus(status).timeout(timeout)).actionGet();
        if (healthResponse != null && healthResponse.isTimedOut()) {
            throw new IOException("cluster state is " + healthResponse.getStatus().name()
                    + " and not " + status.name()
                    + ", from here on, everything will fail!");
        }
    } catch (ElasticsearchTimeoutException e) {
        throw new IOException("timeout, cluster does not respond to health request, cowardly refusing to continue with operations");
    }
}
 
开发者ID:jprante,项目名称:elasticsearch-helper,代码行数:18,代码来源:BaseClient.java

示例6: waitForTaskCompletion

import org.elasticsearch.ElasticsearchTimeoutException; //导入依赖的package包/类
/**
 * Blocks the calling thread, waiting for the task to vanish from the TaskManager.
 */
public void waitForTaskCompletion(Task task, long untilInNanos) {
    while (System.nanoTime() - untilInNanos < 0) {
        if (getTask(task.getId()) == null) {
            return;
        }
        try {
            Thread.sleep(WAIT_FOR_COMPLETION_POLL.millis());
        } catch (InterruptedException e) {
            throw new ElasticsearchException("Interrupted waiting for completion of [{}]", e, task);
        }
    }
    throw new ElasticsearchTimeoutException("Timed out waiting for completion of [{}]", task);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:TaskManager.java

示例7: waitForTimeoutTestCase

import org.elasticsearch.ElasticsearchTimeoutException; //导入依赖的package包/类
/**
 * Test waiting for a task that times out.
 * @param wait wait for the running task and return all the failures you accumulated waiting for it
 */
private void waitForTimeoutTestCase(Function<TaskId, ? extends Iterable<? extends Throwable>> wait) throws Exception {
    // Start blocking test task
    ListenableActionFuture<TestTaskPlugin.NodesResponse> future = TestTaskPlugin.TestTaskAction.INSTANCE.newRequestBuilder(client())
            .execute();
    try {
        TaskId taskId = waitForTestTaskStartOnAllNodes();

        // Wait for the task to start
        assertBusy(() -> client().admin().cluster().prepareGetTask(taskId).get());

        // Spin up a request that should wait for those tasks to finish
        // It will timeout because we haven't unblocked the tasks
        Iterable<? extends Throwable> failures = wait.apply(taskId);

        for (Throwable failure : failures) {
            assertNotNull(
                    ExceptionsHelper.unwrap(failure, ElasticsearchTimeoutException.class, ReceiveTimeoutTransportException.class));
        }
    } finally {
        // Now we can unblock those requests
        TestTaskPlugin.UnblockTestTasksAction.INSTANCE.newRequestBuilder(client()).get();
    }
    future.get();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:TasksIT.java

示例8: joinClusterAndWaitForInitialState

import org.elasticsearch.ElasticsearchTimeoutException; //导入依赖的package包/类
public void joinClusterAndWaitForInitialState() {
    try {
        discovery.startInitialJoin();
        if (!initialStateListener.waitForInitialState(initialStateTimeout)) {
            logger.warn("waited for {} and no initial state was set by the discovery", initialStateTimeout);
        }
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new ElasticsearchTimeoutException("Interrupted while waiting for initial discovery state");
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:DiscoveryService.java

示例9: download

import org.elasticsearch.ElasticsearchTimeoutException; //导入依赖的package包/类
public boolean download(URL source, Path dest, @Nullable DownloadProgress progress, TimeValue timeout) throws Exception {
    if (Files.exists(dest) && skipExisting) {
        return true;
    }

    //don't do any progress, unless asked
    if (progress == null) {
        progress = new NullProgress();
    }

    //set the timestamp to the file date.
    long timestamp = 0;

    boolean hasTimestamp = false;
    if (useTimestamp && Files.exists(dest) ) {
        timestamp = Files.getLastModifiedTime(dest).toMillis();
        hasTimestamp = true;
    }

    GetThread getThread = new GetThread(source, dest, hasTimestamp, timestamp, progress);

    try {
        getThread.setDaemon(true);
        getThread.start();
        getThread.join(timeout.millis());

        if (getThread.isAlive()) {
            throw new ElasticsearchTimeoutException("The GET operation took longer than " + timeout + ", stopping it.");
        }
    }
    catch (InterruptedException ie) {
        return false;
    } finally {
        getThread.closeStreams();
    }

    return getThread.wasSuccessful();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:39,代码来源:HttpDownloadHelper.java

示例10: processTasks

import org.elasticsearch.ElasticsearchTimeoutException; //导入依赖的package包/类
@Override
protected void processTasks(ListTasksRequest request, final Consumer<Task> operation) {
    if (false == request.getWaitForCompletion()) {
        super.processTasks(request, operation);
        return;
    }
    // If we should wait for completion then we have to intercept every found task and wait for it to leave the manager.
    TimeValue timeout = request.getTimeout();
    if (timeout == null) {
        timeout = DEFAULT_WAIT_FOR_COMPLETION_TIMEOUT;
    }
    final long timeoutTime = System.nanoTime() + timeout.nanos();
    super.processTasks(request, new Consumer<Task>() {
        @Override
        public void accept(Task t) {
            operation.accept(t);
            while (System.nanoTime() - timeoutTime < 0) {
                Task task = taskManager.getTask(t.getId());
                if (task == null) {
                    return;
                }
                if (task.getAction().startsWith(ListTasksAction.NAME)) {
                    // It doesn't make sense to wait for List Tasks and it can cause an infinite loop of the task waiting
                    // for itself of one of its child tasks
                    return;
                }
                try {
                    Thread.sleep(WAIT_FOR_COMPLETION_POLL.millis());
                } catch (InterruptedException e) {
                    throw new ElasticsearchException("Interrupted waiting for completion of [{}]", e, t);
                }
            }
            throw new ElasticsearchTimeoutException("Timed out waiting for completion of [{}]", t);
        }
    });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:37,代码来源:TransportListTasksAction.java

示例11: waitForCluster

import org.elasticsearch.ElasticsearchTimeoutException; //导入依赖的package包/类
public static void waitForCluster(ElasticsearchClient client, ClusterHealthStatus status, TimeValue timeout) throws UnableToStartException {
    try {
        ClusterHealthResponse healthResponse =
                (ClusterHealthResponse)client.execute(ClusterHealthAction.INSTANCE, new ClusterHealthRequest().waitForStatus(status).timeout(timeout)).actionGet();
        if (healthResponse != null && healthResponse.isTimedOut()) {
            throw new UnableToStartException("cluster state is " + healthResponse.getStatus().name()
                    + " and not " + status.name()
                    + ", from here on, everything will fail!");
        }
    } catch (ElasticsearchTimeoutException e) {
        throw new UnableToStartException("timeout, cluster does not respond to health request, cowardly refusing to continue with operations");
    }
}
 
开发者ID:cestella,项目名称:streaming_outliers,代码行数:14,代码来源:ElasticSearchComponent.java

示例12: waitForCluster

import org.elasticsearch.ElasticsearchTimeoutException; //导入依赖的package包/类
protected void waitForCluster(final ClusterHealthStatus status, final TimeValue timeout, final Client client) throws IOException {
    try {
        log.debug("waiting for cluster state {}", status.name());
        final ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForStatus(status)
                .setTimeout(timeout).setWaitForNodes("3").execute().actionGet();
        if (healthResponse.isTimedOut()) {
            throw new IOException("cluster state is " + healthResponse.getStatus().name() + " and not " + status.name()
                    + ", cowardly refusing to continue with operations");
        } else {
            log.debug("... cluster state ok");
        }
    } catch (final ElasticsearchTimeoutException e) {
        throw new IOException("timeout, cluster does not respond to health request, cowardly refusing to continue with operations");
    }
}
 
开发者ID:petalmd,项目名称:armor,代码行数:16,代码来源:AbstractUnitTest.java

示例13: waitForCluster

import org.elasticsearch.ElasticsearchTimeoutException; //导入依赖的package包/类
protected void waitForCluster(final ClusterHealthStatus status, final TimeValue timeout) throws IOException {
    try {
        log.debug("waiting for cluster state {}", status.name());
        final ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForStatus(status)
                .setWaitForNodes(">2").setTimeout(timeout).execute().actionGet();
        if (healthResponse.isTimedOut()) {
            throw new IOException("cluster state is " + healthResponse.getStatus().name() + " and not " + status.name()
                    + ", cowardly refusing to continue with operations");
        } else {
            log.debug("... cluster state ok");
        }
    } catch (final ElasticsearchTimeoutException e) {
        throw new IOException("timeout, cluster does not respond to health request, cowardly refusing to continue with operations");
    }
}
 
开发者ID:codecentric,项目名称:elasticsearch-shield-kerberos-realm,代码行数:16,代码来源:AbstractUnitTest.java

示例14: waitForCluster

import org.elasticsearch.ElasticsearchTimeoutException; //导入依赖的package包/类
public static void waitForCluster(Client client, ClusterHealthStatus status, TimeValue timeout) throws IOException {
    try {
        ClusterHealthResponse healthResponse =
                client.admin().cluster().prepareHealth().setWaitForStatus(status).setTimeout(timeout).execute().actionGet();
        if (healthResponse != null && healthResponse.isTimedOut()) {
            throw new IOException("cluster state is " + healthResponse.getStatus().name()
                    + " and not " + status.name()
                    + ", cowardly refusing to continue with operations");
        }
    } catch (ElasticsearchTimeoutException e) {
        throw new IOException("timeout, cluster does not respond to health request, cowardly refusing to continue with operations");
    }
}
 
开发者ID:szwork2013,项目名称:elasticsearch-sentiment,代码行数:14,代码来源:ClientHelper.java

示例15: waitForCluster

import org.elasticsearch.ElasticsearchTimeoutException; //导入依赖的package包/类
private void waitForCluster(final ClusterHealthStatus status, final TimeValue timeout) throws IOException {
    try {
        logger.debug("waiting for cluster state {}", status.name());
        final ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForStatus(status)
                .setTimeout(timeout).execute().actionGet();
        if (healthResponse.isTimedOut()) {
            throw new IOException("cluster state is " + healthResponse.getStatus().name() + " and not " + status.name()
                    + ", cowardly refusing to continue with operations");
        } else {
            logger.debug("... cluster state ok");
        }
    } catch (final ElasticsearchTimeoutException e) {
        throw new IOException("timeout, cluster does not respond to health request, cowardly refusing to continue with operations");
    }
}
 
开发者ID:salyh,项目名称:elasticsearch-imap,代码行数:16,代码来源:ElasticsearchStateManager.java


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