Handles the response of the getVersion request.
@param incomingMessage the response message to process.
325562
private void handleGetVersionResponse(SerialMessage incomingMessage) {
		this.ZWaveLibraryType = incomingMessage.getMessagePayloadByte(12);
		this.zWaveVersion = new String(ArrayUtils.subarray(incomingMessage.getMessagePayload(), 0, 11));
		logger.debug(String.format("Got MessageGetVersion response. Version = %s, Library Type = 0x%02X", zWaveVersion, ZWaveLibraryType));
	}
179515
@Override
    public void deliver(VoltMessage message)
    {
        if (message instanceof Iv2RepairLogResponseMessage) {
            Iv2RepairLogResponseMessage response = (Iv2RepairLogResponseMessage)message;
            if (response.getRequestId() != m_requestId) {
                if (repairLogger.isTraceEnabled()) {
                    repairLogger.trace(m_whoami + "rejecting stale repair response."
                            + " Current request id is: " + m_requestId
                            + " Received response for request id: " + response.getRequestId());
                }
                return;
            }

            // Step 1: if the msg has a known (not MAX VALUE) handle, update m_maxSeen.
            if (response.getTxnId() != Long.MAX_VALUE) {
                m_maxSeenTxnId = Math.max(m_maxSeenTxnId, response.getTxnId());
            }

            // Step 2: track hashinator versions

            if (response.hasHashinatorConfig()) {
                Pair<Long,byte[]> proposed = response.getHashinatorVersionedConfig();
                if (proposed.getFirst() > m_newestHashinatorConfig.getFirst()) {
                    m_newestHashinatorConfig = proposed;
                }
            }

            // Step 3: offer to the union
            addToRepairLog(response);
            if (repairLogger.isDebugEnabled()) {
                repairLogger.debug(m_whoami + " collected from " + CoreUtils.hsIdToString(response.m_sourceHSId) +
                        ", message: " + response.getPayload());
            }

            // Step 4: update the corresponding replica repair struct.
            ReplicaRepairStruct rrs = m_replicaRepairStructs.get(response.m_sourceHSId);
            if (rrs.m_expectedResponses < 0) {
                if (repairLogger.isDebugEnabled()) {
                    repairLogger.debug(m_whoami + "collecting " + response.getOfTotal()
                    + " repair log entries from "
                    + CoreUtils.hsIdToString(response.m_sourceHSId));
                }
            }

            if (rrs.update(response)) {
                if (repairLogger.isDebugEnabled()) {
                    repairLogger.debug(m_whoami + "collected " + rrs.m_receivedResponses
                            + " responses for " + rrs.m_expectedResponses
                            + " repair log entries from " + CoreUtils.hsIdToString(response.m_sourceHSId));
                }

                if (areRepairLogsComplete()) {

                    TheHashinator.updateHashinator(ElasticHashinator.class,
                            m_newestHashinatorConfig.getFirst(), m_newestHashinatorConfig.getSecond(), true);

                    //no real transaction repair when triggered with MigratePartitionLeader. Theoretically it should not be here.
                    //MigratePartitionLeader should not trigger MP promotion.
                    if (m_isMigratePartitionLeader) {
                        m_promotionResult.set(new RepairResult(m_maxSeenTxnId));
                    } else {
                        repairSurvivors();
                    }
                }
            }
        }
    }
1018805
public ListVersionsHandler parseListVersionsResponse(InputStream inputStream, final boolean shouldSDKDecodeResponse)
            throws IOException {
        ListVersionsHandler handler = new ListVersionsHandler(shouldSDKDecodeResponse);
        parseXmlInputStream(handler, sanitizeXmlDocument(handler, inputStream));
        return handler;
    }
1066514
@Override
    public int getInUseSessionVersion(ServletRequest req, SessionAffinityContext sac) {
        int version = sac.getResponseSessionVersion();
        if (version == -1) { // not set, use request version
            version = sac.getRequestedSessionVersion();
        }
        return version;
    }
