• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ReceiverAdapter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: start

import org.jgroups.ReceiverAdapter; //导入依赖的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: start

import org.jgroups.ReceiverAdapter; //导入依赖的package包/类
void start(String props, String name, long repl_timeout, boolean allow_dirty_reads, boolean follower) throws Exception {
    ch=new JChannel(props).name(name);
    counter_service=new CounterService(ch).raftId(name).replTimeout(repl_timeout).allowDirtyReads(allow_dirty_reads);
    if(follower)
        disableElections(ch);
    ch.setReceiver(new ReceiverAdapter() {
        public void viewAccepted(View view) {
            System.out.println("-- view: " + view);
        }
    });

    try {
        ch.connect("cntrs");
        loop();
    }
    finally {
        Util.close(ch);
    }
}
 
开发者ID:belaban,项目名称:jgroups-raft,代码行数:20,代码来源:CounterServiceDemo.java


示例3: initialize

import org.jgroups.ReceiverAdapter; //导入依赖的package包/类
@Override
synchronized public void initialize() throws Exception {
    super.initialize();

    CompletableFuture<JChannel> channelFuture = CompletableFuture.supplyAsync(() -> {
        // Put this where JGroups can see it:
        System.setProperty("jgroups.udp.mcast_port", String.valueOf(multicastPort));

        try {
            JChannel channel = new JChannel("cluster.xml");
            channel.setName("EventsAndStatus");
            channel.setDiscardOwnMessages(false); // Also the default, this is documentation.
            channel.setReceiver(new ReceiverAdapter() {
                @Override
                public void receive(Message msg) {
                    eventBus.post(msg.getObject());
                }
            });
            channel.connect(clusterName);
            log.info("JGroups cluster initialization complete");
            return channel;
        } catch (Exception e) {
            throw new RuntimeException("Unable to initialize JGroups", e);
        }
    });

    executor.schedule(
            () -> channelFuture.completeExceptionally(new TimeoutException(
                    "Failed to connect in " + INITIALIZATION_TIMEOUT_SECONDS + " seconds")),
            INITIALIZATION_TIMEOUT_SECONDS, TimeUnit.SECONDS);

    this.channel = channelFuture.get();
}
 
开发者ID:OasisDigital,项目名称:nges,代码行数:34,代码来源:JGroupsMessageGroup.java


示例4: doPreSetup

import org.jgroups.ReceiverAdapter; //导入依赖的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: main

import org.jgroups.ReceiverAdapter; //导入依赖的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


示例6: start

import org.jgroups.ReceiverAdapter; //导入依赖的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: JChannelWrapper

import org.jgroups.ReceiverAdapter; //导入依赖的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


示例8: JGroupsClusterInitializer

import org.jgroups.ReceiverAdapter; //导入依赖的package包/类
public JGroupsClusterInitializer(final ReceiverAdapter receiverAdapter) {
    this.receiverAdapter = receiverAdapter;
}
 
开发者ID:cerner,项目名称:jwala,代码行数:4,代码来源:JGroupsClusterInitializer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GuiUtils类代码示例发布时间:2022-05-21
下一篇:
Java Cell类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap