Search in sources :

Example 1 with CreateBucketResult

use of org.apache.geode.internal.cache.PartitionedRegionDataStore.CreateBucketResult in project geode by apache.

the class ProxyBucketRegion method recoverFromDisk.

public void recoverFromDisk() {
    final boolean isDebugEnabled = logger.isDebugEnabled();
    RuntimeException exception = null;
    if (isDebugEnabled) {
        logger.debug("{} coming to recover from disk. wasHosting {}", getFullPath(), persistenceAdvisor.wasHosting());
    }
    try {
        if (persistenceAdvisor.wasHosting()) {
            if (isDebugEnabled) {
                logger.debug("{} used to host data. Attempting to recover.", getFullPath());
            }
            CreateBucketResult result;
            if (hasPersistentChildRegion()) {
                // If this is a parent PR, create the bucket, possibly going over
                // redundancy. We need to do this so that we can create the child
                // region in this member. This member may have the latest data for the
                // child region.
                result = partitionedRegion.getDataStore().grabBucket(bid, getDistributionManager().getDistributionManagerId(), true, true, false, null, true);
            } else {
                if (this.partitionedRegion.isShadowPR() && this.partitionedRegion.getColocatedWith() != null) {
                    PartitionedRegion colocatedRegion = ColocationHelper.getColocatedRegion(this.partitionedRegion);
                    if (this.partitionedRegion.getDataPolicy().withPersistence() && !colocatedRegion.getDataPolicy().withPersistence()) {
                        result = colocatedRegion.getDataStore().grabBucket(bid, getDistributionManager().getDistributionManagerId(), true, true, false, null, true);
                        if (result.nowExists()) {
                            result = partitionedRegion.getDataStore().grabBucket(bid, null, true, false, false, null, true);
                        }
                    } else {
                        result = partitionedRegion.getDataStore().grabBucket(bid, null, true, false, false, null, true);
                    }
                } else {
                    result = partitionedRegion.getDataStore().grabBucket(bid, null, true, false, false, null, true);
                }
            }
            if (result.nowExists()) {
                return;
            } else if (result != CreateBucketResult.REDUNDANCY_ALREADY_SATISFIED) {
                // TODO prpersist - check cache closure, create new error message
                this.partitionedRegion.checkReadiness();
                throw new InternalGemFireError("Unable to restore the persistent bucket " + this.getName());
            }
            if (isDebugEnabled) {
                logger.debug("{} redundancy is already satisfied, so discarding persisted data. Current hosts {}", getFullPath(), advisor.adviseReplicates());
            }
            // Destroy the data if we can't create the bucket, or if the redundancy is already satisfied
            destroyOfflineData();
        }
        if (isDebugEnabled) {
            logger.debug("{} initializing membership view from peers", getFullPath());
        }
        persistenceAdvisor.initializeMembershipView();
    } catch (DiskAccessException dae) {
        this.partitionedRegion.handleDiskAccessException(dae);
        throw dae;
    } catch (RuntimeException e) {
        exception = e;
        throw e;
    } finally {
        persistenceAdvisor.recoveryDone(exception);
    }
}
Also used : CreateBucketResult(org.apache.geode.internal.cache.PartitionedRegionDataStore.CreateBucketResult) DiskAccessException(org.apache.geode.cache.DiskAccessException) InternalGemFireError(org.apache.geode.InternalGemFireError)

Aggregations

InternalGemFireError (org.apache.geode.InternalGemFireError)1 DiskAccessException (org.apache.geode.cache.DiskAccessException)1 CreateBucketResult (org.apache.geode.internal.cache.PartitionedRegionDataStore.CreateBucketResult)1