280352
static String getAppVersion(Context context) {
        String appVersion = "";
        if (context != null) {
            try {
                final PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
                appVersion = packageInfo.versionName;
            } catch (Exception e) {
                PrefHelper.LogException("Error obtaining AppVersion", e);
            }
        }
        return (TextUtils.isEmpty(appVersion) ? BLANK : appVersion);
    }
739959
@Override
	public void receiveResponse(Tree message) {

		// Verify protocol version
		if (checkVersion) {
			String ver = message.get("ver", "unknown");
			if (!PROTOCOL_VERSION.equals(ver)) {
				logger.warn("Invalid protocol version (" + ver + ")!");
				return;
			}
		}

		// Get response's unique ID
		String id = message.get("id", (String) null);
		if (id == null || id.isEmpty()) {
			logger.warn("Missing \"id\" property!", message);
			return;
		}

		// Incoming (response) stream handling
		IncomingStream responseStream;
		responseStreamReadLock.lock();
		try {
			responseStream = responseStreams.get(id);
		} finally {
			responseStreamReadLock.unlock();
		}
		if (responseStream != null) {
			boolean remove = false;
			try {
				if (responseStream.receive(message)) {
					remove = true;
				}
			} catch (Throwable error) {
				remove = true;

				// Write error to log file
				if (writeErrorsToLog) {
					logger.error("Unexpected error occurred while streaming!", error);
				}
			}
			if (remove) {
				responseStreamWriteLock.lock();
				try {
					responseStreams.remove(id);
				} finally {
					responseStreamWriteLock.unlock();
				}
			}
			return;
		}
		if (message.get("stream", false)) {
			responseStreamWriteLock.lock();
			try {
				responseStream = responseStreams.get(id);
				if (responseStream == null) {
					responseStream = new IncomingStream(nodeID, scheduler, streamTimeout);
					responseStreams.put(id, responseStream);
				}
			} finally {
				responseStreamWriteLock.unlock();
			}
			if (responseStream.receive(message)) {
				responseStreamWriteLock.lock();
				try {
					responseStreams.remove(id);
				} finally {
					responseStreamWriteLock.unlock();
				}
			}
			message.putObject("data", responseStream.getPacketStream());
		}

		// Get stored promise
		PendingPromise pending = promises.remove(id);
		if (pending == null) {
			logger.warn("Unknown (maybe timeouted) response received!", message);
			return;
		}
		try {

			// Get response status (successed or not?)
			boolean success = message.get("success", true);
			if (success) {

				// Ok -> resolve
				pending.promise.complete(message.get("data"));

			} else {

				// Failed -> reject
				Tree error = message.get("error");
				MoleculerError moleculerError;
				if (error == null) {
					moleculerError = new MoleculerError("Remote invocation failed!", null, "MoleculerError",
							pending.nodeID, false, 500, "UNKNOWN_ERROR", message);
				} else {
					moleculerError = MoleculerErrorUtils.create(error);
				}

				pending.promise.complete(moleculerError);
				logger.error(moleculerError.getMessage(), moleculerError);

				return;
			}
		} catch (Throwable cause) {
			logger.error("Unable to pass on incoming response!", cause);
		}
	}
626940
@Override
    public String getVersion() throws ConnectionException {
        return connectionPool.executeWithFailover(
                new AbstractOperationImpl<String>(tracerFactory.newTracer(CassandraOperationType.GET_VERSION)) {
                    @Override
                    public String internalExecute(Client client, ConnectionContext state) throws Exception {
                        return client.describe_version();
                    }
                }, config.getRetryPolicy().duplicate()).getResult();
    }
557293
public static String getVersion(InputStream is) {
		try {
			String text = readAsString(is);
			return getVersionFromText(text);
		} catch (IOException e) {
			LOG.error(e.getMessage(), e);
			return null;
		}
	}
