@Override public void members(List<PingData> mbrs) { PhysicalAddress own_physical_addr=(PhysicalAddress)down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr)); PingData data=new PingData(local_addr, false, org.jgroups.util.NameCache.get(local_addr), own_physical_addr); PingHeader hdr=new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name); Set<PhysicalAddress> physical_addrs=mbrs.stream().filter(ping_data -> ping_data != null && ping_data.getPhysicalAddr() != null) .map(PingData::getPhysicalAddr).collect(Collectors.toSet()); for(PhysicalAddress physical_addr: physical_addrs) { if(physical_addr != null && own_physical_addr.equals(physical_addr)) // no need to send the request to myself continue; // the message needs to be DONT_BUNDLE, see explanation above final Message msg=new Message(physical_addr).setFlag(Message.Flag.INTERNAL, Message.Flag.DONT_BUNDLE, Message.Flag.OOB) .putHeader(this.id, hdr).setBuffer(marshal(data)); log.trace("%s: sending discovery request to %s", local_addr, msg.getDest()); down_prot.down(msg); } }
public void init() throws Exception { super.init(); stubManager = RouterStubManager.emptyGossipClientStubManager(this).useNio(this.use_nio); // we cannot use TCPGOSSIP together with TUNNEL (https://jira.jboss.org/jira/browse/JGRP-1101) TP transport=getTransport(); if(transport instanceof TUNNEL) throw new IllegalStateException("TCPGOSSIP cannot be used with TUNNEL; use either TUNNEL:PING or " + "TCP:TCPGOSSIP as valid configurations"); }
@ManagedOperation public void addInitialHost(String hostname, int port) { //if there is such a stub already, remove and destroy it removeInitialHost(hostname, port); //now re-add it InetSocketAddress isa = new InetSocketAddress(hostname, port); initial_hosts.add(isa); stubManager.createAndRegisterStub(null, new IpAddress(isa.getAddress(), isa.getPort())); stubManager.connectStubs(); // tries to connect all unconnected stubs }
public boolean setProperties(Properties props) { String str; str=props.getProperty("gossip_refresh_rate"); // wait for at most n members if(str != null) { gossip_refresh_rate=Integer.parseInt(str); props.remove("gossip_refresh_rate"); } str=props.getProperty("initial_hosts"); if(str != null) { props.remove("initial_hosts"); try { initial_hosts=createInitialHosts(str); } catch(UnknownHostException ex) { if(log.isErrorEnabled()) log.error("failed creating initial hosts", ex); return false; } } if(initial_hosts == null || initial_hosts.isEmpty()) { if(log.isErrorEnabled()) log.error("initial_hosts must contain the address of at least one GossipRouter"); return false; } return super.setProperties(props); }
@Override public void members(List<PingData> mbrs) { PhysicalAddress own_physical_addr=(PhysicalAddress)down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr)); PingData data=new PingData(local_addr, false, org.jgroups.util.NameCache.get(local_addr), own_physical_addr); PingHeader hdr=new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name); Set<PhysicalAddress> physical_addrs=mbrs.stream().filter(ping_data -> ping_data != null && ping_data.getPhysicalAddr() != null) .map(PingData::getPhysicalAddr).collect(Collectors.toSet()); for(PhysicalAddress physical_addr: physical_addrs) { if(physical_addr != null && own_physical_addr.equals(physical_addr)) // no need to send the request to myself continue; // the message needs to be DONT_BUNDLE, see explanation above final Message msg=new Message(physical_addr).setFlag(Message.Flag.INTERNAL, Message.Flag.DONT_BUNDLE, Message.Flag.OOB) .putHeader(this.id, hdr).setBuffer(marshal(data)); log.trace("%s: sending discovery request to %s", local_addr, msg.getDest()); down_prot.down(msg); } }
public void handleConnect() { if (cluster_name == null || local_addr == null) log.error(Util.getMessage("GroupaddrOrLocaladdrIsNullCannotRegisterWithGossipRouterS")); else { InetAddress bind_addr=getTransport().getBindAddress(); log.trace("registering " + local_addr + " under " + cluster_name + " with GossipRouter"); stubManager.destroyStubs(); PhysicalAddress physical_addr = (PhysicalAddress) down_prot.down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr)); stubManager = new RouterStubManager(this, cluster_name, local_addr, NameCache.get(local_addr), physical_addr, reconnect_interval).useNio(this.use_nio); for (InetSocketAddress host : initial_hosts) { RouterStub stub=stubManager.createAndRegisterStub(new IpAddress(bind_addr, 0), new IpAddress(host.getAddress(), host.getPort())); stub.socketConnectionTimeout(sock_conn_timeout); } stubManager.connectStubs(); } }
@ManagedOperation public void addInitialHost(String hostname, int port) { //if there is such a stub already, remove and destroy it removeInitialHost(hostname, port); //now re-add it InetSocketAddress isa = new InetSocketAddress(hostname, port); initial_hosts.add(isa); stubManager.createAndRegisterStub(null, new IpAddress(isa.getAddress(), isa.getPort())); stubManager.connectStubs(); // tries to connect all unconnected stubs }
public void init() throws Exception { super.init(); stubManager = RouterStubManager.emptyGossipClientStubManager(this).useNio(this.use_nio); // we cannot use TCPGOSSIP together with TUNNEL (https://jira.jboss.org/jira/browse/JGRP-1101) TP transport=getTransport(); if(transport instanceof TUNNEL) throw new IllegalStateException("TCPGOSSIP cannot be used with TUNNEL; use either TUNNEL:PING or " + "TCP:TCPGOSSIP as valid configurations"); }
public void handleConnect() { if (cluster_name == null || local_addr == null) log.error(Util.getMessage("GroupaddrOrLocaladdrIsNullCannotRegisterWithGossipRouterS")); else { InetAddress bind_addr=getTransport().getBindAddress(); log.trace("registering " + local_addr + " under " + cluster_name + " with GossipRouter"); stubManager.destroyStubs(); PhysicalAddress physical_addr = (PhysicalAddress) down_prot.down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr)); stubManager = new RouterStubManager(this, cluster_name, local_addr, NameCache.get(local_addr), physical_addr, reconnect_interval).useNio(this.use_nio); for (InetSocketAddress host : initial_hosts) { RouterStub stub=stubManager.createAndRegisterStub(new IpAddress(bind_addr, 0), new IpAddress(host.getAddress(), host.getPort())); stub.socketConnectionTimeout(sock_conn_timeout); } stubManager.connectStubs(); } }