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


Java JChannel类代码示例

本文整理汇总了Java中org.jgroups.JChannel的典型用法代码示例。如果您正苦于以下问题:Java JChannel类的具体用法?Java JChannel怎么用?Java JChannel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JChannel类属于org.jgroups包,在下文中一共展示了JChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: SolverServerImplementation

import org.jgroups.JChannel; //导入依赖的package包/类
public SolverServerImplementation(boolean local, JChannel channel) {
	super();
	
	iLocal = local;
	iChannel = channel;
	// iChannel.setReceiver(this);
	iChannel.setUpHandler(new MuxUpHandler());
	iDispatcher = new MuxRpcDispatcher(SCOPE_SERVER, channel, this, this, this);
	
	iCourseSolverContainer = new CourseSolverContainerRemote(channel, SCOPE_COURSE, local);
	iExamSolverContainer = new ExaminationSolverContainerRemote(channel, SCOPE_EXAM);
	iStudentSolverContainer = new StudentSolverContainerRemote(channel, SCOPE_STUDENT);
	iInstructorSchedulingContainer = new InstructorSchedulingContainerRemote(channel, SCOPE_INSTRUCTOR);
	iOnlineStudentSchedulingContainer = new OnlineStudentSchedulingContainerRemote(channel, SCOPE_ONLINE);
	iRemoteRoomAvailability = new RemoteRoomAvailability(channel, SCOPE_AVAILABILITY);
	iUpdater = new OnlineStudentSchedulingGenericUpdater(iDispatcher, iOnlineStudentSchedulingContainer);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:18,代码来源:SolverServerImplementation.java

示例3: 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

示例4: start

import org.jgroups.JChannel; //导入依赖的package包/类
public void start()
{
	try
	{
		if(this.active)
		{
			this.channel = new JChannel();
			this.channel.setReceiver(this);
			this.channel.connect("openmobster");
		}
	}
	catch(Exception e)
	{
		log.error(this, e);
		throw new RuntimeException(e);
	}
}
 
开发者ID:ZalemSoftware,项目名称:OpenMobster,代码行数:18,代码来源:ClusterService.java

示例5: start

import org.jgroups.JChannel; //导入依赖的package包/类
public void start(JChannel ch) throws Exception {
    this.ch=ch;
    lock_service=new LockService(ch);
    lock_service.addLockListener(this);
    ch.connect("lock-cluster");
    JmxConfigurator.registerChannel(ch, Util.getMBeanServer(), "lock-service", ch.getClusterName(), true);

    try {
        loop();
    }
    catch(Exception e) {
        e.printStackTrace();
    }
    finally {
        Util.close(ch);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:18,代码来源:LockServiceDemo.java

示例6: start

import org.jgroups.JChannel; //导入依赖的package包/类
public void start() throws Exception {
    ch=new JChannel(props);
    if(name != null)
        ch.setName(name);
    execution_service=new ExecutionService(ch);
    runner=new ExecutionRunner(ch);
    ch.connect("executing-cluster");
    JmxConfigurator.registerChannel(ch, Util.getMBeanServer(), 
        "execution-service", ch.getClusterName(), true);
    
    // Start a consumer
    queue.add(executor.submit(runner));
    random = new Random();
    printValues = false;

    try {
        loop();
    }
    catch(Exception e) {
        e.printStackTrace();
    }
    finally {
        Util.close(ch);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:26,代码来源:ExecutionServiceDemo.java

示例7: registerChannel

import org.jgroups.JChannel; //导入依赖的package包/类
/**
 * Registers an already created channel with the given MBeanServer. Wraps instance of JChannel
 * with DynamicMBean and delegates all calls to the actual JChannel wrapped.
 * <p>
 * Optionally, this method will also wrap each protocol in the given channel with DynamicMBean
 * and register it as well.
 * 
 * @param channel
 * @param server
 * @param domain
 *            Has to be a JMX ObjectName of the domain, e.g. DefaultDomain:name=JGroups
 * @param register_protocols
 */
public static void registerChannel(JChannel channel, MBeanServer server, String domain,
                String cluster_name, boolean register_protocols) throws Exception {

    if(channel == null)
        throw new NullPointerException("channel cannot be null");
    if (cluster_name == null)
        cluster_name=channel.getClusterName();
    if (cluster_name == null)
        cluster_name = "null";

    cluster_name=ObjectName.quote(cluster_name);

    if (register_protocols) {
        ProtocolStack stack = channel.getProtocolStack();
        List<Protocol> protocols = stack.getProtocols();
        for (Protocol p : protocols) {
            if (p.getClass().isAnnotationPresent(MBean.class)) {
                String jmx_name=getProtocolRegistrationName(cluster_name,domain,p);
                register(p, server, jmx_name);
            }
        }
    }
    register(channel, server, getChannelRegistrationName(channel, domain, cluster_name));
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:38,代码来源:JmxConfigurator.java

示例8: start

import org.jgroups.JChannel; //导入依赖的package包/类
public synchronized boolean start(JChannel channel) throws Exception {
    boolean started = false;
    if (server == null) {
        try {
            InetSocketAddress address = new InetSocketAddress("0.0.0.0", port);
            server = HttpServer.create(address, 0);
            server.setExecutor(Executors.newCachedThreadPool());
            server.createContext("/", new Handler(this));
            server.start();
            started = true;
        } catch (Exception e) {
            server = null;
            throw e;
        }
    }
    addChannel(channel);
    return started;
}
 
开发者ID:jboss-openshift,项目名称:openshift-ping,代码行数:19,代码来源:JBossServer.java

示例9: start

import org.jgroups.JChannel; //导入依赖的package包/类
@ManagedOperation
public void start() throws Exception {
    hash_function=new ConsistentHashFunction<>();
    addMembershipListener((MembershipListener)hash_function);
    ch=new JChannel(props);
    disp=new RpcDispatcher(ch, null, this, this);
    RpcDispatcher.Marshaller marshaller=new CustomMarshaller();
    disp.setRequestMarshaller(marshaller);
    disp.setResponseMarshaller(marshaller);
    disp.setMethodLookup(new MethodLookup() {
        public Method findMethod(short id) {
            return methods.get(id);
        }
    });

    ch.connect(cluster_name);
    local_addr=ch.getAddress();
    view=ch.getView();
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:20,代码来源:PartitionedHashMap.java

示例10: start

import org.jgroups.JChannel; //导入依赖的package包/类
@ManagedOperation
public void start() throws Exception {
    if(hash_function_factory != null) {
        hash_function=hash_function_factory.create();
    }
    if(hash_function == null)
        hash_function=new ConsistentHashFunction<>();

    ch=new JChannel(props);
    disp=new RpcDispatcher(ch, null, this, this);
    RpcDispatcher.Marshaller marshaller=new CustomMarshaller();
    disp.setRequestMarshaller(marshaller);
    disp.setResponseMarshaller(marshaller);
    disp.setMethodLookup(new MethodLookup() {
        public Method findMethod(short id) {
            return methods.get(id);
        }
    });

    ch.connect(cluster_name);
    local_addr=ch.getAddress();
    view=ch.getView();
    timer=ch.getProtocolStack().getTransport().getTimer();

    l2_cache.addChangeListener(this);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:27,代码来源:ReplCache.java

示例11: getStackConfigurator

import org.jgroups.JChannel; //导入依赖的package包/类
/**
 * Returns a protocol stack configurator based on the provided properties string.
 *
 * @param properties an old style property string, a string representing a system resource containing a JGroups
 *                   XML configuration, a string representing a URL pointing to a JGroups XML configuration,
 *                   or a string representing a file name that contains a JGroups XML configuration.
 */
public static ProtocolStackConfigurator getStackConfigurator(String properties) throws Exception {
    // added by bela: for null String props we use the default properties
    if(properties == null)
        properties=JChannel.DEFAULT_PROTOCOL_STACK;

    // Attempt to treat the properties string as a pointer to an XML configuration.
    XmlConfigurator configurator = null;

    checkForNullConfiguration(properties);
    configurator=getXmlConfigurator(properties);

    if (configurator != null) // did the properties string point to a JGroups XML configuration ?
        return configurator;
    else
        return new PlainConfigurator(properties); // try to process the properties string as an old style property string
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:24,代码来源:ConfiguratorFactory.java

示例12: createChannel

import org.jgroups.JChannel; //导入依赖的package包/类
protected static JChannel createChannel(String name) throws Exception {
    Protocol[] protocols={
      new SHARED_LOOPBACK().setValue("oob_thread_pool_min_threads", 1)
        .setValue("oob_thread_pool_max_threads", 5)
      .setValue("oob_thread_pool_queue_enabled", false),
      new SHARED_LOOPBACK_PING(),
      new NAKACK2(),
      new UNICAST3(),
      new STABLE(),
      new GMS(),
      new UFC(),
      new MFC().setValue("max_credits", 2000000).setValue("min_threshold", 0.4),
      new FRAG2().fragSize(8000),
    };
    return new JChannel(protocols).name(name);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:17,代码来源:RemoteGetStressTest.java

示例13: setUp

import org.jgroups.JChannel; //导入依赖的package包/类
@BeforeMethod
void setUp() throws Exception {
    a=new JChannel(props).name("A");
    a.connect(GROUP);
    r1=new MyReceiver("A");
    a.setReceiver(r1);

    b=new JChannel(props).name("B");
    b.connect(GROUP);
    r2=new MyReceiver("B");
    b.setReceiver(r2);

    c=new JChannel(props).name("C");
    c.connect(GROUP);
    r3=new MyReceiver("C");
    c.setReceiver(r3);

    Util.waitUntilAllChannelsHaveSameSize(10000, 1000,a,b,c);

    for(int i=0; i < senders.length; i++)
        senders[i]=new Sender(NUM_MSGS, num,a,b,c);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:23,代码来源:SequencerOrderTest.java

示例14: replaceStateTransferProtocolWith

import org.jgroups.JChannel; //导入依赖的package包/类
protected void replaceStateTransferProtocolWith(JChannel ch, Class<?> state_transfer_class) throws Exception {
    ProtocolStack stack=ch.getProtocolStack();
    if(stack.findProtocol(state_transfer_class) != null)
        return; // protocol of the right class is already in stack
    Protocol prot=stack.findProtocol(STATE_TRANSFER.class, StreamingStateTransfer.class);
    Protocol new_state_transfer_protcol=(Protocol)state_transfer_class.newInstance();
    if(prot != null) {
        stack.replaceProtocol(prot, new_state_transfer_protcol);
    }
    else { // no state transfer protocol found in stack
        Protocol flush=stack.findProtocol(FLUSH.class);
        if(flush != null)
            stack.insertProtocol(new_state_transfer_protcol, ProtocolStack.BELOW, FLUSH.class);
        else
            stack.insertProtocolAtTop(new_state_transfer_protcol);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:18,代码来源:StateTransferTest2.java

示例15: createTcpgossipChannel

import org.jgroups.JChannel; //导入依赖的package包/类
protected JChannel createTcpgossipChannel(String name) throws Exception {
    TCPGOSSIP gossip=new TCPGOSSIP();
    List<InetSocketAddress> initial_hosts=new ArrayList<>();
    initial_hosts.add(new InetSocketAddress(bind_addr, gossip_router_port));
    gossip.setInitialHosts(initial_hosts);

    JChannel ch=new JChannel(new TCP().setValue("use_send_queues",true)
                               .setValue("sock_conn_timeout",300).setValue("bind_addr", bind_addr),
                             gossip,
                             new MERGE3().setValue("min_interval",1000).setValue("max_interval",3000),
                             new FD().setValue("timeout",2000).setValue("max_tries",2),
                             new VERIFY_SUSPECT(),
                             new NAKACK2().setValue("use_mcast_xmit",false),
                             new UNICAST3(), new STABLE(), new GMS().joinTimeout(1000));
    if(name != null)
        ch.setName(name);
    return ch;
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:19,代码来源:TCPGOSSIP_Test.java


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