1357151
private void handleIdentifyNodeResponse(SerialMessage incomingMessage) {
		logger.trace("Handle Message Get Node ProtocolInfo Response");
		
		int nodeId = lastSentMessage.getMessagePayloadByte(0);
		logger.debug("ProtocolInfo for Node = " + nodeId);
		
		boolean listening = (incomingMessage.getMessagePayloadByte(0) & 0x80)!=0 ? true : false;
		boolean routing = (incomingMessage.getMessagePayloadByte(0) & 0x40)!=0 ? true : false;
		int version = (incomingMessage.getMessagePayloadByte(0) & 0x07) + 1;
		logger.debug("Listening = " + listening);
		logger.debug("Routing = " + routing);
		logger.debug("Version = " + version);
		
		this.zwaveNodes.get(nodeId).setListening(listening);
		this.zwaveNodes.get(nodeId).setRouting(routing);
		this.zwaveNodes.get(nodeId).setVersion(version);

		ZWaveDeviceClass.Basic basic = ZWaveDeviceClass.Basic.getBasic(incomingMessage.getMessagePayloadByte(3));
		if (basic == null) {
			logger.error(String.format("Basic device class 0x%02x not found", incomingMessage.getMessagePayloadByte(3)));
			return;
		}
		ZWaveDeviceClass.Generic generic = ZWaveDeviceClass.Generic.getGeneric(incomingMessage.getMessagePayloadByte(4));
		if (generic == null) {
			logger.error(String.format("Generic device class 0x%02x not found", incomingMessage.getMessagePayloadByte(4)));
			return;
		}
		ZWaveDeviceClass.Specific specific = ZWaveDeviceClass.Specific.getSpecific(generic, incomingMessage.getMessagePayloadByte(5));
		if (specific == null) {
			logger.error(String.format("Specific device class 0x%02x not found", incomingMessage.getMessagePayloadByte(5)));
			return;
		}
		logger.debug(String.format("Basic = %s 0x%02x", basic.getLabel(), basic.getKey()));
		logger.debug(String.format("Generic = %s 0x%02x", generic.getLabel(), generic.getKey()));
		logger.debug(String.format("Specific = %s 0x%02x", specific.getLabel(), specific.getKey()));
		
		ZWaveDeviceClass deviceClass = this.zwaveNodes.get(nodeId).getDeviceClass();
		deviceClass.setBasicDeviceClass(basic);
		deviceClass.setGenericDeviceClass(generic);
		deviceClass.setSpecificDeviceClass(specific);
		
		// Add mandatory command classes as specified by it's generic device class.
		for (ZWaveCommandClass.CommandClass commandClass : generic.getMandatoryCommandClasses()) {
			ZWaveCommandClass zwaveCommandClass = ZWaveCommandClass.getInstance(commandClass.getKey(), this.zwaveNodes.get(nodeId), this);
			if (zwaveCommandClass != null)
				this.zwaveNodes.get(nodeId).addCommandClass(zwaveCommandClass);
		}

		// Add mandatory command classes as specified by it's specific device class.
		for (ZWaveCommandClass.CommandClass commandClass : specific.getMandatoryCommandClasses()) {
			ZWaveCommandClass zwaveCommandClass = ZWaveCommandClass.getInstance(commandClass.getKey(), this.zwaveNodes.get(nodeId), this);
			if (zwaveCommandClass != null)
				this.zwaveNodes.get(nodeId).addCommandClass(zwaveCommandClass);
		}
		
		// Add the WAKE_UP command class to this node, since it's not listening.
		if (!listening) {
			ZWaveCommandClass zwaveCommandClass = ZWaveCommandClass.getInstance(ZWaveCommandClass.CommandClass.WAKE_UP.getKey(), this.zwaveNodes.get(nodeId), this);
			if (zwaveCommandClass != null)
				this.zwaveNodes.get(nodeId).addCommandClass(zwaveCommandClass);
		}

    	// advance node stage of the current node.
		this.getNode(nodeId).advanceNodeStage();
	}
