@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)); } } }
public int getInt() { if (!isBytes()) { Assert.assertTrue(false, "expected int part to be of type BYTE, part = " + this.toString()); } if (getLength() != 4) { Assert.assertTrue(false, "expected int length to be 4 but it was " + getLength() + "; part = " + this.toString()); } byte[] bytes = getSerializedForm(); return decodeInt(bytes, 0); }
/** * Gets rid of all the parts that have been added to this message. */ public void clearParts() { for (Part part : this.partsList) { part.clear(); } this.currentPart = 0; }
@Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append("partCode="); sb.append(typeCodeToString(this.typeCode)); sb.append(" partLength=" + getLength()); return sb.toString(); }
@Before public void setUp() throws Exception { this.removeAll = new RemoveAll(); MockitoAnnotations.initMocks(this); when(this.authzRequest.removeAllAuthorize(any(), any(), any())) .thenReturn(mock(RemoveAllOperationContext.class)); when(this.cache.getRegion(isA(String.class))).thenReturn(mock(PartitionedRegion.class)); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.callbackArgPart.getObject()).thenReturn(CALLBACK_ARG); when(this.eventPart.getSerializedForm()).thenReturn(EVENT); when(this.flagsPart.getInt()).thenReturn(0); when(this.keyPart.getStringOrObject()).thenReturn(KEYS); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.eventPart); when(this.message.getPart(eq(2))).thenReturn(this.flagsPart); when(this.message.getPart(eq(3))).thenReturn(this.callbackArgPart); when(this.message.getPart(eq(4))).thenReturn(this.numberofKeysPart); when(this.message.getPart(eq(5))).thenReturn(this.keyPart); when(this.message.getPart(eq(6))).thenReturn(this.timeoutPart); when(this.numberofKeysPart.getInt()).thenReturn(1); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getCacheServerStats()).thenReturn(mock(CacheServerStats.class)); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getChunkedResponseMessage()).thenReturn(this.chunkedResponseMessage); when(this.timeoutPart.getInt()).thenReturn(5); }
if (part0.isBytes() && part0.getLength() == 1 && part0.getSerializedForm()[0] == 0) { int batchId = part0.getInt(); int numEvents = msg.getPart(1).getInt(); ack = new GatewayAck(batchId, numEvents); break; part0 = msg.getPart(0); Object obj = part0.getObject(); if (obj instanceof List) { List<BatchException70> l = (List<BatchException70>) part0.getObject();
int numberOfEvents = numberOfEventsPart.getInt(); stats.incEventsReceived(numberOfEvents); int batchId = batchIdPart.getInt(); int dsid = clientMessage.getPart(partNumber++).getInt(); clientMessage.getPart(partNumber++).getSerializedForm()[0] == 1 ? true : false; int actionType = actionTypePart.getInt(); byte[] possibleDuplicatePartBytes; try { possibleDuplicatePartBytes = (byte[]) possibleDuplicatePart.getObject(); } catch (Exception e) { logger.warn(String.format( regionName = regionNamePart.getString(); if (regionName.equals(PeerTypeRegistration.REGION_FULL_PATH)) { indexWithoutPDXEvent--; eventIdPart.setVersion(serverConnection.getClientVersion()); eventId = (EventID) eventIdPart.getObject(); } catch (Exception e) { logger.warn(String.format( key = keyPart.getStringOrObject(); } catch (Exception e) {
regionName = regionNamePart.getString(); key = keyPart.getStringOrObject(); int interestType = (Integer) interestTypePart.getObject(); boolean isDurable = (Boolean) isDurablePart.getObject(); boolean receiveUpdatesAsInvalidates = (Boolean) receiveUpdatesAsInvalidatesPart.getObject();
@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)); } }
int flags = 0; if (isReply) { flags = msg.getPart(partIdx++).getInt(); if ((flags & HAS_VERSION_TAG) != 0) { VersionTag tag = (VersionTag) msg.getPart(partIdx++).getObject(); byte[] bytesReceived = part.getSerializedForm(); if (bytesReceived[0] != ClientMetadataService.INITIAL_VERSION && bytesReceived.length == ClientMetadataService.SIZE_BYTES_ARRAY_RECEIVED) { entryNotFound = (msg.getPart(partIdx++).getInt() == 1); if (logger.isDebugEnabled() && (flags & HAS_ENTRY_NOT_FOUND_PART) != 0) { logger.debug("destroy response has entryNotFound={}", entryNotFound);
@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; }
when(cache.getMyId()).thenReturn(mock(InternalDistributedMember.class)); when(callbackArgPart.getObject()).thenReturn(CALLBACK_ARG); doCallRealMethod().when(functionObject).getRequiredPermissions(any(), any()); when(functionPart.getStringOrObject()).thenReturn(FUNCTION); when(functionStatePart.getSerializedForm()).thenReturn(RESULT); when(heapMemoryMonitor.createLowMemoryIfNeeded(any(), any(DistributedMember.class))) .thenReturn(mock(LowMemoryException.class));
@Before public void setUp() throws Exception { this.destroyRegion = new DestroyRegion(); MockitoAnnotations.initMocks(this); when(this.authzRequest.destroyRegionAuthorize(eq(REGION_NAME), eq(CALLBACK_ARG))) .thenReturn(mock(RegionDestroyOperationContext.class)); when(this.cache.getRegion(isA(String.class))).thenReturn(this.region); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.callbackArgPart.getObject()).thenReturn(CALLBACK_ARG); when(this.eventPart.getSerializedForm()).thenReturn(EVENT); when(this.message.getNumberOfParts()).thenReturn(3); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.eventPart); when(this.message.getPart(eq(2))).thenReturn(this.callbackArgPart); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getCacheServerStats()).thenReturn(this.cacheServerStats); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getReplyMessage()).thenReturn(this.responseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); }
try { String dataSerializerClassName = (String) CacheServerHelper.deserialize(msg.getPart(i).getSerializedForm()); int id = msg.getPart(i + 1).getInt(); InternalDataSerializer.register(dataSerializerClassName, false, eventId, null, id); int numOfClasses = msg.getPart(i + 2).getInt(); int j = 0; for (; j < numOfClasses; j++) { String className = (String) CacheServerHelper.deserialize(msg.getPart(i + 3 + j).getSerializedForm()); InternalDataSerializer.updateSupportedClassesMap(dataSerializerClassName, className);
protected static Operation getOperation(final Part operationPart, final Operation defaultOperation) throws Exception { if (operationPart.isBytes()) { final byte[] bytes = operationPart.getSerializedForm(); if (null == bytes || 0 == bytes.length) { // older clients can send empty bytes for default operation. return defaultOperation; } else { return Operation.fromOrdinal(bytes[0]); } } // Fallback for older clients. final Operation operation = (Operation) operationPart.getObject(); if (operation == null) { // native clients may send a null since the op is java-serialized. return defaultOperation; } return operation; }
MemberMappedArgument extractMemberMappedArgument(Part part) throws IOException, ClassNotFoundException { MemberMappedArgument memberMappedArg = null; if (part != null) { Object obj = part.getObject(); if (obj instanceof MemberMappedArgument) { memberMappedArg = (MemberMappedArgument) obj; } } return memberMappedArg; }
@Before public void setUp() throws Exception { this.containsKey66 = new ContainsKey66(); MockitoAnnotations.initMocks(this); when(this.region.containsKey(eq(REGION_NAME))).thenReturn(true); when(this.cache.getRegion(isA(String.class))).thenReturn(this.region); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getCacheServerStats()).thenReturn(this.cacheServerStats); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getResponseMessage()).thenReturn(this.responseMessage); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.keyPart.getStringOrObject()).thenReturn(KEY); when(this.modePart.getInt()).thenReturn(0); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.keyPart); when(this.message.getPart(eq(2))).thenReturn(this.modePart); }
Part part = cm.getPart(partNo); try { Object o = part.getObject(); if (isDebugEnabled) { logger.debug("part({}) contained {}", partNo, o); byte[] bytesReceived = part.getSerializedForm(); if (bytesReceived[0] != ClientMetadataService.INITIAL_VERSION) { // nw hop if (region != null) {