private DistributedRegion getRegion(DistributionManager dm) { if (region != null) { return region; } // set the init level requirement so that we don't hang in CacheFactory.getInstance() (bug // 36175) int oldLevel = LocalRegion.setThreadInitLevelRequirement(LocalRegion.BEFORE_INITIAL_IMAGE); try { GemFireCacheImpl gfc = (GemFireCacheImpl) CacheFactory.getInstance(dm.getSystem()); Region r = gfc.getRegionByPathForProcessing(this.regionPath); if (r instanceof DistributedRegion) { region = (DistributedRegion) r; } } finally { LocalRegion.setThreadInitLevelRequirement(oldLevel); } return region; }
/** returns a set of all DistributedRegions for allRegions processing */ private Set<DistributedRegion> getAllRegions(DistributionManager dm) { // set the init level requirement so that we don't hang in CacheFactory.getInstance() (bug // 36175) int oldLevel = LocalRegion.setThreadInitLevelRequirement(LocalRegion.BEFORE_INITIAL_IMAGE); try { GemFireCacheImpl gfc = (GemFireCacheImpl) CacheFactory.getInstance(dm.getSystem()); Set<DistributedRegion> result = new HashSet(); for (LocalRegion r : gfc.getAllRegions()) { // it's important not to check if the cache is closing, so access // the isDestroyed boolean directly if (r instanceof DistributedRegion && !r.isDestroyed) { result.add((DistributedRegion) r); } } return result; } finally { LocalRegion.setThreadInitLevelRequirement(oldLevel); } }
/** * Send a generic ReplyMessage. This is in a method so that subclasses can override the reply * message type * * @param pr the Partitioned Region for the message whose statistics are incremented * @param startTime the start time of the operation in nanoseconds * @see PutMessage#sendReply */ protected void sendReply( InternalDistributedMember member, int procId, DM dm, ReplyException ex, LocalRegion pr, long startTime) { // if (pr != null && startTime > 0) { // pr.getPrStats().endRemoteOperationMessagesProcessing(startTime); // } ReplyMessage.send(member, procId, ex, getReplySender(dm), pr != null && pr.isInternalRegion()); }
// // inlining DiskId // // always have these fields // /** // * id consists of // * most significant // * 1 byte = users bits // * 2-8 bytes = oplog id // * least significant. // * // * The highest bit in the oplog id part is set to 1 if the oplog id // * is negative. // * @todo this field could be an int for an overflow only region // */ // private long id; // /** // * Length of the bytes on disk. // * This is always set. If the value is invalid then it will be set to 0. // * The most significant bit is used by overflow to mark it as needing to be written. // */ // protected int valueLength = 0; // // have intOffset or longOffset // // intOffset // /** // * The position in the oplog (the oplog offset) where this entry's value is // * stored // */ // private volatile int offsetInOplog; // // longOffset // /** // * The position in the oplog (the oplog offset) where this entry's value is // * stored // */ // private volatile long offsetInOplog; // // have overflowOnly or persistence // // overflowOnly // // no fields // // persistent // /** unique entry identifier * */ // private long keyId; // DO NOT modify this class. It was generated from LeafRegionEntry.cpp // lru code @Override public void setDelayedDiskId(LocalRegion r) { DiskStoreImpl ds = r.getDiskStore(); long maxOplogSize = ds.getMaxOplogSize(); this.id = DiskId.createDiskId(maxOplogSize, false /* over flow only */, ds.needsLinkedList()); }
public void process(LocalRegion lr, DistributedMember src, long lastMod) { if (this.op.isRegion()) { // it is a region operation RegionEventImpl re = new RegionEventImpl(lr, this.op, this.cbArg, true, src); // re.setQueued(true); if (this.op.isRegionInvalidate()) { lr.basicInvalidateRegion(re); } else if (this.op == Operation.REGION_CLEAR) { lr.cmnClearRegion(re, false /* cacheWrite */, false /*useRVV*/); } else { throw new IllegalStateException( LocalizedStrings.QueuedOperation_THE_0_SHOULD_NOT_HAVE_BEEN_QUEUED.toLocalizedString( this.op)); } } else { // it is an entry operation // TODO :EventID should be passed from the sender & should be reused here EntryEventImpl ee = EntryEventImpl.create(lr, this.op, this.key, null, this.cbArg, true, src); try { // ee.setQueued(true); if (this.op.isCreate() || this.op.isUpdate()) { UpdateOperation.UpdateMessage.setNewValueInEvent( this.value, this.valueObj, ee, this.deserializationPolicy); try { long time = lastMod; if (ee.getVersionTag() != null) { time = ee.getVersionTag().getVersionTimeStamp(); } if (AbstractUpdateOperation.doPutOrCreate(lr, ee, time, true, true)) { // am I done? } } catch (ConcurrentCacheModificationException e) { // operation was rejected by the cache's concurrency control // mechanism as being old } } else if (this.op.isDestroy()) { ee.setOldValueFromRegion(); try { lr.basicDestroy(ee, false, null); // expectedOldValue // ???:ezoerner:20080815 // can a remove(key, value) operation be // queued? } catch (ConcurrentCacheModificationException e) { // operation was rejected by the cache's concurrency control mechanism as being old } catch (EntryNotFoundException ignore) { } catch (CacheWriterException e) { throw new Error( LocalizedStrings.QueuedOperation_CACHEWRITER_SHOULD_NOT_BE_CALLED .toLocalizedString(), e); } catch (TimeoutException e) { throw new Error( LocalizedStrings.QueuedOperation_DISTRIBUTEDLOCK_SHOULD_NOT_BE_ACQUIRED .toLocalizedString(), e); } } else if (this.op.isInvalidate()) { ee.setOldValueFromRegion(); boolean forceNewEntry = lr.dataPolicy.withReplication() && !lr.isInitialized(); boolean invokeCallbacks = lr.isInitialized(); try { lr.basicInvalidate(ee, invokeCallbacks, forceNewEntry); } catch (ConcurrentCacheModificationException e) { // operation was rejected by the cache's concurrency control mechanism as being old } catch (EntryNotFoundException ignore) { } } else { throw new IllegalStateException( LocalizedStrings.QueuedOperation_THE_0_SHOULD_NOT_HAVE_BEEN_QUEUED.toLocalizedString( this.op)); } } finally { ee.release(); } } }