1278584
@Override
    public void onMessage(StreamMessage received)
    {
        if (this.reloadConfig && this.watcher != null)
        {
            Map<String, Object> reloadedConfig = null;

            try
            {
                reloadedConfig = this.watcher.readIfUpdated();
            }
            catch (IOException ex)
            {
                String logFormat = "Config file reload failed. Skip reload config.";
                logger.warn(logFormat, ex);
            }

            if (reloadedConfig != null)
            {
                onUpdate(reloadedConfig);
            }
        }

        this.executingKeyHistory = received.getHeader().getHistory();
        this.responsed = false;

        // Execute message processing.
        // This class not handles exceptions.
        // Because if throws exception, this class not need ack.
        try
        {
            onExecute(received);
        }
        finally
        {
            clearExecuteStatus();
        }

        // If not responsed, auto ack
        if (this.responsed == false)
        {
            super.ack();
        }
    }
1263786
public void processReceivedMessage( Message message, Session session ) throws IOException {
		this.logger.fine( "The DM's HTTP client is about to process a message (" + message + ") received through a web socket." );

		// HttpMessage
		if( message instanceof HttpMessage ) {
			HttpMessage httpMsg = (HttpMessage) message;

			// Store the session
			registerSession( httpMsg.getOwnerId(), session );

			// Publish the message
			publish( httpMsg.getCtx(), httpMsg.getMessage());
		}

		// Subscription message
		else if( message instanceof SubscriptionMessage ) {
			SubscriptionMessage sub = (SubscriptionMessage) message;

			// Store the session
			registerSession( sub.getOwnerId(), session );

			// Update the subscriptions
			if( sub.isSubscribe())
				subscribe( sub.getOwnerId(), sub.getCtx());
			else
				unsubscribe( sub.getOwnerId(), sub.getCtx());
		}
	}
768595
private void handleSerialApiGetInitDataResponse(
			SerialMessage incomingMessage) {
		logger.debug(String.format("Got MessageSerialApiGetInitData response."));
		this.isConnected = true;
		int nodeBytes = incomingMessage.getMessagePayloadByte(2);
		
		if (nodeBytes != NODE_BYTES) {
			logger.error("Invalid number of node bytes = {}", nodeBytes);
			return;
		}

		int nodeId = 1;
		
		// loop bytes
		for (int i = 3;i < 3 + nodeBytes;i++) {
			int incomingByte = incomingMessage.getMessagePayloadByte(i);
			// loop bits in byte
			for (int j=0;j<8;j++) {
				int b1 = incomingByte & (int)Math.pow(2.0D, j);
				int b2 = (int)Math.pow(2.0D, j);
				if (b1 == b2) {
					logger.info(String.format("Found node id = %d", nodeId));
					// Place nodes in the local ZWave Controller 
					this.zwaveNodes.put(nodeId, new ZWaveNode(this.homeId, nodeId, this));
					this.getNode(nodeId).advanceNodeStage();
				}
				nodeId++;
			}
		}
		
		logger.info("------------Number of Nodes Found Registered to ZWave Controller------------");
		logger.info(String.format("# Nodes = %d", this.zwaveNodes.size()));
		logger.info("----------------------------------------------------------------------------");
		
		// Advance node stage for the first node.
	}
