@Override public String toString() { return "CacheDistributionAdvisor for region " + getAdvisee().getFullPath(); }
UpdateAttributesMessage getUpdateAttributesMessage(ReplyProcessor21 processor, Set recipients) { UpdateAttributesMessage msg = new UpdateAttributesMessage(); msg.adviseePath = this.advisee.getFullPath(); msg.setRecipients(recipients); if (processor != null) { msg.processorId = processor.getProcessorId(); } msg.profile = this.advisee.getProfile(); msg.exchangeProfiles = this.profileExchange; msg.removeProfile = this.removeProfile; return msg; }
@Override public InternalDistributedSystem getSystem() { return getAdvisee().getSystem(); }
@Override public String toString() { //String identity = super.toString(); //String identity = "BucketAdvisor " + getAdvisee().getFullPath() + // ":" + getAdvisee().getSerialNumber(); //identity = identity.substring(identity.lastIndexOf(".")+1); //final StringBuffer sb = new StringBuffer("[" + identity + ": "); final StringBuilder sb = new StringBuilder("[BucketAdvisor ") .append(getAdvisee().getFullPath()).append(':') .append(getAdvisee().getSerialNumber()).append(": "); sb.append("state=").append(primaryStateToString()); sb.append("]"); return sb.toString(); }
/** * Attempts to process this message with the specified * {@link DistributionAdvisee}. Also if exchange profiles then add the * profile from {@link DistributionAdvisee} to reply. * * @param advisee * the CacheDistributionAdvisee to apply this profile to * @param removeProfile * true to remove profile else add profile * @param exchangeProfiles * true to add the profile to reply */ protected final void handleDistributionAdvisee(DistributionAdvisee advisee, boolean removeProfile, boolean exchangeProfiles, final List<Profile> replyProfiles) { final DistributionAdvisor da; if (advisee != null && (da = advisee.getDistributionAdvisor()) != null) { if (removeProfile) { da.removeProfile(this, false); } else { da.putProfile(this); } if (exchangeProfiles) { // assume non-null replyProfiles when exchangeProfiles is true replyProfiles.add(advisee.getProfile()); } } }
public void sendProfileUpdate(boolean exchangeProfiles) { DM mgr = this.advisee.getDistributionManager(); DistributionAdvisor advisor = this.advisee.getDistributionAdvisor(); this.profileExchange = exchangeProfiles; InternalDistributedSystem system = this.advisee.getSystem(); processor = new UpdateAttributesReplyProcessor(system, recipients); UpdateAttributesMessage message = getUpdateAttributesMessage(processor, recipients);
public void run() { assertTrue(Locator.hasLocator()); InternalLocator l = (InternalLocator)Locator.getLocator(); DistributionAdvisee advisee = l.getServerLocatorAdvisee(); ControllerAdvisor ca = (ControllerAdvisor)advisee.getDistributionAdvisor(); assertEquals(0, ca.fetchControllers().size()); assertEquals(0, ca.fetchBridgeServers().size()); } });
/** * Dumps out all profiles in this advisor. * @param infoMsg prefix message to log */ public void dumpProfiles(String infoMsg) { Profile[] profs = this.profiles; final StringBuffer buf = new StringBuffer(2000); if (infoMsg != null) { buf.append(infoMsg); buf.append(": "); } buf.append("FYI, DUMPING PROFILES IN "); buf.append(toString()); buf.append(":\n"); buf.append("My Profile="); buf.append(getAdvisee().getProfile()); buf.append("\nOther Profiles:\n"); for (int i = 0; i < profs.length; i++) { buf.append("\t"); buf.append(profs[i].toString()); buf.append("\n"); } if (logger.isDebugEnabled()) { logger.debug(buf.toString()); } }
public void broadcastChange() { try { Set<InternalDistributedMember> recips = adviseGeneric(); // for now just tell everyone JmxManagerProfile p = new JmxManagerProfile(getDistributionManager().getId(), incrementAndGetVersion()); getAdvisee().fillInProfile(p); JmxManagerProfileMessage.send(getAdvisee().getSystem().getDistributionManager(), recips, p); } catch (CancelException ignore) { } }
/** * Initiates volunteering for primary. Repeated calls are harmless. Invoked * by the BucketAdvisor. Caller must be synchronized on BucketAdvisor. */ void volunteerForPrimary() { boolean handedOff = false; while (!handedOff) { getAdvisee().getCancelCriterion().checkCancelInProgress(null); boolean interrupted = Thread.interrupted(); try { execute(new Runnable() { public void run() { doVolunteerForPrimary(); } }); handedOff = true; } catch (InterruptedException e) { interrupted = true; getAdvisee().getCancelCriterion().checkCancelInProgress(e); } finally { if (interrupted) { Thread.currentThread().interrupt(); } } } }
/** 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); }
public DM getDistributionManager() { return getAdvisee().getDistributionManager(); }
/** * Returns all {@link InternalDistributedMember}s currently * flagged as primary. * <p> * Since profile messages may arrive out of order from different members, * more than one member may temporarily be flagged as primary. * <p> * The user of this BucketAdvisor should simply assume that the first * profile is primary until the dust settles, leaving only one primary * profile. * * @return zero or greater array of primary members */ private InternalDistributedMember[] findPrimaryMembers() { Set primaryMembers = adviseFilter(new Filter() { public boolean include(Profile profile) { assert profile instanceof BucketProfile; BucketProfile srp = (BucketProfile) profile; return srp.isPrimary; } }); if (primaryMembers.size() > 1 && logger.isDebugEnabled()) { logger.debug("[findPrimaryProfiles] found the following primary members for {}: {}", getAdvisee().getName(), primaryMembers); } return (InternalDistributedMember[]) primaryMembers.toArray( new InternalDistributedMember[primaryMembers.size()]); }
private JmxManagerAdvisor(DistributionAdvisee advisee) { super(advisee); JmxManagerProfile p = new JmxManagerProfile(getDistributionManager().getId(), incrementAndGetVersion()); advisee.fillInProfile(p); ((JmxManagerAdvisee)advisee).initProfile(p); }
public void sendProfileUpdate(boolean exchangeProfiles) { DM mgr = this.advisee.getDistributionManager(); DistributionAdvisor advisor = this.advisee.getDistributionAdvisor(); this.profileExchange = exchangeProfiles; InternalDistributedSystem system = this.advisee.getSystem(); processor = new UpdateAttributesReplyProcessor(system, recipients); UpdateAttributesMessage message = getUpdateAttributesMessage(processor, recipients);
public void run() { assertTrue(Locator.hasLocator()); InternalLocator l = (InternalLocator)Locator.getLocator(); DistributionAdvisee advisee = l.getServerLocatorAdvisee(); ControllerAdvisor ca = (ControllerAdvisor)advisee.getDistributionAdvisor(); assertEquals(0, ca.fetchControllers().size()); assertEquals(0, ca.fetchBridgeServers().size()); } });
/** * Dumps out all profiles in this advisor. * @param log the LogWriter to write profile dump to * @param infoMsg prefix message to log */ public void dumpProfiles(LogWriterI18n log, String infoMsg) { Profile[] profs = this.profiles; final StringBuilder buf = new StringBuilder(2000); if (infoMsg != null) { buf.append(infoMsg); buf.append(": "); } buf.append("FYI, DUMPING PROFILES IN "); buf.append(toString()); buf.append(":\n"); buf.append("My Profile="); buf.append(getAdvisee().getProfile()); buf.append("\nOther Profiles:\n"); for (int i = 0; i < profs.length; i++) { buf.append("\t"); buf.append(profs[i].toString()); buf.append("\n"); } log.info(LocalizedStrings.DEBUG, buf.toString()); }
/** * Attempts to process this message with the specified * {@link DistributionAdvisee}. Also if exchange profiles then add the * profile from {@link DistributionAdvisee} to reply. * * @param advisee * the CacheDistributionAdvisee to apply this profile to * @param removeProfile * true to remove profile else add profile * @param exchangeProfiles * true to add the profile to reply */ protected final void handleDistributionAdvisee(DistributionAdvisee advisee, boolean removeProfile, boolean exchangeProfiles, final List<Profile> replyProfiles) { final DistributionAdvisor da; if (advisee != null && (da = advisee.getDistributionAdvisor()) != null) { if (removeProfile) { da.removeProfile(this, false); } else { da.putProfile(this); } if (exchangeProfiles) { // assume non-null replyProfiles when exchangeProfiles is true replyProfiles.add(advisee.getProfile()); } } }
public void broadcastChange() { try { Set<InternalDistributedMember> recips = adviseGeneric(); // for now just tell everyone JmxManagerProfile p = new JmxManagerProfile(getDistributionManager().getId(), incrementAndGetVersion()); getAdvisee().fillInProfile(p); JmxManagerProfileMessage.send(getAdvisee().getSystem().getDistributionManager(), recips, p); } catch (CancelException ignore) { } }