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


Java NodeDisconnectedException类代码示例

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


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

示例1: doExecute

import org.elasticsearch.transport.NodeDisconnectedException; //导入依赖的package包/类
private void doExecute(TRequest request, ActionListener<TResponse> listener, final int attempt, UUID jobId, long startTime) {
    statsTables.activeRequestsInc();
    if (disabled) {
        sendResponse(listener, new NodeDisconnectedException(clusterService.localNode(), actionName));
        return;
    }
    try {
        Statement statement = statementCache.get(request.stmt());
        Analysis analysis = analyzer.analyze(statement, getParamContext(request));
        if (analysis.analyzedStatement().isWriteOperation() && settings.getAsBoolean(NODE_READ_ONLY_SETTING, false)) {
            throw new ReadOnlyException();
        }
        processAnalysis(analysis, request, listener, attempt, jobId, startTime);
    } catch (Throwable e) {
        logger.error("Error executing SQLRequest", e);
        sendResponse(listener, buildSQLActionException(e));
        statsTables.jobFinished(jobId, e.getMessage());
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:20,代码来源:TransportBaseSQLAction.java

示例2: maybeNodeFailed

import org.elasticsearch.transport.NodeDisconnectedException; //导入依赖的package包/类
final void maybeNodeFailed(DiscoveryNode node, Exception ex) {
    if (ex instanceof NodeDisconnectedException || ex instanceof NodeNotConnectedException) {
        hostFailureListener.onNodeDisconnected(node, ex);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:6,代码来源:TransportClientNodesService.java

示例3: testBasicSerialization

import org.elasticsearch.transport.NodeDisconnectedException; //导入依赖的package包/类
public void testBasicSerialization() throws Exception {
    ImmutableOpenMap.Builder<String, ImmutableOpenIntMap<List<IndicesShardStoresResponse.StoreStatus>>> indexStoreStatuses = ImmutableOpenMap.builder();
    List<IndicesShardStoresResponse.Failure> failures = new ArrayList<>();
    ImmutableOpenIntMap.Builder<List<IndicesShardStoresResponse.StoreStatus>> storeStatuses = ImmutableOpenIntMap.builder();

    DiscoveryNode node1 = new DiscoveryNode("node1", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
    DiscoveryNode node2 = new DiscoveryNode("node2", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
    List<IndicesShardStoresResponse.StoreStatus> storeStatusList = new ArrayList<>();
    storeStatusList.add(new IndicesShardStoresResponse.StoreStatus(node1, null, IndicesShardStoresResponse.StoreStatus.AllocationStatus.PRIMARY, null));
    storeStatusList.add(new IndicesShardStoresResponse.StoreStatus(node2, UUIDs.randomBase64UUID(), IndicesShardStoresResponse.StoreStatus.AllocationStatus.REPLICA, null));
    storeStatusList.add(new IndicesShardStoresResponse.StoreStatus(node1, UUIDs.randomBase64UUID(), IndicesShardStoresResponse.StoreStatus.AllocationStatus.UNUSED, new IOException("corrupted")));
    storeStatuses.put(0, storeStatusList);
    storeStatuses.put(1, storeStatusList);
    ImmutableOpenIntMap<List<IndicesShardStoresResponse.StoreStatus>> storesMap = storeStatuses.build();
    indexStoreStatuses.put("test", storesMap);
    indexStoreStatuses.put("test2", storesMap);

    failures.add(new IndicesShardStoresResponse.Failure("node1", "test", 3, new NodeDisconnectedException(node1, "")));

    IndicesShardStoresResponse storesResponse = new IndicesShardStoresResponse(indexStoreStatuses.build(), Collections.unmodifiableList(failures));
    XContentBuilder contentBuilder = XContentFactory.jsonBuilder();
    contentBuilder.startObject();
    storesResponse.toXContent(contentBuilder, ToXContent.EMPTY_PARAMS);
    contentBuilder.endObject();
    BytesReference bytes = contentBuilder.bytes();

    try (XContentParser parser = createParser(JsonXContent.jsonXContent, bytes)) {
        Map<String, Object> map = parser.map();
        List failureList = (List) map.get("failures");
        assertThat(failureList.size(), equalTo(1));
        HashMap failureMap = (HashMap) failureList.get(0);
        assertThat(failureMap.containsKey("index"), equalTo(true));
        assertThat(((String) failureMap.get("index")), equalTo("test"));
        assertThat(failureMap.containsKey("shard"), equalTo(true));
        assertThat(((int) failureMap.get("shard")), equalTo(3));
        assertThat(failureMap.containsKey("node"), equalTo(true));
        assertThat(((String) failureMap.get("node")), equalTo("node1"));

        Map<String, Object> indices = (Map<String, Object>) map.get("indices");
        for (String index : new String[] {"test", "test2"}) {
            assertThat(indices.containsKey(index), equalTo(true));
            Map<String, Object> shards = ((Map<String, Object>) ((Map<String, Object>) indices.get(index)).get("shards"));
            assertThat(shards.size(), equalTo(2));
            for (String shardId : shards.keySet()) {
                HashMap shardStoresStatus = (HashMap) shards.get(shardId);
                assertThat(shardStoresStatus.containsKey("stores"), equalTo(true));
                List stores = (ArrayList) shardStoresStatus.get("stores");
                assertThat(stores.size(), equalTo(storeStatusList.size()));
                for (int i = 0; i < stores.size(); i++) {
                    HashMap storeInfo = ((HashMap) stores.get(i));
                    IndicesShardStoresResponse.StoreStatus storeStatus = storeStatusList.get(i);
                    assertThat(((String) storeInfo.get("allocation_id")), equalTo((storeStatus.getAllocationId())));
                    assertThat(storeInfo.containsKey("allocation"), equalTo(true));
                    assertThat(((String) storeInfo.get("allocation")), equalTo(storeStatus.getAllocationStatus().value()));
                    assertThat(storeInfo.containsKey(storeStatus.getNode().getId()), equalTo(true));
                    if (storeStatus.getStoreException() != null) {
                        assertThat(storeInfo.containsKey("store_exception"), equalTo(true));
                    }
                }
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:64,代码来源:IndicesShardStoreResponseTests.java


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