本文整理匯總了Java中io.netty.channel.group.ChannelGroup.size方法的典型用法代碼示例。如果您正苦於以下問題:Java ChannelGroup.size方法的具體用法?Java ChannelGroup.size怎麽用?Java ChannelGroup.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.netty.channel.group.ChannelGroup
的用法示例。
在下文中一共展示了ChannelGroup.size方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testMasterSlaveSentinelConnectionCount
import io.netty.channel.group.ChannelGroup; //導入方法依賴的package包/類
@Test
public void testMasterSlaveSentinelConnectionCount() throws Exception {
ChannelGroup channels = (ChannelGroup) ReflectionTestUtils.getField(sentinelClient, "channels");
int count = channels.size();
StatefulRedisMasterSlaveConnection<String, String> connection = MasterSlave.connect(sentinelClient,
new Utf8StringCodec(), sentinelUri);
connection.sync().ping();
connection.setReadFrom(ReadFrom.SLAVE);
slaveCall(connection);
assertThat(channels.size()).isEqualTo(count + 2 /* connections */ + 1 /* sentinel connections */);
connection.close();
}
示例2: testMasterSlaveSentinelClosesSentinelConnections
import io.netty.channel.group.ChannelGroup; //導入方法依賴的package包/類
@Test
public void testMasterSlaveSentinelClosesSentinelConnections() throws Exception {
ChannelGroup channels = (ChannelGroup) ReflectionTestUtils.getField(sentinelClient, "channels");
int count = channels.size();
StatefulRedisMasterSlaveConnection<String, String> connection = MasterSlave.connect(sentinelClient,
new Utf8StringCodec(), sentinelUri);
connection.sync().ping();
connection.setReadFrom(ReadFrom.SLAVE);
slaveCall(connection);
connection.close();
assertThat(channels.size()).isEqualTo(count);
}
示例3: getNumberOfConnectedClients
import io.netty.channel.group.ChannelGroup; //導入方法依賴的package包/類
private int getNumberOfConnectedClients() {
final Server server = getComponent(Server.KEY);
if (server == null) {
Log.i(TAG, "Container not yet connected.");
return 0;
}
ChannelGroup activeChannels = server.getActiveChannels();
return activeChannels.size();
}
示例4: closeChannels
import io.netty.channel.group.ChannelGroup; //導入方法依賴的package包/類
public static void closeChannels(ChannelGroup allChannels) {
if (allChannels.size() > 0) {
// TODO : allow an option here to control if we need to drain connections and wait instead of
// killing them all
try {
// log.info("Closing %s open client connections", allChannels.size());
if (!allChannels.close().await(5, TimeUnit.SECONDS)) {
// log.warn("Failed to close all open client connections");
}
} catch (InterruptedException e) {
// log.warn("Interrupted while closing client connections");
Thread.currentThread().interrupt();
}
}
}
示例5: allConnected
import io.netty.channel.group.ChannelGroup; //導入方法依賴的package包/類
private int allConnected() {
ChannelGroup group = getGroup(ALL);
return group == null ? 0 : group.size();
}