Java Code Examples for org.elasticsearch.common.lease.Releasables#close()

The following examples show how to use org.elasticsearch.common.lease.Releasables#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BootstrapProxy.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public static void stop() {
    try {
        Releasables.close(INSTANCE.node);
    } finally {
        INSTANCE.keepAliveLatch.countDown();
    }
}
 
Example 2
Source File: AbstractBigArray.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
protected final void doClose() {
    if (recycler != null) {
        Releasables.close(cache);
        cache = null;
    }
}
 
Example 3
Source File: InternalTestCluster.java    From crate with Apache License 2.0 5 votes vote down vote up
void resetClient() {
    if (closed.get() == false) {
        Releasables.close(nodeClient, transportClient);
        nodeClient = null;
        transportClient = null;
    }
}
 
Example 4
Source File: NettyTransportChannel.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@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());
        }
    }
}
 
Example 5
Source File: AbstractBigArray.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
protected final void doClose() {
    if (recycler != null) {
        Releasables.close(cache);
        cache = null;
    }
}
 
Example 6
Source File: SignificantStringTermsAggregator.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void doClose() {
    Releasables.close(bucketOrds, termsAggFactory);
}
 
Example 7
Source File: GatewayAllocator.java    From crate with Apache License 2.0 4 votes vote down vote up
public void cleanCaches() {
    Releasables.close(asyncFetchStarted.values());
    asyncFetchStarted.clear();
    Releasables.close(asyncFetchStore.values());
    asyncFetchStore.clear();
}
 
Example 8
Source File: GeoCentroidAggregator.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void doClose() {
    Releasables.close(centroids, counts);
}
 
Example 9
Source File: MaxAggregator.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void doClose() {
    Releasables.close(maxes);
}
 
Example 10
Source File: GlobalOrdinalsSignificantTermsAggregator.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
protected void doClose() {
    Releasables.close(termsAggFactory);
}
 
Example 11
Source File: SignificantLongTermsAggregator.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void doClose() {
    Releasables.close(bucketOrds, termsAggFactory);
}
 
Example 12
Source File: Engine.java    From crate with Apache License 2.0 4 votes vote down vote up
protected final GetResult getFromSearcher(Get get, BiFunction<String, SearcherScope, Searcher> searcherFactory,
                                          SearcherScope scope) throws EngineException {
    final Searcher searcher = searcherFactory.apply("get", scope);
    final DocIdAndVersion docIdAndVersion;
    try {
        docIdAndVersion = VersionsAndSeqNoResolver.loadDocIdAndVersion(searcher.reader(), get.uid(), true);
    } catch (Exception e) {
        Releasables.closeWhileHandlingException(searcher);
        //TODO: A better exception goes here
        throw new EngineException(shardId, "Couldn't resolve version", e);
    }

    if (docIdAndVersion != null) {
        if (get.versionType().isVersionConflictForReads(docIdAndVersion.version, get.version())) {
            Releasables.close(searcher);
            throw new VersionConflictEngineException(
                shardId,
                get.id(),
                get.versionType().explainConflictForReads(docIdAndVersion.version, get.version())
            );
        }
        if (get.getIfSeqNo() != SequenceNumbers.UNASSIGNED_SEQ_NO && (
            get.getIfSeqNo() != docIdAndVersion.seqNo || get.getIfPrimaryTerm() != docIdAndVersion.primaryTerm)) {

            Releasables.close(searcher);
            throw new VersionConflictEngineException(
                shardId,
                get.id(),
                get.getIfSeqNo(),
                get.getIfPrimaryTerm(),
                docIdAndVersion.seqNo,
                docIdAndVersion.primaryTerm
            );
        }
    }

    if (docIdAndVersion != null) {
        // don't release the searcher on this path, it is the
        // responsibility of the caller to call GetResult.release
        return new GetResult(docIdAndVersion, searcher);
    } else {
        Releasables.close(searcher);
        return GetResult.NOT_EXISTS;
    }
}
 
Example 13
Source File: CardinalityAggregator.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
protected void doClose() {
    Releasables.close(counts, collector);
}
 
Example 14
Source File: HyperLogLogPlusPlus.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void close() {
    Releasables.close(runLens, hashSet.sizes);
}
 
Example 15
Source File: ChildrenQuery.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void close() {
    Releasables.close(parentIdxs, scores);
}
 
Example 16
Source File: GlobalOrdinalsStringTermsAggregator.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
protected void doClose() {
    Releasables.close(segmentDocCounts);
}
 
Example 17
Source File: ReleasablePagedBytesReference.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void close() {
    Releasables.close(bytearray);
}
 
Example 18
Source File: ReleasablePagedBytesReference.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void close() {
    Releasables.close(releasable);
}
 
Example 19
Source File: BigArrays.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
protected final void doClose() {
    Releasables.close(releasable);
}
 
Example 20
Source File: Engine.java    From crate with Apache License 2.0 4 votes vote down vote up
public void release() {
    Releasables.close(searcher);
}