use of org.apache.geode.internal.cache.persistence.PersistentMemberID in project geode by apache.
the class DistributedRegion method initialize.
/**
* Called while NOT holding lock on parent's subregions
*
* @throws IllegalStateException if region is not compatible with a region in another VM.
*/
@Override
protected void initialize(InputStream snapshotInputStream, InternalDistributedMember imageTarget, InternalRegionArguments internalRegionArgs) throws TimeoutException, IOException, ClassNotFoundException {
Assert.assertTrue(!isInitialized());
if (logger.isDebugEnabled()) {
logger.debug("DistributedRegion.initialize BEGIN: {}", getFullPath());
}
// if we're versioning entries we need a region-level version vector
if (this.scope.isDistributed() && this.concurrencyChecksEnabled) {
createVersionVector();
}
if (this.scope.isGlobal()) {
// create lock service eagerly now
getLockService();
}
try {
try {
PersistentMemberID persistentMemberId = null;
boolean recoverFromDisk = isRecoveryNeeded();
DiskRegion dskRgn = getDiskRegion();
if (recoverFromDisk) {
if (logger.isDebugEnabled()) {
logger.debug("DistributedRegion.getInitialImageAndRecovery: Starting Recovery");
}
// do recovery
dskRgn.initializeOwner(this);
if (logger.isDebugEnabled()) {
logger.debug("DistributedRegion.getInitialImageAndRecovery: Finished Recovery");
}
persistentMemberId = dskRgn.getMyPersistentID();
}
// Create OQL indexes before starting GII.
createOQLIndexes(internalRegionArgs, recoverFromDisk);
if (getDataPolicy().withReplication() || getDataPolicy().withPreloaded()) {
getInitialImageAndRecovery(snapshotInputStream, imageTarget, internalRegionArgs, recoverFromDisk, persistentMemberId);
} else {
new CreateRegionProcessor(this).initializeRegion();
if (snapshotInputStream != null) {
releaseBeforeGetInitialImageLatch();
loadSnapshotDuringInitialization(snapshotInputStream);
}
}
} catch (DiskAccessException dae) {
this.handleDiskAccessException(dae, true);
throw dae;
}
initMembershipRoles();
this.isInitializingThread = false;
// makes sure all latches are released if they haven't been already
super.initialize(null, null, null);
} finally {
if (this.eventTracker != null) {
this.eventTracker.setInitialized();
}
}
}
use of org.apache.geode.internal.cache.persistence.PersistentMemberID in project geode by apache.
the class BucketPersistenceAdvisor method recoveryDone.
public void recoveryDone(RuntimeException e) {
this.recovering = false;
if (!getPersistedMembers().isEmpty()) {
((BucketAdvisor) advisor).setHadPrimary();
}
// Make sure any removes that we saw during recovery are
// applied.
removeListener(recoveryListener);
for (PersistentMemberID id : recoveryListener.getRemovedMembers()) {
removeMember(id);
}
if (someMemberRecoveredLatch.getCount() > 0) {
this.recoveryException = e;
this.someMemberRecoveredLatch.countDown();
} else if (recoveryException != null) {
logger.fatal(LocalizedMessage.create(LocalizedStrings.BucketPersistenceAdvisor_ERROR_RECOVERYING_SECONDARY_BUCKET_0, new Object[] { proxyBucket.getPartitionedRegion().getFullPath(), proxyBucket.getBucketId() }), e);
}
}
use of org.apache.geode.internal.cache.persistence.PersistentMemberID in project geode by apache.
the class ShowMissingDiskStoresFunction method execute.
@Override
public void execute(FunctionContext context) {
final Set<PersistentMemberPattern> memberMissingIDs = new HashSet<PersistentMemberPattern>();
Set<ColocatedRegionDetails> missingColocatedRegions = new HashSet<ColocatedRegionDetails>();
if (context == null) {
throw new RuntimeException();
}
try {
final InternalCache cache = getCache();
if (cache != null && !cache.isClosed()) {
final DistributedMember member = cache.getMyId();
// Missing DiskStores
PersistentMemberManager mm = cache.getPersistentMemberManager();
Map<String, Set<PersistentMemberID>> waitingRegions = mm.getWaitingRegions();
for (Set<PersistentMemberID> entry : waitingRegions.values()) {
for (PersistentMemberID id : entry) {
memberMissingIDs.add(new PersistentMemberPattern(id));
}
}
// Missing colocated regions
Set<PartitionedRegion> prs = cache.getPartitionedRegions();
for (PartitionedRegion pr : prs) {
List<String> missingChildRegions = pr.getMissingColocatedChildren();
for (String child : missingChildRegions) {
missingColocatedRegions.add(new ColocatedRegionDetails(member.getHost(), member.getName(), pr.getFullPath(), child));
}
}
}
if (memberMissingIDs.isEmpty() && missingColocatedRegions.isEmpty()) {
context.getResultSender().lastResult(null);
} else {
if (!memberMissingIDs.isEmpty()) {
if (missingColocatedRegions.isEmpty()) {
context.getResultSender().lastResult(memberMissingIDs);
} else {
context.getResultSender().sendResult(memberMissingIDs);
}
}
if (!missingColocatedRegions.isEmpty()) {
context.getResultSender().lastResult(missingColocatedRegions);
}
}
} catch (Exception e) {
context.getResultSender().sendException(e);
}
}
use of org.apache.geode.internal.cache.persistence.PersistentMemberID in project geode by apache.
the class AbstractDiskRegion method addMyInitializingPMID.
public PersistentMemberID addMyInitializingPMID(PersistentMemberID pmid) {
PersistentMemberID result = this.myInitializingId;
this.myInitializingId = pmid;
if (result != null) {
this.myInitializedId = result;
}
return result;
}
use of org.apache.geode.internal.cache.persistence.PersistentMemberID in project geode by apache.
the class PRHARedundancyProvider method endBucketCreationLocally.
public void endBucketCreationLocally(int bucketId, InternalDistributedMember newPrimary) {
// has been destroyed.
if (prRegion.getCancelCriterion().isCancelInProgress() || prRegion.isDestroyed()) {
return;
}
if (logger.isDebugEnabled()) {
logger.debug("endBucketCreationLocally: for region {} bucketId={} new primary: {}", this.prRegion.getFullPath(), bucketId, newPrimary);
}
BucketAdvisor bucketAdvisor = prRegion.getRegionAdvisor().getBucketAdvisor(bucketId);
final ProxyBucketRegion proxyBucketRegion = bucketAdvisor.getProxyBucketRegion();
BucketPersistenceAdvisor persistentAdvisor = proxyBucketRegion.getPersistenceAdvisor();
// on the persistent advisor and marking a bucket as initialized twice.
synchronized (proxyBucketRegion) {
if (persistentAdvisor != null) {
BucketRegion realBucket = proxyBucketRegion.getCreatedBucketRegion();
if (realBucket != null) {
PersistentMemberID persistentID = realBucket.getPersistentID();
persistentAdvisor.endBucketCreation(persistentID);
}
}
// We've received an endBucketCreationMessage, but the primary
// may not have. So now we wait for the chosen member to become
// primary.
bucketAdvisor.setPrimaryElector(newPrimary);
if (prRegion.getGemFireCache().getMyId().equals(newPrimary)) {
// If we're the choosen primary, volunteer for primary now
if (bucketAdvisor.isHosting()) {
bucketAdvisor.clearPrimaryElector();
bucketAdvisor.volunteerForPrimary();
}
} else {
// that case, volunteer for primary now.
if (!bucketAdvisor.adviseInitialized().contains(newPrimary)) {
bucketAdvisor.clearPrimaryElector();
bucketAdvisor.volunteerForPrimary();
}
// clear the primary elector field.
if (bucketAdvisor.getHadPrimary()) {
bucketAdvisor.clearPrimaryElector();
bucketAdvisor.volunteerForPrimary();
}
}
}
// send out a profile update to indicate the persistence is initialized, if needed.
if (persistentAdvisor != null) {
bucketAdvisor.endBucketCreation();
}
List<PartitionedRegion> colocatedWithList = ColocationHelper.getColocatedChildRegions(prRegion);
for (PartitionedRegion child : colocatedWithList) {
if (child.getRegionAdvisor().isBucketLocal(bucketId)) {
child.getRedundancyProvider().endBucketCreationLocally(bucketId, newPrimary);
}
}
}
Aggregations