/** * Create a new backup of the bucket, allowing redundancy to be exceeded. All colocated child * buckets will also be created. * * @param bucketId the bucket to create * @param isRebalance true if bucket creation is directed by rebalancing * @return true if the bucket and its colocated chain of children are created */ public CreateBucketResult createRedundantBucket(int bucketId, boolean isRebalance, InternalDistributedMember moveSource) { // recurse down to create each tier of children after creating leader bucket return grabBucket(bucketId, moveSource, true, false, isRebalance, null, false); }
@Test public void sendRefusalReplyIfDataStoreNotGrabbedBucket() { ManageBackupBucketMessage message = spy(new ManageBackupBucketMessage(recipent, regionId, processor, bucketId, isReblance, replaceOfflineDate, source, forecCreation)); when(partitionedRegionDataStore.isPartitionedRegionReady(partitionedRegion, bucketId)) .thenReturn(true); when(partitionedRegionDataStore.grabBucket(bucketId, source, forecCreation, replaceOfflineDate, isReblance, null, false)).thenReturn(PartitionedRegionDataStore.CreateBucketResult.FAILED); doReturn(recipent).when(message).getSender(); message.operateOnPartitionedRegion(distributionManager, partitionedRegion, 1); verify(distributionManager, times(1)).putOutgoing(replyMessage.capture()); assertThat(replyMessage.getValue().isAcceptedBucket()).isFalse(); assertThat(replyMessage.getValue().isNotYetInitialized()).isFalse(); }
@Test public void sendAcceptanceReplyIfDataStoreGrabbedBucket() { ManageBackupBucketMessage message = spy(new ManageBackupBucketMessage(recipent, regionId, processor, bucketId, isReblance, replaceOfflineDate, source, forecCreation)); when(partitionedRegionDataStore.isPartitionedRegionReady(partitionedRegion, bucketId)) .thenReturn(true); when(partitionedRegionDataStore.grabBucket(bucketId, source, forecCreation, replaceOfflineDate, isReblance, null, false)).thenReturn(PartitionedRegionDataStore.CreateBucketResult.CREATED); doReturn(recipent).when(message).getSender(); message.operateOnPartitionedRegion(distributionManager, partitionedRegion, 1); verify(distributionManager, times(1)).putOutgoing(replyMessage.capture()); assertThat(replyMessage.getValue().isAcceptedBucket()).isTrue(); assertThat(replyMessage.getValue().isNotYetInitialized()).isFalse(); }
if (grabBucket(bucketId, null, forceCreation, false, true, sender, false).nowExists()) { this.partitionedRegion.checkReadiness(); if (logger.isDebugEnabled()) {
boolean bucketManaged = prDS != null && prDS.grabBucket(bucketId, moveSource, forceCreation, replaceOfflineData, isRebalance, null, false).equals(CreateBucketResult.CREATED); if (!bucketManaged) {
/** * This method is called upon receipt and make the desired changes to the PartitionedRegion Note: * It is very important that this message does NOT cause any deadlocks as the sender will wait * indefinitely for the acknowledgement */ @Override protected boolean operateOnPartitionedRegion(ClusterDistributionManager dm, PartitionedRegion partitionedRegion, long startTime) { if (logger.isTraceEnabled(LogMarker.DM_VERBOSE)) { logger.trace(LogMarker.DM_VERBOSE, "ManageBucketMessage operateOnRegion: {}", partitionedRegion.getFullPath()); } partitionedRegion.checkReadiness(); // Don't allow closed PartitionedRegions that have // datastores to host buckets PartitionedRegionDataStore prDs = partitionedRegion.getDataStore(); // This is to ensure that initialization is complete for all colocated regions // before bucket creation request is serviced. BUGFIX for 35888 // GEODE-5255 boolean isReady = prDs.isPartitionedRegionReady(partitionedRegion, bucketId); if (!isReady) { // This VM is NOT ready to manage a new bucket, refuse operation sendManageBackupBucketReplyMessage(dm, partitionedRegion, startTime, ReplyType.INITIALIZING); return false; } boolean managingBucket = prDs.grabBucket(this.bucketId, this.moveSource, this.forceCreation, replaceOfflineData, this.isRebalance, null, false) == CreateBucketResult.CREATED; sendManageBackupBucketReplyMessage(dm, partitionedRegion, startTime, managingBucket ? ReplyType.SUCCESS : ReplyType.FAIL); return false; }
result = partitionedRegion.getDataStore().grabBucket(bid, getDistributionManager().getDistributionManagerId(), true, true, false, null, true); } else { result = colocatedRegion.getDataStore().grabBucket(bid, getDistributionManager().getDistributionManagerId(), true, true, false, null, true); result = partitionedRegion.getDataStore().grabBucket(bid, null, true, false, false, null, true); result = partitionedRegion.getDataStore().grabBucket(bid, null, true, false, false, null, true); result = partitionedRegion.getDataStore().grabBucket(bid, null, true, false, false, null, true);