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


Java RemoteTransportException类代码示例

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


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

示例1: unwrap

import org.elasticsearch.transport.RemoteTransportException; //导入依赖的package包/类
public static Throwable unwrap(@Nonnull Throwable t) {
    int counter = 0;
    Throwable result = t;
    while (result instanceof RemoteTransportException ||
           result instanceof UncheckedExecutionException ||
           result instanceof UncategorizedExecutionException ||
           result instanceof ExecutionException) {
        Throwable cause = result.getCause();
        if (cause == null) {
            return result;
        }
        if (cause == result) {
            return result;
        }
        if (counter > 10) {
            return result;
        }
        counter++;
        result = cause;
    }
    return result;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:Exceptions.java

示例2: sendFiles

import org.elasticsearch.transport.RemoteTransportException; //导入依赖的package包/类
void sendFiles(Store store, StoreFileMetaData[] files, Function<StoreFileMetaData, OutputStream> outputStreamFactory) throws Exception {
    store.incRef();
    try {
        ArrayUtil.timSort(files, (a, b) -> Long.compare(a.length(), b.length())); // send smallest first
        for (int i = 0; i < files.length; i++) {
            final StoreFileMetaData md = files[i];
            try (IndexInput indexInput = store.directory().openInput(md.name(), IOContext.READONCE)) {
                // it's fine that we are only having the indexInput in the try/with block. The copy methods handles
                // exceptions during close correctly and doesn't hide the original exception.
                Streams.copy(new InputStreamIndexInput(indexInput, md.length()), outputStreamFactory.apply(md));
            } catch (Exception e) {
                final IOException corruptIndexException;
                if ((corruptIndexException = ExceptionsHelper.unwrapCorruption(e)) != null) {
                    if (store.checkIntegrityNoException(md) == false) { // we are corrupted on the primary -- fail!
                        logger.warn("{} Corrupted file detected {} checksum mismatch", shardId, md);
                        failEngine(corruptIndexException);
                        throw corruptIndexException;
                    } else { // corruption has happened on the way to replica
                        RemoteTransportException exception = new RemoteTransportException("File corruption occurred on recovery but " +
                                "checksums are ok", null);
                        exception.addSuppressed(e);
                        logger.warn(
                            (org.apache.logging.log4j.util.Supplier<?>) () -> new ParameterizedMessage(
                                "{} Remote file corruption on node {}, recovering {}. local checksum OK",
                                shardId,
                                request.targetNode(),
                                md),
                            corruptIndexException);
                        throw exception;
                    }
                } else {
                    throw e;
                }
            }
        }
    } finally {
        store.decRef();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:40,代码来源:RecoverySourceHandler.java

示例3: sendShardAction

import org.elasticsearch.transport.RemoteTransportException; //导入依赖的package包/类
private void sendShardAction(final String actionName, final ClusterState currentState, final ShardEntry shardEntry, final Listener listener) {
    ClusterStateObserver observer = new ClusterStateObserver(currentState, clusterService, null, logger, threadPool.getThreadContext());
    DiscoveryNode masterNode = currentState.nodes().getMasterNode();
    Predicate<ClusterState> changePredicate = MasterNodeChangePredicate.build(currentState);
    if (masterNode == null) {
        logger.warn("{} no master known for action [{}] for shard entry [{}]", shardEntry.shardId, actionName, shardEntry);
        waitForNewMasterAndRetry(actionName, observer, shardEntry, listener, changePredicate);
    } else {
        logger.debug("{} sending [{}] to [{}] for shard entry [{}]", shardEntry.shardId, actionName, masterNode.getId(), shardEntry);
        transportService.sendRequest(masterNode,
            actionName, shardEntry, new EmptyTransportResponseHandler(ThreadPool.Names.SAME) {
                @Override
                public void handleResponse(TransportResponse.Empty response) {
                    listener.onSuccess();
                }

                @Override
                public void handleException(TransportException exp) {
                    if (isMasterChannelException(exp)) {
                        waitForNewMasterAndRetry(actionName, observer, shardEntry, listener, changePredicate);
                    } else {
                        logger.warn((Supplier<?>) () -> new ParameterizedMessage("{} unexpected failure while sending request [{}] to [{}] for shard entry [{}]", shardEntry.shardId, actionName, masterNode, shardEntry), exp);
                        listener.onFailure(exp instanceof RemoteTransportException ? (Exception) (exp.getCause() instanceof Exception ? exp.getCause() : new ElasticsearchException(exp.getCause())) : exp);
                    }
                }
            });
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:ShardStateAction.java

示例4: testConvert

import org.elasticsearch.transport.RemoteTransportException; //导入依赖的package包/类
public void testConvert() throws IOException {
    RestRequest request = new FakeRestRequest();
    RestChannel channel = new DetailedExceptionRestChannel(request);
    ShardSearchFailure failure = new ShardSearchFailure(new ParsingException(1, 2, "foobar", null),
            new SearchShardTarget("node_1", new Index("foo", "_na_"), 1));
    ShardSearchFailure failure1 = new ShardSearchFailure(new ParsingException(1, 2, "foobar", null),
            new SearchShardTarget("node_1", new Index("foo", "_na_"), 2));
    SearchPhaseExecutionException ex = new SearchPhaseExecutionException("search", "all shards failed",  new ShardSearchFailure[] {failure, failure1});
    BytesRestResponse response = new BytesRestResponse(channel, new RemoteTransportException("foo", ex));
    String text = response.content().utf8ToString();
    String expected = "{\"error\":{\"root_cause\":[{\"type\":\"parsing_exception\",\"reason\":\"foobar\",\"line\":1,\"col\":2}],\"type\":\"search_phase_execution_exception\",\"reason\":\"all shards failed\",\"phase\":\"search\",\"grouped\":true,\"failed_shards\":[{\"shard\":1,\"index\":\"foo\",\"node\":\"node_1\",\"reason\":{\"type\":\"parsing_exception\",\"reason\":\"foobar\",\"line\":1,\"col\":2}}]},\"status\":400}";
    assertEquals(expected.trim(), text.trim());
    String stackTrace = ExceptionsHelper.stackTrace(ex);
    assertTrue(stackTrace.contains("Caused by: ParsingException[foobar]"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:BytesRestResponseTests.java

示例5: getDefaultIndex

import org.elasticsearch.transport.RemoteTransportException; //导入依赖的package包/类
private String getDefaultIndex(OpenshiftRequestContext context, Client esClient, String kibanaVersion, String projectPrefix) {
    GetRequest request = esClient
            .prepareGet(context.getKibanaIndex(), DEFAULT_INDEX_TYPE, kibanaVersion)
            .putHeader(ConfigConstants.SG_CONF_REQUEST_HEADER, "true")
            .request();

    try {
        GetResponse response = esClient.get(request).get();

        Map<String, Object> source = response.getSource();

        // if source == null then its a different version of kibana that was
        // used -- we'll need to recreate
        if (source != null && source.containsKey(DEFAULT_INDEX_FIELD)) {
            LOGGER.debug("Received response with 'defaultIndex' = {}", source.get(DEFAULT_INDEX_FIELD));
            String index = (String) source.get(DEFAULT_INDEX_FIELD);

            return getProjectFromIndex(index, projectPrefix);
        } else {
            LOGGER.debug("Received response without 'defaultIndex'");
        }

    } catch (InterruptedException | ExecutionException e) {

        if (e.getCause() instanceof RemoteTransportException
                && e.getCause().getCause() instanceof IndexNotFoundException) {
            LOGGER.debug("No index found");
        } else {
            LOGGER.error("Error getting default index for {}", e, context.getUser());
        }
    }

    return "";
}
 
开发者ID:fabric8io,项目名称:openshift-elasticsearch-plugin,代码行数:35,代码来源:KibanaSeed.java

示例6: getProjectNamesFromIndexes

import org.elasticsearch.transport.RemoteTransportException; //导入依赖的package包/类
private Set<String> getProjectNamesFromIndexes(OpenshiftRequestContext context, Client esClient, String projectPrefix) {

        Set<String> patterns = new HashSet<String>();

        SearchRequest request = esClient.prepareSearch(context.getKibanaIndex()).setTypes(INDICIES_TYPE)
                .putHeader(ConfigConstants.SG_CONF_REQUEST_HEADER, "true")
                .request();

        try {
            SearchResponse response = esClient.search(request).get();

            if (response.getHits() != null && response.getHits().getTotalHits() > 0) {
                for (SearchHit hit : response.getHits().getHits()) {
                    String id = hit.getId();
                    String project = getProjectFromIndex(id, projectPrefix);

                    if (!project.equals(id) || project.equalsIgnoreCase(ADMIN_ALIAS_NAME)) {
                        patterns.add(project);
                    }

                    // else -> this is user created, leave it alone
                }
            }

        } catch (InterruptedException | ExecutionException e) {
            // if is ExecutionException with cause of IndexMissingException
            if (e.getCause() instanceof RemoteTransportException
                    && e.getCause().getCause() instanceof IndexNotFoundException) {
                LOGGER.debug("Encountered IndexMissingException, returning empty response");
            } else {
                LOGGER.error("Error getting index patterns for {}", e, context.getUser());
            }
        }

        return patterns;
    }
 
开发者ID:fabric8io,项目名称:openshift-elasticsearch-plugin,代码行数:37,代码来源:KibanaSeed.java


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