/** * @return Set the keys associated with the ReplicateRegion of the * {@link RemoteContainsKeyValueMessage} */ public boolean waitForContainsResult() throws RemoteOperationException { try { waitForRemoteResponse(); } catch (CacheException ce) { logger.debug("ContainsKeyValueResponse got remote CacheException", ce); throw new RemoteOperationException( "RemoteContainsKeyResponse got remote CacheException; triggering RemoteOperationException.", ce); } if (!this.returnValueReceived) { throw new RemoteOperationException( "no return value received"); } return this.returnValue; } }
/** * @throws CacheException if the peer generates an error */ public void waitForResult() throws CacheException, RemoteOperationException { waitForRemoteResponse(); if (!this.returnValueReceived) { throw new RemoteOperationException( "no response code received"); } return; }
public VersionTag<?> waitForResponse() throws RemoteOperationException { try { waitForRemoteResponse(); } catch (RemoteOperationException e) { logger.debug("RemoteFetchVersionMessage threw", e); throw e; } catch (EntryNotFoundException e) { logger.debug("RemoteFetchVersionMessage threw", e); throw e; } catch (CacheException e) { logger.debug("RemoteFetchVersionMessage threw", e); throw new RemoteOperationException("RemoteFetchVersionMessage threw exception", e); } return tag; } }
/** * @return Object associated with the key that was sent in the get message * @throws RemoteOperationException if the peer is no longer available */ public EntrySnapshot waitForResponse() throws EntryNotFoundException, RemoteOperationException { try { waitForRemoteResponse(); } catch (EntryNotFoundException | TransactionException e) { throw e; } catch (CacheException ce) { logger.debug("FetchEntryResponse failed with remote CacheException", ce); throw new RemoteOperationException("FetchEntryResponse failed with remote CacheException", ce); } return this.returnValue; } }
@Override public void memberDeparted(DistributionManager distributionManager, final InternalDistributedMember id, final boolean crashed) { if (id != null) { if (removeMember(id, true)) { this.memberDepartedException = new RemoteOperationException( "memberDeparted event for <" + id + "> crashed = " + crashed); } checkIfDone(); } else { Exception e = new Exception("memberDeparted got null memberId"); logger.info("memberDeparted got null memberId crashed=" + crashed, e); } }
public void distribute() throws RemoteOperationException { RemoteOperationResponse p = (RemoteOperationResponse) this.processor; Set<?> failures = region.getDistributionManager().putOutgoing(this); if (failures != null && failures.size() > 0) { throw new RemoteOperationException(String.format("Failed sending < %s >", this)); } p.waitForRemoteResponse(); }
/** * @return the result of the remote put operation * @throws RemoteOperationException if the peer is no longer available * @throws CacheException if the peer generates an error */ public PutResult waitForResult() throws CacheException, RemoteOperationException { waitForRemoteResponse(); if (this.op == null) { throw new RemoteOperationException( "did not receive a valid reply"); } return new PutResult(this.returnValue, this.op, this.oldValue, this.versionTag); }
@Override protected boolean operateOnRegion(ClusterDistributionManager dm, LocalRegion r, long startTime) throws RemoteOperationException { if (!(r instanceof PartitionedRegion)) { // prs already wait on initialization r.waitOnInitialization(); // bug #43371 - accessing a region before it's initialized } Set<?> keys = r.keySet(); try { RemoteFetchKeysReplyMessage.send(getSender(), processorId, dm, keys); } catch (IOException io) { if (logger.isDebugEnabled()) { logger.debug("Caught exception while sending keys: {}", io.getMessage(), io); throw new RemoteOperationException( "Unable to send response to fetch keys request", io); } } return false; }
throw new RemoteOperationException( "Unable to deserialize value (IOException)", e); } catch (ClassNotFoundException e) { throw new RemoteOperationException( "Unable to deserialize value (ClassNotFoundException)", e);
/** * Send RemoteFetchVersionMessage to the recipient for the given key * * @return the processor used to fetch the VersionTag for the key * @throws RemoteOperationException if the member is no longer available */ public static FetchVersionResponse send(InternalDistributedMember recipient, LocalRegion r, Object key) throws RemoteOperationException { FetchVersionResponse response = new FetchVersionResponse(r.getSystem(), recipient); RemoteFetchVersionMessage msg = new RemoteFetchVersionMessage(recipient, r.getFullPath(), response, key); Set<?> failures = r.getDistributionManager().putOutgoing(msg); if (failures != null && failures.size() > 0) { throw new RemoteOperationException( String.format("Failed sending < %s >", msg)); } return response; }
public static RemoveAllResponse send(DistributedMember recipient, EntryEventImpl event, RemoveAllEntryData[] removeAllData, int removeAllDataCount, boolean useOriginRemote, boolean possibleDuplicate) throws RemoteOperationException { RemoveAllResponse p = new RemoveAllResponse(event.getRegion().getSystem(), recipient); RemoteRemoveAllMessage msg = new RemoteRemoveAllMessage(event, recipient, p, removeAllData, removeAllDataCount, useOriginRemote, possibleDuplicate); Set<?> failures = event.getRegion().getDistributionManager().putOutgoing(msg); if (failures != null && failures.size() > 0) { throw new RemoteOperationException( String.format("Failed sending < %s >", msg)); } return p; }
public static PutAllResponse send(DistributedMember recipient, EntryEventImpl event, PutAllEntryData[] putAllData, int putAllDataCount, boolean useOriginRemote, boolean possibleDuplicate) throws RemoteOperationException { PutAllResponse p = new PutAllResponse(event.getRegion().getSystem(), recipient); RemotePutAllMessage msg = new RemotePutAllMessage(event, recipient, p, putAllData, putAllDataCount, useOriginRemote, possibleDuplicate, !event.isGenerateCallbacks()); Set<?> failures = event.getRegion().getDistributionManager().putOutgoing(msg); if (failures != null && failures.size() > 0) { throw new RemoteOperationException( String.format("Failed sending < %s >", msg)); } return p; }
@Test public void waitForRemoteResponseWithReplyExceptionWithRemoteOperationExceptionCauseThrowsThatCause() throws Exception { ReplyException replyException = mock(ReplyException.class); RemoteOperationException cause = new RemoteOperationException("msg"); when(replyException.getCause()).thenReturn(cause); doThrow(replyException).when(replyProcessor).waitForRepliesUninterruptibly(); assertThatThrownBy(() -> replyProcessor.waitForRemoteResponse()).isSameAs(cause); }
/** * Sends a LocalRegion {@link org.apache.geode.cache.Region#getEntry(Object)} message * * @param recipient the member that the getEntry message is sent to * @param r the Region for which getEntry was performed upon * @param key the object to which the value should be fetched * @return the processor used to fetch the returned value associated with the key * @throws RemoteOperationException if the peer is no longer available */ public static FetchEntryResponse send(InternalDistributedMember recipient, LocalRegion r, final Object key) throws RemoteOperationException { Assert.assertTrue(recipient != null, "RemoteFetchEntryMessage NULL recipient"); FetchEntryResponse p = new FetchEntryResponse(r.getSystem(), recipient, r, key); RemoteFetchEntryMessage m = new RemoteFetchEntryMessage(recipient, r.getFullPath(), p, key); Set<?> failures = r.getDistributionManager().putOutgoing(m); if (failures != null && failures.size() > 0) { throw new RemoteOperationException( String.format("Failed sending < %s >", m)); } return p; }
/** * @return Object associated with the key that was sent in the get message */ public Object waitForResponse(boolean preferCD) throws RemoteOperationException { waitForRemoteResponse(); if (DistributionStats.enableClockStats) { getDistributionManager().getStats().incReplyHandOffTime(this.start); } if (!this.returnValueReceived) { throw new RemoteOperationException( "no return value received"); } return getValue(preferCD); } }
/** * Sends a transactional RemoteInvalidateMessage * {@link org.apache.geode.cache.Region#invalidate(Object)}message to the recipient * * @param recipient the recipient of the message * @param r the ReplicateRegion for which the invalidate was performed * @param event the event causing this message * @param useOriginRemote whether the receiver should use originRemote=true in its event * @return the InvalidateResponse processor used to await the potential * {@link org.apache.geode.cache.CacheException} */ public static InvalidateResponse send(DistributedMember recipient, InternalRegion r, EntryEventImpl event, boolean useOriginRemote, boolean possibleDuplicate) throws RemoteOperationException { InvalidateResponse p = new InvalidateResponse(r.getSystem(), recipient, event.getKey()); RemoteInvalidateMessage m = new RemoteInvalidateMessage(recipient, r.getFullPath(), p, event, useOriginRemote, possibleDuplicate); Set<?> failures = r.getDistributionManager().putOutgoing(m); if (failures != null && failures.size() > 0) { throw new RemoteOperationException( String.format("Failed sending < %s >", m)); } return p; }
/** * Sends a RemoteDestroyMessage {@link org.apache.geode.cache.Region#destroy(Object)}message to * the recipient * * @param recipient the recipient of the message * @param r the ReplicateRegion for which the destroy was performed * @param event the event causing this message * @return the processor used to await the potential {@link org.apache.geode.cache.CacheException} */ public static RemoteDestroyReplyProcessor send(DistributedMember recipient, InternalRegion r, EntryEventImpl event, Object expectedOldValue, boolean useOriginRemote, boolean possibleDuplicate) throws RemoteOperationException { RemoteDestroyReplyProcessor p = new RemoteDestroyReplyProcessor(r.getSystem(), recipient, false); p.requireResponse(); RemoteDestroyMessage m = new RemoteDestroyMessage(recipient, r.getFullPath(), p, event, expectedOldValue, useOriginRemote, possibleDuplicate); Set<?> failures = r.getDistributionManager().putOutgoing(m); if (failures != null && failures.size() > 0) { throw new RemoteOperationException( String.format("Failed sending < %s >", m)); } return p; }
/** * Sends a ReplicateRegion {@link org.apache.geode.cache.Region#get(Object)} message * * @param recipient the member that the get message is sent to * @param r the ReplicateRegion for which get was performed upon * @param key the object to which the value should be feteched * @param requestingClient the client requesting the value * @return the processor used to fetch the returned value associated with the key */ public static RemoteGetResponse send(InternalDistributedMember recipient, LocalRegion r, final Object key, final Object aCallbackArgument, ClientProxyMembershipID requestingClient) throws RemoteOperationException { Assert.assertTrue(recipient != null, "RemoteGetMessage NULL recipient"); RemoteGetResponse p = new RemoteGetResponse(r.getSystem(), recipient); RemoteGetMessage m = new RemoteGetMessage(recipient, r.getFullPath(), p, key, aCallbackArgument, requestingClient); Set<?> failures = r.getDistributionManager().putOutgoing(m); if (failures != null && failures.size() > 0) { throw new RemoteOperationException( String.format("Failed sending < %s >", m)); } return p; }
/** * Sends a ReplicateRegion message for either * {@link org.apache.geode.cache.Region#containsKey(Object)}or * {@link org.apache.geode.cache.Region#containsValueForKey(Object)} depending on the * <code>valueCheck</code> argument * * @param recipient the member that the contains keys/value message is sent to * @param r the LocalRegion * @param key the key to be queried * @param valueCheck true if {@link org.apache.geode.cache.Region#containsValueForKey(Object)} is * desired, false if {@link org.apache.geode.cache.Region#containsKey(Object)}is desired * @return the processor used to read the returned keys */ public static RemoteContainsKeyValueResponse send(InternalDistributedMember recipient, LocalRegion r, Object key, boolean valueCheck) throws RemoteOperationException { Assert.assertTrue(recipient != null, "recipient can not be NULL"); RemoteContainsKeyValueResponse p = new RemoteContainsKeyValueResponse(r.getSystem(), recipient, key); RemoteContainsKeyValueMessage m = new RemoteContainsKeyValueMessage(recipient, r.getFullPath(), p, key, valueCheck); Set<?> failures = r.getDistributionManager().putOutgoing(m); if (failures != null && failures.size() > 0) { throw new RemoteOperationException(String.format("Failed sending < %s >", m)); } return p; }
@Test public void getRegionKeysForIterationTranslatesRemoteOperationException() { expectedException.expect(TransactionDataNodeHasDepartedException.class); InternalDistributedSystem system = mock(InternalDistributedSystem.class); ClusterDistributionManager manager = mock(ClusterDistributionManager.class); when(system.getDistributionManager()).thenReturn(manager); when(manager.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); InternalDistributedMember target = new InternalDistributedMember("localhost", 1234); RemoteFetchKeysMessage.FetchKeysResponse responseProcessor = new RemoteFetchKeysMessage.FetchKeysResponse(system, target); RemoteFetchKeysMessage.FetchKeysResponse spy = Mockito.spy(responseProcessor); Exception replyException = new ReplyException("testing", new RemoteOperationException("The cache is closing", new CacheClosedException())); doThrow(replyException).when(spy).waitForRepliesUninterruptibly(); spy.waitForKeys(); fail( "Expected to translate RemoteOperationException.CacheClosedException to TransactionDataNodeHasDepartedException "); }