@Override public Address generateAddress() { return TopologyUUID.randomUUID(channel.getName(), siteId, rackId, machineId); }
private void setChannelUniqueId(Channel channel) { String logical_address_name = channel.getName(); if (logical_address_name == null) { // We push the independent name in the protocol stack before connecting to the cluster if (this.nodeName == null || "".equals(this.nodeName)) { this.nodeName = generateUniqueNodeName(); } log.debug("Assigning unique node id " + nodeName + " to the channel"); channel.setName(this.nodeName); } }
@Override public ClusterNode getClusterNode(Address a) { IpAddress result = addressMap.get(a); if (result == null) { result = (IpAddress) channel.down(new Event(Event.GET_PHYSICAL_ADDRESS, a)); if (result == null) { throw MESSAGES.addressNotRegistered(a); } addressMap.put(a, result); } InetSocketAddress socketAddress = new InetSocketAddress(result.getIpAddress(), result.getPort()); String id = channel.getName(a); if (id == null) { id = socketAddress.getAddress().getHostAddress() + ":" + socketAddress.getPort(); } return new ClusterNodeImpl(id, a, socketAddress); } }
public void channelConnected(Channel channel) { log.info("*** Channel connected {},{}", channel.getName(), channel.getView().getMembers()); listeners.stream().forEach(listener -> listener.onConnected(membersAsString(channel.getView().getMembers()))); }
public void channelClosed(Channel channel) { log.info("*** Channel closed {},{}", channel.getName(), channel.getView().getMembers()); listeners.stream().forEach(listener -> listener.onClosed(membersAsString(channel.getView().getMembers()))); }
@Override public void channelConnected(Channel channel) { // Validate view String localName = channel.getName(); Address localAddress = channel.getAddress(); for (Address address: channel.getView()) { String name = channel.getName(address); if ((name != null) && name.equals(localName) && !address.equals(localAddress)) { channel.close(); throw JGroupsMessages.MESSAGES.duplicateNodeName(this.factory.getValue().getProtocolStackConfiguration().getEnvironment().getNodeName()); } } }
@Override public synchronized boolean shutdown() { if (super.shutdown()) { String mainChannelName = mainChannel.getName(); List<String> forksForChannel = FORK_STACKS_BY_CHANNEL_NAME.get(mainChannelName); if (forksForChannel != null) { forksForChannel.remove(clusterName); if (forksForChannel.isEmpty()) { FORK_STACKS_BY_CHANNEL_NAME.remove(mainChannelName); Protocol removed = this.mainChannel.getProtocolStack().removeProtocol(FORK.class); if (removed != null) { LOGGER.debug("FORK protocol removed from original channel stack for channel {0}", mainChannelName); } else { LOGGER.debug("FORK protocol not found in original channel stack for channel {0}", mainChannelName); } } } return true; } return false; } }
@Override public synchronized boolean shutdown() { if (super.shutdown()) { String mainChannelName = mainChannel.getName(); List<String> forksForChannel = FORK_STACKS_BY_CHANNEL_NAME.get(mainChannelName); if (forksForChannel != null) { forksForChannel.remove(clusterName); if (forksForChannel.isEmpty()) { FORK_STACKS_BY_CHANNEL_NAME.remove(mainChannelName); Protocol removed = this.mainChannel.getProtocolStack().removeProtocol(FORK.class); if (removed != null) { LOGGER.debug("FORK protocol removed from original channel stack for channel {0}", mainChannelName); } else { LOGGER.debug("FORK protocol not found in original channel stack for channel {0}", mainChannelName); } } } return true; } return false; } }
@Override public ClusterNode getClusterNode(Address a) { IpAddress result = addressMap.get(a); if (result == null) { result = (IpAddress) channel.downcall(new Event(Event.GET_PHYSICAL_ADDRESS, a)); if (result == null) { throw new IllegalStateException("Address " + a + "not registered in transport layer"); } addressMap.put(a, result); } AddressPort addrPort = new AddressPort(result.getIpAddress(), Integer.valueOf(result.getPort())); String id = channel.getName(a); if (id == null) { id = addrPort.getHostAddress() + ":" + addrPort.getPort(); } return new ClusterNodeImpl(id, a, addrPort); } }
String mainChannelName = mainChannel.getName(); List<String> existingForksForChannel = FORK_STACKS_BY_CHANNEL_NAME.get(mainChannelName); if (existingForksForChannel == null) {
String mainChannelName = mainChannel.getName(); List<String> existingForksForChannel = FORK_STACKS_BY_CHANNEL_NAME.get(mainChannelName); if (existingForksForChannel == null) {
public void start() { if (this.channel == null) { throw ClusteringImplMessages.MESSAGES.channelNotDefined(); } if (!this.channel.isConnected()) { throw ClusteringImplMessages.MESSAGES.channelNotConnected(this.channel.getName()); } this.stateIdPrefix = this.getClass().getName() + "." + this.scopeId + "."; // Subscribe to events generated by the channel MembershipListener meml = new MembershipListenerImpl(); MessageListener msgl = this.stateIdPrefix == null ? null : new MessageListenerImpl(); this.dispatcher = new RpcHandler(this.scopeId, this.channel, msgl, meml, new RequestMarshallerImpl(), new ResponseMarshallerImpl()); meml.viewAccepted(this.channel.getView()); // Since we haven't triggered a flush, we need to manually open the gate to allow rpcs. this.flushBlockGate.open(); this.directlyInvokeLocal = this.channel.getDiscardOwnMessages(); // get current JG group properties this.me = this.nodeFactory.getClusterNode(this.channel.getAddress()); this.verifyNodeIsUnique(); // Start the asynch listener handler thread this.asynchHandler.start(); }