public boolean waitForResponse() { try { waitForRepliesUninterruptibly(); } catch(ReplyException e) { Throwable t = e.getCause(); //Most of these cases indicate that the PR is destroyed on the // remote VM. Which is fine, because that means the bucket was "removed" if (t instanceof CancelException) { String msg = "RemoveBucketMessage got remote cancellation,"; logger.debug(msg, t); return true; } if (t instanceof PRLocallyDestroyedException) { String msg = "RemoveBucketMessage got local destroy on the PartitionRegion "; logger.debug(msg, t); return true; } if (t instanceof ForceReattemptException) { String msg = "RemoveBucketMessage got ForceReattemptException due to local destroy on the PartitionRegion"; logger.debug(msg, t); return true; } e.handleAsUnexpected(); } return this.removed; } }
/** * Sends a message to remove the bucket. * * @param recipient the member to remove the bucket from * @param region the PartitionedRegion of the bucket * @param bucketId the bucket to remove * @return the processor used to wait for the response */ public static RemoveBucketResponse send( InternalDistributedMember recipient, PartitionedRegion region, int bucketId, boolean forceRemovePrimary) { Assert.assertTrue(recipient != null, "RemoveBucketMessage NULL recipient"); RemoveBucketResponse response = new RemoveBucketResponse( region.getSystem(), recipient, region); RemoveBucketMessage msg = new RemoveBucketMessage( recipient, region.getPRId(), response, bucketId, forceRemovePrimary); Set<InternalDistributedMember> failures = region.getDistributionManager().putOutgoing(msg); if (failures != null && failures.size() > 0) { //throw new ForceReattemptException("Failed sending <" + msg + ">"); return null; } region.getPrStats().incPartitionMessagesSent(); return response; }
this.partitionedRegion, bucketId, false); if (response != null) { boolean removed = response.waitForResponse(); if (removed == false) { if (logger.isDebugEnabled()) {
this.partitionedRegion, bucketId, false); if (response != null) { boolean removed = response.waitForResponse(); if (removed == false && getLogWriter().fineEnabled()) { getLogWriter().fine(
/** * Remove a redundant bucket on the target member * * @param target * the member on which to create the redundant bucket * @param bucketId * the identifier of the bucket * @param pr * the partitioned region which contains the bucket * @return true if the redundant bucket was removed */ public static boolean removeRedundantBucketForRegion( InternalDistributedMember target, int bucketId, PartitionedRegion pr) { boolean removed = false; if (pr.getDistributionManager().getId().equals(target)) { // invoke directly on local member... removed = pr.getDataStore().removeBucket(bucketId, false); } else { // send message to remote member... RemoveBucketResponse response = RemoveBucketMessage.send(target, pr, bucketId, false); if (response != null) { removed = response.waitForResponse(); } } return removed; }
public boolean waitForResponse() { try { waitForRepliesUninterruptibly(); } catch(ReplyException e) { Throwable t = e.getCause(); //Most of these cases indicate that the PR is destroyed on the // remote VM. Which is fine, because that means the bucket was "removed" if (t instanceof CancelException) { String msg = "RemoveBucketMessage got remote cancellation,"; getDistributionManager().getLoggerI18n().fine(msg, t); return true; } if (t instanceof PRLocallyDestroyedException) { String msg = "RemoveBucketMessage got local destroy on the PartitionRegion "; getDistributionManager().getLoggerI18n().fine(msg, t); return true; } if (t instanceof ForceReattemptException) { String msg = "RemoveBucketMessage got ForceReattemptException due to local destroy on the PartitionRegion"; getDistributionManager().getLoggerI18n().fine(msg, t); return true; } e.handleAsUnexpected(); } return this.removed; } }
private static boolean dumpBucket(final DistributedMember source, final Region<?, ?> region, final int bucketId) { final PartitionedRegion pr = prCheck(region, bucketId); InternalDistributedMember bucketSource = dataStoreCheck(source, pr); Set<InternalDistributedMember> currentBucketOwners = pr.getRegionAdvisor() .getBucketOwners(bucketId); if (!currentBucketOwners.contains(bucketSource)) { Object[] params = new Object[] { bucketSource, Integer.valueOf(bucketId) }; throw new IllegalArgumentException( LocalizedStrings.PartitionManager_SOURCE_MEMBER_0_BUCKETID_1_DOES_NOT_HAVE_THE_BUCKET .toLocalizedString(params)); } InternalDistributedMember self = (InternalDistributedMember)pr.getCache() .getDistributedSystem().getDistributedMember(); if (bucketSource.equals(self)) { PartitionedRegionDataStore dataStore = pr.getDataStore(); return dataStore.removeBucket(bucketId, true); } else { RemoveBucketResponse response = RemoveBucketMessage.send(bucketSource, pr, bucketId, true); if (response != null) { return response.waitForResponse(); } } return false; }
/** * Remove a redundant bucket on the target member * * @param target * the member on which to create the redundant bucket * @param bucketId * the identifier of the bucket * @param pr * the partitioned region which contains the bucket * @return true if the redundant bucket was removed */ public static boolean removeRedundantBucketForRegion( InternalDistributedMember target, int bucketId, PartitionedRegion pr) { boolean removed = false; if (pr.getDistributionManager().getId().equals(target)) { // invoke directly on local member... removed = pr.getDataStore().removeBucket(bucketId, false); } else { // send message to remote member... RemoveBucketResponse response = RemoveBucketMessage.send(target, pr, bucketId, false); if (response != null) { removed = response.waitForResponse(); } } return removed; }
/** * Sends a message to remove the bucket. * * @param recipient the member to remove the bucket from * @param region the PartitionedRegion of the bucket * @param bucketId the bucket to remove * @return the processor used to wait for the response */ public static RemoveBucketResponse send( InternalDistributedMember recipient, PartitionedRegion region, int bucketId, boolean forceRemovePrimary) { Assert.assertTrue(recipient != null, "RemoveBucketMessage NULL recipient"); RemoveBucketResponse response = new RemoveBucketResponse( region.getSystem(), recipient, region); RemoveBucketMessage msg = new RemoveBucketMessage( recipient, region.getPRId(), response, bucketId, forceRemovePrimary); Set<InternalDistributedMember> failures = region.getDistributionManager().putOutgoing(msg); if (failures != null && failures.size() > 0) { //throw new ForceReattemptException("Failed sending <" + msg + ">"); return null; } region.getPrStats().incPartitionMessagesSent(); return response; }
@Override public void process(DistributionMessage msg) { try { if (msg instanceof RemoveBucketReplyMessage) { RemoveBucketReplyMessage reply = (RemoveBucketReplyMessage) msg; this.removed = reply.removed(); if (DistributionManager.VERBOSE) { getDistributionManager().getLoggerI18n().fine( "RemoveBucketResponse is " + removed); } } } finally { super.process(msg); } }
public Object call() { InternalDistributedMember recipient = members[finalOtherVM]; PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(regionPath[0]); RemoveBucketResponse response = RemoveBucketMessage.send(recipient, pr, 0, false); if (response != null) { response.waitForRepliesUninterruptibly(); return true; } else { return Boolean.FALSE; } } })).booleanValue();
public Object call() { InternalDistributedMember recipient = members[finalOtherVM]; PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(regionPath[0]); RemoveBucketResponse response = RemoveBucketMessage.send(recipient, pr, 0, false); if (response != null) { response.waitForRepliesUninterruptibly(); return true; } else { return Boolean.FALSE; } } })).booleanValue();
/** * Ignore any incoming exception from other VMs, we just want an * acknowledgement that the message was processed. */ @Override protected void processException(ReplyException ex) { getDistributionManager().getLoggerI18n().fine( "RemoveBucketMessage ignoring exception", ex); }