protected void processGossipResponse(Tree data) throws Exception {

		// Debug
		if (debugHeartbeats) {
			String sender = data.get("sender", (String) null);
			logger.info("Gossip response received from \"" + sender + "\" node:\r\n" + data);
		}

		// Online / offline nodes in responnse
		Tree online = data.get("online");
		Tree offline = data.get("offline");

		// Process "online" block
		if (online != null) {
			for (Tree row : online) {

				// Get nodeID
				String nodeID = row.getName();
				if (this.nodeID.equals(nodeID)) {
					continue;
				}
				int size = row.size();
				if (!row.isEnumeration() || size < 1 || size > 3) {
					logger.warn("Invalid \"offline\" block: " + row);
					continue;
				}

				// Get parameters from input
				Tree info = null;
				long cpuSeq = 0;
				int cpu = 0;

				if (row.size() == 1) {
					info = row.get(0);
				} else if (row.size() == 2) {
					cpuSeq = row.get(0).asLong();
					cpu = row.get(1).asInteger();
				} else if (row.size() == 3) {
					info = row.get(0);
					cpuSeq = row.get(1).asLong();
					cpu = row.get(2).asInteger();
				} else {
					logger.warn("Invalid \"online\" block: " + row.toString(false));
					continue;
				}

				if (info != null) {

					// Update "info" block,
					// send updated, connected or reconnected event
					updateNodeInfo(nodeID, info);
				}
				if (cpuSeq > 0) {

					// We update our CPU info
					NodeDescriptor node = nodes.get(nodeID);
					if (node != null) {
						node.writeLock.lock();
						try {
							node.updateCpu(cpuSeq, cpu);
						} finally {
							node.writeLock.unlock();
						}
					}
				}
			}
		}

		// Process "offline" block
		if (offline != null) {
			for (Tree row : offline) {
				String nodeID = row.getName();

				NodeDescriptor node;
				if (this.nodeID.equals(nodeID)) {
					long seq = row.asLong();
					node = getDescriptor();
					node.writeLock.lock();
					try {
						long newSeq = Math.max(node.seq, seq + 1);
						if (node.seq < newSeq) {
							node.seq = newSeq;
							node.info.put("seq", newSeq);
						}
					} finally {
						node.writeLock.unlock();
					}
					continue;
				}

				node = nodes.get(nodeID);
				if (node == null) {
					return;
				}
				if (!row.isPrimitive()) {
					logger.warn("Invalid \"offline\" block: " + row);
					continue;
				}

				// Get parameters from input
				boolean disconnected = false;
				node.writeLock.lock();
				try {
					long seq = row.asLong();
					if (node.seq < seq && node.markAsOffline(seq)) {

						// We know it is online, so we change it to offline
						// Remove remote actions and listeners
						registry.removeActions(node.nodeID);
						eventbus.removeListeners(node.nodeID);
						writer.close(node.nodeID);
						disconnected = true;

					}
				} finally {
					node.writeLock.unlock();
				}
				if (node != null && disconnected) {

					// Notify listeners (not unexpected disconnection)
					logger.info("Node \"" + node.nodeID + "\" disconnected.");
					broadcastNodeDisconnected(node.info, false);
				}
			}
		}
	}
protected void processGossipResponse ( Tree data ) throws Exception { if ( debugHeartbeats ) { String sender = data . get ( "sender" , ( String ) null ) ; logger . info ( "Gossip response received from \"" + sender + "\" node:\r\n" + data ) ; } Tree online = data . get ( "online" ) ; Tree offline = data . get ( "offline" ) ; if ( online != null ) { for ( Tree row : online ) { String nodeID = row . getName ( ) ; if ( this . nodeID . equals ( nodeID ) ) { continue ; } int size = row . size ( ) ; if ( ! row . isEnumeration ( ) || size < 1 || size > 3 ) { logger . warn ( "Invalid \"offline\" block: " + row ) ; continue ; } Tree info = null ; long cpuSeq = 0 ; int cpu = 0 ; if ( row . size ( ) == 1 ) { info = row . get ( 0 ) ; } else if ( row . size ( ) == 2 ) { cpuSeq = row . get ( 0 ) . asLong ( ) ; cpu = row . get ( 1 ) . asInteger ( ) ; } else if ( row . size ( ) == 3 ) { info = row . get ( 0 ) ; cpuSeq = row . get ( 1 ) . asLong ( ) ; cpu = row . get ( 2 ) . asInteger ( ) ; } else { logger . warn ( "Invalid \"online\" block: " + row . toString ( false ) ) ; continue ; } if ( info != null ) { updateNodeInfo ( nodeID , info ) ; } if ( cpuSeq > 0 ) { NodeDescriptor node = nodes . get ( nodeID ) ; if ( node != null ) { node . writeLock . lock ( ) ; try { node . updateCpu ( cpuSeq , cpu ) ; } finally { node . writeLock . unlock ( ) ; } } } } } if ( offline != null ) { for ( Tree row : offline ) { String nodeID = row . getName ( ) ; NodeDescriptor node ; if ( this . nodeID . equals ( nodeID ) ) { long seq = row . asLong ( ) ; node = getDescriptor ( ) ; node . writeLock . lock ( ) ; try { long newSeq = Math . max ( node . seq , seq + 1 ) ; if ( node . seq < newSeq ) { node . seq = newSeq ; node . info . put ( "seq" , newSeq ) ; } } finally { node . writeLock . unlock ( ) ; } continue ; } node = nodes . get ( nodeID ) ; if ( node == null ) { return ; } if ( ! row . isPrimitive ( ) ) { logger . warn ( "Invalid \"offline\" block: " + row ) ; continue ; } boolean disconnected = false ; node . writeLock . lock ( ) ; try { long seq = row . asLong ( ) ; if ( node . seq < seq && node . markAsOffline ( seq ) ) { registry . removeActions ( node . nodeID ) ; eventbus . removeListeners ( node . nodeID ) ; writer . close ( node . nodeID ) ; disconnected = true ; } } finally { node . writeLock . unlock ( ) ; } if ( node != null && disconnected ) { logger . info ( "Node \"" + node . nodeID + "\" disconnected." ) ; broadcastNodeDisconnected ( node . info , false ) ; } } } }
--- GOSSIP RESPONSE MESSAGE RECEIVED ---