当前位置: 首页>>代码示例>>Java>>正文


Java JChannel.close方法代码示例

本文整理汇总了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();
}
 
开发者ID:florentw,项目名称:bench,代码行数:19,代码来源:JgroupsStateTransferTest.java

示例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();
   }
}
 
开发者ID:developerSid,项目名称:AwesomeJavaLibraryExamples,代码行数:18,代码来源:JClusterAgent.java

示例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();
   }
}
 
开发者ID:developerSid,项目名称:AwesomeJavaLibraryExamples,代码行数:31,代码来源:JClusterHandler.java

示例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();
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:10,代码来源:Chat.java

示例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();
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:9,代码来源:SimpleChat.java

示例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;
   			}
   		});
       }
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:63,代码来源:OnlineSectioningTestFwk.java


注:本文中的org.jgroups.JChannel.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。