TXManagerImpl getTXManager(ServerConnection serverConnection) { return (TXManagerImpl) serverConnection.getCache().getCacheTransactionManager(); } }
@Before public void setUp() throws Exception { this.keySet = new KeySet(); MockitoAnnotations.initMocks(this); when(this.authzRequest.keySetAuthorize(eq(REGION_NAME))) .thenReturn(this.keySetOperationContext); when(this.cache.getRegion(isA(String.class))).thenReturn(this.region); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); 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); }
@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.getAll = new GetAll(); MockitoAnnotations.initMocks(this); when(this.authzRequest.getAuthorize(any(), any(), any())) .thenReturn(mock(GetOperationContext.class)); when(this.cache.getRegion(isA(String.class))).thenReturn(mock(LocalRegion.class)); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.keyPart.getObject()).thenReturn(KEYS); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.keyPart); 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); }
@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); }
protected DistributedSystem getDistributedSystem() { return getCache().getDistributedSystem(); }
@Before public void setUp() throws Exception { this.getAll651 = new GetAll651(); MockitoAnnotations.initMocks(this); when(this.authzRequest.getAuthorize(any(), any(), any())) .thenReturn(mock(GetOperationContext.class)); when(this.cache.getRegion(isA(String.class))).thenReturn(mock(LocalRegion.class)); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.keyPart.getObject()).thenReturn(KEYS); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.keyPart); 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); }
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; }
/** * Test for GEODE-537 No NPE should be thrown from the * {@link CommitCommand#writeCommitResponse(org.apache.geode.internal.cache.TXCommitMessage, Message, ServerConnection)} * if the response message is null as it is the case when JTA transaction is rolled back with * TX_SYNCHRONIZATION AFTER_COMPLETION STATUS_ROLLEDBACK */ @Test public void testWriteNullResponse() throws Exception { InternalCache cache = mock(InternalCache.class); Message origMsg = mock(Message.class); ServerConnection servConn = mock(ServerConnection.class); when(servConn.getResponseMessage()).thenReturn(mock(Message.class)); when(servConn.getCache()).thenReturn(cache); when(cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); CommitCommand.writeCommitResponse(null, origMsg, servConn); }
@Before public void setUp() throws Exception { this.getClientPartitionAttributesCommand = new GetClientPartitionAttributesCommand(); MockitoAnnotations.initMocks(this); when(this.cache.getRegion(isA(String.class))).thenReturn(mock(PartitionedRegion.class)); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getResponseMessage()).thenReturn(this.responseMessage); }
@Before public void setUp() throws Exception { this.getClientPartitionAttributesCommand66 = new GetClientPartitionAttributesCommand66(); MockitoAnnotations.initMocks(this); when(this.cache.getRegion(isA(String.class))).thenReturn(mock(LocalRegion.class)); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getResponseMessage()).thenReturn(this.responseMessage); }
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()); } }
protected void writeReply(Message origMsg, ServerConnection servConn, boolean entryNotFound, VersionTag tag) throws IOException { Message replyMsg = servConn.getReplyMessage(); servConn.getCache().getCancelCriterion().checkCancelInProgress(null); replyMsg.setMessageType(MessageType.REPLY); replyMsg.setNumberOfParts(2); replyMsg.setTransactionId(origMsg.getTransactionId()); replyMsg.addBytesPart(okBytes()); replyMsg.addIntPart(entryNotFound ? 1 : 0); replyMsg.send(servConn); if (logger.isTraceEnabled()) { logger.trace("{}: rpl tx: {} parts={}", servConn.getName(), origMsg.getTransactionId(), replyMsg.getNumberOfParts()); } }
protected void writeReply(Message origMsg, VersionedObjectList response, ServerConnection servConn) throws IOException { Message replyMsg = servConn.getReplyMessage(); servConn.getCache().getCancelCriterion().checkCancelInProgress(null); replyMsg.setMessageType(MessageType.REPLY); replyMsg.setNumberOfParts(2); replyMsg.setTransactionId(origMsg.getTransactionId()); replyMsg.addBytesPart(okBytes()); if (response != null) { response.clearObjects(); replyMsg.addObjPart(response); } replyMsg.send(servConn); if (logger.isTraceEnabled()) { logger.trace("{}: rpl tx: {}", servConn.getName(), origMsg.getTransactionId()); } }
protected void writeReplyWithRefreshMetadata(Message origMsg, ServerConnection servConn, PartitionedRegion pr, boolean entryNotFoundForRemove, byte nwHop, VersionTag tag) throws IOException { Message replyMsg = servConn.getReplyMessage(); servConn.getCache().getCancelCriterion().checkCancelInProgress(null); replyMsg.setMessageType(MessageType.REPLY); replyMsg.setNumberOfParts(2); replyMsg.setTransactionId(origMsg.getTransactionId()); replyMsg.addBytesPart(new byte[] {pr.getMetadataVersion(), nwHop}); pr.getPrStats().incPRMetaDataSentCount(); replyMsg.addIntPart(entryNotFoundForRemove ? 1 : 0); replyMsg.send(servConn); if (logger.isTraceEnabled()) { logger.trace("{}: rpl with REFRESH_METADATA tx: {}", servConn.getName(), origMsg.getTransactionId()); } }
protected void writeReply(Message origMsg, ServerConnection servConn, boolean sendOldValue, boolean oldValueIsObject, Object oldValue, VersionTag tag) throws IOException { Message replyMsg = servConn.getReplyMessage(); servConn.getCache().getCancelCriterion().checkCancelInProgress(null); replyMsg.setMessageType(MessageType.REPLY); replyMsg.setNumberOfParts(sendOldValue ? 3 : 1); replyMsg.setTransactionId(origMsg.getTransactionId()); replyMsg.addBytesPart(okBytes()); if (sendOldValue) { replyMsg.addIntPart(oldValueIsObject ? 1 : 0); replyMsg.addObjPart(oldValue); } replyMsg.send(servConn); if (logger.isTraceEnabled()) { logger.trace("{}: rpl tx: {} parts={}", servConn.getName(), origMsg.getTransactionId(), replyMsg.getNumberOfParts()); } }
private void writeReplyWithRefreshMetadata(Message origMsg, VersionedObjectList response, ServerConnection servConn, PartitionedRegion pr, byte nwHop) throws IOException { Message replyMsg = servConn.getReplyMessage(); servConn.getCache().getCancelCriterion().checkCancelInProgress(null); replyMsg.setMessageType(MessageType.REPLY); replyMsg.setNumberOfParts(2); replyMsg.setTransactionId(origMsg.getTransactionId()); replyMsg.addBytesPart(new byte[] {pr.getMetadataVersion(), nwHop}); if (response != null) { response.clearObjects(); replyMsg.addObjPart(response); } replyMsg.send(servConn); pr.getPrStats().incPRMetaDataSentCount(); if (logger.isTraceEnabled()) { logger.trace("{}: rpl with REFRESH_METADATA tx: {}", servConn.getName(), origMsg.getTransactionId()); } }