Merge branch 'master' of github.com:OpenHFT/Chronicle-Map

This commit is contained in:
leventov
2014-09-24 22:14:33 +04:00
4 changed files with 66 additions and 6 deletions
@@ -329,16 +329,39 @@ abstract class AbstractChannelReplicator implements Closeable {
final Thread thread = new Thread(new Runnable() {
public void run() {
SelectableChannel socketChannel = null;
try {
if (reconnectionInterval > 0)
Thread.sleep(reconnectionInterval);
SelectableChannel socketChannel = doConnect();
closeables.add(socketChannel);
socketChannel = doConnect();
try {
closeables.add(socketChannel);
} catch (IllegalStateException e) {
// close could have be called from another thread, while we were in Thread.sleep()
// which would cause a IllegalStateException
closeQuietly(socketChannel);
return;
}
AbstractConnector.this.socketChannel = socketChannel;
} catch (Exception e) {
LOG.error("", e);
closeQuietly(socketChannel);
LOG.debug("", e);
}
}
private void closeQuietly(SelectableChannel socketChannel) {
if (socketChannel == null)
return;
try {
socketChannel.close();
} catch (Exception e1) {
// do nothing
}
}
});
@@ -346,6 +369,8 @@ abstract class AbstractChannelReplicator implements Closeable {
thread.setName(name);
thread.setDaemon(true);
thread.start();
}
public void setSuccessfullyConnected() {
@@ -29,7 +29,7 @@ final class CloseablesManager implements Closeable {
private static final Logger LOG = LoggerFactory.getLogger(CloseablesManager.class.getName());
private boolean isClosed = false;
private List<Closeable> closeables = new ArrayList<Closeable>();
private final List<Closeable> closeables = new ArrayList<Closeable>();
private void checkState() {
if (isClosed)
@@ -55,6 +55,8 @@ final class CloseablesManager implements Closeable {
public synchronized void closeQuietly(Closeable closeable) {
try {
close(closeable);
} catch (IllegalStateException e) {
// this can occur if already closed ( for example closed is called from another thread )
} catch (IOException e) {
LOG.error("", e);
}
@@ -84,4 +86,8 @@ final class CloseablesManager implements Closeable {
// do nothing
}
}
boolean isClosed() {
return isClosed;
}
}