當前位置: 首頁>>代碼示例>>Java>>正文


Java Version.min方法代碼示例

本文整理匯總了Java中org.elasticsearch.Version.min方法的典型用法代碼示例。如果您正苦於以下問題:Java Version.min方法的具體用法?Java Version.min怎麽用?Java Version.min使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.Version的用法示例。


在下文中一共展示了Version.min方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: build

import org.elasticsearch.Version; //導入方法依賴的package包/類
public DiscoveryNodes build() {
    ImmutableOpenMap.Builder<String, DiscoveryNode> dataNodesBuilder = ImmutableOpenMap.builder();
    ImmutableOpenMap.Builder<String, DiscoveryNode> masterNodesBuilder = ImmutableOpenMap.builder();
    ImmutableOpenMap.Builder<String, DiscoveryNode> ingestNodesBuilder = ImmutableOpenMap.builder();
    Version minNodeVersion = Version.CURRENT;
    Version maxNodeVersion = Version.CURRENT;
    Version minNonClientNodeVersion = Version.CURRENT;
    for (ObjectObjectCursor<String, DiscoveryNode> nodeEntry : nodes) {
        if (nodeEntry.value.isDataNode()) {
            dataNodesBuilder.put(nodeEntry.key, nodeEntry.value);
            minNonClientNodeVersion = Version.min(minNonClientNodeVersion, nodeEntry.value.getVersion());
        }
        if (nodeEntry.value.isMasterNode()) {
            masterNodesBuilder.put(nodeEntry.key, nodeEntry.value);
            minNonClientNodeVersion = Version.min(minNonClientNodeVersion, nodeEntry.value.getVersion());
        }
        if (nodeEntry.value.isIngestNode()) {
            ingestNodesBuilder.put(nodeEntry.key, nodeEntry.value);
        }
        minNodeVersion = Version.min(minNodeVersion, nodeEntry.value.getVersion());
        maxNodeVersion = Version.max(maxNodeVersion, nodeEntry.value.getVersion());
    }

    return new DiscoveryNodes(
        nodes.build(), dataNodesBuilder.build(), masterNodesBuilder.build(), ingestNodesBuilder.build(),
        masterNodeId, localNodeId, minNonClientNodeVersion, maxNodeVersion, minNodeVersion
    );
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:29,代碼來源:DiscoveryNodes.java

示例2: sendRequestToChannel

import org.elasticsearch.Version; //導入方法依賴的package包/類
private void sendRequestToChannel(DiscoveryNode node, final Channel targetChannel, final long requestId, final String action,
                                    final TransportRequest request, TransportRequestOptions options, Version channelVersion,
                                  byte status) throws IOException,
    TransportException {
    if (compress) {
        options = TransportRequestOptions.builder(options).withCompress(true).build();
    }
    status = TransportStatus.setRequest(status);
    ReleasableBytesStreamOutput bStream = new ReleasableBytesStreamOutput(bigArrays);
    // we wrap this in a release once since if the onRequestSent callback throws an exception
    // we might release things twice and this should be prevented
    final Releasable toRelease = Releasables.releaseOnce(() -> Releasables.close(bStream.bytes()));
    boolean addedReleaseListener = false;
    StreamOutput stream = bStream;
    try {
        // only compress if asked, and, the request is not bytes, since then only
        // the header part is compressed, and the "body" can't be extracted as compressed
        if (options.compress() && canCompress(request)) {
            status = TransportStatus.setCompress(status);
            stream = CompressorFactory.COMPRESSOR.streamOutput(stream);
        }

        // we pick the smallest of the 2, to support both backward and forward compatibility
        // note, this is the only place we need to do this, since from here on, we use the serialized version
        // as the version to use also when the node receiving this request will send the response with
        Version version = Version.min(getCurrentVersion(), channelVersion);

        stream.setVersion(version);
        threadPool.getThreadContext().writeTo(stream);
        stream.writeString(action);
        BytesReference message = buildMessage(requestId, status, node.getVersion(), request, stream, bStream);
        final TransportRequestOptions finalOptions = options;
        Runnable onRequestSent = () -> { // this might be called in a different thread
            try {
                toRelease.close();
            } finally {
                transportServiceAdapter.onRequestSent(node, requestId, action, request, finalOptions);
            }
        };
        addedReleaseListener = internalSendMessage(targetChannel, message, onRequestSent);
    } finally {
        IOUtils.close(stream);
        if (!addedReleaseListener) {
            toRelease.close();
        }
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:48,代碼來源:TcpTransport.java


注:本文中的org.elasticsearch.Version.min方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。