use of org.apache.geode.internal.offheap.annotations.Unretained in project geode by apache.
the class GatewaySenderEventImpl method getDeserializedValue.
/**
* Return this event's deserialized value
*
* @return this event's deserialized value
*/
public Object getDeserializedValue() {
if (this.valueIsObject == 0x00) {
Object result = this.value;
if (result == null) {
@Unretained(OffHeapIdentifier.GATEWAY_SENDER_EVENT_IMPL_VALUE) Object so = this.valueObj;
if (this.valueObjReleased) {
throw new IllegalStateException("Value is no longer available. getDeserializedValue must be called before processEvents returns.");
}
if (so instanceof StoredObject) {
return ((StoredObject) so).getValueAsDeserializedHeapObject();
} else {
throw new IllegalStateException("expected valueObj field to be an instance of StoredObject but it was " + so);
}
}
return result;
} else {
Object vo = this.valueObj;
if (vo != null) {
if (vo instanceof StoredObject) {
@Unretained(OffHeapIdentifier.GATEWAY_SENDER_EVENT_IMPL_VALUE) StoredObject so = (StoredObject) vo;
return so.getValueAsDeserializedHeapObject();
} else {
// it is already deserialized
return vo;
}
} else {
if (this.value != null) {
Object result = EntryEventImpl.deserialize(this.value);
this.valueObj = result;
return result;
} else if (this.substituteValue != null) {
// If the substitute value is set, return it.
return this.substituteValue;
} else {
if (this.valueObjReleased) {
throw new IllegalStateException("Value is no longer available. getDeserializedValue must be called before processEvents returns.");
}
// both value and valueObj are null but we did not free it.
return null;
}
}
}
}
use of org.apache.geode.internal.offheap.annotations.Unretained in project geode by apache.
the class GatewaySenderEventImpl method getSerializedValueSize.
public int getSerializedValueSize() {
int localSerializedValueSize = this.serializedValueSize;
if (localSerializedValueSize != DEFAULT_SERIALIZED_VALUE_SIZE) {
return localSerializedValueSize;
}
@Unretained(OffHeapIdentifier.GATEWAY_SENDER_EVENT_IMPL_VALUE) Object vo = this.valueObj;
if (vo instanceof StoredObject) {
localSerializedValueSize = ((StoredObject) vo).getSizeInBytes();
} else {
if (this.substituteValue != null) {
localSerializedValueSize = sizeOf(this.substituteValue);
} else {
localSerializedValueSize = CachedDeserializableFactory.calcMemSize(getSerializedValue());
}
}
this.serializedValueSize = localSerializedValueSize;
return localSerializedValueSize;
}
use of org.apache.geode.internal.offheap.annotations.Unretained in project geode by apache.
the class FilterProfile method getLocalFilterRoutingForPutAllOp.
/**
* computes FilterRoutingInfo objects for each of the given events
*/
public void getLocalFilterRoutingForPutAllOp(DistributedPutAllOperation dpao, DistributedPutAllOperation.PutAllEntryData[] putAllData) {
final boolean isDebugEnabled = logger.isDebugEnabled();
if (this.region != null && this.localProfile.hasCacheServer) {
Set clientsInv = null;
Set clients = null;
int size = putAllData.length;
CqService cqService = getCqService(dpao.getRegion());
boolean doCQs = cqService.isRunning() && this.region != null;
for (int idx = 0; idx < size; idx++) {
PutAllEntryData pEntry = putAllData[idx];
if (pEntry != null) {
@Unretained final EntryEventImpl ev = dpao.getEventForPosition(idx);
FilterRoutingInfo fri = pEntry.filterRouting;
FilterInfo fi = null;
if (fri != null) {
fi = fri.getLocalFilterInfo();
}
if (isDebugEnabled) {
logger.debug("Finding locally interested clients for {}", ev);
}
if (doCQs) {
if (fri == null) {
fri = new FilterRoutingInfo();
}
fillInCQRoutingInfo(ev, true, NO_PROFILES, fri);
fi = fri.getLocalFilterInfo();
}
if (this.allKeyClientsInv != null || this.keysOfInterestInv != null || this.patternsOfInterestInv != null || this.filtersOfInterestInv != null) {
clientsInv = this.getInterestedClients(ev, this.allKeyClientsInv, this.keysOfInterestInv, this.patternsOfInterestInv, this.filtersOfInterestInv);
}
if (this.allKeyClients != null || this.keysOfInterest != null || this.patternsOfInterest != null || this.filtersOfInterest != null) {
clients = this.getInterestedClients(ev, this.allKeyClients, this.keysOfInterest, this.patternsOfInterest, this.filtersOfInterest);
}
if (clients != null || clientsInv != null) {
if (fi == null) {
fi = new FilterInfo();
// no need to create or update a FilterRoutingInfo at this time
}
fi.setInterestedClients(clients);
fi.setInterestedClientsInv(clientsInv);
}
ev.setLocalFilterInfo(fi);
}
}
}
}
use of org.apache.geode.internal.offheap.annotations.Unretained in project geode by apache.
the class DistributedPutAllOperation method getEventForPosition.
@Unretained
public EntryEventImpl getEventForPosition(int position) {
PutAllEntryData entry = this.putAllData[position];
if (entry == null) {
return null;
}
if (entry.event != null) {
return entry.event;
}
LocalRegion region = (LocalRegion) this.event.getRegion();
@Retained EntryEventImpl ev = EntryEventImpl.create(region, entry.getOp(), entry.getKey(), null, /* value */
this.event.getCallbackArgument(), false, /* originRemote */
this.event.getDistributedMember(), this.event.isGenerateCallbacks(), entry.getEventID());
boolean returnedEv = false;
try {
ev.setPossibleDuplicate(entry.isPossibleDuplicate());
if (entry.versionTag != null && region.concurrencyChecksEnabled) {
VersionSource id = entry.versionTag.getMemberID();
if (id != null) {
entry.versionTag.setMemberID(ev.getRegion().getVersionVector().getCanonicalId(id));
}
ev.setVersionTag(entry.versionTag);
}
entry.event = ev;
returnedEv = true;
if (entry.getValue() == null && ev.getRegion().getAttributes().getDataPolicy() == DataPolicy.NORMAL) {
ev.setLocalInvalid(true);
}
ev.setNewValue(entry.getValue());
ev.setOldValue(entry.getOldValue());
CqService cqService = region.getCache().getCqService();
if (cqService.isRunning() && !entry.getOp().isCreate() && !ev.hasOldValue()) {
ev.setOldValueForQueryProcessing();
}
ev.setInvokePRCallbacks(!entry.isNotifyOnly());
if (getBaseEvent().getContext() != null) {
ev.setContext(getBaseEvent().getContext());
}
ev.callbacksInvoked(entry.isCallbacksInvoked());
ev.setTailKey(entry.getTailKey());
return ev;
} finally {
if (!returnedEv) {
ev.release();
}
}
}
use of org.apache.geode.internal.offheap.annotations.Unretained in project geode by apache.
the class EntryEventImpl method exportNewValue.
/**
* Export the event's new value to the given importer.
*/
public void exportNewValue(NewValueImporter importer) {
final boolean prefersSerialized = importer.prefersNewSerialized();
if (prefersSerialized) {
if (getCachedSerializedNewValue() != null) {
importer.importNewBytes(getCachedSerializedNewValue(), true);
return;
} else if (this.newValueBytes != null && this.newValue instanceof CachedDeserializable) {
importer.importNewBytes(this.newValueBytes, true);
return;
}
}
@Unretained(ENTRY_EVENT_NEW_VALUE) final Object nv = getRawNewValue();
if (nv instanceof StoredObject) {
@Unretained(ENTRY_EVENT_NEW_VALUE) final StoredObject so = (StoredObject) nv;
final boolean isSerialized = so.isSerialized();
if (importer.isUnretainedNewReferenceOk()) {
importer.importNewObject(nv, isSerialized);
} else if (!isSerialized || prefersSerialized) {
byte[] bytes = so.getValueAsHeapByteArray();
importer.importNewBytes(bytes, isSerialized);
if (isSerialized) {
setCachedSerializedNewValue(bytes);
}
} else {
importer.importNewObject(so.getValueAsDeserializedHeapObject(), true);
}
} else if (nv instanceof byte[]) {
importer.importNewBytes((byte[]) nv, false);
} else if (nv instanceof CachedDeserializable) {
CachedDeserializable cd = (CachedDeserializable) nv;
Object cdV = cd.getValue();
if (cdV instanceof byte[]) {
importer.importNewBytes((byte[]) cdV, true);
setCachedSerializedNewValue((byte[]) cdV);
} else {
importer.importNewObject(cdV, true);
}
} else {
importer.importNewObject(nv, true);
}
}
Aggregations