Refine search
/** * Creates a channel with the given properties. Connects to the channel, then creates a PullPushAdapter * and starts it */ public ReplicatedTree(String groupname, String props, long state_fetch_timeout) throws Exception { if(groupname != null) this.groupname=groupname; if(props != null) this.props=props; this.state_fetch_timeout=state_fetch_timeout; channel=new JChannel(this.props); channel.setReceiver(this); channel.connect(this.groupname); start(); }
public void start(String props, String name) throws Exception { this.props=props; this.name=name; StringBuilder sb=new StringBuilder(); sb.append("\n\n----------------------- MPerf -----------------------\n"); sb.append("Date: ").append(new Date()).append('\n'); sb.append("Run by: ").append(System.getProperty("user.name")).append("\n"); sb.append("JGroups version: ").append(Version.description).append('\n'); System.out.println(sb); channel=new JChannel(props); channel.setName(name); channel.setReceiver(this); channel.connect("mperf"); local_addr=channel.getAddress(); JmxConfigurator.registerChannel(channel, Util.getMBeanServer(), "jgroups", "mperf", true); // send a CONFIG_REQ to the current coordinator, so we can get the current config Address coord=channel.getView().getCoord(); if(coord != null && !local_addr.equals(coord)) send(coord,null,MPerfHeader.CONFIG_REQ, Message.Flag.RSVP); }
public QuoteClient() { super(); try { channel=new JChannel(props); channel.setDiscardOwnMessages(true); disp=(RpcDispatcher)new RpcDispatcher(channel, this).setMembershipListener(this); channel.connect(channel_name); } catch(Exception e) { System.err.println("QuoteClient(): " + e); } addWindowListener(this); }
public void start() throws Exception { int c; RspList rsps; channel=new JChannel(); // default props disp=new RpcDispatcher(channel, this).setMembershipListener(this); channel.connect("rpc-test"); while(true) { System.out.println("[x]: exit [s]: send sync group RPC"); System.out.flush(); c=System.in.read(); switch(c) { case 'x': channel.close(); disp.stop(); return; case 's': rsps=sendGroupRpc(); System.out.println("responses:\n" + rsps); break; } System.in.skip(System.in.available()); } }
private void createJChannel() throws Exception { System.out.println("Creating Channel"); receiver = new MyReceiver(numberOfNodes, this); jChannel = new JChannel(config); jChannel.setReceiver(receiver); jChannel.connect(CLUSTER); receiver.waitUntilClusterIsFormed(); Util.registerChannel(jChannel, JMX_DOMAIN); members.addAll(jChannel.getView().getMembers()); }
public void start() { try { channel=new JChannel(props); disp=(RpcDispatcher)new RpcDispatcher(channel, this) .setMembershipListener(this).setStateListener(this); channel.connect(channel_name); System.out.println("\nQuote Server started at " + new Date()); System.out.println("Joined channel '" + channel_name + "' (" + channel.getView().size() + " members)"); channel.getState(null, 0); System.out.println("Ready to serve requests"); } catch(Exception e) { log.error("QuoteServer.start() : " + e); System.exit(-1); } }
public static void main(String args[]) { ReplicatedHashMapDemo client=new ReplicatedHashMapDemo(); JChannel channel; String props="udp.xml"; try { for(int i=0; i < args.length; i++) { String arg=args[i]; if("-props".equals(arg)) { props=args[++i]; continue; } help(); return; } } catch(Exception e) { help(); return; } try { channel=new JChannel(props); channel.connect("ReplicatedHashMapDemo-Cluster"); client.start(channel); } catch(Throwable t) { t.printStackTrace(); } }
public ReplicatedTree(String groupname, String props, long state_fetch_timeout, boolean jmx) throws Exception { if(groupname != null) this.groupname=groupname; if(props != null) this.props=props; this.jmx=jmx; this.state_fetch_timeout=state_fetch_timeout; channel=new JChannel(this.props); channel.setReceiver(this); channel.connect(this.groupname); if(jmx) { MBeanServer server=Util.getMBeanServer(); if(server == null) throw new Exception("No MBeanServers found; need to run with an MBeanServer present, or inside JDK 5"); JmxConfigurator.registerChannel(channel, server, "jgroups", channel.getClusterName() , true); } start(); }
public void start(String props, String name) throws Exception { this.props=props; this.name=name; StringBuilder sb=new StringBuilder(); sb.append("\n\n----------------------- MPerf -----------------------\n"); sb.append("Date: ").append(new Date()).append('\n'); sb.append("Run by: ").append(System.getProperty("user.name")).append("\n"); sb.append("JGroups version: ").append(Version.description).append('\n'); System.out.println(sb); channel=new JChannel(props); channel.setName(name); disp=new RpcDispatcher(channel, this).setMembershipListener(this).setMethodLookup(id -> METHODS[id]) .setMarshaller(new MperfMarshaller()); send_options.mode(sync? ResponseMode.GET_ALL : ResponseMode.GET_NONE); if(oob) send_options.flags(Message.Flag.OOB); channel.connect("mperf"); local_addr=channel.getAddress(); JmxConfigurator.registerChannel(channel, Util.getMBeanServer(), "jgroups", "mperf", true); // send a CONFIG_REQ to the current coordinator, so we can get the current config Address coord=channel.getView().getCoord(); if(coord != null && !local_addr.equals(coord)) invokeRpc(configReq, coord, RequestOptions.ASYNC().flags(Message.Flag.RSVP), local_addr); }
protected void applyNewConfig(byte[] buffer) { final InputStream in=new ByteArrayInputStream(buffer); Thread thread=new Thread(() -> { try { JChannel ch=new JChannel(in); Util.sleepRandom(1000, 5000); channel.disconnect(); JChannel tmp=channel; channel=ch; channel.setName(name); channel.setReceiver(MPerf.this); channel.connect("mperf"); local_addr=channel.getAddress(); JmxConfigurator.unregisterChannel(tmp, Util.getMBeanServer(), "jgroups", "mperf"); Util.close(tmp); JmxConfigurator.registerChannel(channel, Util.getMBeanServer(), "jgroups", "mperf", true); } catch(Exception e) { System.err.println("failed creating new channel"); } }); System.out.println("<< restarting channel"); thread.start(); }
public void start(String ... options) throws Exception { String props="udp.xml", name=null; options(options); if(options !=null) { for(int i=0; i < options.length; i++) { if(options[i].startsWith("-props")) { props=options[++i]; continue; } if(options[i].startsWith("-name")) { name=options[++i]; } } } ch=new JChannel(props).name(name).receiver(this); TP transport=ch.getProtocolStack().getTransport(); // uncomment below to disable the regular and OOB thread pools // transport.setOOBThreadPool(new DirectExecutor()); // transport.setDefaultThreadPool(new DirectExecutor()); //ThreadPoolExecutor thread_pool=new ThreadPoolExecutor(4, 4, 30000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(5000)); //transport.setDefaultThreadPool(thread_pool); //transport.setOOBThreadPool(thread_pool); //transport.setInternalThreadPool(thread_pool); ch.connect("rt"); View v=ch.getView(); if(v.size() > 2) throw new IllegalStateException(String.format("More than 2 members found (%s); terminating\n", v)); }
public void start() throws Exception { channel=new JChannel(props); disp=new MessageDispatcher(channel, this).setMembershipListener(this); channel.connect("MessageDispatcherSpeedTestGroup"); try { if(server) { System.out.println("-- Started as server. Press ctrl-c to kill"); while(true) { Util.sleep(10000); } } else { sendMessages(num); } } catch(Throwable t) { t.printStackTrace(System.err); } finally { channel.close(); disp.stop(); } }
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); } }
public void start(String props, String name, boolean unicast) throws Exception { ch=new JChannel(props); if(name != null) ch.setName(name); ch.setReceiver(this); ch.connect("ping"); while(true) { Util.keyPress("enter to ping"); Address dest=null; if(unicast) dest=Util.pickRandomElement(members); Message msg=new Message(dest, PING_REQ); msg.setFlag(Message.Flag.DONT_BUNDLE, Message.Flag.NO_FC); start=System.nanoTime(); ch.send(msg); } }
public void start() throws Exception { channel=new JChannel(props).name(name); 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); }