本文整理汇总了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();
}