public void tearDown2() throws Exception { this.advisor.close(); super.tearDown2(); }
@Override protected synchronized boolean basicAddProfile(Profile p) { boolean added = super.basicAddProfile(p); DistributionAdvisee advisee = getAdvisee(); if (advisee instanceof LocalRegion) { final Profile[] newProfiles = this.profiles; ((LocalRegion)advisee).profileAdded(this, p, newProfiles); } return added; }
@Override public Profile getProfile() { return getDistributionAdvisor().createProfile(); }
@SuppressWarnings("synthetic-access") public void memberDeparted(final InternalDistributedMember id, boolean crashed) { boolean shouldSync = crashed && shouldSyncForCrashedMember(id); final Profile profile = getProfile(id); boolean removed = removeId(id, crashed, false/*destroyed*/, true/*fromMembershipListener*/); // if concurrency checks are enabled and this was a crash we may need to // sync with other members in case an update was lost. We do this in the // waiting thread pool so as not to block other membership listeners if (removed && shouldSync) { syncForCrashedMember(id, profile); } }
/** * Atomically add listener to the list to receive notification when a * *new* profile is added or a profile is removed, and return adviseGeneric(). * This ensures that no membership listener calls are missed, but there is no guarantee * that there won't be redundant listener calls. */ public Set addMembershipListenerAndAdviseGeneric(MembershipListener listener) { initializationGate(); // exchange profiles before acquiring lock on membershipListeners membershipListeners.putIfAbsent(listener, Boolean.TRUE); return adviseGeneric(); }
/** Creates the current distribution profile for this member */ public Profile createProfile() { Profile newProfile = instantiateProfile( getDistributionManager().getId(), incrementAndGetVersion()); getAdvisee().fillInProfile(newProfile); return newProfile; }
if (!isCurrentMember(newProfile)) { if (logger.isTraceEnabled(LogMarker.DA)) { logger.trace(LogMarker.DA, "putProfile: ignoring {}; not in current view for {}", newProfile.getDistributedMember(), getAdvisee().getFullPath()); (Integer) this.removedProfiles.get(newProfile.getId()); if (removedSerialNumber != null && !isNewerSerialNumber(newProfile.getSerialNumber(), removedSerialNumber.intValue())) { logger.trace(LogMarker.DA, "putProfile: Skipping putProfile: {} is not newer than serialNumber {} for {}", newProfile, removedSerialNumber, getAdvisee().getFullPath()); Profile oldProfile = getProfile(newProfile.getId()); final boolean isDebugEnabled_DA = logger.isTraceEnabled(LogMarker.DA); if (isDebugEnabled_DA) { logger.trace(LogMarker.DA, "putProfile: Updating existing profile: {} with new profile: {} for {}", oldProfile, newProfile, getAdvisee().getFullPath()); if (oldProfile != null && !isNewerProfile(newProfile, oldProfile)) { logger.trace(LogMarker.DA, "putProfile: Ignoring {} because it's older than or same as {} for {}", newProfile, oldProfile,getAdvisee().getFullPath()); forceNewMembershipVersion(); boolean doAddOrUpdate = evaluateProfiles(newProfile, oldProfile); if (!doAddOrUpdate) { return false; if (basicAddProfile(newProfile)) { profileCreated(newProfile); notifyListenersProfileAdded(newProfile);
final boolean isDebugEnabled_DA = logger.isTraceEnabled(LogMarker.DA); if (isDebugEnabled_DA) { logger.trace(LogMarker.DA, "updateRemovedProfiles: ensure member {} with serial {} is removed from region {}", memberId, serialNum, getAdvisee().getFullPath()); if (stillInView(memberId)) { boolean isNews = true; Profile profileToRemove = getProfile(memberId); if (profileToRemove != null) { if (isNewerSerialNumber(profileToRemove.serialNumber, serialNum)) { if (isDebugEnabled_DA) { logger.trace(LogMarker.DA, "updateRemovedProfiles: member {} has profile {} which is newer than serial {}", memberId, profileToRemove, serialNum); && isNewerSerialNumber(oldSerial.intValue(), serialNum)) { if (isDebugEnabled_DA) { logger.trace(LogMarker.DA, "updateRemovedProfiles: member {} sent removal of serial {} but we hae already removed {}", memberId, serialNum, oldSerial); removedId = basicRemoveId(memberId, false, regionDestroyed); removedId = basicRemoveId(memberId, false, regionDestroyed);
public JmxManagerAdvisee(GemFireCacheImpl cache) { this.serialNumber = DistributionAdvisor.createSerialNumber(); this.cache = cache; } @Override
boolean fromMembershipListener) { if (VERBOSE) { getLogWriter().info( LocalizedStrings.DEBUG, "removeId: removing member " + memberId + " from resource " + getAdvisee().getFullPath() Profile profileToRemove = getProfile(memberId); while (profileToRemove != null) { result = true; if (VERBOSE) { getLogWriter().info( LocalizedStrings.DEBUG, "removeId: tracking removal of " + profileToRemove basicRemoveId(profileToRemove.getId(), crashed, destroyed); profileToRemove = getProfile(memberId); boolean result = basicRemoveId(memberId, crashed, destroyed); while (basicRemoveId(memberId, crashed, destroyed)) {
final boolean isDebugEnabled_DA = logger.isTraceEnabled(LogMarker.DA); if (isDebugEnabled_DA) { logger.trace(LogMarker.DA, "removeId: removing member {} from resource {}", memberId, getAdvisee().getFullPath()); Profile profileToRemove = getProfile(memberId); while (profileToRemove != null) { result = true; basicRemoveId(profileToRemove.getId(), crashed, destroyed); profileToRemove = getProfile(memberId); boolean result = basicRemoveId(memberId, crashed, destroyed); while (basicRemoveId(memberId, crashed, destroyed)) {
if (msg.containsRegionContentChange() && (advisor = msg.getDistributionAdvisor()) != null) { viewVersion = advisor.startOperation(); if (TXStateProxy.LOG_VERSIONS) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_QUERYDISTRIB, advisor.endOperation(viewVersion); if (TXStateProxy.LOG_VERSIONS) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_QUERYDISTRIB, advisor.endOperation(viewVersion); if (TXStateProxy.LOG_VERSIONS) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_QUERYDISTRIB,
/** Provide recipients for profile exchange, * called by UpdateAttributesProcessor and CreateRegionProcessor. * Can not be initialized at this point because it is only called in * the following scenarios: * 1) We're doing a lazy initialization and synchronization on initializeLock * prevents other threads from causing initialization on this advisor. * 2) We're creating a new region and doing profile exchange as part of region * initialization, in which case no other threads have access to the region * or this advisor. */ public Set adviseProfileExchange() { // Get the list of recipients from the nearest initialized advisor // in the parent chain Assert.assertTrue(!isInitialized()); DistributionAdvisor advisor; DistributionAdvisee advisee = getAdvisee(); do { advisee = advisee.getParentAdvisee(); if (advisee == null) return getDefaultDistributionMembers(); advisor = advisee.getDistributionAdvisor(); } while (!advisor.isInitialized()); // do not call adviseGeneric because we don't want to trigger another // profile exchange on the parent return advisor.adviseFilter(null); }
/** * Removes the specified profile if it is registered with this advisor. * @return true if it was registered; false if not. * @since 5.7 */ public boolean removeProfile(Profile profile, boolean destroyed) { return removeId(profile.getId(), false, destroyed, false/*fromMembershipListener*/); }
public DM getDistributionManager() { return getAdvisee().getDistributionManager(); }
@Override public boolean execute(Object o, long viewVersion) { if (viewVersion != -1) { DistributionAdvisor advisor = (DistributionAdvisor)o; advisor.endOperation(viewVersion); if (LOG_VERSIONS) { LogWriterI18n logger = InternalDistributedSystem.getLoggerI18n(); if (logger != null) { logger.info(LocalizedStrings.DEBUG, "TXBatch: done dispatching operation for " + advisor.getAdvisee().getFullPath() + " in view version " + viewVersion); } } } return true; } };
/** * Removes the profile for the specified member and serial number * * @param memberId the member to remove the profile for * @param serialNum specific serial number to remove * @return true if a matching profile for the member was found */ // TODO could this be merged with removeId? public boolean removeIdWithSerial(InternalDistributedMember memberId, int serialNum, boolean regionDestroyed) { //try { if (VERBOSE) { getLogWriter().info( LocalizedStrings.DEBUG, "removeIdWithSerial: removing member " + memberId + " with serial " + serialNum + " from resource " + getAdvisee().getName() //, new Exception("stack trace") ); } Assert.assertTrue(serialNum != ILLEGAL_SERIAL); return updateRemovedProfiles(memberId, serialNum, regionDestroyed); /*} finally { if (DEBUG) { getLogWriter().info("removeIdWithSerial " + memberId + " exiting " + toStringWithProfiles()); } }*/ }
/** exchange profiles to initialize this advisor */ private void exchangeProfiles() { Assert.assertHoldsLock(this,false); // causes deadlock Assert.assertHoldsLock(this.initializeLock,true); new UpdateAttributesProcessor(getAdvisee()).distribute(true); setInitialized(); }
/** * Removes the profile for the specified member and serial number * * @param memberId the member to remove the profile for * @param serialNum specific serial number to remove * @return true if a matching profile for the member was found */ // TODO could this be merged with removeId? public boolean removeIdWithSerial(InternalDistributedMember memberId, int serialNum, boolean regionDestroyed) { if (logger.isTraceEnabled(LogMarker.DA)) { logger.trace(LogMarker.DA, "removeIdWithSerial: removing member {} with serial {} from resource {}", memberId, serialNum, getAdvisee().getName()); } Assert.assertTrue(serialNum != ILLEGAL_SERIAL); return updateRemovedProfiles(memberId, serialNum, regionDestroyed); }
/** Get the {@link Profile} for the given member including self. */ public GfxdProfile getProfile(InternalDistributedMember member) { Profile profile = super.getProfile(member); if (profile != null || (profile = getMyProfile()).getDistributedMember().equals(member)) { return (GfxdProfile)profile; } return null; }