org.elasticsearch.transport.TransportService.registerRequestHandler()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(13.1k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中org.elasticsearch.transport.TransportService.registerRequestHandler()方法的一些代码示例,展示了TransportService.registerRequestHandler()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TransportService.registerRequestHandler()方法的具体详情如下:
包路径:org.elasticsearch.transport.TransportService
类名称:TransportService
方法名:registerRequestHandler

TransportService.registerRequestHandler介绍

[英]Registers a new request handler
[中]注册一个新的请求处理程序

代码示例

代码示例来源:origin: org.elasticsearch/elasticsearch

protected TransportBroadcastAction(Settings settings, String actionName, ThreadPool threadPool, ClusterService clusterService,
                  TransportService transportService, ActionFilters actionFilters,
                  IndexNameExpressionResolver indexNameExpressionResolver, Supplier<Request> request,
                  Supplier<ShardRequest> shardRequest, String shardExecutor) {
  super(settings, actionName, threadPool, transportService, actionFilters, indexNameExpressionResolver, request);
  this.clusterService = clusterService;
  this.transportService = transportService;
  this.transportShardAction = actionName + "[s]";
  this.shardExecutor = shardExecutor;
  transportService.registerRequestHandler(transportShardAction, shardRequest, ThreadPool.Names.SAME, new ShardTransportHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public NodesFaultDetection(Settings settings, ThreadPool threadPool, TransportService transportService,
              Supplier<ClusterState> clusterStateSupplier, ClusterName clusterName) {
  super(settings, threadPool, transportService, clusterName);
  this.clusterStateSupplier = clusterStateSupplier;
  logger.debug("[node  ] uses ping_interval [{}], ping_timeout [{}], ping_retries [{}]", pingInterval, pingRetryTimeout,
    pingRetryCount);
  transportService.registerRequestHandler(
    PING_ACTION_NAME, PingRequest::new, ThreadPool.Names.SAME, false, false, new PingRequestHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public VerifyNodeRepositoryAction(TransportService transportService, ClusterService clusterService, RepositoriesService repositoriesService) {
  this.transportService = transportService;
  this.clusterService = clusterService;
  this.repositoriesService = repositoriesService;
  transportService.registerRequestHandler(ACTION_NAME, VerifyNodeRepositoryRequest::new, ThreadPool.Names.SNAPSHOT, new VerifyNodeRepositoryRequestHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Inject
public TransportLivenessAction(ClusterService clusterService, TransportService transportService) {
  this.clusterService = clusterService;
  transportService.registerRequestHandler(NAME, LivenessRequest::new, ThreadPool.Names.SAME,
    false, false /*can not trip circuit breaker*/, this);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public MasterFaultDetection(Settings settings, ThreadPool threadPool, TransportService transportService,
              java.util.function.Supplier<ClusterState> clusterStateSupplier, MasterService masterService,
              ClusterName clusterName) {
  super(settings, threadPool, transportService, clusterName);
  this.clusterStateSupplier = clusterStateSupplier;
  this.masterService = masterService;
  logger.debug("[master] uses ping_interval [{}], ping_timeout [{}], ping_retries [{}]", pingInterval, pingRetryTimeout,
    pingRetryCount);
  transportService.registerRequestHandler(
    MASTER_PING_ACTION_NAME, MasterPingRequest::new, ThreadPool.Names.SAME, false, false, new MasterPingRequestHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

protected TransportTasksAction(Settings settings, String actionName, ThreadPool threadPool,
                ClusterService clusterService, TransportService transportService, ActionFilters actionFilters,
                IndexNameExpressionResolver indexNameExpressionResolver, Writeable.Reader<TasksRequest> requestSupplier,
                Supplier<TasksResponse> responseSupplier,
                String nodeExecutor) {
  super(settings, actionName, threadPool, transportService, actionFilters, requestSupplier, indexNameExpressionResolver);
  this.clusterService = clusterService;
  this.transportService = transportService;
  this.transportNodeAction = actionName + "[n]";
  this.requestSupplier = requestSupplier;
  this.responseSupplier = responseSupplier;
  transportService.registerRequestHandler(transportNodeAction, nodeExecutor, NodeTaskRequest::new, new NodeTransportHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public PublishClusterStateAction(
    TransportService transportService,
    NamedWriteableRegistry namedWriteableRegistry,
    IncomingClusterStateListener incomingClusterStateListener,
    DiscoverySettings discoverySettings) {
  this.transportService = transportService;
  this.namedWriteableRegistry = namedWriteableRegistry;
  this.incomingClusterStateListener = incomingClusterStateListener;
  this.discoverySettings = discoverySettings;
  transportService.registerRequestHandler(SEND_ACTION_NAME, BytesTransportRequest::new, ThreadPool.Names.SAME, false, false,
    new SendClusterStateRequestHandler());
  transportService.registerRequestHandler(COMMIT_ACTION_NAME, CommitClusterStateRequest::new, ThreadPool.Names.SAME, false, false,
    new CommitClusterStateRequestHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public MembershipAction(TransportService transportService, MembershipListener listener,
            Collection<BiConsumer<DiscoveryNode,ClusterState>> joinValidators) {
  this.transportService = transportService;
  this.listener = listener;
  transportService.registerRequestHandler(DISCOVERY_JOIN_ACTION_NAME, JoinRequest::new,
    ThreadPool.Names.GENERIC, new JoinRequestRequestHandler());
  transportService.registerRequestHandler(DISCOVERY_JOIN_VALIDATE_ACTION_NAME,
    () -> new ValidateJoinRequest(), ThreadPool.Names.GENERIC,
    new ValidateJoinRequestRequestHandler(transportService::getLocalNode, joinValidators));
  transportService.registerRequestHandler(DISCOVERY_LEAVE_ACTION_NAME, LeaveRequest::new,
    ThreadPool.Names.GENERIC, new LeaveRequestRequestHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

protected void registerRequestHandlers(String actionName, TransportService transportService, Supplier<Request> request,
                    Supplier<ReplicaRequest> replicaRequest, String executor) {
  transportService.registerRequestHandler(actionName, request, ThreadPool.Names.SAME, new OperationTransportHandler());
  transportService.registerRequestHandler(transportPrimaryAction, () -> new ConcreteShardRequest<>(request), executor,
    new PrimaryOperationTransportHandler());
  // we must never reject on because of thread pool capacity on replicas
  transportService.registerRequestHandler(transportReplicaAction,
    () -> new ConcreteReplicaRequest<>(replicaRequest),
    executor, true, true,
    new ReplicaOperationTransportHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
protected void registerRequestHandlers(String actionName, TransportService transportService, Supplier<ResyncReplicationRequest> request,
                    Supplier<ResyncReplicationRequest> replicaRequest, String executor) {
  transportService.registerRequestHandler(actionName, request, ThreadPool.Names.SAME, new OperationTransportHandler());
  // we should never reject resync because of thread pool capacity on primary
  transportService.registerRequestHandler(transportPrimaryAction,
    () -> new ConcreteShardRequest<>(request),
    executor, true, true,
    new PrimaryOperationTransportHandler());
  transportService.registerRequestHandler(transportReplicaAction,
    () -> new ConcreteReplicaRequest<>(replicaRequest),
    executor, true, true,
    new ReplicaOperationTransportHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

protected HandledTransportAction(Settings settings, String actionName, boolean canTripCircuitBreaker, ThreadPool threadPool,
                 TransportService transportService, ActionFilters actionFilters,
                 IndexNameExpressionResolver indexNameExpressionResolver, Supplier<Request> request) {
  super(settings, actionName, threadPool, actionFilters, indexNameExpressionResolver, transportService.getTaskManager());
  transportService.registerRequestHandler(actionName, request, ThreadPool.Names.SAME, false, canTripCircuitBreaker,
    new TransportHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Inject
public NodeMappingRefreshAction(TransportService transportService, MetaDataMappingService metaDataMappingService) {
  this.transportService = transportService;
  this.metaDataMappingService = metaDataMappingService;
  transportService.registerRequestHandler(ACTION_NAME,
    NodeMappingRefreshRequest::new, ThreadPool.Names.SAME, new NodeMappingRefreshTransportHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

protected HandledTransportAction(Settings settings, String actionName, boolean canTripCircuitBreaker, ThreadPool threadPool,
                 TransportService transportService, ActionFilters actionFilters,
                 Writeable.Reader<Request> requestReader, IndexNameExpressionResolver indexNameExpressionResolver) {
  super(settings, actionName, threadPool, actionFilters, indexNameExpressionResolver, transportService.getTaskManager());
  transportService.registerRequestHandler(actionName, ThreadPool.Names.SAME, false, canTripCircuitBreaker, requestReader,
    new TransportHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Inject
public LocalAllocateDangledIndices(TransportService transportService, ClusterService clusterService,
                  AllocationService allocationService, MetaDataIndexUpgradeService metaDataIndexUpgradeService) {
  this.transportService = transportService;
  this.clusterService = clusterService;
  this.allocationService = allocationService;
  this.metaDataIndexUpgradeService = metaDataIndexUpgradeService;
  transportService.registerRequestHandler(ACTION_NAME, AllocateDangledRequest::new, ThreadPool.Names.SAME,
    new AllocateDangledRequestHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Inject
public PeerRecoverySourceService(TransportService transportService, IndicesService indicesService,
                 RecoverySettings recoverySettings) {
  this.transportService = transportService;
  this.indicesService = indicesService;
  this.recoverySettings = recoverySettings;
  transportService.registerRequestHandler(Actions.START_RECOVERY, StartRecoveryRequest::new, ThreadPool.Names.GENERIC,
    new StartRecoveryTransportRequestHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

protected TransportInstanceSingleOperationAction(Settings settings, String actionName, ThreadPool threadPool,
                         ClusterService clusterService, TransportService transportService,
                         ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
                         Supplier<Request> request) {
  super(settings, actionName, threadPool, transportService, actionFilters, indexNameExpressionResolver, request);
  this.clusterService = clusterService;
  this.transportService = transportService;
  this.executor = executor();
  this.shardActionName = actionName + "[s]";
  transportService.registerRequestHandler(shardActionName, request, executor, new ShardTransportHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Inject
public TransportCancelTasksAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
                 TransportService transportService, ActionFilters actionFilters,
                 IndexNameExpressionResolver indexNameExpressionResolver) {
  super(settings, CancelTasksAction.NAME, threadPool, clusterService, transportService, actionFilters,
    indexNameExpressionResolver, CancelTasksRequest::new, CancelTasksResponse::new, ThreadPool.Names.MANAGEMENT);
  transportService.registerRequestHandler(BAN_PARENT_ACTION_NAME, ThreadPool.Names.SAME, BanParentTaskRequest::new,
    new BanParentRequestHandler());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Inject
public ShardStateAction(ClusterService clusterService, TransportService transportService,
            AllocationService allocationService, RoutingService routingService, ThreadPool threadPool) {
  this.transportService = transportService;
  this.clusterService = clusterService;
  this.threadPool = threadPool;
  transportService.registerRequestHandler(SHARD_STARTED_ACTION_NAME, ThreadPool.Names.SAME, StartedShardEntry::new,
    new ShardStartedTransportHandler(clusterService, new ShardStartedClusterStateTaskExecutor(allocationService, logger), logger));
  transportService.registerRequestHandler(SHARD_FAILED_ACTION_NAME, ThreadPool.Names.SAME, FailedShardEntry::new,
    new ShardFailedTransportHandler(clusterService,
      new ShardFailedClusterStateTaskExecutor(allocationService, routingService, logger), logger));
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * Registers a proxy request handler that allows to forward requests for the given action to another node. To be used when the
 * response type is always the same (most of the cases).
 */
public static void registerProxyAction(TransportService service, String action,
                    Writeable.Reader<? extends TransportResponse> reader) {
  RequestHandlerRegistry<? extends TransportRequest> requestHandler = service.getRequestHandler(action);
  service.registerRequestHandler(getProxyAction(action), ThreadPool.Names.SAME, true, false,
    in -> new ProxyRequest<>(in, requestHandler::newRequest), new ProxyRequestHandler<>(service, action, request -> reader));
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * Registers a proxy request handler that allows to forward requests for the given action to another node. To be used when the
 * response type changes based on the upcoming request (quite rare)
 */
public static void registerProxyActionWithDynamicResponseType(TransportService service, String action,
                               Function<TransportRequest,
                                 Writeable.Reader<? extends TransportResponse>> responseFunction) {
  RequestHandlerRegistry<? extends TransportRequest> requestHandler = service.getRequestHandler(action);
  service.registerRequestHandler(getProxyAction(action), ThreadPool.Names.SAME, true, false,
    in -> new ProxyRequest<>(in, requestHandler::newRequest), new ProxyRequestHandler<>(service, action, responseFunction));
}

相关文章

微信公众号

最新文章

更多

TransportService类方法