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


Java TransportChannel类代码示例

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


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

示例1: messageReceived

import org.elasticsearch.transport.TransportChannel; //导入依赖的package包/类
@Override
public void messageReceived(PingRequest request, TransportChannel channel) throws Exception {
    // if we are not the node we are supposed to be pinged, send an exception
    // this can happen when a kill -9 is sent, and another node is started using the same port
    if (!localNode.equals(request.targetNode())) {
        throw new IllegalStateException("Got pinged as node " + request.targetNode() + "], but I am node " + localNode );
    }

    // PingRequest will have clusterName set to null if it came from a node of version <1.4.0
    if (request.clusterName != null && !request.clusterName.equals(clusterName)) {
        // Don't introduce new exception for bwc reasons
        throw new IllegalStateException("Got pinged with cluster name [" + request.clusterName + "], but I'm part of cluster ["
            + clusterName + "]");
    }

    notifyPingReceived(request);

    channel.sendResponse(new PingResponse());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:NodesFaultDetection.java

示例2: messageReceived

import org.elasticsearch.transport.TransportChannel; //导入依赖的package包/类
@Override
public void messageReceived(T request, TransportChannel channel, Task task) throws Exception {
    synchronized (InterceptingTransportService.this) {
        if (actions.contains(action)) {
            List<TransportRequest> requestList = requests.get(action);
            if (requestList == null) {
                requestList = new ArrayList<>();
                requestList.add(request);
                requests.put(action, requestList);
            } else {
                requestList.add(request);
            }
        }
    }
    requestHandler.messageReceived(request, channel, task);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:IndicesRequestIT.java

示例3: messageReceived

import org.elasticsearch.transport.TransportChannel; //导入依赖的package包/类
@Override
public void messageReceived(final PingRequest request, final TransportChannel channel) throws Exception {
    if (indexingProxyService.isRunning(request.getIndex())) {
        channel.sendResponse(new PingResponse(true, true));
    } else {
        indexingProxyService.startRequestSender(request.getIndex(), 0, wrap(response -> {
            channel.sendResponse(new PingResponse(true, false));
        }, e -> {
            try {
                channel.sendResponse(e);
            } catch (final IOException e1) {
                throw new ElasticsearchException("Failed to write a response.", e1);
            }
        }));
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-indexing-proxy,代码行数:17,代码来源:PingRequestHandler.java

示例4: messageReceived

import org.elasticsearch.transport.TransportChannel; //导入依赖的package包/类
@Override
public void messageReceived(PullFullClusterStateRequest request, final TransportChannel channel) throws Exception {
    ClusterStateWithDLSN clusterStateWithDLSN = clusterStateOpLog.getLatestClusterState();
    if (!clusterStateWithDLSN.state().getClusterName().equals(request.clusterName)) {
       throw new java.lang.Exception("master cluster name is [" + clusterStateWithDLSN.state().getClusterName() + "], request cluster name is [" + request.clusterName + "]");
    }
    if (!clusterStateWithDLSN.state().nodes().localNodeMaster()) {
        throw new java.lang.Exception("current node is no longer master node");
    }
    BytesStreamOutput bStream = new BytesStreamOutput();
    try (StreamOutput stream = CompressorFactory.defaultCompressor().streamOutput(bStream)) {
        clusterStateWithDLSN.writeTo(stream);
    }
    BytesReference fullStateBytes = bStream.bytes();
    channel.sendResponse(new org.elasticsearch.transport.BytesTransportResponse(fullStateBytes));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:PullFullClusterStateAction.java

示例5: messageReceived

import org.elasticsearch.transport.TransportChannel; //导入依赖的package包/类
@Override
public void messageReceived(PingRequest request, TransportChannel channel) throws Exception {
    
    // PingRequest will have clusterName set to null if it came from a node of version <1.4.0
    if (request.clusterName != null && !request.clusterName.equals(clusterName)) {
        // Don't introduce new exception for bwc reasons
        throw new IllegalStateException("Got pinged with cluster name [" + request.clusterName + "], but I'm part of cluster [" + clusterName + "]");
    }
    
    // if we are not the node we are supposed to be pinged, send an exception
    // this can happen when a kill -9 is sent, and another node is started using the same port
    if (!localNode.equals(request.pingNode)) {
        logger.warn("Got pinged as node [{}], but I am node [{}], cluster name is equal, it means I am restarted, so rejoin the cluster now", request.pingNode, localNode);
        joinClusterAction.joinElectedMaster(request.masterNode);
        throw new NodeIdNotMatchException(localNode, request.pingNode);
    }
    
    if (request.isDeadNode) {
        logger.warn("master ping me as a dead node, so that I should rejoin the cluster");
        joinClusterAction.joinElectedMaster(request.masterNode);
    }
    channel.sendResponse(new PingResponse(clusterStateOpLog.getDumpedDlsn()));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:NodesFailureDetectionService.java

示例6: messageReceived

import org.elasticsearch.transport.TransportChannel; //导入依赖的package包/类
/**
 * this is method is called on the recovery source node
 * the target is requesting the head of a file it got a PutReplicaChunkRequest for.
 */
@Override
public void messageReceived(final GetBlobHeadRequest request, TransportChannel channel) throws Exception {

    final BlobTransferStatus transferStatus = blobTransferTarget.getActiveTransfer(request.transferId);
    assert transferStatus != null :
        "Received GetBlobHeadRequest for transfer" + request.transferId.toString() + "but don't have an activeTransfer with that id";

    final DiscoveryNode recipientNode = clusterService.state().getNodes().get(request.senderNodeId);
    final long bytesToSend = request.endPos;

    blobTransferTarget.gotAGetBlobHeadRequest(request.transferId);

    channel.sendResponse(TransportResponse.Empty.INSTANCE);

    threadPool.generic().execute(
        new PutHeadChunkRunnable(
            transferStatus.digestBlob(), bytesToSend, transportService, blobTransferTarget,
            recipientNode, request.transferId)
    );
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:BlobHeadRequestHandler.java

示例7: messageReceived

import org.elasticsearch.transport.TransportChannel; //导入依赖的package包/类
@Override
public void messageReceived(final FileFlushRequest request, final TransportChannel channel) throws Exception {
    new ConfigFileWriter().execute(wrap(response -> {
        try {
            channel.sendResponse(new FileFlushResponse(true));
        } catch (final IOException e) {
            throw new ElasticsearchException("Failed to write a response.", e);
        }
    }, e -> {
        logger.error("Failed to flush config files.", e);
        try {
            channel.sendResponse(e);
        } catch (final IOException e1) {
            throw new ElasticsearchException("Failed to write a response.", e1);
        }
    }));
}
 
开发者ID:codelibs,项目名称:elasticsearch-configsync,代码行数:18,代码来源:ConfigSyncService.java

示例8: messageReceived

import org.elasticsearch.transport.TransportChannel; //导入依赖的package包/类
@Override
public void messageReceived(RecoveryPrepareForTranslogOperationsRequest request, TransportChannel channel) throws Exception {
    try (RecoveryRef recoveryRef = onGoingRecoveries.getRecoverySafe(request.recoveryId(), request.shardId()
    )) {
        recoveryRef.target().prepareForTranslogOperations(request.totalTranslogOps(), request.getMaxUnsafeAutoIdTimestamp());
    }
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:PeerRecoveryTargetService.java

示例9: messageReceived

import org.elasticsearch.transport.TransportChannel; //导入依赖的package包/类
@Override
public void messageReceived(UnicastPingRequest request, TransportChannel channel) throws Exception {
    if (request.pingResponse.clusterName().equals(clusterName)) {
        channel.sendResponse(handlePingRequest(request));
    } else {
        throw new IllegalStateException(
            String.format(
                Locale.ROOT,
                "mismatched cluster names; request: [%s], local: [%s]",
                request.pingResponse.clusterName().value(),
                clusterName.value()));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:UnicastZenPing.java

示例10: messageReceived

import org.elasticsearch.transport.TransportChannel; //导入依赖的package包/类
@Override
public void messageReceived(VerifyNodeRepositoryRequest request, TransportChannel channel) throws Exception {
    DiscoveryNode localNode = clusterService.state().nodes().getLocalNode();
    try {
        doVerify(request.repository, request.verificationToken, localNode);
    } catch (Exception ex) {
        logger.warn((Supplier<?>) () -> new ParameterizedMessage("[{}] failed to verify repository", request.repository), ex);
        throw ex;
    }
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:VerifyNodeRepositoryAction.java

示例11: messageReceived

import org.elasticsearch.transport.TransportChannel; //导入依赖的package包/类
@Override
public void messageReceived(ShardEntry request, TransportChannel channel) throws Exception {
    logger.debug("{} received shard started for [{}]", request.shardId, request);
    clusterService.submitStateUpdateTask(
        "shard-started",
        request,
        ClusterStateTaskConfig.build(Priority.URGENT),
        shardStartedClusterStateTaskExecutor,
        shardStartedClusterStateTaskExecutor);
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:ShardStateAction.java

示例12: messageReceived

import org.elasticsearch.transport.TransportChannel; //导入依赖的package包/类
@Override
public void messageReceived(final BanParentTaskRequest request, final TransportChannel channel) throws Exception {
    if (request.ban) {
        logger.debug("Received ban for the parent [{}] on the node [{}], reason: [{}]", request.parentTaskId,
            clusterService.localNode().getId(), request.reason);
        taskManager.setBan(request.parentTaskId, request.reason);
    } else {
        logger.debug("Removing ban for the parent [{}] on the node [{}]", request.parentTaskId,
            clusterService.localNode().getId());
        taskManager.removeBan(request.parentTaskId);
    }
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:TransportCancelTasksAction.java

示例13: messageReceived

import org.elasticsearch.transport.TransportChannel; //导入依赖的package包/类
@Override
public void messageReceived(final NodeRequest request, TransportChannel channel) throws Exception {
    List<ShardRouting> shards = request.getShards();
    final int totalShards = shards.size();
    if (logger.isTraceEnabled()) {
        logger.trace("[{}] executing operation on [{}] shards", actionName, totalShards);
    }
    final Object[] shardResultOrExceptions = new Object[totalShards];

    int shardIndex = -1;
    for (final ShardRouting shardRouting : shards) {
        shardIndex++;
        onShardOperation(request, shardResultOrExceptions, shardIndex, shardRouting);
    }

    List<BroadcastShardOperationFailedException> accumulatedExceptions = new ArrayList<>();
    List<ShardOperationResult> results = new ArrayList<>();
    for (int i = 0; i < totalShards; i++) {
        if (shardResultOrExceptions[i] instanceof BroadcastShardOperationFailedException) {
            accumulatedExceptions.add((BroadcastShardOperationFailedException) shardResultOrExceptions[i]);
        } else {
            results.add((ShardOperationResult) shardResultOrExceptions[i]);
        }
    }

    channel.sendResponse(new NodeResponse(request.getNodeId(), totalShards, results, accumulatedExceptions));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:TransportBroadcastByNodeAction.java

示例14: AsyncReplicaAction

import org.elasticsearch.transport.TransportChannel; //导入依赖的package包/类
AsyncReplicaAction(ReplicaRequest request, String targetAllocationID, TransportChannel channel, ReplicationTask task) {
    this.request = request;
    this.channel = channel;
    this.task = task;
    this.targetAllocationID = targetAllocationID;
    final ShardId shardId = request.shardId();
    assert shardId != null : "request shardId must be set";
    this.replica = getIndexShard(shardId);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:TransportReplicationAction.java

示例15: messageReceived

import org.elasticsearch.transport.TransportChannel; //导入依赖的package包/类
@Override
public void messageReceived(final Request request, final TransportChannel channel) throws Exception {
    if (logger.isTraceEnabled()) {
        logger.trace("executing [{}] on shard [{}]", request, request.internalShardId);
    }
    Response response = shardOperation(request, request.internalShardId);
    channel.sendResponse(response);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:TransportSingleShardAction.java


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