/** * Get the physical address * @return The value */ public org.jgroups.Address getOwnAddress() { return channel.getAddress(); }
/** * {@inheritDoc} */ protected Address getLocalAddress() { return channel.getAddress(); }
/** * @return Get the address of this machine in the cluster */ public Address getLocalAddress() { return this.channel.getAddress(); }
public Address getLocalAddress() { return this.channel.getAddress(); }
private Address getLocalAddress() { return this.dispatcher.getChannel().getAddress(); }
@Override public String toString() { final StringBuilder sb = new StringBuilder("ClusteringService[cluster_name='"); sb.append(clusterName()).append("', address=").append(getChannel().getAddress()).append("]"); return sb.toString(); }
@Override public String toString() { final StringBuilder sb = new StringBuilder("ClusteringService[cluster_name='"); sb.append(clusterName()).append("', address=").append(getChannel().getAddress()).append("]"); return sb.toString(); }
/** * Get WorkManagers * @return The value */ public Set<Map<String, String>> getWorkManagers() { Set<Map<String, String>> setOfMaps = new HashSet<Map<String, String>>(); for (Address address : getAddresses(channel.getAddress())) { setOfMaps.add(address.toMap()); } return setOfMaps; }
/** * JGroups message listener. Overrides ReceiverAdapter. */ public void receive(Message msg) { Object o = msg.getObject(); if (o instanceof String) { String message = (String) o; if (message.startsWith(HEARTBEAT_PREAMBLE)) { String onlineUserId = message.substring(HEARTBEAT_PREAMBLE.length()); heartbeatMap.put(onlineUserId, new Date()); } else if (message.startsWith(MESSAGE_PREAMBLE)) { Address address = clusterChannel.getAddress(); String[] parts = message.split(":"); String from = parts[1]; String to = parts[2]; String m = parts[3]; addMessageToMap(new UserMessage(from, to, m)); } else if (message.startsWith(CLEAR_PREAMBLE)) { String userId = message.substring(CLEAR_PREAMBLE.length()); synchronized (messageMap) { messageMap.remove(userId); } } } }
/** * Shuts down and clears resources held by this service. * * @return {@code true} if the service has been shutdown or {@code false} if it had already been shut down. */ public synchronized boolean shutdown() { if (channel == null) { return false; } Address address = channel.getAddress(); LOGGER.debug("{0} shutting down clustering service...", address); consumers.clear(); // Mark this as not accepting any more ... isOpen.set(false); try { // Disconnect from the channel and close it ... channel.disconnect(); channel.removeChannelListener(listener); channel.setReceiver(null); channel.close(); LOGGER.debug("{0} successfully closed main channel", address); } finally { channel = null; } membersInCluster.set(1); return true; }
/** * Shuts down and clears resources held by this service. * * @return {@code true} if the service has been shutdown or {@code false} if it had already been shut down. */ public synchronized boolean shutdown() { if (channel == null) { return false; } Address address = channel.getAddress(); LOGGER.debug("{0} shutting down clustering service...", address); consumers.clear(); // Mark this as not accepting any more ... isOpen.set(false); try { // Disconnect from the channel and close it ... channel.disconnect(); channel.removeChannelListener(listener); channel.setReceiver(null); channel.close(); LOGGER.debug("{0} successfully closed main channel", address); } finally { channel = null; } membersInCluster.set(1); return true; }
public void receive(Message message) { if (message.getSrc() != channel.getAddress()) { try { Object payload = helper.deserialize(message.getBuffer()); delegate.onMessage(payload); } catch (MessageException e) { monitor.error("Error deserializing message payload", e); } } }
@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()); } } }
if (channel != null && !channel.getAddress().equals(address) && !nodes.containsValue(address))
this.localJGAddress = this.channel.getAddress(); this.me = this.nodeFactory.getClusterNode(localJGAddress);
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(); }
/** * Sends a message of a given type across a cluster. * * @param payload the main body of the message; must not be {@code null} * @return {@code true} if the send operation was successful, {@code false} otherwise */ public boolean sendMessage( Serializable payload ) { if (!isOpen() || !multipleMembersInCluster()) { return false; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("{0} SENDING {1} ", toString(), payload); } try { byte[] messageData = toByteArray(payload); Message jgMessage = new Message(null, channel.getAddress(), messageData); channel.send(jgMessage); return true; } catch (Exception e) { // Something went wrong here throw new SystemFailureException(ClusteringI18n.errorSendingMessage.text(clusterName()), e); } }
RequestOptions options = new RequestOptions(ResponseMode.GET_ALL, methodTimeout, false, new NoHandlerForRPCRspFilter(filter)); if (excludeSelf) { options.setExclusionList(this.channel.getAddress());
RequestOptions options = new RequestOptions(ResponseMode.GET_NONE, this.getMethodCallTimeout(), false, new NoHandlerForRPCRspFilter()); if (excludeSelf) { options.setExclusionList(this.channel.getAddress());
/** * Sends a message of a given type across a cluster. * * @param payload the main body of the message; must not be {@code null} * @return {@code true} if the send operation was successful, {@code false} otherwise */ public boolean sendMessage( Serializable payload ) { if (!isOpen() || !multipleMembersInCluster()) { return false; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("{0} SENDING {1} ", toString(), payload); } try { byte[] messageData = toByteArray(payload); Message jgMessage = new Message(null, channel.getAddress(), messageData); channel.send(jgMessage); return true; } catch (Exception e) { // Something went wrong here throw new SystemFailureException(ClusteringI18n.errorSendingMessage.text(clusterName()), e); } }