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

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

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

TransportService.addressSupported介绍

暂无

代码示例

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

void handleJoinRequest(final DiscoveryNode node, final ClusterState state, final MembershipAction.JoinCallback callback) {
  if (!transportService.addressSupported(node.getAddress().getClass())) {
    // TODO, what should we do now? Maybe inform that node that its crap?
    logger.warn("received a wrong address type from [{}], ignoring...", node);
  } else if (nodeJoinController == null) {
    throw new IllegalStateException("discovery module is not yet started");
  } else {
    // we do this in a couple of places including the cluster update thread. This one here is really just best effort
    // to ensure we fail as fast as possible.
    MembershipAction.ensureIndexCompatibility(node.getVersion(), state.getMetaData());
    // try and connect to the node, if it fails, we can raise an exception back to the client...
    transportService.connectToNode(node);
    // validate the join request, will throw a failure if it fails, which will get back to the
    // node calling the join request
    try {
      membership.sendValidateJoinRequestBlocking(node, state, joinTimeout);
    } catch (Exception e) {
      logger.warn((Supplier<?>) () -> new ParameterizedMessage("failed to validate incoming join request from node [{}]", node), e);
      callback.onFailure(new IllegalStateException("failure when sending a validation request to node", e));
      return;
    }
    nodeJoinController.handleJoinRequest(node, callback);
  }
}

代码示例来源:origin: harbby/presto-connectors

void handleJoinRequest(final DiscoveryNode node, final ClusterState state, final MembershipAction.JoinCallback callback) {
  if (!transportService.addressSupported(node.address().getClass())) {
    // TODO, what should we do now? Maybe inform that node that its crap?
    logger.warn("received a wrong address type from [{}], ignoring...", node);
  } else if (nodeJoinController == null) {
    throw new IllegalStateException("discovery module is not yet started");
  } else {
    // The minimum supported version for a node joining a master:
    Version minimumNodeJoinVersion = localNode().getVersion().minimumCompatibilityVersion();
    // Sanity check: maybe we don't end up here, because serialization may have failed.
    if (node.getVersion().before(minimumNodeJoinVersion)) {
      callback.onFailure(
          new IllegalStateException("Can't handle join request from a node with a version [" + node.getVersion() + "] that is lower than the minimum compatible version [" + minimumNodeJoinVersion.minimumCompatibilityVersion() + "]")
      );
      return;
    }
    // try and connect to the node, if it fails, we can raise an exception back to the client...
    transportService.connectToNode(node);
    // validate the join request, will throw a failure if it fails, which will get back to the
    // node calling the join request
    try {
      membership.sendValidateJoinRequestBlocking(node, state, joinTimeout);
    } catch (Throwable e) {
      logger.warn("failed to validate incoming join request from node [{}]", node);
      callback.onFailure(new IllegalStateException("failure when sending a validation request to node", e));
      return;
    }
    nodeJoinController.handleJoinRequest(node, callback);
  }
}

相关文章

微信公众号

最新文章

更多

TransportService类方法