653147
@Override
	public void receiveRequest(Tree message) {

		// Get request's unique ID
		String id = message.get("id", (String) null);
		if (id == null || id.isEmpty()) {
			logger.warn("Missing \"id\" property!");
			return;
		}

		// Get sender's nodeID
		String sender = message.get("sender", (String) null);
		if (sender == null || sender.isEmpty()) {
			logger.warn("Missing \"sender\" property!");
			return;
		}

		// Verify protocol version
		if (checkVersion) {
			String ver = message.get("ver", "unknown");
			if (!PROTOCOL_VERSION.equals(ver)) {
				logger.warn("Invalid protocol version (" + ver + ")!");
				transporter.publish(PACKET_RESPONSE, sender,
						throwableToTree(id, nodeID, new ProtocolVersionMismatchError(nodeID, PROTOCOL_VERSION, ver)));
				return;
			}
		}

		// Incoming stream handling
		IncomingStream requestStream;
		requestStreamReadLock.lock();
		try {
			requestStream = requestStreams.get(id);
		} finally {
			requestStreamReadLock.unlock();
		}
		if (requestStream != null) {
			boolean remove = false;
			try {
				if (requestStream.receive(message)) {
					remove = true;
				}
			} catch (Throwable error) {
				remove = true;

				// Send error
				try {
					transporter.publish(PACKET_RESPONSE, sender, throwableToTree(id, nodeID, error));
				} catch (Throwable ignored) {
					logger.debug("Unable to send response!", ignored);
				}

				// Write error to log file
				if (writeErrorsToLog) {
					logger.error("Unexpected error occurred while streaming!", error);
				}

			}
			if (remove) {
				requestStreamWriteLock.lock();
				try {
					requestStreams.remove(id);
				} finally {
					requestStreamWriteLock.unlock();
				}
			}
		} else if (message.get("stream", false)) {
			requestStreamWriteLock.lock();
			try {
				requestStream = requestStreams.get(id);
				if (requestStream == null) {
					requestStream = new IncomingStream(nodeID, scheduler, streamTimeout);
					requestStreams.put(id, requestStream);
				}
			} finally {
				requestStreamWriteLock.unlock();
			}
			if (requestStream.receive(message)) {
				requestStreamWriteLock.lock();
				try {
					requestStreams.remove(id);
				} finally {
					requestStreamWriteLock.unlock();
				}
			}
		}

		// Get action property
		String action = message.get("action", (String) null);
		if (action == null || action.isEmpty()) {
			if (requestStream == null) {
				logger.warn("Missing \"action\" property!");
				transporter.publish(PACKET_RESPONSE, sender,
						throwableToTree(id, nodeID, new InvalidPacketDataError(nodeID)));
			}
			return;
		}
		if (requestStream != null && requestStream.inited()) {

			// Action method invoked (do not invoke twice)
			return;
		}

		// Get strategy (action endpoint array) by action name
		Strategy<ActionEndpoint> strategy = null;
		long stamp = lock.tryOptimisticRead();
		if (stamp != 0) {
			try {
				strategy = strategies.get(action);
			} catch (Exception modified) {
				stamp = 0;
			}
		}
		if (!lock.validate(stamp) || stamp == 0) {
			stamp = lock.readLock();
			try {
				strategy = strategies.get(action);
			} finally {
				lock.unlockRead(stamp);
			}
		}
		if (strategy == null) {
			logger.warn("Invalid action name (" + action + ")!");
			transporter.publish(PACKET_RESPONSE, sender,
					throwableToTree(id, nodeID, new ServiceNotFoundError(nodeID, action)));
			return;
		}

		// Get local action endpoint (with cache handling)
		ActionEndpoint endpoint = strategy.getEndpoint(nodeID);
		if (endpoint == null) {
			logger.warn("Not a local action (" + action + ")!");
			transporter.publish(PACKET_RESPONSE, sender,
					throwableToTree(id, nodeID, new ServiceNotAvailableError(nodeID, action)));
			return;
		}

		// Process params and meta
		Tree params = message.get("params");
		Tree meta = message.get("meta");
		if (meta != null && !meta.isEmpty()) {
			if (params == null) {
				params = new Tree();
			}
			params.getMeta().setObject(params);
		}

		// Get timeout
		int timeout = message.get("timeout", 0);
		CallOptions.Options opts;
		if (timeout > 0) {
			opts = CallOptions.timeout(timeout);
		} else {
			opts = null;
		}

		// Get other properties
		int level = message.get("level", 1);
		String parentID = message.get("parentID", (String) null);
		String requestID = message.get("requestID", id);

		// Create context
		Context ctx = contextFactory.create(action, params, opts,
				requestStream == null ? null : requestStream.getPacketStream(), id, level, requestID, parentID);

		// Invoke action
		try {
			new Promise(endpoint.handler(ctx)).then(data -> {

				// Send response
				FastBuildTree msg = new FastBuildTree(7);
				msg.putUnsafe("sender", nodeID);
				msg.putUnsafe("id", id);
				msg.putUnsafe("ver", PROTOCOL_VERSION);
				msg.putUnsafe("success", true);

				PacketStream responseStream = null;
				if (data != null) {
					Object d = data.asObject();
					if (d != null && d instanceof PacketStream) {
						msg.putUnsafe("stream", true);
						msg.putUnsafe("seq", 0);
						responseStream = (PacketStream) d;
					} else {
						msg.putUnsafe("data", d);
					}
					Tree m = data.getMeta(false);
					if (m != null && !m.isEmpty()) {
						msg.putUnsafe("meta", m);
					}
				}
				transporter.publish(PACKET_RESPONSE, sender, msg);

				// Define sender for response stream
				if (responseStream != null) {
					responseStream.onPacket(new PacketListener() {

						// Create sequence counter
						private final AtomicLong sequence = new AtomicLong();

						@Override
						public final void onPacket(byte[] bytes, Throwable cause, boolean close) {
							if (bytes != null) {
								transporter.sendDataPacket(PACKET_RESPONSE, sender, ctx, bytes,
										sequence.incrementAndGet());
							} else if (cause != null) {
								if (writeErrorsToLog) {
									logger.error("Unexpected error occured while streaming!", cause);
								}
								transporter.sendErrorPacket(PACKET_RESPONSE, sender, ctx, cause,
										sequence.incrementAndGet());
							}
							if (close) {
								transporter.sendClosePacket(PACKET_RESPONSE, sender, ctx, sequence.incrementAndGet());
							}
						}

					});
				}

			}).catchError(error -> {

				// Send error
				transporter.publish(PACKET_RESPONSE, sender, throwableToTree(id, nodeID, error));

				// Write error to log file
				if (writeErrorsToLog) {
					logger.error("Unexpected error occurred while invoking \"" + action + "\" action!", error);
				}

			});
		} catch (Throwable error) {

			// Send error
			transporter.publish(PACKET_RESPONSE, sender, throwableToTree(id, nodeID, error));

			// Write error to log file
			if (writeErrorsToLog) {
				logger.error("Unexpected error occurred while invoking \"" + action + "\" action!", error);
			}

		}

	}
