本文整理汇总了Java中org.jgroups.JChannel.connect方法的典型用法代码示例。如果您正苦于以下问题:Java JChannel.connect方法的具体用法?Java JChannel.connect怎么用?Java JChannel.connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jgroups.JChannel
的用法示例。
在下文中一共展示了JChannel.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
示例2: 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);
}
示例3: start
import org.jgroups.JChannel; //导入方法依赖的package包/类
public void start() throws Exception {
ch=new JChannel(props);
if(name != null)
ch.setName(name);
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);
}
}
示例4: 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);
}
}
示例5: 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();
}
示例6: 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);
}
示例7: 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();
}
}
示例8: 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;
}
示例9: 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);
}
示例10: doPreSetup
import org.jgroups.JChannel; //导入方法依赖的package包/类
@Override
protected void doPreSetup() throws Exception {
super.doPreSetup();
clientChannel = new JChannel();
clientChannel.connect(CLUSTER_NAME);
defaultComponentChannel = new JChannel();
}
示例11: 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);
}
}
示例12: 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();
}
示例13: init
import org.jgroups.JChannel; //导入方法依赖的package包/类
@BeforeClass
void init() throws Exception {
targets=new RpcDispatcherAnycastServerObject[NUM];
final String GROUP="RpcDispatcherAnycastMultipleCallsTest";
JChannel first_channel=null;
for(int i=0; i < NUM; i++) {
JChannel c=first_channel == null? createChannel(true,NUM) : createChannel(first_channel);
if(first_channel == null){
first_channel=c;
}
targets[i]=new RpcDispatcherAnycastServerObject(c);
c.connect(GROUP);
}
}
示例14: setUp
import org.jgroups.JChannel; //导入方法依赖的package包/类
@BeforeClass
protected void setUp() throws Exception {
JChannel c1=createChannel(true, 2);
this.map1=new ReplicatedHashMap<>(c1);
map1.setBlockingUpdates(true);
c1.connect("ReplicatedHashMapTest");
this.map1.start(5000);
JChannel c2=createChannel(c1);
this.map2=new ReplicatedHashMap<>(wrap, c2);
map2.setBlockingUpdates(true);
c2.connect("ReplicatedHashMapTest");
this.map2.start(5000);
}
示例15: setUp
import org.jgroups.JChannel; //导入方法依赖的package包/类
protected void setUp(Class<? extends Protocol> flow_control_class) throws Exception {
Protocol flow_control_prot=flow_control_class.newInstance();
flow_control_prot.setValue("min_credits", 1000).setValue("max_credits", 10000).setValue("max_block_time", 1000);
ch=new JChannel(new SHARED_LOOPBACK().setValue("thread_pool_rejection_policy", "run"),
new SHARED_LOOPBACK_PING(),
new NAKACK2().setValue("use_mcast_xmit", false),
new UNICAST3(),
new STABLE().setValue("max_bytes", 50000),
new GMS().setValue("print_local_addr", false),
flow_control_prot,
new FRAG2().fragSize(800));
ch.connect("FCTest");
}