mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-167 when running the profile I found that we were not closing every connection, so no being super fussy about adding everything to closable.
This commit is contained in:
@@ -27,10 +27,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.channels.SelectableChannel;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.*;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
@@ -65,8 +62,7 @@ abstract class AbstractChannelReplicator implements Closeable {
|
||||
throws IOException {
|
||||
executorService = Executors.newSingleThreadExecutor(
|
||||
new NamedThreadFactory(name, true));
|
||||
selector = Selector.open();
|
||||
closeables.add(selector);
|
||||
selector = openSelector();
|
||||
|
||||
throttler = throttlingConfig.throttling(DAYS) > 0 ?
|
||||
new Throttler(selector,
|
||||
@@ -74,6 +70,29 @@ abstract class AbstractChannelReplicator implements Closeable {
|
||||
maxEntrySizeBytes, throttlingConfig.throttling(DAYS)) : null;
|
||||
}
|
||||
|
||||
Selector openSelector() throws IOException {
|
||||
Selector result = null;
|
||||
try {
|
||||
result = Selector.open();
|
||||
} finally {
|
||||
if (result != null)
|
||||
closeables.add(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
SocketChannel openSocketChannel() throws IOException {
|
||||
SocketChannel result = null;
|
||||
|
||||
try {
|
||||
result = SocketChannel.open();
|
||||
} finally {
|
||||
if (result != null)
|
||||
closeables.add(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void addPendingRegistration(Runnable registration) {
|
||||
pendingRegistrations.add(registration);
|
||||
}
|
||||
@@ -389,4 +408,5 @@ abstract class AbstractChannelReplicator implements Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user