1213795
def handle_version(self, message_header, message):
        
        log.debug("handle version")
        verack = VerAck()
        log.debug("send VerAck")
        self.send_message(verack)
        self.verack = True

        # begin!
        self.send_getheaders( self.first_block_hash )
1195662
def HandleVersion(self, payload):
        """"""
        self.Version = IOHelper.AsSerializableWithType(payload, "neo.Network.Payloads.VersionPayload.VersionPayload")

        if not self.Version:
            return

        if self.incoming_client:
            if self.Version.Nonce == self.nodeid:
                self.Disconnect()
            self.SendVerack()
        else:
            self.nodeid = self.Version.Nonce
            self.SendVersion()
273150
public ProtocolVersion getVersion() 
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "getVersion");
    
    // The ProtocolVersion to be returned
    ProtocolVersion version = ProtocolVersion.UNKNOWN;
    // Get the MetaData out of the connection
    ConnectionMetaData connMetaData = connection.getMetaData();
    
    // If the MetaData is non-null we can retrieve a version.
    if(connMetaData != null)
      version = connMetaData.getProtocolVersion();
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getVersion", version);
  
    return version;
  }
948856
public String getServerVersion() throws IOException {
        // only do this once -- future invocations will use the known value
        if (m_serverVersion == null) {
            // Make the APIA call for describe repository
            // and make sure that HTTP 302 status is handled.
            String desc = getResponseAsString("/describe?xml=true", true, true);
            logger.debug("describeRepository response:\n" + desc);
            String[] parts = desc.split("<repositoryVersion>");
            if (parts.length < 2) {
                throw new IOException("Could not find repositoryVersion element in content of /describe?xml=true");
            }
            int i = parts[1].indexOf("<");
            if (i == -1) {
                throw new IOException("Could not find end of repositoryVersion element in content of /describe?xml=true");
            }
            m_serverVersion = parts[1].substring(0, i).trim();
            logger.debug("Server version is " + m_serverVersion);
        }
        return m_serverVersion;
    }