use of org.apache.geode.cache.persistence.PersistentReplicatesOfflineException in project geode by apache.
the class DistributedRegion method virtualPut.
@Override
protected boolean virtualPut(EntryEventImpl event, boolean ifNew, boolean ifOld, Object expectedOldValue, boolean requireOldValue, long lastModified, boolean overwriteDestroyed) throws TimeoutException, CacheWriterException {
final boolean isTraceEnabled = logger.isTraceEnabled();
Lock dlock = null;
if (// lock only applies to global scope
this.scope.isGlobal() && // only if operation originating locally
!event.isOriginRemote() && // search and load processor handles own locking
!event.isNetSearch() && !event.isNetLoad() && // @todo darrel/kirk: what about putAll?
!event.isLocalLoad() && !event.isSingleHopPutOp()) {
// Single Hop Op means dlock is already taken at origin node.
dlock = this.getDistributedLockIfGlobal(event.getKey());
}
if (isTraceEnabled) {
logger.trace("virtualPut invoked for event {}", event);
}
try {
if (!hasSeenEvent(event)) {
if (this.requiresOneHopForMissingEntry(event)) {
// bug #45704: see if a one-hop must be done for this operation
RegionEntry re = getRegionEntry(event.getKey());
if (re == null || /* || re.isTombstone() */
!this.generateVersionTag) {
if (!event.isBulkOpInProgress() || this.dataPolicy.withStorage()) {
// putAll will send a single one-hop for empty regions. for other missing entries
// we need to get a valid version number before modifying the local cache
boolean didDistribute = RemotePutMessage.distribute(event, lastModified, false, false, expectedOldValue, requireOldValue, !this.generateVersionTag);
if (!didDistribute && isTraceEnabled) {
logger.trace("Unable to perform one-hop messaging");
}
if (!this.generateVersionTag && !didDistribute) {
throw new PersistentReplicatesOfflineException();
}
if (didDistribute) {
if (isTraceEnabled) {
logger.trace("Event after remotePut operation: {}", event);
}
if (event.getVersionTag() == null) {
// and so should not be applied to this cache
return false;
}
}
}
}
}
return super.virtualPut(event, ifNew, ifOld, expectedOldValue, requireOldValue, lastModified, overwriteDestroyed);
} else {
if (event.getDeltaBytes() != null && event.getRawNewValue() == null) {
// The value in this vm may not be same as this event's value.
throw new InvalidDeltaException("Cache encountered replay of event containing delta bytes for key " + event.getKey());
}
// return
if (isTraceEnabled) {
logger.trace("DR.virtualPut: this cache has already seen this event {}", event);
}
// LR.basicPutPart3 in purpose.
if (event.isBulkOpInProgress() && !event.isOriginRemote()) {
event.getPutAllOperation().addEntry(event, true);
}
/*
* doing this so that other VMs will apply this no matter what. If it is an "update" they
* will not apply it if they don't have the key. Because this is probably a retry, it will
* never get applied to this local AbstractRegionMap, and so will never be flipped to a
* 'create'
*/
event.makeCreate();
if (!getConcurrencyChecksEnabled() || event.hasValidVersionTag()) {
distributeUpdate(event, lastModified, ifNew, ifOld, expectedOldValue, requireOldValue);
event.invokeCallbacks(this, true, true);
}
return true;
}
} finally {
if (dlock != null) {
dlock.unlock();
}
}
}
use of org.apache.geode.cache.persistence.PersistentReplicatesOfflineException in project geode by apache.
the class DistributedRemoveAllOperation method initMessage.
@Override
protected void initMessage(CacheOperationMessage msg, DirectReplyProcessor proc) {
super.initMessage(msg, proc);
RemoveAllMessage m = (RemoveAllMessage) msg;
// if concurrency checks are enabled and this is not a replicated
// region we need to see if any of the entries have no versions and,
// if so, cull them out and send a 1-hop message to a replicate that
// can generate a version for the operation
RegionAttributes attr = this.event.getRegion().getAttributes();
if (attr.getConcurrencyChecksEnabled() && !attr.getDataPolicy().withReplication() && attr.getScope() != Scope.GLOBAL) {
if (attr.getDataPolicy() == DataPolicy.EMPTY) {
// all entries are without version tags
boolean success = RemoteRemoveAllMessage.distribute((EntryEventImpl) this.event, this.removeAllData, this.removeAllDataSize);
if (success) {
m.callbackArg = this.event.getCallbackArgument();
m.removeAllData = new RemoveAllEntryData[0];
m.removeAllDataSize = 0;
m.skipCallbacks = !event.isGenerateCallbacks();
return;
} else if (!getRegion().getGenerateVersionTag()) {
// to distribute versionless entries.
throw new PersistentReplicatesOfflineException();
}
} else {
// some entries may have Create ops - these will not have version tags
RemoveAllEntryData[] versionless = selectVersionlessEntries();
if (logger.isTraceEnabled()) {
logger.trace("Found these versionless entries: {}", Arrays.toString(versionless));
}
if (versionless.length > 0) {
boolean success = RemoteRemoveAllMessage.distribute((EntryEventImpl) this.event, versionless, versionless.length);
if (success) {
versionless = null;
RemoveAllEntryData[] versioned = selectVersionedEntries();
if (logger.isTraceEnabled()) {
logger.trace("Found these remaining versioned entries: {}", Arrays.toString(versioned));
}
m.callbackArg = this.event.getCallbackArgument();
m.removeAllData = versioned;
m.removeAllDataSize = versioned.length;
m.skipCallbacks = !event.isGenerateCallbacks();
return;
} else if (!getRegion().getGenerateVersionTag()) {
// to distribute versionless entries.
throw new PersistentReplicatesOfflineException();
}
} else {
if (logger.isDebugEnabled()) {
logger.debug("All entries have versions, so using normal DPAO message");
}
}
}
}
m.callbackArg = this.event.getCallbackArgument();
m.removeAllData = this.removeAllData;
m.removeAllDataSize = this.removeAllDataSize;
m.skipCallbacks = !event.isGenerateCallbacks();
}
use of org.apache.geode.cache.persistence.PersistentReplicatesOfflineException in project geode by apache.
the class PersistentRecoveryOrderDUnitTest method testRecoverFromNonPeristentRegion.
/**
* Tests that a persistent region cannot recover from a non persistent region.
*/
@Test
public void testRecoverFromNonPeristentRegion() throws Exception {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
createPersistentRegion(vm0);
createNonPersistentRegion(vm1);
putAnEntry(vm0);
closeRegion(vm0);
try {
updateTheEntry(vm1);
fail("expected PersistentReplicatesOfflineException not thrown");
} catch (Exception expected) {
if (!(expected.getCause() instanceof PersistentReplicatesOfflineException)) {
throw expected;
}
}
// This should initialize from vm1
createPersistentRegion(vm0);
checkForRecoveryStat(vm0, true);
updateTheEntry(vm1);
checkForEntry(vm0);
checkForEntry(vm1);
}
use of org.apache.geode.cache.persistence.PersistentReplicatesOfflineException in project geode by apache.
the class DistributedPutAllOperation method initMessage.
@Override
protected void initMessage(CacheOperationMessage msg, DirectReplyProcessor proc) {
super.initMessage(msg, proc);
PutAllMessage m = (PutAllMessage) msg;
// if concurrency checks are enabled and this is not a replicated
// region we need to see if any of the entries have no versions and,
// if so, cull them out and send a 1-hop message to a replicate that
// can generate a version for the operation
RegionAttributes attr = this.event.getRegion().getAttributes();
if (attr.getConcurrencyChecksEnabled() && !attr.getDataPolicy().withReplication() && attr.getScope() != Scope.GLOBAL) {
if (attr.getDataPolicy() == DataPolicy.EMPTY) {
// all entries are without version tags
boolean success = RemotePutAllMessage.distribute((EntryEventImpl) this.event, this.putAllData, this.putAllDataSize);
if (success) {
m.callbackArg = this.event.getCallbackArgument();
m.putAllData = new PutAllEntryData[0];
m.putAllDataSize = 0;
m.skipCallbacks = !event.isGenerateCallbacks();
return;
} else if (!getRegion().getGenerateVersionTag()) {
// to distribute versionless entries.
throw new PersistentReplicatesOfflineException();
}
} else {
// some entries may have Create ops - these will not have version tags
PutAllEntryData[] versionless = selectVersionlessEntries();
if (logger.isTraceEnabled()) {
logger.trace("Found these versionless entries: {}", Arrays.toString(versionless));
}
if (versionless.length > 0) {
boolean success = RemotePutAllMessage.distribute((EntryEventImpl) this.event, versionless, versionless.length);
if (success) {
versionless = null;
PutAllEntryData[] versioned = selectVersionedEntries();
if (logger.isTraceEnabled()) {
logger.trace("Found these remaining versioned entries: {}", Arrays.toString(versioned));
}
m.callbackArg = this.event.getCallbackArgument();
m.putAllData = versioned;
m.putAllDataSize = versioned.length;
m.skipCallbacks = !event.isGenerateCallbacks();
return;
} else if (!getRegion().getGenerateVersionTag()) {
// to distribute versionless entries.
throw new PersistentReplicatesOfflineException();
}
} else {
if (logger.isDebugEnabled()) {
logger.debug("All entries have versions, so using normal DPAO message");
}
}
}
}
m.callbackArg = this.event.getCallbackArgument();
m.putAllData = this.putAllData;
m.putAllDataSize = this.putAllDataSize;
m.skipCallbacks = !event.isGenerateCallbacks();
}
Aggregations