use of org.apache.geode.cache.Region.Entry in project geode by apache.
the class TXStateProxyImpl method accessEntry.
public Entry accessEntry(KeyInfo keyInfo, LocalRegion region) {
try {
this.operationCount++;
Entry retVal = getRealDeal(keyInfo, region).accessEntry(keyInfo, region);
trackBucketForTx(keyInfo);
return retVal;
} catch (TransactionDataRebalancedException | PrimaryBucketException re) {
throw getTransactionException(keyInfo, re);
}
}
use of org.apache.geode.cache.Region.Entry in project geode by apache.
the class PartitionedTXRegionStub method getEntry.
public Entry getEntry(KeyInfo keyInfo, boolean allowTombstones) {
PartitionedRegion pr = (PartitionedRegion) region;
try {
Entry e = pr.getEntryRemotely((InternalDistributedMember) state.getTarget(), keyInfo.getBucketId(), keyInfo.getKey(), false, allowTombstones);
trackBucketForTx(keyInfo);
return e;
} catch (EntryNotFoundException enfe) {
return null;
} catch (TransactionException e) {
RuntimeException re = getTransactionException(keyInfo, e);
re.initCause(e.getCause());
throw re;
} catch (PrimaryBucketException e) {
RuntimeException re = getTransactionException(keyInfo, e);
re.initCause(e);
throw re;
} catch (ForceReattemptException e) {
RuntimeException re;
if (isBucketNotFoundException(e)) {
re = new TransactionDataRebalancedException(LocalizedStrings.PartitionedRegion_TRANSACTIONAL_DATA_MOVED_DUE_TO_REBALANCING.toLocalizedString());
} else {
re = new TransactionDataNodeHasDepartedException(LocalizedStrings.PartitionedRegion_TRANSACTION_DATA_NODE_0_HAS_DEPARTED_TO_PROCEED_ROLLBACK_THIS_TRANSACTION_AND_BEGIN_A_NEW_ONE.toLocalizedString(state.getTarget()));
}
re.initCause(e);
waitToRetry();
throw re;
}
}
use of org.apache.geode.cache.Region.Entry in project geode by apache.
the class GetEntryCommand method getValueAndIsObject.
@Override
public void getValueAndIsObject(Region p_region, Object key, Object callbackArg, ServerConnection servConn, Object[] result) {
Object data = null;
LocalRegion region = (LocalRegion) p_region;
Entry entry = region.getEntry(key);
if (logger.isDebugEnabled()) {
logger.debug("GetEntryCommand: for key: {} returning entry: {}", key, entry);
}
if (entry != null) {
EntrySnapshot snap = new EntrySnapshot();
NonLocalRegionEntry re = new NonLocalRegionEntry(entry, region);
snap.setRegionEntry(re);
snap.setRegion(region);
data = snap;
}
result[0] = data;
// isObject is true
result[1] = true;
}
use of org.apache.geode.cache.Region.Entry in project geode by apache.
the class ZRemRangeByRankExecutor method executeCommand.
@Override
public void executeCommand(Command command, ExecutionHandlerContext context) {
List<byte[]> commandElems = command.getProcessedCommand();
if (commandElems.size() < 4) {
command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.ZREMRANGEBYRANK));
return;
}
ByteArrayWrapper key = command.getKey();
checkDataType(key, RedisDataType.REDIS_SORTEDSET, context);
Region<ByteArrayWrapper, DoubleWrapper> keyRegion = getRegion(context, key);
if (keyRegion == null) {
command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), NONE_REMOVED));
return;
}
int startRank;
int stopRank;
try {
startRank = Coder.bytesToInt(commandElems.get(2));
stopRank = Coder.bytesToInt(commandElems.get(3));
} catch (NumberFormatException e) {
command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_NOT_NUMERIC));
return;
}
int sSetSize = keyRegion.size();
startRank = getBoundedStartIndex(startRank, sSetSize);
stopRank = getBoundedEndIndex(stopRank, sSetSize);
if (stopRank > sSetSize - 1)
stopRank = sSetSize - 1;
if (startRank > stopRank) {
command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), 0));
return;
}
int numRemoved = 0;
List<?> removeList = null;
try {
if (startRank == 0 && stopRank == sSetSize - 1) {
numRemoved = keyRegion.size();
context.getRegionProvider().removeKey(key);
} else {
removeList = getRemoveKeys(context, key, startRank, stopRank);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
if (removeList != null) {
for (Object entry : removeList) {
ByteArrayWrapper removeKey;
if (entry instanceof Entry)
removeKey = (ByteArrayWrapper) ((Entry<?, ?>) entry).getKey();
else
removeKey = (ByteArrayWrapper) ((Struct) entry).getFieldValues()[0];
Object oldVal = keyRegion.remove(removeKey);
if (oldVal != null)
numRemoved++;
}
if (keyRegion.isEmpty())
context.getRegionProvider().removeKey(key);
}
command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), numRemoved));
}
use of org.apache.geode.cache.Region.Entry in project geode by apache.
the class CacheXml66DUnitTest method getDistributedSystemProperties.
@Override
public Properties getDistributedSystemProperties() {
Properties props = super.getDistributedSystemProperties();
if (this.xmlProps != null) {
for (Iterator iter = this.xmlProps.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
String key = (String) entry.getKey();
String value = (String) entry.getValue();
props.setProperty(key, value);
}
}
return props;
}
Aggregations