Java Code Examples for com.indeed.util.core.io.Closeables2#closeAll()
The following examples show how to use
com.indeed.util.core.io.Closeables2#closeAll() .
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: CachedFlamdexReader.java From imhotep with Apache License 2.0 | 6 votes |
@Override public void close() { try { if (readLockRef == null) { Closeables2.closeAll(log, metricCache, wrapped); } else { Closeables2.closeAll(log, metricCache, wrapped, readLockRef); } } finally { if (memory == null) { return; } if (memory.usedMemory() > 0) { log.error("CachedFlamdexReader is leaking! memory reserved after all memory has been freed: "+memory.usedMemory()); } Closeables2.closeQuietly(memory, log); } }
Example 2
Source File: MetricCacheImpl.java From imhotep with Apache License 2.0 | 6 votes |
@Override public void close() { synchronized (loadedMetrics) { if (!closed) { closed = true; try { Closeables2.closeAll(log, Collections2.transform(loadedMetrics.entrySet(), new Function<Map.Entry<String, IntValueLookup>, Closeable>() { public Closeable apply(final Map.Entry<String, IntValueLookup> metric) { return closeMetric.asCloseable(metric); } })); } finally { loadedMetrics.clear(); } } } }
Example 3
Source File: AbstractImhotepMultiSession.java From imhotep with Apache License 2.0 | 6 votes |
public RawFTGSIterator mergeFTGSSplit(final String[] intFields, final String[] stringFields, final String sessionId, final InetSocketAddress[] nodes, final int splitIndex) { final RawFTGSIterator[] splits = new RawFTGSIterator[nodes.length]; try { execute(splits, nodes, new ThrowingFunction<InetSocketAddress, RawFTGSIterator>() { public RawFTGSIterator apply(final InetSocketAddress node) throws Exception { final ImhotepRemoteSession remoteSession = new ImhotepRemoteSession(node.getHostName(), node.getPort(), sessionId, tempFileSizeBytesLeft); remoteSession.setNumStats(numStats); return remoteSession.getFTGSIteratorSplit(intFields, stringFields, splitIndex, nodes.length); } }); } catch (Throwable t) { Closeables2.closeAll(log, splits); throw Throwables.propagate(t); } return mergeFTGSSplits(splits); }
Example 4
Source File: AbstractImhotepMultiSession.java From imhotep with Apache License 2.0 | 6 votes |
@Override public RawFTGSIterator mergeSubsetFTGSSplit(final Map<String, long[]> intFields, final Map<String, String[]> stringFields, final String sessionId, final InetSocketAddress[] nodes, final int splitIndex) { final RawFTGSIterator[] splits = new RawFTGSIterator[nodes.length]; try { execute(splits, nodes, new ThrowingFunction<InetSocketAddress, RawFTGSIterator>() { public RawFTGSIterator apply(final InetSocketAddress node) throws Exception { final ImhotepRemoteSession remoteSession = new ImhotepRemoteSession(node.getHostName(), node.getPort(), sessionId, tempFileSizeBytesLeft); remoteSession.setNumStats(numStats); return remoteSession.getSubsetFTGSIteratorSplit(intFields, stringFields, splitIndex, nodes.length); } }); } catch (Throwable t) { Closeables2.closeAll(log, splits); throw Throwables.propagate(t); } return mergeFTGSSplits(splits); }
Example 5
Source File: FastIntFTGSMerger.java From imhotep with Apache License 2.0 | 5 votes |
@Override public synchronized void close() { if (!done) { done = true; Closeables2.closeAll(log, Closeables2.forArray(log, iterators), doneCallback); } }
Example 6
Source File: DocIteratorMerger.java From imhotep with Apache License 2.0 | 5 votes |
public synchronized void close() { try { Closeables2.closeAll(log, circularBuffer.getInputStream(), circularBuffer.getOutputStream(), iterator); } finally { try { executorService.shutdownNow(); executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { throw Throwables.propagate(e); } finally { Closeables2.closeAll(log, iterators); } } }
Example 7
Source File: AbstractImhotepMultiSession.java From imhotep with Apache License 2.0 | 5 votes |
public RawFTGSIterator getFTGSIteratorSplit(final String[] intFields, final String[] stringFields, final int splitIndex, final int numSplits) { final RawFTGSIterator[] splits = new RawFTGSIterator[sessions.length]; try { executeSessions(splits, new ThrowingFunction<ImhotepSession, RawFTGSIterator>() { public RawFTGSIterator apply(final ImhotepSession imhotepSession) throws Exception { return imhotepSession.getFTGSIteratorSplit(intFields, stringFields, splitIndex, numSplits); } }); } catch (Throwable t) { Closeables2.closeAll(log, splits); throw Throwables.propagate(t); } return new RawFTGSMerger(Arrays.asList(splits), numStats, null); }
Example 8
Source File: AbstractImhotepMultiSession.java From imhotep with Apache License 2.0 | 5 votes |
@Override public RawFTGSIterator getSubsetFTGSIteratorSplit(final Map<String, long[]> intFields, final Map<String, String[]> stringFields, final int splitIndex, final int numSplits) { final RawFTGSIterator[] splits = new RawFTGSIterator[sessions.length]; try { executeSessions(splits, new ThrowingFunction<ImhotepSession, RawFTGSIterator>() { public RawFTGSIterator apply(final ImhotepSession imhotepSession) throws Exception { return imhotepSession.getSubsetFTGSIteratorSplit(intFields, stringFields, splitIndex, numSplits); } }); } catch (Throwable t) { Closeables2.closeAll(log, splits); throw Throwables.propagate(t); } return new RawFTGSMerger(Arrays.asList(splits), numStats, null); }
Example 9
Source File: FTGSSplitter.java From imhotep with Apache License 2.0 | 5 votes |
@Override public void close() { if (done.compareAndSet(false, true)) { try { if (Thread.currentThread() != runThread) { while (true) { try { runThread.interrupt(); runThread.join(10); if (!runThread.isAlive()) break; } catch (InterruptedException e) { //ignore } } } } finally { Closeables2.closeAll(log, iterator, Closeables2.forIterable(log, Iterables.transform(Arrays.asList(files), new Function<File, Closeable>() { public Closeable apply(final File input) { return new Closeable() { public void close() throws IOException { input.delete(); } }; } })), Closeables2.forArray(log, outputs), Closeables2.forArray(log, ftgsIterators), Closeables2.forArray(log, outputStreams)); } } }
Example 10
Source File: AbstractFTGSMerger.java From imhotep with Apache License 2.0 | 5 votes |
@Override public synchronized void close() { if (!done) { done = true; Closeables2.closeAll(log, Closeables2.forArray(log, iterators), doneCallback); } }