public TXBucketRegionState(BucketRegion r, TXState txs) { super(r, txs); this.pr = r.getPartitionedRegion(); }
@Override public String getNameForStats() { return this.getPartitionedRegion().getFullPath(); }
@Override public boolean notifiesMultipleSerialGateways() { return getPartitionedRegion().notifiesMultipleSerialGateways(); }
protected void invokePartitionListenerAfterBucketCreated() { PartitionListener[] partitionListeners = getPartitionedRegion().getPartitionListeners(); if (partitionListeners == null || partitionListeners.length == 0) { return; } for (int i = 0; i < partitionListeners.length; i++) { PartitionListener listener = partitionListeners[i]; if (listener != null) { listener.afterBucketCreated(getId(), keySet()); } } }
public long generateTailKey() { long key = this.eventSeqNum.addAndGet(this.partitionedRegion.getTotalNumberOfBuckets()); if (key < 0 || key % getPartitionedRegion().getTotalNumberOfBuckets() != getId()) { logger.error("ERROR! The sequence number {} generated for the bucket {} is incorrect.", new Object[] {key, getId()}); } if (logger.isDebugEnabled()) { logger.debug("WAN: On primary bucket {}, setting the seq number as {}", getId(), this.eventSeqNum.get()); } return eventSeqNum.get(); }
protected void invokePartitionListenerAfterBucketRemoved() { PartitionListener[] partitionListeners = getPartitionedRegion().getPartitionListeners(); if (partitionListeners == null || partitionListeners.length == 0) { return; } for (int i = 0; i < partitionListeners.length; i++) { PartitionListener listener = partitionListeners[i]; if (listener != null) { listener.afterBucketRemoved(getId(), keySet()); } } }
private void givenBucketRegion() { BucketRegion bucketRegion = mock(BucketRegion.class); when(bucketRegion.isUsedForPartitionedRegionBucket()).thenReturn(true); when(bucketRegion.getPartitionedRegion()).thenReturn(partitionedRegion); when(bucketRegion.getBucketAdvisor()).thenReturn(mock(BucketAdvisor.class)); owner = bucketRegion; setupLocalRegion(); regionMap = spy(new TestableAbstractRegionMap()); }
theRegion = ((BucketRegion) reg).getPartitionedRegion(); } else { theRegion = reg;
final InternalRegion theRegion; if (reg instanceof BucketRegion) { theRegion = ((BucketRegion) reg).getPartitionedRegion(); } else { theRegion = reg;
@Override protected void notifyClientsOfTombstoneGC(Map<VersionSource, Long> regionGCVersions, Set<Object> removedKeys, EventID eventID, FilterInfo routing) { if (CacheClientNotifier.getInstance() != null) { // Only route the event to clients interested in the partitioned region. // We do this by constructing a region-level event and then use it to // have the filter profile ferret out all of the clients that have interest // in this region FilterProfile fp = getFilterProfile(); // fix for bug #46309 - don't send null/empty key set to clients if ((removedKeys != null && !removedKeys.isEmpty()) // bug #51877 - NPE in clients && (routing != null || (fp != null && fp.hasInterest()))) { RegionEventImpl regionEvent = new RegionEventImpl(getPartitionedRegion(), Operation.REGION_DESTROY, null, true, getMyId()); FilterInfo clientRouting = routing; if (clientRouting == null) { clientRouting = fp.getLocalFilterRouting(regionEvent); } regionEvent.setLocalFilterInfo(clientRouting); ClientUpdateMessage clientMessage = ClientTombstoneMessage.gc(getPartitionedRegion(), removedKeys, eventID); CacheClientNotifier.notifyClients(regionEvent, clientMessage); } } }
if (getBucketAdvisor().isPrimary()) { long key = this.eventSeqNum.addAndGet(this.partitionedRegion.getTotalNumberOfBuckets()); if (key < 0 || key % getPartitionedRegion().getTotalNumberOfBuckets() != getId()) { logger.error("ERROR! The sequence number {} generated for the bucket {} is incorrect.", new Object[] {key, getId()});
public static void send(BucketRegion r, final Set<Object> keys, EventID eventID) { Set<InternalDistributedMember> recipients = r.getPartitionedRegion().getRegionAdvisor().adviseAllServersWithInterest(); recipients.removeAll(r.getDistributionAdvisor().adviseReplicates()); if (recipients.size() == 0) { return; } PartitionResponse p = new Response(r.getSystem(), recipients); PRTombstoneMessage m = new PRTombstoneMessage(recipients, r.getPartitionedRegion().getPRId(), p, keys, eventID); m.setTransactionDistributed(r.getCache().getTxManager().isDistributed()); r.getDistributionManager().putOutgoing(m); try { p.waitForCacheException(); } catch (ForceReattemptException e) { // ignore - the member is going away or has destroyed the PR so // it won't be forwarding anything to clients for the PR } }
FilterRoutingInfo fri = bucket.getPartitionedRegion().getRegionAdvisor() .adviseFilterRouting(ev, Collections.EMPTY_SET); o.es.setFilterRoutingInfo(fri);
&& buk.getPartitionedRegion().isShadowPR()) { if (buk.getPartitionedRegion().getColocatedWithRegion() != null) { buk.getPartitionedRegion().getColocatedWithRegion().getRegionAdvisor() .getBucketAdvisor(bucketId).setShadowBucketDestroyed(true);
final InternalRegion theRegion; if (reg instanceof BucketRegion) { theRegion = ((BucketRegion) reg).getPartitionedRegion(); } else { theRegion = reg;
theRegion = ((BucketRegion) reg).getPartitionedRegion(); } else { theRegion = reg;
/** * This method is called when a miss from a get ends up finding an object through a cache loader * or from a server. In that case we want to make sure that we don't move this bucket while * putting the value in the ache. * * @see LocalRegion#basicPutEntry(EntryEventImpl, long) */ @Override protected RegionEntry basicPutEntry(final EntryEventImpl event, final long lastModified) throws TimeoutException, CacheWriterException { boolean locked = lockKeysAndPrimary(event); try { if (getPartitionedRegion().isParallelWanEnabled()) { handleWANEvent(event); } event.setInvokePRCallbacks(true); forceSerialized(event); return super.basicPutEntry(event, lastModified); } finally { if (locked) { releaseLockForKeysAndPrimary(event); } } }
@Override protected FilterRoutingInfo getRecipientFilterRouting(Set cacheOpRecipients) { // for putAll, we need to determine the routing information for each event and // create a consolidated routing object representing all events that can be // used for distribution CacheDistributionAdvisor advisor; LocalRegion region = (LocalRegion) this.event.getRegion(); if (region instanceof PartitionedRegion) { advisor = ((PartitionedRegion) region).getCacheDistributionAdvisor(); } else if (region.isUsedForPartitionedRegionBucket()) { advisor = ((BucketRegion) region).getPartitionedRegion().getCacheDistributionAdvisor(); } else { advisor = ((DistributedRegion) region).getCacheDistributionAdvisor(); } FilterRoutingInfo consolidated = new FilterRoutingInfo(); for (int i = 0; i < this.putAllData.length; i++) { @Unretained EntryEventImpl ev = getEventForPosition(i); if (ev != null) { FilterRoutingInfo eventRouting = advisor.adviseFilterRouting(ev, cacheOpRecipients); if (eventRouting != null) { consolidated.addFilterInfo(eventRouting); } putAllData[i].filterRouting = eventRouting; } } // we need to create routing information for each PUT event return consolidated; }
@Override protected FilterRoutingInfo getRecipientFilterRouting(Set cacheOpRecipients) { // for removeAll, we need to determine the routing information for each event and // create a consolidated routing object representing all events that can be // used for distribution CacheDistributionAdvisor advisor; LocalRegion region = (LocalRegion) this.event.getRegion(); if (region instanceof PartitionedRegion) { advisor = ((PartitionedRegion) region).getCacheDistributionAdvisor(); } else if (region.isUsedForPartitionedRegionBucket()) { advisor = ((BucketRegion) region).getPartitionedRegion().getCacheDistributionAdvisor(); } else { advisor = ((DistributedRegion) region).getCacheDistributionAdvisor(); } FilterRoutingInfo consolidated = new FilterRoutingInfo(); for (int i = 0; i < this.removeAllData.length; i++) { @Unretained EntryEventImpl ev = getEventForPosition(i); if (ev != null) { FilterRoutingInfo eventRouting = advisor.adviseFilterRouting(ev, cacheOpRecipients); if (eventRouting != null) { consolidated.addFilterInfo(eventRouting); } removeAllData[i].filterRouting = eventRouting; } } // we need to create routing information for each PUT event return consolidated; }
/** * This notifies all WAN sites about updated timestamp on local site. */ @Override public void notifyTimestampsToGateways(EntryEventImpl event) { // Create updateTimeStampEvent from event. VersionTagHolder updateTimeStampEvent = new VersionTagHolder(event.getVersionTag()); updateTimeStampEvent.setOperation(Operation.UPDATE_VERSION_STAMP); updateTimeStampEvent.setKeyInfo(event.getKeyInfo()); updateTimeStampEvent.setGenerateCallbacks(false); updateTimeStampEvent.distributedMember = event.getDistributedMember(); updateTimeStampEvent.setNewEventId(getSystem()); if (event.getRegion() instanceof BucketRegion) { BucketRegion bucketRegion = (BucketRegion) event.getRegion(); PartitionedRegion partitionedRegion = bucketRegion.getPartitionedRegion(); updateTimeStampEvent.setRegion(partitionedRegion); // increment the tailKey for the event if (partitionedRegion.isParallelWanEnabled()) { bucketRegion.handleWANEvent(updateTimeStampEvent); } if (partitionedRegion.isInitialized()) { partitionedRegion.notifyGatewaySender(EnumListenerEvent.TIMESTAMP_UPDATE, updateTimeStampEvent); } } else { updateTimeStampEvent.setRegion(event.getRegion()); notifyGatewaySender(EnumListenerEvent.TIMESTAMP_UPDATE, updateTimeStampEvent); } }