private RemoteRegionOperation(InternalDistributedMember recipient, DistributedRegion region, Operation op) { super(recipient, region.getFullPath(), new RemoteOperationResponse(region.getSystem(), Collections.singleton(recipient))); this.op = op; this.region = region; }
@Override public String toString() { //bug 37189 These strings are a work-around for an escaped reference //in ReplyProcessor21 constructor String msgsBeingProcessedStr = (this.msgsBeingProcessed == null) ? "nullRef" : String.valueOf(this.msgsBeingProcessed.get()); String regionStr = (InitialImageOperation.this.region == null) ? "nullRef" : InitialImageOperation.this.region.getFullPath(); String numMembersStr = (this.members == null) ? "nullRef" : String.valueOf(numMembers()); // String membersToStr = (this.members == null) ? "nullRef" : membersToString(); return "<" + this.getClass().getName() + " " + this.getProcessorId() + " waiting for " + numMembersStr + " replies" + (exception == null ? "" : (" exception: " + exception)) + " from " + membersToString() + "; waiting for " + msgsBeingProcessedStr + " messages in-flight; " + "region=" + regionStr + "; abort=" + this.abort + ">"; }
@Override public String toString() { //bug 37189 These strings are a work-around for an escaped reference //in ReplyProcessor21 constructor String msgsBeingProcessedStr = (this.msgsBeingProcessed == null) ? "nullRef" : String.valueOf(this.msgsBeingProcessed.get()); String regionStr = (InitialImageOperation.this.region == null) ? "nullRef" : InitialImageOperation.this.region.getFullPath(); String numMembersStr = (this.members == null) ? "nullRef" : String.valueOf(numMembers()); // String membersToStr = (this.members == null) ? "nullRef" : membersToString(); return "<" + this.getClass().getName() + " " + this.getProcessorId() + " waiting for " + numMembersStr + " replies" + (exception == null ? "" : (" exception: " + exception)) + " from " + membersToString() + "; waiting for " + msgsBeingProcessedStr + " messages in-flight; " + "region=" + regionStr + "; abort=" + this.abort + ">"; }
@Override protected DistributionMessage createRequestMessage(Set recipients, FunctionStreamingResultCollector processor, boolean isReExecute, boolean isFnSerializationReqd) { DistributedRegionFunctionStreamingMessage msg = new DistributedRegionFunctionStreamingMessage( this.region.getFullPath(), this.functionObject, processor.getProcessorId(), this.filter, this.memberArgs.get(recipients .toArray()[0]), isReExecute, isFnSerializationReqd, this.region.getTXState()); msg.setRecipients(recipients); return msg; } }
/** release locks in other members obtained for an RVV clear */ public static void releaseLocks(RegionEventImpl regionEvent, Set<InternalDistributedMember> recipients) { DistributedRegion region = (DistributedRegion) regionEvent.getRegion(); ReleaseClearLockMessage.send(recipients, region.getDistributionManager(), region.getFullPath()); }
/** release locks in other members obtained for an RVV clear */ public static void releaseLocks(RegionEventImpl regionEvent, Set<InternalDistributedMember> recipients) { DistributedRegion region = (DistributedRegion) regionEvent.getRegion(); ReleaseClearLockMessage.send(recipients, region.getDistributionManager(), region.getFullPath()); }
public boolean goWithFullGII(DistributedRegion rgn, RegionVersionVector requesterRVV) { if (getSender().getVersionObject().compareTo(Version.GFE_80) < 0) { // pre-8.0 could not handle a delta-GII return true; } if (!rgn.getDataPolicy().withPersistence()) { // non-persistent regions always do full GII if (logger.isDebugEnabled()) { logger.debug("Region {} is not a persistent region, do full GII", rgn.getFullPath()); } return true; } if (!rgn.getVersionVector().isRVVGCDominatedBy(requesterRVV)) { if (logger.isDebugEnabled()) { logger.debug("Region {}'s local RVVGC is not dominated by remote RVV={}, do full GII", rgn.getFullPath(), requesterRVV); } return true; } // TODO GGG: verify GII after UpgradeDiskStore return false; }
private ResultCollector executeOnReplicate( final DistributedRegionFunctionExecutor execution, final Function function, final Object args, ResultCollector rc, final Set filter, final DistributedMember target) { final Set singleMember = Collections.singleton(target); execution.validateExecution(function, singleMember); execution.setExecutionNodes(singleMember); HashMap<InternalDistributedMember, Object> memberArgs = new HashMap<InternalDistributedMember, Object>(); memberArgs.put((InternalDistributedMember)target, execution.getArgumentsForMember(target.getId())); ResultSender resultSender = new DistributedRegionFunctionResultSender(null, rc, function, execution.getServerResultSender()); DistributedRegionFunctionResultWaiter waiter = new DistributedRegionFunctionResultWaiter( this.getSystem(), this.getFullPath(), rc, function, filter, Collections.singleton(target), memberArgs, resultSender); rc = waiter.getFunctionResultFrom(Collections.singleton(target), function, execution); return rc; }
/** * Throws RegionAccessException if required roles are missing and the * LossAction is NO_ACCESS * * @throws RegionAccessException * if required roles are missing and the LossAction is NO_ACCESS */ @Override protected void checkForNoAccess() { if (this.requiresReliabilityCheck && this.isMissingRequiredRoles) { if (getMembershipAttributes().getLossAction().isNoAccess()) { synchronized (this.missingRequiredRoles) { if (!this.isMissingRequiredRoles) return; Set roles = Collections.unmodifiableSet(new HashSet( this.missingRequiredRoles)); throw new RegionAccessException(LocalizedStrings.DistributedRegion_OPERATION_IS_DISALLOWED_BY_LOSSACTION_0_BECAUSE_THESE_REQUIRED_ROLES_ARE_MISSING_1.toLocalizedString(new Object[] {getMembershipAttributes().getLossAction(), roles}), getFullPath(), roles); } } } }
/** * Throws RegionAccessException if required roles are missing and the * LossAction is NO_ACCESS * * @throws RegionAccessException * if required roles are missing and the LossAction is NO_ACCESS */ @Override protected void checkForNoAccess() { if (this.requiresReliabilityCheck && this.isMissingRequiredRoles) { if (getMembershipAttributes().getLossAction().isNoAccess()) { synchronized (this.missingRequiredRoles) { if (!this.isMissingRequiredRoles) return; Set roles = Collections.unmodifiableSet(new HashSet( this.missingRequiredRoles)); throw new RegionAccessException(LocalizedStrings.DistributedRegion_OPERATION_IS_DISALLOWED_BY_LOSSACTION_0_BECAUSE_THESE_REQUIRED_ROLES_ARE_MISSING_1.toLocalizedString(new Object[] {getMembershipAttributes().getLossAction(), roles}), getFullPath(), roles); } } } }
public boolean goWithFullGII(DistributedRegion rgn, RegionVersionVector requesterRVV) { LogWriterI18n logger = rgn.getLogWriterI18n(); if (!rgn.getDataPolicy().withPersistence()) { // non-persistent regions always do full GII if (logger.fineEnabled()) { logger.fine("Region " + rgn.getFullPath() + " is not a persistent region, do full GII"); } return true; } if (!rgn.getVersionVector().isRVVGCDominatedBy(requesterRVV)) { if (logger.fineEnabled()) { logger.fine("Region " + rgn.getFullPath() + "'s local RVVGC is not dominated by remote RVV="+requesterRVV+", do full GII"); } return true; } // TODO GGG: verify GII after UpgradeDiskStore return false; }
private void operateOnCache(GemFireCacheImpl cache) { final boolean isDebugEnabled = logger.isDebugEnabled(); for (DistributedRegion r: this.getDistributedRegions(cache)) { CacheDistributionAdvisor cda = (CacheDistributionAdvisor)r.getDistributionAdvisor(); CacheDistributionAdvisor.CacheProfile cp = (CacheDistributionAdvisor.CacheProfile)cda.getProfile(getSender()); if (cp != null){ if (isDebugEnabled) { logger.debug("Setting hasCacheServer flag on region \"{}\" for {}", r.getFullPath(), getSender()); } cp.hasCacheServer = true; } } for (PartitionedRegion r: this.getPartitionedRegions(cache)) { CacheDistributionAdvisor cda = (CacheDistributionAdvisor)r.getDistributionAdvisor(); CacheDistributionAdvisor.CacheProfile cp = (CacheDistributionAdvisor.CacheProfile)cda.getProfile(getSender()); if (cp != null){ if (isDebugEnabled) { logger.debug("Setting hasCacheServer flag on region \"{}\" for {}", r.getFullPath(), getSender()); } cp.hasCacheServer = true; } } }
private void unlockTargetBucketLock(InternalDistributedMember recipient) { if (hasLockedBucket) { LogWriterI18n logger = this.region.getDistributionManager().getLoggerI18n(); logger.info(LocalizedStrings.DEBUG, "Processing SnapshotBucketLockReleaseProcessor to " + recipient); try { SnapshotBucketLockReleaseMessage.send(recipient, this.region.getDistributionManager(), region.getFullPath()); logger.info(LocalizedStrings.DEBUG, "Processing SnapshotBucketLockReleaseProcessor done " + recipient); } catch (Throwable t) { logger.warning(LocalizedStrings.DEBUG, t); } } }
/** pause local operations so that a clear() can be performed and flush comm channels to the given member */ public void lockLocallyForClear(DM dm, InternalDistributedMember locker) { RegionVersionVector rvv = getVersionVector(); if (rvv != null) { // block new operations from being applied to the region map rvv.lockForClear(getFullPath(), dm, locker); //Check for region destroyed after we have locked, to make sure //we don't continue a clear if the region has been destroyed. checkReadiness(); // wait for current operations to if (!locker.equals(dm.getDistributionManagerId())) { Set<InternalDistributedMember> mbrs = getDistributionAdvisor().adviseCacheOp(); StateFlushOperation.flushTo(mbrs, this); } } }
/** pause local operations so that a clear() can be performed and flush comm channels to the given member */ public void lockLocallyForClear(DM dm, InternalDistributedMember locker) { RegionVersionVector rvv = getVersionVector(); if (rvv != null) { // block new operations from being applied to the region map rvv.lockForClear(getFullPath(), dm, locker); //Check for region destroyed after we have locked, to make sure //we don't continue a clear if the region has been destroyed. checkReadiness(); // wait for current operations to if (!locker.equals(dm.getDistributionManagerId())) { Set<InternalDistributedMember> mbrs = getDistributionAdvisor().adviseCacheOp(); StateFlushOperation.flushTo(mbrs, this); } } }
@Override protected boolean operateOnRegion(CacheEvent event, DistributionManager dm) throws EntryNotFoundException { DistributedRegion region = (DistributedRegion)event.getRegion(); switch (this.clearOp) { case OP_CLEAR: region.clearRegionLocally((RegionEventImpl)event, false, this.rvv); region.notifyBridgeClients(event); this.appliedOperation = true; break; case OP_LOCK_FOR_CLEAR: if (region.getDataPolicy().withStorage()) { DistributedClearOperation.regionLocked(this.getSender(), region.getFullPath(), region); region.lockLocallyForClear(dm, this.getSender()); } this.appliedOperation = true; break; } return true; }
@Override protected boolean operateOnRegion(CacheEvent event, DistributionManager dm) throws EntryNotFoundException { DistributedRegion region = (DistributedRegion)event.getRegion(); switch (this.clearOp) { case OP_CLEAR: region.clearRegionLocally((RegionEventImpl)event, false, this.rvv); region.notifyBridgeClients((RegionEventImpl)event); this.appliedOperation = true; break; case OP_LOCK_FOR_CLEAR: if (region.getDataPolicy().withStorage()) { DistributedClearOperation.regionLocked(this.getSender(), region.getFullPath(), region); region.lockLocallyForClear(dm, this.getSender()); } this.appliedOperation = true; break; } return true; }
@Override public void becomeLockGrantor() { checkReadiness(); checkForLimitedOrNoAccess(); if (!this.scope.isGlobal()) { throw new IllegalStateException(LocalizedStrings.DistributedRegion_DISTRIBUTION_LOCKS_ARE_ONLY_SUPPORTED_FOR_REGIONS_WITH_GLOBAL_SCOPE_NOT_0.toLocalizedString(this.scope)); } DistributedLockService svc = getLockService(); try { super.becomeLockGrantor(); if (!svc.isLockGrantor()) { svc.becomeLockGrantor(); } } finally { if (getSystem().getLogWriter().fineEnabled() && !svc.isLockGrantor()) { getSystem().getLogWriter().fine( "isLockGrantor is false after becomeLockGrantor for " + getFullPath()); } } }
protected void initMessage(CacheOperationMessage msg, DirectReplyProcessor p) { final DistributedRegion region = getRegion(); msg.regionPath = region.getFullPath(); msg.processorId = p == null ? 0 : p.getProcessorId(); msg.processor = p; if (this.event.getOperation().isEntry()) { EntryEventImpl entryEvent = getEvent(); msg.callbackArg = entryEvent.getRawCallbackArgument(); msg.possibleDuplicate = entryEvent.isPossibleDuplicate(); VersionTag tag = entryEvent.getVersionTag(); msg.setInhibitNotificationsBit(entryEvent.inhibitAllNotifications()); if (tag != null && tag.hasValidVersion()) { msg.setVersionTag(tag); } } else { msg.callbackArg = ((RegionEventImpl)this.event).getRawCallbackArgument(); } msg.op = this.event.getOperation(); msg.owner = this; msg.regionAllowsConflation = region.getEnableAsyncConflation(); }
protected void initMessage(CacheOperationMessage msg, DirectReplyProcessor p) { msg.regionPath = getRegion().getFullPath(); msg.processorId = p == null ? 0 : p.getProcessorId(); msg.processor = p; if (this.event.getOperation().isEntry()) { EntryEventImpl entryEvent = getEvent(); msg.callbackArg = entryEvent.getRawCallbackArgument(); msg.possibleDuplicate = entryEvent.isPossibleDuplicate(); VersionTag tag = entryEvent.getVersionTag(); msg.setInhibitNotificationsBit(entryEvent.inhibitAllNotifications()); if (tag != null && tag.hasValidVersion()) { msg.setVersionTag(tag); } } else { msg.callbackArg = ((RegionEventImpl)this.event).getRawCallbackArgument(); } msg.op = this.event.getOperation(); msg.owner = this; msg.regionAllowsConflation = getRegion().getEnableAsyncConflation(); }