private LocalRegion findRegion() { GemFireCacheImpl cache = null; try { cache = GemFireCacheImpl.getInstance(); if (cache != null) { return cache.getRegionByPathForProcessing(regionName); } } catch (CancelException e) { // nothing to do } return null; }
private LocalRegion findRegion() { GemFireCacheImpl cache = null; try { cache = GemFireCacheImpl.getInstance(); if (cache != null) { return cache.getRegionByPathForProcessing(regionName); } } catch (CancelException e) { // nothing to do } return null; }
private CacheDistributionAdvisee findRegion() { CacheDistributionAdvisee result = null; GemFireCacheImpl cache = null; try { cache = GemFireCacheImpl.getInstance(); if (cache != null) { LocalRegion lr = cache.getRegionByPathForProcessing(regionName); if (lr instanceof CacheDistributionAdvisee) { result = (CacheDistributionAdvisee)lr; } } } catch (CancelException e) { // nothing to do } return result; }
private CacheDistributionAdvisee findRegion() { CacheDistributionAdvisee result = null; GemFireCacheImpl cache = null; try { cache = GemFireCacheImpl.getInstance(); if (cache != null) { LocalRegion lr = cache.getRegionByPathForProcessing(regionName); if (lr instanceof CacheDistributionAdvisee) { result = (CacheDistributionAdvisee)lr; } } } catch (CancelException e) { // nothing to do } return result; }
protected LocalRegion getLocalRegionForProcessing(DistributionManager dm) { Assert.assertTrue(this.regionPath != null, "regionPath was null"); GemFireCacheImpl gfc = (GemFireCacheImpl)CacheFactory.getInstance(dm.getSystem()); return gfc.getRegionByPathForProcessing(this.regionPath); }
public void run() { // use internal methods to get the region since it's still initializing GemFireCacheImpl cache = (GemFireCacheImpl)getCache(); final RegionMap r = cache.getRegionByPathForProcessing(regionName).getRegionMap(); // X's update should have been propagated to A and put into the cache. // If this throws an assertion error then there's no point in // continuing the test because we didn't set up the initial // condition needed for the next step. WaitCriterion wc = new WaitCriterion() { public boolean done() { return r.containsKey("keyFromX"); } public String description() { return "waiting for region " + regionName + " to contain keyFromX"; } }; waitForCriterion(wc, 20000, 1000, true); } });
@Override public void processIncoming(final DistributionManager dm, final String adviseePath, final boolean removeProfile, final boolean exchangeProfiles, final List<Profile> replyProfiles, final LogWriterI18n logger) { final GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); final LocalRegion region; final UUIDAdvisor advisor; if (cache != null && !cache.isClosed() && (region = cache.getRegionByPathForProcessing(regionPath)) != null && (advisor = region.uuidAdvisor) != null) { // exchange our profile even if not initialized so that the receiver // records this VM and continues to send updates to its own profile handleDistributionAdvisee(advisor.getAdvisee(), removeProfile, exchangeProfiles, replyProfiles); } }
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; }
@Override protected void process(DistributionManager dm) { ReplyException rex = null; boolean ignored = false; try { GemFireCacheImpl gfc = GemFireCacheImpl.getExisting(); final LocalRegion lclRgn = gfc.getRegionByPathForProcessing(this.regionPath); if (lclRgn != null) { lclRgn.waitOnInitialization(); final long lastMod = gfc.cacheTimeMillis(); Iterator it = this.ops.iterator(); while (it.hasNext()) { QueuedOperation op = (QueuedOperation)it.next(); op.process(lclRgn, getSender(), lastMod); } } else { ignored = true; } } catch (RegionDestroyedException e) { ignored = true; } catch (CancelException e) { ignored = true; } finally { ReplyMessage.send(getSender(), this.processorId, rex, dm, ignored, false, null, false); } }
@Override protected void process(DistributionManager dm) { ReplyException rex = null; boolean ignored = false; try { GemFireCacheImpl gfc = (GemFireCacheImpl)CacheFactory.getInstance(dm.getSystem()); final LocalRegion lclRgn = gfc.getRegionByPathForProcessing(this.regionPath); if (lclRgn != null) { lclRgn.waitOnInitialization(); final long lastMod = gfc.cacheTimeMillis(); Iterator it = this.ops.iterator(); while (it.hasNext()) { QueuedOperation op = (QueuedOperation)it.next(); op.process(lclRgn, getSender(), lastMod); } } else { ignored = true; } } catch (RegionDestroyedException e) { ignored = true; } catch (CancelException e) { ignored = true; } finally { ReplyMessage.send(getSender(), this.processorId, rex, dm, ignored, false, false); } }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); try { // Read EventID EventID eventID = (EventID)DataSerializer.readObject(in); DistributedMember member = DSFIDFactory.readInternalDistributedMember(in); String regionName = DataSerializer.readString(in); final LocalRegion rgn = Misc.getGemFireCache() .getRegionByPathForProcessing(regionName); if (rgn != null) { this.initializeEvent(rgn, eventID, member); } } catch (IOException ioe) { throw ioe; } catch (Exception e) { throw new IOException(e); } }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); try { // Read EventID EventID eventID = (EventID)DataSerializer.readObject(in); DistributedMember member = DSFIDFactory.readInternalDistributedMember(in); String regionName = DataSerializer.readString(in); final LocalRegion rgn = Misc.getGemFireCache() .getRegionByPathForProcessing(regionName); if (rgn != null) { this.initializeEvent(rgn, eventID, member); } } catch (IOException ioe) { throw ioe; } catch (Exception e) { throw new IOException(e); } }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); // Read EventID EventID eventID = DataSerializer.readObject(in); DistributedMember member = DSFIDFactory.readInternalDistributedMember(in); String regionName = DataSerializer.readString(in); final GemFireCacheImpl cache = Misc.getGemFireCacheNoThrow(); final LocalRegion rgn = cache != null ? cache.getRegionByPathForProcessing(regionName) : null; // initialize event even if Region is null so that child classes can // proceed with their fromData this.initializeEvent(rgn, eventID, member); }
private CacheDistributionAdvisee 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; } else if (r == null) { // check for ProxyBucketRegion; may need to wait for TX ops on // proxy bucket region Bucket bucket = PartitionedRegionHelper.getProxyBucketRegion(gfc, this.regionPath, false); if (bucket != null) { return bucket; } } } catch (PRLocallyDestroyedException prlde) { // ignore } finally { LocalRegion.setThreadInitLevelRequirement(oldLevel); } return region; }
/** * @see TXMessage#operateOnTX(TXStateProxy, DistributionManager) */ @Override protected boolean operateOnTX(final TXStateProxy tx, DistributionManager dm) { final TXState txState; // if no TXState was created (e.g. due to only getEntry/size operations // that don't start remote TX) then ignore if (tx != null && (txState = tx.getLocalTXState()) != null) { final GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); if (cache != null && !cache.isClosed() && cache.getCancelCriterion().cancelInProgress() == null) { final LocalRegion dataRegion = cache .getRegionByPathForProcessing(this.regionPath); if (dataRegion != null) { txState.revertFailedOp(dataRegion, this.regionKey, this.op, this.destroy, this.bulkOp, this.originalValue, this.originalDelta); } } } return true; }
@Override protected final void processMessage(DistributionManager dm) throws GemFireCheckedException { if (this.region == null) { if (this.prId >= 0) { // PR case this.pr = PartitionedRegion.getPRFromId(this.prId); if (this.pr == null) { throw new ForceReattemptException( LocalizedStrings.PartitionMessage_0_COULD_NOT_FIND_PARTITIONED_REGION_WITH_ID_1 .toLocalizedString(new Object[] { Misc.getGemFireCache().getMyId(), Integer.valueOf(this.prId) })); } this.region = this.pr; this.regionPath = region.getFullPath(); } else { this.region = Misc.getGemFireCache().getRegionByPathForProcessing( this.regionPath); if (this.region == null) { throw new ForceReattemptException( LocalizedStrings.Region_CLOSED_OR_DESTROYED .toLocalizedString(this.regionPath)); } } } super.processMessage(dm); }
@Override protected final void processMessage(DistributionManager dm) throws GemFireCheckedException { if (this.region == null) { if (this.prId >= 0) { // PR case this.pr = PartitionedRegion.getPRFromId(this.prId); if (this.pr == null) { throw new ForceReattemptException( LocalizedStrings.PartitionMessage_0_COULD_NOT_FIND_PARTITIONED_REGION_WITH_ID_1 .toLocalizedString(new Object[] { Misc.getGemFireCache().getMyId(), Integer.valueOf(this.prId) })); } this.region = this.pr; this.regionPath = region.getFullPath(); } else { this.region = Misc.getGemFireCache().getRegionByPathForProcessing( this.regionPath); if (this.region == null) { throw new ForceReattemptException( LocalizedStrings.Region_CLOSED_OR_DESTROYED .toLocalizedString(this.regionPath)); } } } super.processMessage(dm); }
@Override protected final void processMessage(DistributionManager dm) throws GemFireCheckedException { if (this.region == null) { if (this.prId >= 0) { // PR case this.pr = PartitionedRegion.getPRFromId(this.prId); if (this.pr == null) { throw new ForceReattemptException( LocalizedStrings.PartitionMessage_0_COULD_NOT_FIND_PARTITIONED_REGION_WITH_ID_1 .toLocalizedString(new Object[] { Misc.getGemFireCache().getMyId(), Integer.valueOf(this.prId) })); } this.region = this.pr; this.regionPath = region.getFullPath(); } else { this.region = Misc.getGemFireCache().getRegionByPathForProcessing( this.regionPath); if (this.region == null) { throw new ForceReattemptException( LocalizedStrings.Region_CLOSED_OR_DESTROYED .toLocalizedString(this.regionPath)); } } } super.processMessage(dm); }
@Override protected final void processMessage(DistributionManager dm) throws GemFireCheckedException { if (this.region == null) { if (this.prId >= 0) { // PR case this.pr = PartitionedRegion.getPRFromId(this.prId); if (this.pr == null) { throw new ForceReattemptException( LocalizedStrings. PartitionMessage_0_COULD_NOT_FIND_PARTITIONED_REGION_WITH_ID_1 .toLocalizedString(new Object[] { Misc.getGemFireCache().getMyId(), Integer.valueOf(this.prId) })); } this.region = this.pr; this.regionPath = region.getFullPath(); } else { this.region = Misc.getGemFireCache().getRegionByPathForProcessing( this.regionPath); if (this.region == null) { throw new ForceReattemptException( LocalizedStrings.Region_CLOSED_OR_DESTROYED .toLocalizedString(this.regionPath)); } } } super.processMessage(dm); }
@Override protected final void processMessage(DistributionManager dm) throws GemFireCheckedException { if (this.region == null) { if (this.prId >= 0) { // PR case this.pr = PartitionedRegion.getPRFromId(this.prId); if (this.pr == null) { throw new ForceReattemptException( LocalizedStrings. PartitionMessage_0_COULD_NOT_FIND_PARTITIONED_REGION_WITH_ID_1 .toLocalizedString(new Object[] { Misc.getGemFireCache().getMyId(), Integer.valueOf(this.prId) })); } this.region = this.pr; this.regionPath = region.getFullPath(); } else { this.region = Misc.getGemFireCache().getRegionByPathForProcessing( this.regionPath); if (this.region == null) { throw new ForceReattemptException( LocalizedStrings.Region_CLOSED_OR_DESTROYED .toLocalizedString(this.regionPath)); } } } super.processMessage(dm); }