@Override public String toString() { return "Bucket id = " + bucketId + " from local member = " + getDistributionManager().getDistributionManagerId() + ": " + super.toString(); } };
private static InternalDistributedMember getMemberId() { return CCRegion.getDistributionManager().getDistributionManagerId(); }
private boolean isLockGrantor() { return this.dm.getDistributionManagerId().equals(this.grantor); }
/** * Constructor that implements the {@link CacheTransactionManager} interface. Only only one * instance per {@link org.apache.geode.cache.Cache} */ public TXManagerImpl(CachePerfStats cachePerfStats, InternalCache cache) { this.cache = cache; this.dm = ((InternalDistributedSystem) cache.getDistributedSystem()).getDistributionManager(); this.distributionMgrId = this.dm.getDistributionManagerId(); this.uniqId = new AtomicInteger(0); this.cachePerfStats = cachePerfStats; this.hostedTXStates = new HashMap<>(); this.txContext = new ThreadLocal<>(); this.pauseJTA = new ThreadLocal<Boolean>(); this.isTXDistributed = new ThreadLocal<>(); this.transactionTimeToLive = Integer .getInteger(DistributionConfig.GEMFIRE_PREFIX + "cacheServer.transactionTimeToLive", 180); currentInstance = this; }
@Override protected Throwable processCheckForPR(PartitionedRegion pr, DistributionManager distributionManager) { if (pr != null && !pr.getDistributionAdvisor().isInitialized()) { Throwable thr = new ForceReattemptException( String.format("%s : could not find partitioned region with Id %s", distributionManager.getDistributionManagerId(), pr.getRegionIdentifier())); return thr; } return null; }
@Override protected AdminResponse createResponse(DistributionManager dm) { HashSet<PersistentID> persistentIds; try { persistentIds = prepareBackupFactory .createPrepareBackup(dm.getDistributionManagerId(), dm.getCache(), properties).run(); } catch (IOException | InterruptedException e) { logger.error(String.format("Error processing request %s.", getClass()), e); return AdminFailureResponse.create(getSender(), e); } return prepareBackupFactory.createBackupResponse(getSender(), persistentIds); }
@Override public void initialize(InputStream snapshotInputStream, InternalDistributedMember imageTarget, InternalRegionArguments internalRegionArgs) throws TimeoutException, ClassNotFoundException { if (logger.isDebugEnabled()) { logger.debug("PartitionedRegion#initialize {}", getName()); } RegionLogger.logCreate(getName(), getDistributionManager().getDistributionManagerId()); this.requiresNotification = this.cache.requiresNotificationFromPR(this); initPRInternals(internalRegionArgs); if (logger.isDebugEnabled()) { logger.debug("PartitionRegion#initialize: finished with {}", this); } this.cache.addPartitionedRegion(this); }
/** * If the PR is missing or isn't ready for use we may want to return a * ForceReattemptException to have the sender retry after a bit */ protected Throwable processCheckForPR(PartitionedRegion pr, DistributionManager distributionManager) { if ((pr == null || !pr.getDistributionAdvisor().isInitialized()) && failIfRegionMissing()) { // if the distributed system is disconnecting, don't send a reply saying // the partitioned region can't be found (bug 36585) Throwable thr = new ForceReattemptException( String.format("%s : could not find partitioned region with Id %s", distributionManager.getDistributionManagerId(), regionId)); return thr; // reply sent in finally block below } return null; }
@Override public PersistentMembershipView getMembershipView() { if (!initialized) { return null; } Set<PersistentMemberID> offlineMembers = getPersistedMembers(); Map<InternalDistributedMember, PersistentMemberID> onlineMembers = cacheDistributionAdvisor.adviseInitializedPersistentMembers(); offlineMembers.removeAll(onlineMembers.values()); PersistentMemberID myId = getPersistentID(); if (myId != null) { onlineMembers .put(cacheDistributionAdvisor.getDistributionManager().getDistributionManagerId(), myId); } return new PersistentMembershipView(offlineMembers, onlineMembers, persistentMemberManager.getRevokedMembers()); }
@Before public void setup() { manager = mock(DistributionManager.class); when(manager.getDistributionManagerId()) .thenReturn(new InternalDistributedMember("localhost", 1)); partitionedRegion = mock(PartitionedRegion.class); advisor = mock(DistributionAdvisor.class); when(partitionedRegion.getDistributionAdvisor()).thenReturn(advisor); when(partitionedRegion.getRegionIdentifier()).thenReturn("testRegion"); }
protected void validateAllMembersAreTheSameVersion(PartitionedRegion region) { Set<InternalDistributedMember> remoteMembers = region.getRegionAdvisor().adviseAllPRNodes(); Version localVersion = cache.getDistributionManager().getDistributionManagerId().getVersionObject(); if (!remoteMembers.isEmpty()) { for (InternalDistributedMember remoteMember : remoteMembers) { if (!remoteMember.getVersionObject().equals(localVersion)) { throw new IllegalStateException( "The lucene index cannot be created on a existing region if all members hosting the region : " + region.getFullPath() + ", are not the same Apache Geode version "); } } } }
@Before public void setUp() throws Exception { dm = mock(DistributionManager.class); sender = mock(InternalDistributedMember.class); cache = mock(InternalCache.class); flushToDiskFactory = mock(FlushToDiskFactory.class); flushToDisk = mock(FlushToDisk.class); msgId = 42; recipients = new HashSet<>(); when(dm.getCache()).thenReturn(cache); when(dm.getDistributionManagerId()).thenReturn(sender); when(flushToDiskFactory.createFlushToDisk(eq(cache))).thenReturn(flushToDisk); when(flushToDiskFactory.createResponse(eq(sender))).thenReturn(mock(FlushToDiskResponse.class)); flushToDiskRequest = new FlushToDiskRequest(sender, recipients, msgId, flushToDiskFactory); }
public PersistentMemberID generatePersistentID(DiskRegionView dr) { File firstDir = getInfoFileDir().getDir(); InternalDistributedSystem ids = getCache().getInternalDistributedSystem(); InternalDistributedMember memberId = ids.getDistributionManager().getDistributionManagerId(); // NOTE - do NOT use DM.cacheTimeMillis here. See bug #49920 long timestamp = System.currentTimeMillis(); return new PersistentMemberID(getDiskStoreID(), memberId.getInetAddress(), firstDir.getAbsolutePath(), memberId.getName(), timestamp, (short) 0); }
@Before public void setUp() throws Exception { // mocks here dm = mock(DistributionManager.class); cache = mock(InternalCache.class); BackupService backupService = mock(BackupService.class); when(dm.getCache()).thenReturn(cache); when(dm.getDistributionManagerId()).thenReturn(sender); when(cache.getBackupService()).thenReturn(backupService); sender = mock(InternalDistributedMember.class); Set<InternalDistributedMember> recipients = new HashSet<>(); AbortBackup abortBackup = mock(AbortBackup.class); abortBackupFactory = mock(AbortBackupFactory.class); when(abortBackupFactory.createAbortBackup(eq(cache))).thenReturn(abortBackup); when(abortBackupFactory.createBackupResponse(eq(sender), eq(new HashSet<>()))) .thenReturn(mock(BackupResponse.class)); int processorId = 79; abortBackupRequest = new AbortBackupRequest(sender, recipients, processorId, abortBackupFactory); }
public Move findBestTargetForFPR(Bucket bucket, boolean checkIPAddress) { InternalDistributedMember targetMemberID = null; Member targetMember = null; List<FixedPartitionAttributesImpl> fpas = this.partitionedRegion.getFixedPartitionAttributesImpl(); if (fpas != null) { for (FixedPartitionAttributesImpl fpaImpl : fpas) { if (fpaImpl.hasBucket(bucket.getId())) { targetMemberID = this.partitionedRegion.getDistributionManager().getDistributionManagerId(); if (this.members.containsKey(targetMemberID)) { targetMember = this.members.get(targetMemberID); if (targetMember.willAcceptBucket(bucket, null, checkIPAddress).willAccept()) { // We should have just one move for creating // all the buckets for a FPR on this node. return new Move(null, targetMember, bucket); } } } } } return null; }
/** * 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; } }
@Override @SuppressWarnings("synthetic-access") public void run() { InternalDistributedMember myId = r.getDistributionManager().getDistributionManagerId(); for (int i = 0; i < putAllDataCount; ++i) { @Released EntryEventImpl ev = PutAllPRMessage.getEventFromEntry(r, myId, eventSender, i, putAllData, false, bridgeContext, posDup, !skipCallbacks); try { ev.setPutAllOperation(dpao); if (logger.isDebugEnabled()) { logger.debug("invoking basicPut with {}", ev); } if (dr.basicPut(ev, false, false, null, false)) { putAllData[i].versionTag = ev.getVersionTag(); versions.addKeyAndVersion(putAllData[i].getKey(), ev.getVersionTag()); } } finally { ev.release(); } } } }, baseEvent.getEventId());
public static Map<DistributedMember, Set<PersistentID>> send(DistributionManager dm) { Set recipients = dm.getOtherDistributionManagerIds(); CompactRequest request = new CompactRequest(); request.setRecipients(recipients); CompactReplyProcessor replyProcessor = new CompactReplyProcessor(dm, recipients); request.msgId = replyProcessor.getProcessorId(); dm.putOutgoing(request); request.setSender(dm.getDistributionManagerId()); request.process((ClusterDistributionManager) dm); try { replyProcessor.waitForReplies(); } catch (ReplyException e) { if (!(e.getCause() instanceof CancelException)) { throw e; } } catch (InterruptedException e) { logger.warn(e); } return replyProcessor.results; }
@Retained EntryEventImpl createEventForPR(EntryEventImpl sourceEvent) { EntryEventImpl e2 = new EntryEventImpl(sourceEvent); boolean returned = false; try { e2.setRegion(this.partitionedRegion); if (FORCE_LOCAL_LISTENERS_INVOCATION) { e2.setInvokePRCallbacks(true); } else { e2.setInvokePRCallbacks(sourceEvent.getInvokePRCallbacks()); } DistributedMember dm = this.getDistributionManager().getDistributionManagerId(); e2.setOriginRemote(!e2.getDistributedMember().equals(dm)); returned = true; return e2; } finally { if (!returned) { e2.release(); } } }
@Override public void run() { InternalDistributedMember myId = theRegion.getDistributionManager().getDistributionManagerId(); for (int i = 0; i < op.removeAllDataSize; ++i) { @Released EntryEventImpl ev = RemoveAllPRMessage.getEventFromEntry(theRegion, myId, myId, i, op.removeAllData, false, op.getBaseEvent().getContext(), false, !op.getBaseEvent().isGenerateCallbacks()); ev.setRemoveAllOperation(op); try { theRegion.basicDestroy(ev, true/* should we invoke cacheWriter? */, null); } catch (EntryNotFoundException ignore) { } finally { ev.release(); } successfulOps.addKeyAndVersion(op.removeAllData[i].key, null); } } }, op.getBaseEvent().getEventId());