• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Releasables类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.elasticsearch.common.lease.Releasables的典型用法代码示例。如果您正苦于以下问题:Java Releasables类的具体用法?Java Releasables怎么用?Java Releasables使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Releasables类属于org.elasticsearch.common.lease包,在下文中一共展示了Releasables类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: stopInternal

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
@Override
@SuppressForbidden(reason = "debug")
protected void stopInternal() {
    Releasables.close(serverOpenChannels, () -> {
        final List<Tuple<String, Future<?>>> serverBootstrapCloseFutures = new ArrayList<>(serverBootstraps.size());
        for (final Map.Entry<String, ServerBootstrap> entry : serverBootstraps.entrySet()) {
            serverBootstrapCloseFutures.add(
                Tuple.tuple(entry.getKey(), entry.getValue().config().group().shutdownGracefully(0, 5, TimeUnit.SECONDS)));
        }
        for (final Tuple<String, Future<?>> future : serverBootstrapCloseFutures) {
            future.v2().awaitUninterruptibly();
            if (!future.v2().isSuccess()) {
                logger.debug(
                    (Supplier<?>) () -> new ParameterizedMessage(
                        "Error closing server bootstrap for profile [{}]", future.v1()), future.v2().cause());
            }
        }
        serverBootstraps.clear();

        if (bootstrap != null) {
            bootstrap.config().group().shutdownGracefully(0, 5, TimeUnit.SECONDS).awaitUninterruptibly();
            bootstrap = null;
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:Netty4Transport.java


示例2: writeOperations

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
/**
 * Writes all operations in the given iterable to the given output stream including the size of the array
 * use {@link #readOperations(StreamInput)} to read it back.
 */
public static void writeOperations(StreamOutput outStream, List<Operation> toWrite) throws IOException {
    final ReleasableBytesStreamOutput out = new ReleasableBytesStreamOutput(BigArrays.NON_RECYCLING_INSTANCE);
    try {
        outStream.writeInt(toWrite.size());
        final BufferedChecksumStreamOutput checksumStreamOutput = new BufferedChecksumStreamOutput(out);
        for (Operation op : toWrite) {
            out.reset();
            final long start = out.position();
            out.skip(Integer.BYTES);
            writeOperationNoSize(checksumStreamOutput, op);
            long end = out.position();
            int operationSize = (int) (out.position() - Integer.BYTES - start);
            out.seek(start);
            out.writeInt(operationSize);
            out.seek(end);
            ReleasablePagedBytesReference bytes = out.bytes();
            bytes.writeTo(outStream);
        }
    } finally {
        Releasables.close(out.bytes());
    }

}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:Translog.java


示例3: setReallocation

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
public void setReallocation(final ClusterService clusterService, final RoutingService routingService) {
    this.routingService = routingService;
    clusterService.addStateApplier(event -> {
        boolean cleanCache = false;
        DiscoveryNode localNode = event.state().nodes().getLocalNode();
        if (localNode != null) {
            if (localNode.isMasterNode() && event.localNodeMaster() == false) {
                cleanCache = true;
            }
        } else {
            cleanCache = true;
        }
        if (cleanCache) {
            Releasables.close(asyncFetchStarted.values());
            asyncFetchStarted.clear();
            Releasables.close(asyncFetchStore.values());
            asyncFetchStore.clear();
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:GatewayAllocator.java


示例4: search

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
protected <A extends InternalAggregation, C extends Aggregator> A search(IndexSearcher searcher,
                                                                         Query query,
                                                                         AggregationBuilder builder,
                                                                         MappedFieldType... fieldTypes) throws IOException {
    C a = createAggregator(builder, searcher, fieldTypes);
    try {
        a.preCollection();
        searcher.search(query, a);
        a.postCollection();
        @SuppressWarnings("unchecked")
        A internalAgg = (A) a.buildAggregation(0L);
        return internalAgg;
    } finally {
        Releasables.close(releasables);
        releasables.clear();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:AggregatorTestCase.java


示例5: createSnapshot

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
private static Snapshot createSnapshot(TranslogReader... translogs) {
    Snapshot[] snapshots = new Snapshot[translogs.length];
    boolean success = false;
    try {
        for (int i = 0; i < translogs.length; i++) {
            snapshots[i] = translogs[i].newSnapshot();
        }

        Snapshot snapshot = new MultiSnapshot(snapshots);
        success = true;
        return snapshot;
    } finally {
        if (success == false) {
            Releasables.close(snapshots);
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:Translog.java


示例6: stop

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
static void stop() {
    try {
        Releasables.close(INSTANCE.node);
    } finally {
        INSTANCE.keepAliveLatch.countDown();
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:Bootstrap.java


示例7: resetClient

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
void resetClient() throws IOException {
    if (closed.get() == false) {
        Releasables.close(nodeClient, transportClient);
        nodeClient = null;
        transportClient = null;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:InternalTestCluster.java


示例8: merge

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
public void merge(long thisBucket, HyperLogLogPlusPlus other, long otherBucket) {
    if (p != other.p) {
        throw new IllegalArgumentException();
    }
    ensureCapacity(thisBucket + 1);
    if (other.algorithm.get(otherBucket) == LINEAR_COUNTING) {
        final IntArray values = other.hashSet.values(otherBucket);
        try {
            for (long i = 0; i < values.size(); ++i) {
                final int encoded = values.get(i);
                if (algorithm.get(thisBucket) == LINEAR_COUNTING) {
                    collectLcEncoded(thisBucket, encoded);
                } else {
                    collectHllEncoded(thisBucket, encoded);
                }
            }
        } finally {
            Releasables.close(values);
        }
    } else {
        if (algorithm.get(thisBucket) != HYPERLOGLOG) {
            upgradeToHll(thisBucket);
        }
        final long thisStart = thisBucket << p;
        final long otherStart = otherBucket << p;
        for (int i = 0; i < m; ++i) {
            runLens.set(thisStart + i, (byte) Math.max(runLens.get(thisStart + i), other.runLens.get(otherStart + i)));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:31,代码来源:HyperLogLogPlusPlus.java


示例9: upgradeToHll

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
void upgradeToHll(long bucket) {
    ensureCapacity(bucket + 1);
    final IntArray values = hashSet.values(bucket);
    try {
        runLens.fill(bucket << p, (bucket << p) + m, (byte) 0);
        for (long i = 0; i < values.size(); ++i) {
            final int encoded = values.get(i);
            collectHllEncoded(bucket, encoded);
        }
        algorithm.set(bucket);
    } finally {
        Releasables.close(values);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:HyperLogLogPlusPlus.java


示例10: doClose

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
@Override
protected final void doClose() {
    if (recycler != null) {
        Releasables.close(cache);
        cache = null;
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:AbstractBigArray.java


示例11: sendResponse

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
@Override
public void sendResponse(TransportResponse response, TransportResponseOptions options) throws IOException {
    if (transport.compress) {
        options = TransportResponseOptions.builder(options).withCompress(transport.compress).build();
    }

    byte status = 0;
    status = TransportStatus.setResponse(status);

    ReleasableBytesStreamOutput bStream = new ReleasableBytesStreamOutput(transport.bigArrays);
    boolean addedReleaseListener = false;
    try {
        bStream.skip(NettyHeader.HEADER_SIZE);
        StreamOutput stream = bStream;
        if (options.compress()) {
            status = TransportStatus.setCompress(status);
            stream = CompressorFactory.defaultCompressor().streamOutput(stream);
        }
        stream.setVersion(version);
        response.writeTo(stream);
        stream.close();

        ReleasablePagedBytesReference bytes = bStream.bytes();
        ChannelBuffer buffer = bytes.toChannelBuffer();
        NettyHeader.writeHeader(buffer, requestId, status, version);
        ChannelFuture future = channel.write(buffer);
        ReleaseChannelFutureListener listener = new ReleaseChannelFutureListener(bytes);
        future.addListener(listener);
        addedReleaseListener = true;
        transportServiceAdapter.onResponseSent(requestId, action, response, options);
    } finally {
        if (!addedReleaseListener) {
            Releasables.close(bStream.bytes());
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:37,代码来源:NettyTransportChannel.java


示例12: close

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
@Override
public void close() {
    List<Releasable> closeables = new ArrayList<>();
    for (OrdinalMapAndAtomicFieldData fds : atomicFD.values()) {
        closeables.addAll(Arrays.asList(fds.fieldData));
    }
    Releasables.close(closeables);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:ParentChildIndexFieldData.java


示例13: close

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
@Override
public void close() {
    try {
        Releasables.close(cachedTermOrds, termDocFreqs, termsTotalFreqs);
    } finally {
        cachedTermOrds = null;
        termDocFreqs = null;
        termsTotalFreqs = null;
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:FreqTermsEnum.java


示例14: validate

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
private <T extends BigArray> T validate(T array) {
    boolean success = false;
    try {
        adjustBreaker(array.ramBytesUsed());
        success = true;
    } finally {
        if (!success) {
            Releasables.closeWhileHandlingException(array);
        }
    }
    return array;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:BigArrays.java


示例15: onResponse

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
@Override
public void onResponse(Releasable releasable) {
    try {
        ReplicaResult replicaResult = shardOperationOnReplica(request, replica);
        releasable.close(); // release shard operation lock before responding to caller
        final TransportReplicationAction.ReplicaResponse response =
            new ReplicaResponse(replica.routingEntry().allocationId().getId(), replica.getLocalCheckpoint());
        replicaResult.respond(new ResponseListener(response));
    } catch (Exception e) {
        Releasables.closeWhileHandlingException(releasable); // release shard operation lock before responding to caller
        AsyncReplicaAction.this.onFailure(e);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:TransportReplicationAction.java


示例16: getSequenceID

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
/**
 * Return a tuple representing the sequence ID for the given {@code Get}
 * operation. The first value in the tuple is the sequence number, the
 * second is the primary term.
 */
private Tuple<Long, Long> getSequenceID(Engine engine, Engine.Get get) throws EngineException {
    final Searcher searcher = engine.acquireSearcher("get");
    try {
        long seqNum = Versions.loadSeqNo(searcher.reader(), get.uid());
        long primaryTerm = Versions.loadPrimaryTerm(searcher.reader(), get.uid());
        return new Tuple(seqNum, primaryTerm);
    } catch (Exception e) {
        Releasables.closeWhileHandlingException(searcher);
        throw new EngineException(shardId, "unable to retrieve sequence id", e);
    } finally {
        searcher.close();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:InternalEngineTests.java


示例17: testReleaseOnce

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
public void testReleaseOnce() {
    AtomicInteger count = new AtomicInteger(0);
    Releasable releasable = Releasables.releaseOnce(count::incrementAndGet, count::incrementAndGet);
    assertEquals(0, count.get());
    releasable.close();
    assertEquals(2, count.get());
    releasable.close();
    assertEquals(2, count.get());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ReleasablesTests.java


示例18: recoverToTarget

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
/**
 * performs the recovery from the local engine to the target
 */
public RecoveryResponse recoverToTarget() {
    final SnapshotIndexCommit phase1Snapshot;
    phase1Snapshot = shard.snapshotIndex(false);
    
    try {
        recoverLuceneFiles(phase1Snapshot);
    } catch (Throwable e) {
        logger.error("errors while recovery to target", e);
        throw new RecoveryEngineException(shard.shardId(), 1, "phase1 failed", e);
    } finally {
        Releasables.closeWhileHandlingException(phase1Snapshot);
    }
    return response;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:DLBasedIndexRecoverySourceHandler.java


示例19: stop

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
public static void stop() {
    try {
        Releasables.close(INSTANCE.node);
    } finally {
        INSTANCE.keepAliveLatch.countDown();
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:BootstrapProxy.java


示例20: merge

import org.elasticsearch.common.lease.Releasables; //导入依赖的package包/类
public void merge(long thisBucket, HyperLogLogPlusPlus other, long otherBucket) {
    Preconditions.checkArgument(p == other.p);
    ensureCapacity(thisBucket + 1);
    if (other.algorithm.get(otherBucket) == LINEAR_COUNTING) {
        final IntArray values = other.hashSet.values(otherBucket);
        try {
            for (long i = 0; i < values.size(); ++i) {
                final int encoded = values.get(i);
                if (algorithm.get(thisBucket) == LINEAR_COUNTING) {
                    collectLcEncoded(thisBucket, encoded);
                } else {
                    collectHllEncoded(thisBucket, encoded);
                }
            }
        } finally {
            Releasables.close(values);
        }
    } else {
        if (algorithm.get(thisBucket) != HYPERLOGLOG) {
            upgradeToHll(thisBucket);
        }
        final long thisStart = thisBucket << p;
        final long otherStart = otherBucket << p;
        for (int i = 0; i < m; ++i) {
            runLens.set(thisStart + i, (byte) Math.max(runLens.get(thisStart + i), other.runLens.get(otherStart + i)));
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:29,代码来源:HyperLogLogPlusPlus.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PngChunkPLTE类代码示例发布时间:2022-05-23
下一篇:
Java OkHttpClientProvider类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap