public Version getClientVersion() { if (serverSender != null && serverSender.sc != null) { // is a client-server connection return serverSender.sc.getClientVersion(); } return null; }
/** * Determines whether keys for destroyed entries (tombstones) should be sent to clients in * register-interest results. * * @return true if tombstones should be sent to the client */ private static boolean sendTombstonesInRIResults(ServerConnection servConn, InterestResultPolicy policy) { return policy == InterestResultPolicy.KEYS_VALUES && servConn.getClientVersion().compareTo(Version.GFE_80) >= 0; }
private boolean sendCqResultsWithKey(ServerConnection servConn) { Version clientVersion = servConn.getClientVersion(); if (clientVersion.compareTo(Version.GFE_65) >= 0) { return true; } return false; }
public static Map<Integer, Command> getCommands(ServerConnection connection) { return getCommands(connection.getClientVersion()); } }
/** * checks to see if this thread needs to masquerade as a transactional thread. clients after * GFE_66 should be able to start a transaction. * * @return true if thread should masquerade as a transactional thread. */ protected boolean shouldMasqueradeForTx(Message clientMessage, ServerConnection serverConnection) { return serverConnection.getClientVersion().compareTo(Version.GFE_66) >= 0 && clientMessage.getTransactionId() > TXManagerImpl.NOTX; }
public void setLastChunkAndNumParts(boolean lastChunk, int numParts) { setLastChunk(lastChunk); if (this.serverConnection != null && this.serverConnection.getClientVersion().compareTo(Version.GFE_65) >= 0) { // we us e three bits for number of parts in last chunk byte // we us e three bits for number of parts in last chunk byte byte localLastChunk = (byte) (numParts << 5); this.lastChunk |= localLastChunk; } }
private static Throwable getClientException(ServerConnection serverConnection, Throwable e) { InternalCache cache = serverConnection.getCache(); if (cache != null) { OldClientSupportService svc = cache.getService(OldClientSupportService.class); if (svc != null) { return svc.getThrowable(e, serverConnection.getClientVersion()); } } return e; }
public ServerToClientFunctionResultSender(ChunkedMessage msg, int messageType, ServerConnection sc, Function function, ExecuteFunctionOperationContext authzContext) { this.msg = msg; this.msg.setVersion(sc.getClientVersion()); this.messageType = messageType; this.sc = sc; this.fn = function; this.authContext = authzContext; this.isSelector = sc.getAcceptor().isSelector(); if (this.isSelector) { this.commBuffer = msg.getCommBuffer(); } }
private static void writeFatalException(Message origMsg, Throwable exception, ServerConnection servConn, int batchId) throws IOException { Message errorMsg = servConn.getErrorResponseMessage(); errorMsg.setMessageType(MessageType.EXCEPTION); errorMsg.setNumberOfParts(2); errorMsg.setTransactionId(origMsg.getTransactionId()); // For older gateway senders, we need to send back an exception // they can deserialize. if ((servConn.getClientVersion() == null || servConn.getClientVersion().compareTo(Version.GFE_80) < 0) && exception instanceof PdxRegistryMismatchException) { PdxConfigurationException newException = new PdxConfigurationException(exception.getMessage()); newException.setStackTrace(exception.getStackTrace()); exception = newException; } errorMsg.addObjPart(exception); // errorMsg.addStringPart(be.toString()); errorMsg.send(servConn); logger.warn(servConn.getName() + ": Wrote batch exception: ", exception); } }
@Before public void setUp() throws Exception { this.createRegion = new CreateRegion(); MockitoAnnotations.initMocks(this); when(this.cache.getRegion(eq(PARENT_REGION_NAME))).thenReturn(this.parentRegion); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.message.getPart(eq(0))).thenReturn(this.parentRegionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.regionNamePart); when(this.parentRegion.getAttributes()).thenReturn(new AttributesFactory().create()); when(this.parentRegionNamePart.getString()).thenReturn(PARENT_REGION_NAME); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getCacheServerStats()).thenReturn(mock(CacheServerStats.class)); when(this.serverConnection.getReplyMessage()).thenReturn(this.responseMessage); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); }
@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); }
@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); }
@Before public void setUp() throws Exception { this.get70 = new Get70(); MockitoAnnotations.initMocks(this); when(this.authzRequest.getAuthorize(any(), any(), any())).thenReturn(this.getOperationContext); when(this.cache.getRegion(isA(String.class))).thenReturn(this.region); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.getOperationContext.getCallbackArg()).thenReturn(CALLBACK_ARG); when(this.keyPart.getStringOrObject()).thenReturn(KEY); when(this.message.getNumberOfParts()).thenReturn(3); 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.valuePart); 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.getResponseMessage()).thenReturn(this.responseMessage); when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); when(this.valuePart.getObject()).thenReturn(CALLBACK_ARG); }
@Before public void setUp() throws Exception { this.destroy65 = new Destroy65(); MockitoAnnotations.initMocks(this); when(this.authzRequest.destroyAuthorize(eq(REGION_NAME), eq(KEY), eq(CALLBACK_ARG))) .thenReturn(this.destroyOperationContext); 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.keyPart.getStringOrObject()).thenReturn(KEY); when(this.message.getNumberOfParts()).thenReturn(6); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.keyPart); when(this.message.getPart(eq(3))).thenReturn(mock(Part.class)); when(this.message.getPart(eq(4))).thenReturn(this.eventPart); when(this.message.getPart(eq(5))).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.getReplyMessage()).thenReturn(this.responseMessage); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); }
@Before public void setUp() throws Exception { this.request = new Request(); MockitoAnnotations.initMocks(this); when(this.authzRequest.getAuthorize(any(), any(), any())).thenReturn(this.getOperationContext); when(this.cache.getRegion(isA(String.class))).thenReturn(this.region); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.getOperationContext.getCallbackArg()).thenReturn(CALLBACK_ARG); when(this.keyPart.getStringOrObject()).thenReturn(KEY); when(this.message.getNumberOfParts()).thenReturn(3); 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.valuePart); 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.getResponseMessage()).thenReturn(this.responseMessage); when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); when(this.valuePart.getObject()).thenReturn(CALLBACK_ARG); }
@Before public void setUp() throws Exception { this.invalidate = new Invalidate(); MockitoAnnotations.initMocks(this); when(this.authzRequest.invalidateAuthorize(any(), any(), any())) .thenReturn(mock(InvalidateOperationContext.class)); when(this.cache.getRegion(isA(String.class))).thenReturn(mock(LocalRegion.class)); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.callbackArgPart.getObject()).thenReturn(CALLBACK_ARG); when(this.eventPart.getSerializedForm()).thenReturn(EVENT); when(this.keyPart.getStringOrObject()).thenReturn(KEY_STRING); when(this.message.getNumberOfParts()).thenReturn(4); 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.eventPart); when(this.message.getPart(eq(3))).thenReturn(this.callbackArgPart); 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.getReplyMessage()).thenReturn(this.responseMessage); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); }
@Before public void setUp() throws Exception { this.registerInterest61 = new RegisterInterest61(); MockitoAnnotations.initMocks(this); when(this.authzRequest.registerInterestAuthorize(eq(REGION_NAME), eq(KEY), anyInt(), any())) .thenReturn(this.registerInterestOperationContext); when(this.cache.getRegion(isA(String.class))).thenReturn(mock(LocalRegion.class)); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.durablePart.getObject()).thenReturn(DURABLE); when(this.interestTypePart.getInt()).thenReturn(0); when(this.keyPart.getStringOrObject()).thenReturn(KEY); when(this.message.getNumberOfParts()).thenReturn(6); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.interestTypePart); when(this.message.getPart(eq(2))).thenReturn(mock(Part.class)); when(this.message.getPart(eq(3))).thenReturn(this.durablePart); when(this.message.getPart(eq(4))).thenReturn(this.keyPart); when(this.message.getPart(eq(5))).thenReturn(this.notifyPart); when(this.notifyPart.getObject()).thenReturn(DURABLE); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.registerInterestOperationContext.getKey()).thenReturn(KEY); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getChunkedResponseMessage()).thenReturn(this.chunkedResponseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.GFE_80); when(this.serverConnection.getAcceptor()).thenReturn(mock(AcceptorImpl.class)); }
@Before public void setUp() throws Exception { this.destroy = new Destroy(); MockitoAnnotations.initMocks(this); when(this.authzRequest.destroyAuthorize(eq(REGION_NAME), eq(KEY), eq(CALLBACK_ARG))) .thenReturn(this.destroyOperationContext); 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.destroyOperationContext.getCallbackArg()).thenReturn(CALLBACK_ARG); when(this.eventPart.getSerializedForm()).thenReturn(EVENT); when(this.keyPart.getStringOrObject()).thenReturn(KEY); when(this.message.getNumberOfParts()).thenReturn(4); 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.eventPart); when(this.message.getPart(eq(3))).thenReturn(this.callbackArgPart); when(this.region.containsKey(eq(REGION_NAME))).thenReturn(true); 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.replyMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); }
@Before public void setUp() throws Exception { this.registerInterestList61 = new RegisterInterestList61(); MockitoAnnotations.initMocks(this); when(this.authzRequest.registerInterestListAuthorize(eq(REGION_NAME), any(), any())) .thenReturn(this.registerInterestOperationContext); when(this.cache.getRegion(isA(String.class))).thenReturn(mock(LocalRegion.class)); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.durablePart.getObject()).thenReturn(DURABLE); when(this.interestTypePart.getInt()).thenReturn(0); when(this.keyPart.getStringOrObject()).thenReturn(KEY); when(this.message.getNumberOfParts()).thenReturn(6); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.interestTypePart); when(this.message.getPart(eq(2))).thenReturn(this.durablePart); when(this.message.getPart(eq(3))).thenReturn(this.numberOfKeysPart); when(this.message.getPart(eq(4))).thenReturn(this.keyPart); when(this.message.getPart(eq(5))).thenReturn(this.notifyPart); when(this.notifyPart.getObject()).thenReturn(DURABLE); when(this.numberOfKeysPart.getInt()).thenReturn(1); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.registerInterestOperationContext.getKey()).thenReturn(KEY); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getChunkedResponseMessage()).thenReturn(this.chunkedResponseMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.GFE_80); when(this.serverConnection.getAcceptor()).thenReturn(mock(AcceptorImpl.class)); }
protected static void writeCommitResponse(TXCommitMessage response, Message origMsg, ServerConnection servConn) throws IOException { Message responseMsg = servConn.getResponseMessage(); responseMsg.setMessageType(MessageType.RESPONSE); responseMsg.setTransactionId(origMsg.getTransactionId()); responseMsg.setNumberOfParts(1); if (response != null) { response.setClientVersion(servConn.getClientVersion()); } responseMsg.addObjPart(response, false); servConn.getCache().getCancelCriterion().checkCancelInProgress(null); if (logger.isDebugEnabled()) { logger.debug("TX: sending a nonNull response for transaction: {}", new TXId((InternalDistributedMember) servConn.getProxyID().getDistributedMember(), origMsg.getTransactionId())); } responseMsg.send(servConn); origMsg.clearParts(); }