isShuttingDown and isShutdown methods added. #323

pull/337/head
Nikita 9 years ago
parent faa0ed2a60
commit f57a474b55

@ -374,5 +374,15 @@ public class Redisson implements RedissonClient {
commandExecutor.get(commandExecutor.writeAllAsync(RedisCommands.FLUSHALL));
}
@Override
public boolean isShutdown() {
return connectionManager.isShutdown();
}
@Override
public boolean isShuttingDown() {
return connectionManager.isShuttingDown();
}
}

@ -450,4 +450,19 @@ public interface RedissonClient {
*/
void flushall();
/**
* Returns {@code true} if this Redisson instance has been shut down.
*
* @return
*/
boolean isShutdown();
/**
* Returns {@code true} if this Redisson instance was started to be shutdown
* or was shutdown {@link #isShutdown()} already.
*
* @return
*/
boolean isShuttingDown();
}

@ -305,6 +305,15 @@ public class RedissonReactive implements RedissonReactiveClient {
connectionManager.shutdown();
}
@Override
public boolean isShutdown() {
return connectionManager.isShutdown();
}
@Override
public boolean isShuttingDown() {
return connectionManager.isShuttingDown();
}
}

@ -374,4 +374,19 @@ public interface RedissonReactiveClient {
*/
NodesGroup<ClusterNode> getClusterNodesGroup();
/**
* Returns {@code true} if this Redisson instance has been shut down.
*
* @return
*/
boolean isShutdown();
/**
* Returns {@code true} if this Redisson instance was started to be shutdown
* or was shutdown {@link #isShutdown()} already.
*
* @return
*/
boolean isShuttingDown();
}

@ -45,6 +45,10 @@ import io.netty.util.concurrent.Promise;
*/
public interface ConnectionManager {
boolean isShutdown();
boolean isShuttingDown();
Promise<PubSubConnectionEntry> subscribe(Codec codec, String channelName, RedisPubSubListener listener);
ConnectionListener getConnectListener();

@ -649,6 +649,17 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
group.shutdownGracefully().syncUninterruptibly();
}
@Override
public boolean isShuttingDown() {
return shutdownLatch.isClosed();
}
@Override
public boolean isShutdown() {
return group.isTerminated();
}
@Override
public Collection<RedisClientEntry> getClients() {
return Collections.unmodifiableCollection(clients);
}
@ -682,6 +693,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
}
}
@Override
public InfinitySemaphoreLatch getShutdownLatch() {
return shutdownLatch;
}

@ -24,6 +24,7 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer;
* Code parts from Manik Surtani (<a href="mailto:manik@jboss.org">manik@jboss.org</a>)
* @author Nikita Koksharov
*/
// TODO refactor to AbstractQueuedLongSynchronizer
public class InfinitySemaphoreLatch extends AbstractQueuedSynchronizer {
private static final long serialVersionUID = 1744280161777661090l;
@ -78,6 +79,10 @@ public class InfinitySemaphoreLatch extends AbstractQueuedSynchronizer {
return getState() == OPEN_STATE;
}
public boolean isClosed() {
return closed;
}
// waiting for an open state
public final boolean closeAndAwaitUninterruptibly() {
closed = true;

Loading…
Cancel
Save