use of org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData in project geode by apache.
the class PutAllPRMessage method fromData.
@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
super.fromData(in);
this.bucketId = (int) InternalDataSerializer.readSignedVL(in);
if ((flags & HAS_BRIDGE_CONTEXT) != 0) {
this.bridgeContext = DataSerializer.readObject(in);
}
this.callbackArg = DataSerializer.readObject(in);
this.putAllPRDataSize = (int) InternalDataSerializer.readUnsignedVL(in);
this.putAllPRData = new PutAllEntryData[putAllPRDataSize];
if (this.putAllPRDataSize > 0) {
final Version version = InternalDataSerializer.getVersionForDataStreamOrNull(in);
final ByteArrayDataInput bytesIn = new ByteArrayDataInput();
for (int i = 0; i < this.putAllPRDataSize; i++) {
this.putAllPRData[i] = new PutAllEntryData(in, null, i, version, bytesIn);
}
boolean hasTags = in.readBoolean();
if (hasTags) {
EntryVersionsList versionTags = EntryVersionsList.create(in);
for (int i = 0; i < this.putAllPRDataSize; i++) {
this.putAllPRData[i].versionTag = versionTags.get(i);
}
}
}
}
use of org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData in project geode by apache.
the class RemotePutAllMessage method fromData.
@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
super.fromData(in);
this.eventId = (EventID) DataSerializer.readObject(in);
this.callbackArg = DataSerializer.readObject(in);
this.posDup = (flags & POS_DUP) != 0;
if ((flags & HAS_BRIDGE_CONTEXT) != 0) {
this.bridgeContext = DataSerializer.readObject(in);
}
this.skipCallbacks = (flags & SKIP_CALLBACKS) != 0;
this.putAllDataCount = (int) InternalDataSerializer.readUnsignedVL(in);
this.putAllData = new PutAllEntryData[putAllDataCount];
if (this.putAllDataCount > 0) {
final Version version = InternalDataSerializer.getVersionForDataStreamOrNull(in);
final ByteArrayDataInput bytesIn = new ByteArrayDataInput();
for (int i = 0; i < this.putAllDataCount; i++) {
this.putAllData[i] = new PutAllEntryData(in, this.eventId, i, version, bytesIn);
}
boolean hasTags = in.readBoolean();
if (hasTags) {
EntryVersionsList versionTags = EntryVersionsList.create(in);
for (int i = 0; i < this.putAllDataCount; i++) {
this.putAllData[i].versionTag = versionTags.get(i);
}
}
}
}
use of org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData in project geode by apache.
the class RemotePutAllMessage method distribute.
/*
* this is similar to send() but it selects an initialized replicate that is used to proxy the
* message
*
*/
public static boolean distribute(EntryEventImpl event, PutAllEntryData[] data, int dataCount) {
boolean successful = false;
DistributedRegion r = (DistributedRegion) event.getRegion();
Collection replicates = r.getCacheDistributionAdvisor().adviseInitializedReplicates();
if (replicates.isEmpty()) {
return false;
}
if (replicates.size() > 1) {
ArrayList l = new ArrayList(replicates);
Collections.shuffle(l);
replicates = l;
}
int attempts = 0;
for (Iterator<InternalDistributedMember> it = replicates.iterator(); it.hasNext(); ) {
InternalDistributedMember replicate = it.next();
try {
attempts++;
final boolean posDup = (attempts > 1);
PutAllResponse response = send(replicate, event, data, dataCount, false, DistributionManager.SERIAL_EXECUTOR, posDup);
response.waitForCacheException();
VersionedObjectList result = response.getResponse();
// Set successful version tags in PutAllEntryData.
List successfulKeys = result.getKeys();
List<VersionTag> versions = result.getVersionTags();
for (PutAllEntryData putAllEntry : data) {
Object key = putAllEntry.getKey();
if (successfulKeys.contains(key)) {
int index = successfulKeys.indexOf(key);
putAllEntry.versionTag = versions.get(index);
}
}
return true;
} catch (TransactionDataNotColocatedException enfe) {
throw enfe;
} catch (CancelException e) {
event.getRegion().getCancelCriterion().checkCancelInProgress(e);
} catch (CacheException e) {
if (logger.isDebugEnabled()) {
logger.debug("RemotePutMessage caught CacheException during distribution", e);
}
// not a cancel-exception, so don't complain any more about it
successful = true;
} catch (RemoteOperationException e) {
if (logger.isTraceEnabled(LogMarker.DM)) {
logger.trace(LogMarker.DM, "RemotePutMessage caught an unexpected exception during distribution", e);
}
}
}
return successful;
}
use of org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData 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.cache.DistributedPutAllOperation.PutAllEntryData in project geode by apache.
the class DistTxEntryEvent method putAllToData.
/**
* @param out
* @throws IOException
*/
private void putAllToData(DataOutput out) throws IOException {
DataSerializer.writeInteger(this.putAllOp.putAllDataSize, out);
EntryVersionsList versionTags = new EntryVersionsList(this.putAllOp.putAllDataSize);
boolean hasTags = false;
final PutAllEntryData[] putAllData = this.putAllOp.getPutAllEntryData();
for (int i = 0; i < this.putAllOp.putAllDataSize; i++) {
if (!hasTags && putAllData[i].versionTag != null) {
hasTags = true;
}
VersionTag<?> tag = putAllData[i].versionTag;
versionTags.add(tag);
putAllData[i].versionTag = null;
putAllData[i].toData(out);
putAllData[i].versionTag = tag;
}
out.writeBoolean(hasTags);
if (hasTags) {
InternalDataSerializer.invokeToData(versionTags, out);
}
}
Aggregations