/** * Marks member as not primary. Initiates volunteerForPrimary if this member is hosting a real * bucket. This method does nothing if the member parameter is the current member. * * @param member the member who is not primary */ public void notPrimary(InternalDistributedMember member) { // Fix for 43569. Only the deposePrimary call should // make the local member drop the primary lock. if (!member.equals(getDistributionManager().getId())) { removePrimary(member); } }
getDistributionManager().getWaitingThreadPool().execute(consumeQueue()); handedOff = true; } finally {
/** * Sets primaryMember and notifies all. Caller must be synced on this. * * @param id the member to use as primary for this bucket */ void setPrimaryMember(InternalDistributedMember id) { if (!getDistributionManager().getId().equals(id)) { // volunteerForPrimary handles primary state change if its our id if (isHosting()) { requestPrimaryState(OTHER_PRIMARY_HOSTING); } else { requestPrimaryState(OTHER_PRIMARY_NOT_HOSTING); } } this.primaryMember.set(id); this.everHadPrimary = true; if (id != null && id.equals(primaryElector)) { primaryElector = null; } this.notifyAll(); // wake up any threads in waitForPrimaryMember }
if (this.getDistributionManager().getSystem().isLoner()) { InternalDistributedMember primary = basicGetPrimaryMember(); HashSet hostsAndProxyMembers = new HashSet(); if (primary != null && !primary.equals(getDistributionManager().getId())) { getDistributionManager(), partitionedRegionId, bucketId, bp, true); if (reply != null) { reply.waitForRepliesUninterruptibly();
boolean needToSendProfileUpdate = false; try { removePrimary(getDistributionManager().getId()); synchronized (this) { if (!isPrimary()) {
/** * Return (and possibly choose) a thread-sticky member from whose data store this bucket's values * should be read * * @return member to use for reads, null if none available */ public InternalDistributedMember getPreferredNode() { if (isHosting()) { getPartitionedRegionStats().incPreferredReadLocal(); return getDistributionManager().getId(); } Profile locProfiles[] = this.profiles; // volatile read if (locProfiles.length == 0) { return null; } getPartitionedRegionStats().incPreferredReadRemote(); if (locProfiles.length == 1) { // only one choice! return locProfiles[0].peerMemberId; } // Pick one at random. int i = myRand.nextInt(locProfiles.length); return locProfiles[i].peerMemberId; }
/** * Searches through profiles to find first profile that is flagged as primary and sets * {@link #primaryMember} to it. Caller must synchronize on this BucketAdvisor. * * @return true if a primary member was found and used * @see #findAndSetPrimaryMember() */ boolean findAndSetPrimaryMember() { if (isPrimary()) { setPrimaryMember(this.getDistributionManager().getDistributionManagerId()); return true; } InternalDistributedMember[] primaryMembers = findPrimaryMembers(); if (primaryMembers.length > 0) { setPrimaryMember(primaryMembers[0]); return true; } else { return false; } }
if (otherPrimary != null && !getDistributionManager().getId().equals(otherPrimary)) { if (logger.isDebugEnabled()) { logger.debug("Attempting to depose primary on {} for {}", otherPrimary, this);
long warnTime = getDistributionManager().getConfig().getAckWaitThreshold() * 1000L; boolean loggedWarning = false; try {
getBucket().getId(), regionAdvisor.getPartitionedRegion().getFullPath()); setPrimaryMember(getDistributionManager().getId()); changedStateToIsPrimary = true; if (hasPrimary() && isPrimary()) {
try { synchronized (this) { boolean wasPrimary = isPrimary() && this.getDistributionManager().getId().equals(member); final InternalDistributedMember currentPrimary = (InternalDistributedMember) this.primaryMember.get();