public boolean isInternalMessage(Message message, boolean allowOldInternalMessages) { int messageType = message.getMessageType(); boolean isInternalMessage = messageType == MessageType.PING || messageType == MessageType.REQUEST_EVENT_VALUE || messageType == MessageType.MAKE_PRIMARY || messageType == MessageType.REMOVE_USER_AUTH || messageType == MessageType.CLIENT_READY || messageType == MessageType.SIZE || messageType == MessageType.TX_FAILOVER || messageType == MessageType.TX_SYNCHRONIZATION || messageType == MessageType.COMMIT || messageType == MessageType.ROLLBACK || messageType == MessageType.CLOSE_CONNECTION || messageType == MessageType.INVALID || messageType == MessageType.PERIODIC_ACK || messageType == MessageType.GET_CLIENT_PR_METADATA || messageType == MessageType.GET_CLIENT_PARTITION_ATTRIBUTES; // we allow older clients to not send credentials for a handful of messages // if and only if a system property is set. This allows a rolling upgrade // to be performed. if (!isInternalMessage && allowOldInternalMessages) { isInternalMessage = messageType == MessageType.GETCQSTATS_MSG_TYPE || messageType == MessageType.MONITORCQ_MSG_TYPE || messageType == MessageType.REGISTER_DATASERIALIZERS || messageType == MessageType.REGISTER_INSTANTIATORS || messageType == MessageType.ADD_PDX_TYPE || messageType == MessageType.GET_PDX_ID_FOR_TYPE || messageType == MessageType.GET_PDX_TYPE_BY_ID || messageType == MessageType.GET_FUNCTION_ATTRIBUTES || messageType == MessageType.ADD_PDX_ENUM || messageType == MessageType.GET_PDX_ID_FOR_ENUM || messageType == MessageType.GET_PDX_ENUM_BY_ID || messageType == MessageType.GET_PDX_TYPES || messageType == MessageType.GET_PDX_ENUMS; } return isInternalMessage; }
@Override protected void processAck(Message msg, String opName) throws Exception { final int msgType = msg.getMessageType(); if (msgType == MessageType.REPLY) { return; } else { Part part = msg.getPart(0); if (msgType == MessageType.EXCEPTION) { Throwable t = (Throwable) part.getObject(); if (t instanceof CommitConflictException || t instanceof SynchronizationCommitConflictException) { throw (GemFireException) t; } } super.processAck(msg, opName); } }
@Override protected Object processResponse(Message msg) throws Exception { final int msgType = msg.getMessageType(); if (msgType == MessageType.REPLY) { return null; } else { Part part = msg.getPart(0); if (msgType == MessageType.EXCEPTION) { Throwable t = (Throwable) part.getObject(); logger.warn("Function execution without result encountered an Exception on server.", t); } else if (isErrorResponse(msgType)) { logger.warn("Function execution without result encountered an Exception on server."); } else { throw new InternalGemFireError( "Unexpected message type " + MessageType.getString(msgType)); } return null; } }
@Override protected Object processResponse(Message msg) throws Exception { final int msgType = msg.getMessageType(); if (msgType == MessageType.REPLY) { return null; } else { Part part = msg.getPart(0); if (msgType == MessageType.EXCEPTION) { Throwable t = (Throwable) part.getObject(); logger.warn("Function execution without result encountered an Exception on server.", t); } else if (isErrorResponse(msgType)) { logger.warn("Function execution without result encountered an Exception on server."); } else { throw new InternalGemFireError( "Unexpected message type " + MessageType.getString(msgType)); } return null; } }
@Override public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection, final SecurityService securityService, long start) throws IOException { // requiresResponse = true; NOT NEEDED... ALWAYS SEND ERROR RESPONSE logger.fatal("{}: Unknown message type ({}) with tx: {} from {}", new Object[] {serverConnection.getName(), MessageType.getString(clientMessage.getMessageType()), Integer.valueOf(clientMessage.getTransactionId()), serverConnection.getSocketString()}); writeErrorResponse(clientMessage, MessageType.UNKNOWN_MESSAGE_TYPE_ERROR, serverConnection); // responded = true; NOT NEEDED... ALWAYS SEND ERROR RESPONSE }
@Override protected Object processResponse(Message msg, Connection con) throws Exception { processAck(msg, "invalidate"); boolean isReply = (msg.getMessageType() == MessageType.REPLY); int partIdx = 0; int flags = 0; if (isReply) { flags = msg.getPart(partIdx++).getInt(); if ((flags & HAS_VERSION_TAG) != 0) { VersionTag tag = (VersionTag) msg.getPart(partIdx++).getObject(); // we use the client's ID since we apparently don't track the server's ID in connections tag.replaceNullIDs((InternalDistributedMember) con.getEndpoint().getMemberId()); this.event.setVersionTag(tag); if (logger.isDebugEnabled()) { logger.debug("received Invalidate response with {}", tag); } } else { if (logger.isDebugEnabled()) { logger.debug("received Invalidate response"); } } } return null; }
MessageType.getString(msg.getMessageType()));
@Test public void processResponseWhenCacheClosedShuouldReturnNull() throws Exception { Cache cache = mock(Cache.class); ClientMetadataService cms = new ClientMetadataService(cache); cms = spy(cms); doReturn(true).when(cache).isClosed(); Message msg = mock(Message.class); GetClientPRMetaDataOp.GetClientPRMetaDataOpImpl op = new GetClientPRMetaDataOp.GetClientPRMetaDataOpImpl("testRegion", cms); op = spy(op); when(msg.getMessageType()).thenReturn(MessageType.RESPONSE_CLIENT_PR_METADATA); assertNull(op.processResponse(msg)); verify(cms, times(1)).setMetadataStable(eq(true)); } }
try { switch (msg.getMessageType()) { case MessageType.REPLY: logger.debug( "We got an exception from the GatewayReceiver. MessageType : {} obj :{}", msg.getMessageType(), obj); default: throw new InternalGemFireError(String.format("Unknown message type %s", Integer.valueOf(msg.getMessageType())));
clientMessage.getMessageType(), null, null);
@Override protected Object processResponse(Message msg) throws Exception { Part part = msg.getPart(0); final int msgType = msg.getMessageType(); if (msgType == MessageType.RESPONSE) { return Integer.valueOf(part.getInt()); } else { if (msgType == MessageType.EXCEPTION) { String s = "While performing a remote " + "getPdxIdForType"; throw new ServerOperationException(s, (Throwable) part.getObject()); // Get the exception toString part. // This was added for c++ thin client and not used in java } else if (isErrorResponse(msgType)) { throw new ServerOperationException(part.getString()); } else { throw new InternalGemFireError( "Unexpected message type " + MessageType.getString(msgType)); } } }
@Override protected Object processResponse(Message msg) throws Exception { Part part = msg.getPart(0); final int msgType = msg.getMessageType(); if (msgType == MessageType.RESPONSE) { return Integer.valueOf(part.getInt()); } else { if (msgType == MessageType.EXCEPTION) { String s = "While performing a remote " + "getPdxIdForEnum"; throw new ServerOperationException(s, (Throwable) part.getObject()); // Get the exception toString part. // This was added for c++ thin client and not used in java } else if (isErrorResponse(msgType)) { throw new ServerOperationException(part.getString()); } else { throw new InternalGemFireError( "Unexpected message type " + MessageType.getString(msgType)); } } }
@Override protected Object processResponse(Message msg) throws Exception { Part part = msg.getPart(0); int msgType = msg.getMessageType(); if (msgType == MessageType.RESPONSE) { return (Map<Integer, EnumInfo>) part.getObject(); } else { if (msgType == MessageType.EXCEPTION) { String s = "While performing a remote " + "getPdxEnums"; throw new ServerOperationException(s, (Throwable) part.getObject()); } else if (isErrorResponse(msgType)) { throw new ServerOperationException(part.getString()); } else { throw new InternalGemFireError( "Unexpected message type " + MessageType.getString(msgType)); } } }
@Override protected Object processResponse(Message msg) throws Exception { Part part = msg.getPart(0); int msgType = msg.getMessageType(); if (msgType == MessageType.RESPONSE) { return (Map<Integer, PdxType>) part.getObject(); } else { if (msgType == MessageType.EXCEPTION) { String s = "While performing a remote " + "getPdxTypes"; throw new ServerOperationException(s, (Throwable) part.getObject()); } else if (isErrorResponse(msgType)) { throw new ServerOperationException(part.getString()); } else { throw new InternalGemFireError( "Unexpected message type " + MessageType.getString(msgType)); } } }
@Override protected Object processResponse(Message msg) throws Exception { Part part = msg.getPart(0); final int msgType = msg.getMessageType(); if (msgType == MessageType.REPLY) { return part.getObject(); } else if (msgType == MessageType.EXCEPTION) { String s = "While performing a remote proxy cache close"; throw new ServerOperationException(s, (Throwable) part.getObject()); // Get the exception toString part. // This was added for c++ thin client and not used in java } else if (isErrorResponse(msgType)) { throw new ServerOperationException(part.getString()); } else { throw new InternalGemFireError("Unexpected message type " + MessageType.getString(msgType)); } }
@Override protected Object processResponse(Message msg) throws Exception { Part part = msg.getPart(0); final int msgType = msg.getMessageType(); if (msgType == MessageType.RESPONSE) { return part; } else { if (msgType == MessageType.REQUEST_EVENT_VALUE_ERROR) { // Value not found in haContainer. return null; } else if (msgType == MessageType.EXCEPTION) { String s = "While performing a remote " + "getFullValue"; throw new ServerOperationException(s, (Throwable) part.getObject()); // Get the exception toString part. // This was added for c++ thin client and not used in java } else if (isErrorResponse(msgType)) { throw new ServerOperationException(part.getString()); } else { throw new InternalGemFireError( "Unexpected message type " + MessageType.getString(msgType)); } } }
final int msgType = msg.getMessageType(); if (msgType == MessageType.REPLY) { return;
/** * Process a response that contains a single Object result. * * @param msg the message containing the response * @param opName text describing this op * @return the result of the response * @throws Exception if response could not be processed or we received a response with a server * exception. */ protected Object processObjResponse(Message msg, String opName) throws Exception { Part part = msg.getPart(0); final int msgType = msg.getMessageType(); if (msgType == MessageType.RESPONSE) { return part.getObject(); } else { if (msgType == MessageType.EXCEPTION) { String s = "While performing a remote " + opName; throw new ServerOperationException(s, (Throwable) part.getObject()); // Get the exception toString part. // This was added for c++ thin client and not used in java } else if (isErrorResponse(msgType)) { throw new ServerOperationException(part.getString()); } else { throw new InternalGemFireError("Unexpected message type " + MessageType.getString(msgType)); } } }
final int msgType = msg.getMessageType();
if (msg.getMessageType() == MessageType.REPLY && msg.getNumberOfParts() > 1) { int flags = msg.getPart(1).getInt(); int partIdx = 2;