本文整理汇总了Java中org.jgroups.JChannel.close方法的典型用法代码示例。如果您正苦于以下问题:Java JChannel.close方法的具体用法?Java JChannel.close怎么用?Java JChannel.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jgroups.JChannel
的用法示例。
在下文中一共展示了JChannel.close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: joining_member_reads_state_from_existing_one
import org.jgroups.JChannel; //导入方法依赖的package包/类
@Test
public void joining_member_reads_state_from_existing_one() throws Exception {
JgroupsStateKey key = new JgroupsStateKey("shared-state-key");
String initialState = "initial-state-of-1";
MemberStateHolder holder1 = spy(new MemberStateHolder(key, initialState));
MemberStateHolder holder2 = spy(new MemberStateHolder(key, null));
JChannel member1 = createMember(holder1);
JChannel member2 = createMember(holder2);
verify(holder1, timeout(TIMEOUT_MS)).getState();
verify(holder2, timeout(TIMEOUT_MS)).setState(initialState);
assertThat(holder1.getState(), is(initialState));
assertThat(holder2.getState(), is(initialState));
member1.close();
member2.close();
}
示例2: main
import org.jgroups.JChannel; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
JChannel channel = new JChannel();
CountDownLatch latch = new CountDownLatch(1); //using this to put the main thread to sleep while we receive messages
try
{
channel.connect("devict.test.channel");
channel.receiver(new AgentMessageReceiver());
Runtime.getRuntime().addShutdownHook(new Thread(latch::countDown)); //this is the cheap Java way to listen for sigkill
latch.await();
}
finally
{
channel.close();
}
}
示例3: main
import org.jgroups.JChannel; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
JChannel channel = new JChannel();
try
{
channel.connect("devict.test.channel");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("> ");
for(String msg = in.readLine(); !StringUtils.equalsIgnoreCase("QUIT", msg); msg = in.readLine())
{
try
{
channel.send(new Message(null, null, msg));
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
System.out.print("> ");
}
}
finally
{
channel.close();
}
}
示例4: start
import org.jgroups.JChannel; //导入方法依赖的package包/类
private void start(String props, String name) throws Exception {
channel=new JChannel(props);
if(name != null)
channel.name(name);
channel.setReceiver(this);
channel.connect("ChatCluster");
eventLoop();
channel.close();
}
示例5: start
import org.jgroups.JChannel; //导入方法依赖的package包/类
private void start() throws Exception {
channel=new JChannel();
channel.setReceiver(this);
channel.connect("ChatCluster");
channel.getState(null, 10000);
eventLoop();
channel.close();
}
示例6: closeChannel
import org.jgroups.JChannel; //导入方法依赖的package包/类
private static boolean closeChannel(final JChannel someChannel) {
if (someChannel!=null) {
try {
someChannel.close();
}
catch (Throwable e) {
//This is interesting but allow closing all channels first
e.printStackTrace();
return false;
}
}
return true;
}
开发者ID:vert-x3,项目名称:vertx-jgroups,代码行数:14,代码来源:JGroupsSimpleClusterManagerWithCustomJChannelTest.java
示例7: startServer
import org.jgroups.JChannel; //导入方法依赖的package包/类
protected void startServer() {
final Session session = Session.getSessionUsingInitiativeYearTerm(
ApplicationProperties.getProperty("initiative", "woebegon"),
ApplicationProperties.getProperty("year","2010"),
ApplicationProperties.getProperty("term","Fal")
);
boolean remote = "true".equalsIgnoreCase(ApplicationProperties.getProperty("remote", "true"));
if (session==null) {
sLog.error("Academic session not found, use properties initiative, year, and term to set academic session.");
System.exit(0);
} else {
sLog.info("Session: "+session);
}
iSessionId = session.getUniqueId();
OnlineSectioningLogger.getInstance().setEnabled(false);
if (remote) {
try {
iChannel = new JChannel(JGroupsUtils.getConfigurator(ApplicationProperty.SolverClusterConfiguration.value()));
iChannel.setUpHandler(new MuxUpHandler());
iSolverServer = new DummySolverServer(iChannel);
iChannel.connect("UniTime:rpc");
iChannel.getState(null, 0);
if (getServer() == null)
throw new Exception(session.getLabel() + " is not available");
} catch (Exception e) {
sLog.error("Failed to access the solver server: " + e.getMessage(), e);
if (iChannel != null && iChannel.isConnected()) iChannel.disconnect();
if (iChannel != null && iChannel.isOpen()) iChannel.close();
System.exit(0);
}
} else {
iServer = new InMemoryServer(new OnlineSectioningServerContext() {
@Override
public boolean isWaitTillStarted() {
return true;
}
@Override
public EmbeddedCacheManager getCacheManager() {
return null;
}
@Override
public Long getAcademicSessionId() {
return session.getUniqueId();
}
@Override
public LockService getLockService() {
return null;
}
});
}
}