Search in sources :

Example 1 with DebuggableThreadPoolExecutor

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));
}
Also used : DebuggableThreadPoolExecutor(org.apache.cassandra.concurrent.DebuggableThreadPoolExecutor) NamedThreadFactory(org.apache.cassandra.concurrent.NamedThreadFactory) FileStreamTask(org.apache.cassandra.streaming.FileStreamTask) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue)

Aggregations

LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 DebuggableThreadPoolExecutor (org.apache.cassandra.concurrent.DebuggableThreadPoolExecutor)1 NamedThreadFactory (org.apache.cassandra.concurrent.NamedThreadFactory)1 FileStreamTask (org.apache.cassandra.streaming.FileStreamTask)1