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

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

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

TransportService.getConnection介绍

[英]Returns either a real transport connection or a local node connection if we are using the local node optimization.
[中]如果使用本地节点优化,则返回实际传输连接或本地节点连接。

代码示例

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

public <T extends TransportResponse> void sendRequest(final DiscoveryNode node, final String action,
                              final TransportRequest request,
                              final TransportResponseHandler<T> handler) {
  try {
    Transport.Connection connection = getConnection(node);
    sendRequest(connection, action, request, TransportRequestOptions.EMPTY, handler);
  } catch (NodeNotConnectedException ex) {
    // the caller might not handle this so we invoke the handler
    handler.handleException(ex);
  }
}

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

public final <T extends TransportResponse> void sendChildRequest(final DiscoveryNode node, final String action,
                                 final TransportRequest request, final Task parentTask,
                                 final TransportRequestOptions options,
                                 final TransportResponseHandler<T> handler) {
  try {
    Transport.Connection connection = getConnection(node);
    sendChildRequest(connection, action, request, parentTask, options, handler);
  } catch (NodeNotConnectedException ex) {
    // the caller might not handle this so we invoke the handler
    handler.handleException(ex);
  }
}

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

public final <T extends TransportResponse> void sendRequest(final DiscoveryNode node, final String action,
                              final TransportRequest request,
                              final TransportRequestOptions options,
                              TransportResponseHandler<T> handler) {
  try {
    Transport.Connection connection = getConnection(node);
    sendRequest(connection, action, request, options, handler);
  } catch (NodeNotConnectedException ex) {
    // the caller might not handle this so we invoke the handler
    handler.handleException(ex);
  }
}

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

/**
 * Returns a connection to the given node on the provided cluster. If the cluster alias is <code>null</code> the node will be resolved
 * against the local cluster.
 * @param clusterAlias the cluster alias the node should be resolve against
 * @param node the node to resolve
 * @return a connection to the given node belonging to the cluster with the provided alias.
 */
Transport.Connection getConnection(String clusterAlias, DiscoveryNode node) {
  if (clusterAlias == null) {
    return transportService.getConnection(node);
  } else {
    return transportService.getRemoteClusterService().getConnection(node, clusterAlias);
  }
}

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

public <T extends TransportResponse> TransportFuture<T> submitRequest(DiscoveryNode node, String action, TransportRequest request,
                                   TransportRequestOptions options,
                                   TransportResponseHandler<T> handler) throws TransportException {
  PlainTransportFuture<T> futureHandler = new PlainTransportFuture<>(handler);
  try {
    Transport.Connection connection = getConnection(node);
    sendRequest(connection, action, request, options, futureHandler);
  } catch (NodeNotConnectedException ex) {
    // the caller might not handle this so we invoke the handler
    futureHandler.handleException(ex);
  }
  return futureHandler;
}

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

/**
 * Used by {@link TransportSearchAction} to send the expand queries (field collapsing).
 */
void sendExecuteMultiSearch(final MultiSearchRequest request, SearchTask task,
              final ActionListener<MultiSearchResponse> listener) {
  final Transport.Connection connection = transportService.getConnection(transportService.getLocalNode());
  transportService.sendChildRequest(connection, MultiSearchAction.NAME, request, task,
      new ConnectionCountingHandler<>(listener, MultiSearchResponse::new, clientConnections, connection.getNode().getId()));
}

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

@Override
protected void doRun() throws Exception {
  Connection connection = null;
  if (transportService.nodeConnected(node)) {
    try {
      // concurrency can still cause disconnects
      connection = transportService.getConnection(node);
    } catch (NodeNotConnectedException e) {
      logger.trace("[{}] node [{}] just disconnected, will create a temp connection", pingingRound.id(), node);
    }
  }
  if (connection == null) {
    connection = pingingRound.getOrConnect(node);
  }
  logger.trace("[{}] sending to {}", pingingRound.id(), node);
  transportService.sendRequest(connection, ACTION_NAME, pingRequest,
    TransportRequestOptions.builder().withTimeout((long) (timeout.millis() * 1.25)).build(),
    getPingResponseHandler(pingingRound, node));
}

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

