use of org.apache.geode.internal.cache.RegionEventImpl in project geode by apache.
the class DynamicRegionFactory method doAfterRegionDestroyed.
private void doAfterRegionDestroyed(Region region, boolean distributed, boolean isOriginRemote, boolean expiration, DistributedMember mbr) {
final Operation op;
if (!distributed && !isOriginRemote) {
op = expiration ? Operation.REGION_EXPIRE_LOCAL_DESTROY : Operation.REGION_LOCAL_DESTROY;
} else {
op = expiration ? Operation.REGION_EXPIRE_DESTROY : Operation.REGION_DESTROY;
}
RegionEvent event = new RegionEventImpl(region, op, null, isOriginRemote, getMember(mbr));
for (Object regionListener : regionListeners) {
DynamicRegionListener listener = (DynamicRegionListener) regionListener;
try {
listener.afterRegionDestroy(event);
} catch (VirtualMachineError err) {
SystemFailure.initiateFailure(err);
// now, so don't let this thread continue.
throw err;
} catch (Throwable t) {
// Whenever you catch Error or Throwable, you must also
// catch VirtualMachineError (see above). However, there is
// _still_ a possibility that you are dealing with a cascading
// error condition, so you also need to check to see if the JVM
// is still usable:
SystemFailure.checkFailure();
this.cache.getLoggerI18n().warning(LocalizedStrings.DynamicRegionFactory_DYNAMICREGIONLISTENER__0__THREW_EXCEPTION_ON_AFTERREGIONDESTROYED, listener, t);
}
}
}
use of org.apache.geode.internal.cache.RegionEventImpl in project geode by apache.
the class PRTombstoneMessage method operateOnPartitionedRegion.
@Override
protected boolean operateOnPartitionedRegion(final DistributionManager dm, PartitionedRegion r, long startTime) throws ForceReattemptException {
if (logger.isTraceEnabled(LogMarker.DM)) {
logger.debug("PRTombstoneMessage operateOnRegion: {}", r.getFullPath());
}
FilterProfile fp = r.getFilterProfile();
if (this.keys != null && this.keys.size() > 0) {
// sanity check
if (fp != null && CacheClientNotifier.getInstance() != null && this.eventID != null) {
RegionEventImpl regionEvent = new RegionEventImpl(r, Operation.REGION_DESTROY, null, true, r.getGemFireCache().getMyId());
regionEvent.setLocalFilterInfo(fp.getLocalFilterRouting(regionEvent));
ClientUpdateMessage clientMessage = ClientTombstoneMessage.gc(r, this.keys, this.eventID);
CacheClientNotifier.notifyClients(regionEvent, clientMessage);
}
}
return true;
}
use of org.apache.geode.internal.cache.RegionEventImpl in project geode by apache.
the class HAGIIDUnitTest method tombstonegc.
/** queue a tombstone GC message for the client. See bug #46832 */
public static void tombstonegc() throws Exception {
LocalRegion r = (LocalRegion) cache.getRegion("/" + REGION_NAME);
assertNotNull(r);
DistributedMember id = r.getCache().getDistributedSystem().getDistributedMember();
RegionEventImpl regionEvent = new RegionEventImpl(r, Operation.REGION_DESTROY, null, true, id);
FilterInfo clientRouting = r.getFilterProfile().getLocalFilterRouting(regionEvent);
assertTrue(clientRouting.getInterestedClients().size() > 0);
regionEvent.setLocalFilterInfo(clientRouting);
Map<VersionSource, Long> map = Collections.emptyMap();
ClientTombstoneMessage message = ClientTombstoneMessage.gc(r, map, new EventID(r.getCache().getDistributedSystem()));
CacheClientNotifier.notifyClients(regionEvent, message);
}
use of org.apache.geode.internal.cache.RegionEventImpl in project geode by apache.
the class EventIDVerificationDUnitTest method createClientCache.
public static void createClientCache(String host, Integer port1, Integer port2) throws Exception {
PORT1 = port1.intValue();
PORT2 = port2.intValue();
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
new EventIDVerificationDUnitTest().createCache(props);
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setMirrorType(MirrorType.NONE);
ClientServerTestCase.configureConnectionPool(factory, host, new int[] { PORT1, PORT2 }, true, -1, 2, null, -1, -1, false, -2);
CacheWriter writer = new CacheWriterAdapter() {
public void beforeCreate(EntryEvent event) {
EventID eventId = ((EntryEventImpl) event).getEventId();
vm0.invoke(() -> EventIDVerificationDUnitTest.setEventIDData(eventId));
vm1.invoke(() -> EventIDVerificationDUnitTest.setEventIDData(eventId));
try {
super.beforeCreate(event);
} catch (CacheWriterException e) {
e.printStackTrace();
fail("Test failed bcoz of exception =" + e);
}
}
public void beforeUpdate(EntryEvent event) {
EventID eventId = ((EntryEventImpl) event).getEventId();
vm0.invoke(() -> EventIDVerificationDUnitTest.setEventIDData(eventId));
vm1.invoke(() -> EventIDVerificationDUnitTest.setEventIDData(eventId));
try {
super.beforeUpdate(event);
} catch (CacheWriterException e) {
e.printStackTrace();
fail("Test failed bcoz of exception =" + e);
}
}
public void beforeDestroy(EntryEvent event) {
EventID eventId = ((EntryEventImpl) event).getEventId();
vm0.invoke(() -> EventIDVerificationDUnitTest.setEventIDData(eventId));
vm1.invoke(() -> EventIDVerificationDUnitTest.setEventIDData(eventId));
try {
super.beforeDestroy(event);
} catch (CacheWriterException e) {
e.printStackTrace();
fail("Test failed bcoz of exception =" + e);
}
}
public void beforeRegionDestroy(RegionEvent event) {
EventID eventId = ((RegionEventImpl) event).getEventId();
vm0.invoke(() -> EventIDVerificationDUnitTest.setEventIDData(eventId));
vm1.invoke(() -> EventIDVerificationDUnitTest.setEventIDData(eventId));
try {
super.beforeRegionDestroy(event);
} catch (CacheWriterException e) {
e.printStackTrace();
fail("Test failed bcoz of exception =" + e);
}
}
public void beforeRegionClear(RegionEvent event) {
EventID eventId = ((RegionEventImpl) event).getEventId();
vm0.invoke(() -> EventIDVerificationDUnitTest.setEventIDData(eventId));
vm1.invoke(() -> EventIDVerificationDUnitTest.setEventIDData(eventId));
try {
super.beforeRegionClear(event);
} catch (CacheWriterException e) {
e.printStackTrace();
fail("Test failed bcoz of exception =" + e);
}
}
};
factory.setCacheWriter(writer);
/*
* factory.setCacheListener(new CacheListenerAdapter() { public void afterCreate(EntryEvent
* event) { synchronized (this) { threadId = ((EntryEventImpl)event).getEventId().getThreadID();
* membershipId = ((EntryEventImpl)event).getEventId().getMembershipID(); } }
*
* public void afterUpdate(EntryEvent event) { synchronized (this) { verifyEventIDs(event); } }
*
* public void afterDestroy(EntryEvent event) { synchronized (this) { verifyEventIDs(event); } }
* public void afterRegionDestroy(RegionEvent event) { synchronized (this) { threadId =
* ((RegionEventImpl)event).getEventId().getThreadID(); membershipId =
* ((RegionEventImpl)event).getEventId().getMembershipID(); } } });
*/
RegionAttributes attrs = factory.create();
Region r = cache.createRegion(REGION_NAME, attrs);
r.registerInterest("ALL_KEYS");
}
use of org.apache.geode.internal.cache.RegionEventImpl in project geode by apache.
the class DynamicRegionFactory method doBeforeRegionDestroyed.
private void doBeforeRegionDestroyed(Region region, boolean distributed, boolean isOriginRemote, boolean expiration, DistributedMember mbr) {
final Operation op;
if (!distributed && !isOriginRemote) {
op = expiration ? Operation.REGION_EXPIRE_LOCAL_DESTROY : Operation.REGION_LOCAL_DESTROY;
} else {
op = expiration ? Operation.REGION_EXPIRE_DESTROY : Operation.REGION_DESTROY;
}
RegionEvent event = new RegionEventImpl(region, op, null, isOriginRemote, getMember(mbr));
for (Object regionListener : regionListeners) {
DynamicRegionListener listener = (DynamicRegionListener) regionListener;
try {
listener.beforeRegionDestroy(event);
} catch (VirtualMachineError err) {
SystemFailure.initiateFailure(err);
// now, so don't let this thread continue.
throw err;
} catch (Throwable t) {
// Whenever you catch Error or Throwable, you must also
// catch VirtualMachineError (see above). However, there is
// _still_ a possibility that you are dealing with a cascading
// error condition, so you also need to check to see if the JVM
// is still usable:
SystemFailure.checkFailure();
this.cache.getLoggerI18n().warning(LocalizedStrings.DynamicRegionFactory_DYNAMICREGIONLISTENER__0__THREW_EXCEPTION_ON_BEFOREREGIONDESTROYED, listener, t);
}
}
}
Aggregations