/** * @throws org.apache.geode.SerializationException if serialization fails */ public MakePrimaryOpImpl(boolean sentClientReady) { super(MessageType.MAKE_PRIMARY, 1); getMessage().addBytesPart(new byte[] {(byte) (sentClientReady ? 0x01 : 0x00)}); }
private void addBytes(byte functionState) { if (ConnectionImpl .getClientFunctionTimeout() == ConnectionImpl.DEFAULT_CLIENT_FUNCTION_TIMEOUT) { getMessage().addBytesPart(new byte[] {functionState}); } else { byte[] bytes = new byte[5]; bytes[0] = functionState; Part.encodeInt(ConnectionImpl.getClientFunctionTimeout(), bytes, 1); getMessage().addBytesPart(bytes); } }
private void addBytes(byte functionStateOrHasResult) { if (ConnectionImpl .getClientFunctionTimeout() == ConnectionImpl.DEFAULT_CLIENT_FUNCTION_TIMEOUT) { getMessage().addBytesPart(new byte[] {functionStateOrHasResult}); } else { byte[] bytes = new byte[5]; bytes[0] = functionStateOrHasResult; Part.encodeInt(ConnectionImpl.getClientFunctionTimeout(), bytes, 1); getMessage().addBytesPart(bytes); } }
protected Message getGFEMessage(Version clientVersion) { Message message = null; int dataSerializerLength = this.serializedDataSerializer.length; message = new Message(dataSerializerLength + 1, clientVersion); // one for eventID // Set message type message.setMessageType(MessageType.REGISTER_DATASERIALIZERS); for (int i = 0; i < dataSerializerLength; i = i + 2) { message.addBytesPart(this.serializedDataSerializer[i]); message.addBytesPart(this.serializedDataSerializer[i + 1]); } message.setTransactionId(0); message.addObjPart(this.getEventId()); return message; }
public ProxyCacheCloseOpImpl(ExecutablePool pool, Properties securityProps, boolean keepAlive) { super(MessageType.REMOVE_USER_AUTH, 1); getMessage().setMessageHasSecurePartFlag(); getMessage().addBytesPart(keepAlive ? new byte[] {1} : new byte[] {0}); }
/** * @throws org.apache.geode.SerializationException if serialization fails */ public RemoveAllOpImpl(Region region, Collection<Object> keys, EventID eventId, boolean prSingleHopEnabled, Object callbackArg) { super(MessageType.REMOVE_ALL, 5 + keys.size()); this.prSingleHopEnabled = prSingleHopEnabled; this.region = (LocalRegion) region; getMessage().addStringPart(region.getFullPath()); getMessage().addBytesPart(eventId.calcBytes()); this.keys = keys; this.callbackArg = callbackArg; }
@Test public void oldSecurityShouldSucceedIfAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); this.put65.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<byte[]> argument = ArgumentCaptor.forClass(byte[].class); verify(this.replyMessage).addBytesPart(argument.capture()); assertThat(argument.getValue()).isEqualTo(OK_BYTES); verify(this.authzRequest).putAuthorize(eq(REGION_NAME), eq(KEY), eq(VALUE), eq(true), eq(CALLBACK_ARG)); verify(this.replyMessage).send(this.serverConnection); }
@Test public void oldSecurityShouldSucceedIfAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); this.put61.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<byte[]> argument = ArgumentCaptor.forClass(byte[].class); verify(this.replyMessage).addBytesPart(argument.capture()); assertThat(argument.getValue()).isEqualTo(OK_BYTES); verify(this.authzRequest).putAuthorize(eq(REGION_NAME), eq(KEY), eq(null), eq(true), eq(CALLBACK_ARG)); verify(this.replyMessage).send(this.serverConnection); }
@Test public void oldSecurityShouldSucceedIfAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); this.put.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<byte[]> argument = ArgumentCaptor.forClass(byte[].class); verify(this.replyMessage).addBytesPart(argument.capture()); assertThat(argument.getValue()).isEqualTo(OK_BYTES); verify(this.authzRequest).putAuthorize(eq(REGION_NAME), eq(KEY), eq(VALUE), eq(true), eq(CALLBACK_ARG)); verify(this.replyMessage).send(this.serverConnection); }
/** * @throws org.apache.geode.SerializationException if serialization fails */ public CreateCQOpImpl(String cqName, String queryStr, int cqState, boolean isDurable, byte regionDataPolicy) { super(MessageType.EXECUTECQ_MSG_TYPE, 5); getMessage().addStringPart(cqName); getMessage().addStringPart(queryStr); getMessage().addIntPart(cqState); { byte durableByte = (byte) (isDurable ? 0x01 : 0x00); getMessage().addBytesPart(new byte[] {durableByte}); } getMessage().addBytesPart(new byte[] {regionDataPolicy}); }
public ExecuteFunctionNoAckOpImpl(String functionId, Object args, MemberMappedArgument memberMappedArg, byte hasResult, boolean isFnSerializationReqd, boolean isHA, boolean optimizeForWrite, String[] groups, boolean allMembers) { super(MessageType.EXECUTE_FUNCTION, MSG_PARTS); getMessage().addBytesPart(new byte[] {AbstractExecution.getFunctionState(isHA, hasResult == (byte) 1 ? true : false, optimizeForWrite)}); getMessage().addStringOrObjPart(functionId); getMessage().addObjPart(args); getMessage().addObjPart(memberMappedArg); getMessage().addObjPart(groups); getMessage().addBytesPart(ExecuteFunctionOp.getByteArrayForFlags(allMembers)); }
/** * @throws org.apache.geode.SerializationException if serialization fails */ public ClearOpImpl(String region, EventID eventId, Object callbackArg) { super(MessageType.CLEAR_REGION, callbackArg != null ? 3 : 2); getMessage().addStringPart(region); getMessage().addBytesPart(eventId.calcBytes()); if (callbackArg != null) { getMessage().addObjPart(callbackArg); } }
/** * @throws org.apache.geode.SerializationException if serialization fails */ public DestroyRegionOpImpl(String region, EventID eventId, Object callbackArg) { super(MessageType.DESTROY_REGION, callbackArg != null ? 3 : 2); getMessage().addStringPart(region); getMessage().addBytesPart(eventId.calcBytes()); if (callbackArg != null) { getMessage().addObjPart(callbackArg); } }
protected void writeReply(Message origMsg, ServerConnection serverConnection) throws IOException { Message replyMsg = serverConnection.getReplyMessage(); serverConnection.getCache().getCancelCriterion().checkCancelInProgress(null); replyMsg.setMessageType(MessageType.REPLY); replyMsg.setNumberOfParts(1); replyMsg.setTransactionId(origMsg.getTransactionId()); replyMsg.addBytesPart(okBytes()); replyMsg.send(serverConnection); if (logger.isTraceEnabled()) { logger.trace("{}: rpl tx: {}", serverConnection.getName(), origMsg.getTransactionId()); } }
@Override protected void writeReply(Message origMsg, ServerConnection serverConnection) throws IOException { Message replyMsg = serverConnection.getReplyMessage(); serverConnection.getCache().getCancelCriterion().checkCancelInProgress(null); replyMsg.setMessageType(MessageType.REPLY); replyMsg.setNumberOfParts(1); replyMsg.setTransactionId(origMsg.getTransactionId()); replyMsg.addBytesPart(okBytes()); replyMsg.send(serverConnection); if (logger.isTraceEnabled()) { logger.trace("{}: rpl tx: {}", serverConnection.getName(), origMsg.getTransactionId()); } } }
protected static void writeResponseWithFunctionAttribute(byte[] data, Message origMsg, ServerConnection serverConnection) throws IOException { Message responseMsg = serverConnection.getResponseMessage(); responseMsg.setMessageType(MessageType.RESPONSE); responseMsg.setTransactionId(origMsg.getTransactionId()); responseMsg.setNumberOfParts(1); responseMsg.addBytesPart(data); serverConnection.getCache().getCancelCriterion().checkCancelInProgress(null); responseMsg.send(serverConnection); origMsg.clearParts(); }
protected void writeReplyWithRefreshMetadata(Message origMsg, ServerConnection serverConnection, PartitionedRegion pr, byte nwHop) throws IOException { Message replyMsg = serverConnection.getReplyMessage(); serverConnection.getCache().getCancelCriterion().checkCancelInProgress(null); replyMsg.setMessageType(MessageType.REPLY); replyMsg.setNumberOfParts(1); replyMsg.setTransactionId(origMsg.getTransactionId()); replyMsg.addBytesPart(new byte[] {pr.getMetadataVersion(), nwHop}); replyMsg.send(serverConnection); pr.getPrStats().incPRMetaDataSentCount(); if (logger.isTraceEnabled()) { logger.trace("{}: rpl with REFRESH_METADATA tx: {}", serverConnection.getName(), origMsg.getTransactionId()); } }
/** * @throws org.apache.geode.SerializationException if serialization fails */ public InvalidateOpImpl(String region, EntryEventImpl event) { super(MessageType.INVALIDATE, event.getCallbackArgument() != null ? 4 : 3); Object callbackArg = event.getCallbackArgument(); this.event = event; getMessage().addStringPart(region); getMessage().addStringOrObjPart(event.getKeyInfo().getKey()); getMessage().addBytesPart(event.getEventId().calcBytes()); if (callbackArg != null) { getMessage().addObjPart(callbackArg); } }
public DestroyOpImpl(String region, Object key, Object expectedOldValue, Operation operation, EntryEventImpl event, Object callbackArg) { super(MessageType.DESTROY, callbackArg != null ? 6 : 5); this.key = key; this.event = event; this.callbackArg = callbackArg; getMessage().addStringPart(region); getMessage().addStringOrObjPart(key); getMessage().addObjPart(expectedOldValue); getMessage().addBytePart(operation.ordinal); getMessage().addBytesPart(event.getEventId().calcBytes()); if (callbackArg != null) { getMessage().addObjPart(callbackArg); } }
@Test public void numberOfPartsIsAdjusted() { int numParts = this.message.getNumberOfParts(); this.message.setNumberOfParts(2 * numParts + 1); assertEquals(2 * numParts + 1, this.message.getNumberOfParts()); this.message.addBytesPart(new byte[1]); this.message.addIntPart(2); this.message.addLongPart(3); this.message.addObjPart("4"); this.message.addStringPart("5"); assertEquals(5, this.message.getNextPartNumber()); }