if (nodes.contains(nodeToPing)) {
  try {
    pingConnection = transportService.getConnection(nodeToPing);
  } catch (NodeNotConnectedException e) {

代码示例来源:origin: apache/servicemix-bundles

/**
 * Returns either a real transport connection or a local node connection if we are using the local node optimization.
 * @throws NodeNotConnectedException if the given node is not connected
 */
public Transport.Connection getConnection(DiscoveryNode node) {
  if (isLocalNode(node)) {
    return localNodeConnection;
  } else {
    return transport.getConnection(node);
  }
}

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

Transport.Connection getConnection() {
  DiscoveryNode discoveryNode = connectedNodes.get();
  return transportService.getConnection(discoveryNode);
}

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

public final <T extends TransportResponse> void sendRequest(final DiscoveryNode node, final String action,
                              final TransportRequest request,
                              final TransportRequestOptions options,
                              TransportResponseHandler<T> handler) {
  try {
    Transport.Connection connection = getConnection(node);
    sendRequest(connection, action, request, options, handler);
  } catch (NodeNotConnectedException ex) {
    // the caller might not handle this so we invoke the handler
    handler.handleException(ex);
  }
}

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

public final <T extends TransportResponse> void sendRequest(final DiscoveryNode node, final String action,
                              final TransportRequest request,
                              final TransportRequestOptions options,
                              TransportResponseHandler<T> handler) {
  try {
    Transport.Connection connection = getConnection(node);
    sendRequest(connection, action, request, options, handler);
  } catch (NodeNotConnectedException ex) {
    // the caller might not handle this so we invoke the handler
    handler.handleException(ex);
  }
}

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

public final <T extends TransportResponse> void sendChildRequest(final DiscoveryNode node, final String action,
                                 final TransportRequest request, final Task parentTask,
                                 final TransportRequestOptions options,
                                 final TransportResponseHandler<T> handler) {
  try {
    Transport.Connection connection = getConnection(node);
    sendChildRequest(connection, action, request, parentTask, options, handler);
  } catch (NodeNotConnectedException ex) {
    // the caller might not handle this so we invoke the handler
    handler.handleException(ex);
  }
}

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

public <T extends TransportResponse> void sendRequest(final DiscoveryNode node, final String action,
                              final TransportRequest request,
                              final TransportResponseHandler<T> handler) {
  try {
    Transport.Connection connection = getConnection(node);
    sendRequest(connection, action, request, TransportRequestOptions.EMPTY, handler);
  } catch (NodeNotConnectedException ex) {
    // the caller might not handle this so we invoke the handler
    handler.handleException(ex);
  }
}

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

public void sendExecuteScrollQuery(DiscoveryNode node, final InternalScrollSearchRequest request, SearchTask task,
                  final SearchActionListener<ScrollQuerySearchResult> listener) {
  transportService.sendChildRequest(transportService.getConnection(node), QUERY_SCROLL_ACTION_NAME, request, task,
    new ActionListenerResponseHandler<>(listener, ScrollQuerySearchResult::new));
}

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

public void sendExecuteScrollFetch(DiscoveryNode node, final InternalScrollSearchRequest request, SearchTask task,
                  final SearchActionListener<ScrollQueryFetchSearchResult> listener) {
  transportService.sendChildRequest(transportService.getConnection(node), QUERY_FETCH_SCROLL_ACTION_NAME, request, task,
    new ActionListenerResponseHandler<>(listener, ScrollQueryFetchSearchResult::new));
}

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

public <T extends TransportResponse> void sendRequest(final DiscoveryNode node, final String action,
                              final TransportRequest request,
                              final TransportResponseHandler<T> handler) {
  try {
    Transport.Connection connection = getConnection(node);
    sendRequest(connection, action, request, TransportRequestOptions.EMPTY, handler);
  } catch (NodeNotConnectedException ex) {
    // the caller might not handle this so we invoke the handler
    handler.handleException(ex);
  }
}

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

/**
 * Returns a connection to the given node on the provided cluster. If the cluster alias is <code>null</code> the node will be resolved
 * against the local cluster.
 * @param clusterAlias the cluster alias the node should be resolve against
 * @param node the node to resolve
 * @return a connection to the given node belonging to the cluster with the provided alias.
 */
Transport.Connection getConnection(String clusterAlias, DiscoveryNode node) {
  if (clusterAlias == null) {
    return transportService.getConnection(node);
  } else {
    return transportService.getRemoteClusterService().getConnection(node, clusterAlias);
  }
}

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

/**
 * Used by {@link TransportSearchAction} to send the expand queries (field collapsing).
 */
void sendExecuteMultiSearch(final MultiSearchRequest request, SearchTask task,
                  final ActionListener<MultiSearchResponse> listener) {
  transportService.sendChildRequest(transportService.getConnection(transportService.getLocalNode()), MultiSearchAction.NAME, request,
    task, new ActionListenerResponseHandler<>(listener, MultiSearchResponse::new));
}

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

/**
 * Used by {@link TransportSearchAction} to send the expand queries (field collapsing).
 */
void sendExecuteMultiSearch(final MultiSearchRequest request, SearchTask task,
              final ActionListener<MultiSearchResponse> listener) {
  final Transport.Connection connection = transportService.getConnection(transportService.getLocalNode());
  transportService.sendChildRequest(connection, MultiSearchAction.NAME, request, task,
      new ConnectionCountingHandler<>(listener, MultiSearchResponse::new, clientConnections, connection.getNode().getId()));
}

相关文章

微信公众号

最新文章

更多

TransportService类方法