use of org.apache.cassandra.concurrent.DebuggableThreadPoolExecutor in project eiger by wlloyd.
the class MessagingService method stream.
/**
* Stream a file from source to destination. This is highly optimized
* to not hold any of the contents of the file in memory.
* @param header Header contains file to stream and other metadata.
* @param to endpoint to which we need to stream the file.
*/
public void stream(StreamHeader header, InetAddress to) {
DebuggableThreadPoolExecutor executor = streamExecutors.get(to);
if (executor == null) {
// Using a core pool size of 0 is important. See documentation of streamExecutors.
executor = new DebuggableThreadPoolExecutor(0, 1, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory("Streaming to " + to));
DebuggableThreadPoolExecutor old = streamExecutors.putIfAbsent(to, executor);
if (old != null) {
executor.shutdown();
executor = old;
}
}
executor.execute(new FileStreamTask(header, to));
}
Aggregations