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


Java Node.idString方法代码示例

本文整理汇总了Java中org.apache.kafka.common.Node.idString方法的典型用法代码示例。如果您正苦于以下问题:Java Node.idString方法的具体用法?Java Node.idString怎么用?Java Node.idString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.kafka.common.Node的用法示例。


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

示例1: initiateConnect

import org.apache.kafka.common.Node; //导入方法依赖的package包/类
/**
 * Initiate a connection to the given node
 */
private void initiateConnect(Node node, long now) {
    String nodeConnectionId = node.idString();
    try {
        log.debug("Initiating connection to node {} at {}:{}.", node.id(), node.host(), node.port());
        // 修改连接状态
        this.connectionStates.connecting(nodeConnectionId, now);
        // 发起连接
        selector.connect(nodeConnectionId,
                         new InetSocketAddress(node.host(), node.port()),
                         this.socketSendBuffer,
                         this.socketReceiveBuffer);
    } catch (IOException e) {
        /* attempt failed, we'll try again after the backoff */
        connectionStates.disconnected(nodeConnectionId, now);
        /* maybe the problem is our metadata, update it */
        metadataUpdater.requestUpdate();
        log.debug("Error connecting to node {} at {}:{}:", node.id(), node.host(), node.port(), e);
    }
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:23,代码来源:NetworkClient.java

示例2: sendAndAwaitInitProducerIdRequest

import org.apache.kafka.common.Node; //导入方法依赖的package包/类
private ClientResponse sendAndAwaitInitProducerIdRequest(Node node) throws IOException {
    String nodeId = node.idString();
    InitProducerIdRequest.Builder builder = new InitProducerIdRequest.Builder(null);
    ClientRequest request = client.newClientRequest(nodeId, builder, time.milliseconds(), true, null);
    return NetworkClientUtils.sendAndReceive(client, request, time);
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:7,代码来源:Sender.java

示例3: maybeUpdate

import org.apache.kafka.common.Node; //导入方法依赖的package包/类
/**
 * Add a metadata request to the list of sends if we can make one
 */
private long maybeUpdate(long now, Node node) {
    String nodeConnectionId = node.idString();
    // 判断是否允许向此node发送请求
    if (canSendRequest(nodeConnectionId)) {
        this.metadataFetchInProgress = true;
        MetadataRequest.Builder metadataRequest;
        // 指定需要更新元数据的Topic
        if (metadata.needMetadataForAllTopics())
            metadataRequest = MetadataRequest.Builder.allTopics();
        else
            metadataRequest = new MetadataRequest.Builder(new ArrayList<>(metadata.topics()),
                    metadata.allowAutoTopicCreation());


        log.debug("Sending metadata request {} to node {}", metadataRequest, node.id());
        sendInternalMetadataRequest(metadataRequest, nodeConnectionId, now);
        return requestTimeoutMs;
    }

    // If there's any connection establishment underway, wait until it completes. This prevents
    // the client from unnecessarily connecting to additional nodes while a previous connection
    // attempt has not been completed.
    if (isAnyNodeConnecting()) {
        // Strictly the timeout we should return here is "connect timeout", but as we don't
        // have such application level configuration, using reconnect backoff instead.
        return reconnectBackoffMs;
    }

    if (connectionStates.canConnect(nodeConnectionId, now)) {
        // we don't have a connection to this node right now, make one
        log.debug("Initialize connection to node {} for sending metadata request", node.id());
        initiateConnect(node, now);
        return reconnectBackoffMs;
    }

    // connected, but can't send more OR connecting
    // In either case, we just need to wait for a network event to let us know the selected
    // connection might be usable again.
    return Long.MAX_VALUE;
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:44,代码来源:NetworkClient.java


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