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


Java JChannel.setReceiver方法代码示例

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


在下文中一共展示了JChannel.setReceiver方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import org.jgroups.JChannel; //导入方法依赖的package包/类
public void start() throws Exception {
    String props="udp.xml";

    channel=new JChannel(props);

    channel.setReceiver(new ReceiverAdapter() {
        public void viewAccepted(View view) {
            setInternalState(view.getMembers());
        }

        public void setInternalState(java.util.List<Address> mbrs) {
            members.clear();
            for(Address mbr : mbrs)
                addNode(mbr);
            coordinator=mbrs.size() <= 1 || (mbrs.size() > 1 && mbrs.iterator().next().equals(my_addr));
            repaint();
        }
    });
    channel.connect(channel_name);
    my_addr=channel.getAddress();
    if(my_addr != null)
        setTitle(my_addr.toString());
    pack();
    setVisible(true);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:26,代码来源:Topology.java

示例2: main

import org.jgroups.JChannel; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Protocol[] prot_stack={
      new UDP().setValue("bind_addr", InetAddress.getByName("127.0.0.1")),
      new PING(),
      new MERGE3(),
      new FD_SOCK(),
      new FD_ALL(),
      new VERIFY_SUSPECT(),
      new BARRIER(),
      new NAKACK2(),
      new UNICAST3(),
      new STABLE(),
      new GMS(),
      new UFC(),
      new MFC(),
      new FRAG2()};
    JChannel ch=new JChannel(prot_stack).name(args[0]);

    ch.setReceiver(new ReceiverAdapter() {
        public void viewAccepted(View new_view) {
            System.out.println("view: " + new_view);
        }

        public void receive(Message msg) {
            System.out.println("<< " + msg.getObject() + " [" + msg.getSrc() + "]");
        }
    });

    ch.connect("ChatCluster");


    for(;;) {
        String line=Util.readStringFromStdin(": ");
        ch.send(null, line);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:37,代码来源:ProgrammaticChat.java

示例3: init

import org.jgroups.JChannel; //导入方法依赖的package包/类
@Override
public CoChannel init(ChannelSelector selector) throws CoChannelException {
    super.init(selector);
    try {
        jch = new JChannel(); // TODO config
        jch.setReceiver(this);
        jch.connect(name());
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        try {
            close();
        } catch (IOException e1) {}
    }
    return this;
}
 
开发者ID:dzh,项目名称:coca,代码行数:16,代码来源:JGroupsGroupChannel.java

示例4: doPreSetup

import org.jgroups.JChannel; //导入方法依赖的package包/类
@Override
protected void doPreSetup() throws Exception {
    super.doPreSetup();
    channel = new JChannel();
    channel.setReceiver(new ReceiverAdapter() {
        @Override
        public void receive(Message msg) {
            messageReceived = msg.getObject();
        }
    });
    channel.connect(CLUSTER_NAME);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:JGroupsProducerTest.java

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

示例6: start

import org.jgroups.JChannel; //导入方法依赖的package包/类
void start(String props, String channel_name) throws Exception {
    ch=new JChannel(props);
    ch.setName(channel_name);
    ch.setReceiver(new ReceiverAdapter() {
        public void viewAccepted(View view) {
            System.out.println("-- view: " + view);
        }
    });
    loop();
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:11,代码来源:CounterServiceDemo.java

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

示例8: initialize

import org.jgroups.JChannel; //导入方法依赖的package包/类
@Override
public void initialize(RevenoClusterConfiguration config) {
    this.config = config;
    Properties props = new Properties();
    props.put("jgroups.tcp.bind_addr", ((InetAddress) config.currentNodeAddress()).getHost());
    props.put("jgroups.tcp.bind_port", Integer.toString(((InetAddress) config.currentNodeAddress()).getPort()));
    props.put("jgroups.tcpping.initial_hosts", makeInitialHostsString(config.nodesAddresses()));
    props.put("jgroups.auth.token", Optional.ofNullable(config.authToken()).orElse(""));
    setProperties(props);

    try {
        String protocol;
        if (jGroupsConfigFile.startsWith("classpath:/")) {
            protocol = ResourceLoader.loadResource(new ByteArrayInputStream(DEFAULT_CONFIG.getBytes("UTF-8")), props);
        } else {
            protocol = ResourceLoader.loadResource(new File(jGroupsConfigFile), props);
        }
        Element xml = ResourceLoader.loadXMLFromString(protocol).getDocumentElement();
        channel = new JChannel(xml);
        channel.setReceiver(new JChannelReceiver());
        channel.setDiscardOwnMessages(true);
        cluster = new JGroupsCluster(config, channel);
        buffer = createBuffer();
    } catch (Exception e) {
        throw Exceptions.runtime(e);
    }
    isInitialized = true;
}
 
开发者ID:dmart28,项目名称:reveno,代码行数:29,代码来源:JGroupsClusterProvider.java

示例9: JChannelWrapper

import org.jgroups.JChannel; //导入方法依赖的package包/类
public JChannelWrapper(JChannelManager manager, final String channelName, JChannel channel) throws Exception {
   this.refCount = 1;
   this.channelName = channelName;
   this.channel = channel;
   this.manager = manager;

   if (logger.isTraceEnabled() && channel.getReceiver() != null) {
      logger.trace(this + "The channel already had a receiver previously!!!! == " + channel.getReceiver(), new Exception("trace"));
   }

   //we always add this for the first ref count
   channel.setReceiver(new ReceiverAdapter() {

      @Override
      public String toString() {
         return "ReceiverAdapter::" + JChannelWrapper.this;
      }

      @Override
      public void receive(org.jgroups.Message msg) {
         if (logger.isTraceEnabled()) {
            logger.trace(this + ":: Wrapper received " + msg + " on channel " + channelName);
         }
         synchronized (receivers) {
            for (JGroupsReceiver r : receivers) {
               r.receive(msg);
            }
         }
      }
   });
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:32,代码来源:JChannelWrapper.java


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