/** * Returns the channel's own address. The result of calling this method on an unconnected channel * is implementation defined (may return null). Calling this method on a closed channel returns * null. Addresses can be used as destination in the <code>send()</code> operation. * * @return The channel's address (opaque) */ public Address getAddress() {return ch.getAddress();}
public Address getLocalAddress() { return channel != null? channel.getAddress() : null; }
public Address localAddress() { return ch != null? ch.getAddress() : null; }
public Address getLocalAddress() { return channel != null? channel.getAddress() : null; }
void setTitle(String title) { String tmp=""; if(no_channel) { mainFrame.setTitle(" Draw Demo "); return; } if(title != null) { mainFrame.setTitle(title); } else { if(channel.getAddress() != null) tmp+=channel.getAddress(); tmp+=" (" + member_size + ")"; mainFrame.setTitle(tmp); } }
public void sitesDown(String... sites) { System.out.printf("-- %s: site(s) %s went down\n", ch.getAddress(), Stream.of(sites).collect(Collectors.joining(", "))); } });
public void sitesUp(String... sites) { System.out.printf("-- %s: site(s) %s came up\n", ch.getAddress(), Stream.of(sites).collect(Collectors.joining(", "))); }
protected static String printViews(JChannel ... channels) { return Stream.of(channels).map(ch -> String.format("%s: %s", ch.getAddress(), ch.getView())) .collect(Collectors.joining("\n")); }
private AnycastAddress getDestinations(List<Address> members) { int rand = members.indexOf(jChannel.getAddress()); AnycastAddress address = new AnycastAddress(); address.add(members.get(rand++ % members.size()), members.get(rand++ % members.size()), members.get(rand % members.size())); return address; }
public ChannelCommandDispatcher(MessageDispatcher dispatcher, CommandMarshaller<C> marshaller, Group<Address> group, Duration timeout, CommandDispatcher<C> localDispatcher, Runnable closeTask) { this.dispatcher = dispatcher; this.marshaller = marshaller; this.group = group; this.timeout = timeout; this.localDispatcher = localDispatcher; this.closeTask = closeTask; this.localAddress = dispatcher.getChannel().getAddress(); this.options = new RequestOptions(ResponseMode.GET_ALL, this.timeout.toMillis(), false, FILTER, Message.Flag.DONT_BUNDLE, Message.Flag.OOB); }
@Override public Membership getMembership() { return new ViewMembership(this.dispatcher.getChannel().getAddress(), this.view.get(), this); }
@Override public Node getLocalMember() { return this.createNode(this.dispatcher.getChannel().getAddress()); }
protected void start() throws Exception { channel.connect(cluster_name); log.info("%s: joined bridge cluster '%s'", channel.getAddress(), cluster_name); }
public static boolean isCoordinator(JChannel ch) { return isCoordinator(ch.getView(),ch.getAddress()); }
public <X extends MessageDispatcher> X setChannel(JChannel ch) { if(ch == null) return (X)this; this.channel=ch; if(ch != null) { local_addr=channel.getAddress(); ch.addChannelListener(this); } if(prot_adapter == null) prot_adapter=new ProtocolAdapter(); // Don't force installing the UpHandler so subclasses can use this method return installUpHandler(prot_adapter, false); }
protected void stop() { log.info("%s: leaving bridge cluster '%s'", channel.getAddress(), channel.getClusterName()); Util.close(channel); }
public MessageDispatcher(JChannel channel) { this.channel=channel; prot_adapter=new ProtocolAdapter(); if(channel != null) { channel.addChannelListener(this); local_addr=channel.getAddress(); installUpHandler(prot_adapter, true); } start(); }
@ManagedOperation public void start() throws Exception { hash_function=new ConsistentHashFunction<>(); addMembershipListener((MembershipListener)hash_function); ch=new JChannel(props); Marshaller m=new CustomMarshaller(); disp=new RpcDispatcher(ch, this).setMarshaller(m).setMethodLookup(methods::get).setMembershipListener(this); ch.connect(cluster_name); local_addr=ch.getAddress(); view=ch.getView(); }
@SuppressWarnings("resource") public ChannelCommandDispatcherFactory(ChannelCommandDispatcherFactoryConfiguration config) { this.marshallingContext = config.getMarshallingContext(); this.timeout = config.getTimeout(); JChannel channel = config.getChannel(); RequestCorrelator correlator = new RequestCorrelator(channel.getProtocolStack(), this, channel.getAddress()).setMarshaller(new CommandResponseMarshaller(config)); this.dispatcher = new MessageDispatcher() .setChannel(channel) .setRequestHandler(this) .setMembershipListener(this) .asyncDispatching(true) // Setting the request correlator starts the dispatcher .correlator(correlator) ; this.view.compareAndSet(null, channel.getView()); }
@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, this).setMethodLookup(methods::get).setMembershipListener(this); Marshaller marshaller=new CustomMarshaller(); disp.setMarshaller(marshaller); ch.connect(cluster_name); local_addr=ch.getAddress(); view=ch.getView(); timer=ch.getProtocolStack().getTransport().getTimer(); l2_cache.addChangeListener(this); }