use of org.apache.geode.cache.EntryDestroyedException in project geode by apache.
the class Coder method getKeyValArrayResponse.
public static ByteBuf getKeyValArrayResponse(ByteBufAllocator alloc, Collection<Entry<ByteArrayWrapper, ByteArrayWrapper>> items) {
Iterator<Map.Entry<ByteArrayWrapper, ByteArrayWrapper>> it = items.iterator();
ByteBuf response = alloc.buffer();
response.writeByte(ARRAY_ID);
int size = 0;
ByteBuf tmp = alloc.buffer();
while (it.hasNext()) {
Map.Entry<ByteArrayWrapper, ByteArrayWrapper> next = it.next();
byte[] key;
byte[] nextByteArray;
try {
key = next.getKey().toBytes();
nextByteArray = next.getValue().toBytes();
} catch (EntryDestroyedException e) {
continue;
}
// Add key
tmp.writeByte(BULK_STRING_ID);
tmp.writeBytes(intToBytes(key.length));
tmp.writeBytes(CRLFar);
tmp.writeBytes(key);
tmp.writeBytes(CRLFar);
// Add value
tmp.writeByte(BULK_STRING_ID);
tmp.writeBytes(intToBytes(nextByteArray.length));
tmp.writeBytes(CRLFar);
tmp.writeBytes(nextByteArray);
tmp.writeBytes(CRLFar);
size++;
}
response.writeBytes(intToBytes(size * 2));
response.writeBytes(CRLFar);
response.writeBytes(tmp);
tmp.release();
return response;
}
use of org.apache.geode.cache.EntryDestroyedException in project geode by apache.
the class FlushAllExecutor method executeCommand.
@Override
public void executeCommand(Command command, ExecutionHandlerContext context) {
if (context.hasTransaction())
throw new UnsupportedOperationInTransactionException();
for (Entry<String, RedisDataType> e : context.getRegionProvider().metaEntrySet()) {
try {
String skey = e.getKey();
RedisDataType type = e.getValue();
removeEntry(Coder.stringToByteWrapper(skey), type, context);
} catch (EntryDestroyedException e1) {
continue;
}
}
command.setResponse(Coder.getSimpleStringResponse(context.getByteBufAllocator(), "OK"));
}
use of org.apache.geode.cache.EntryDestroyedException in project geode by apache.
the class AttributeDescriptor method readReflection.
// used when the resolution of an attribute must be on a superclass
// instead of the runtime class
private Object readReflection(Object target) throws NameNotFoundException, QueryInvocationTargetException {
Support.Assert(target != null);
Support.Assert(target != QueryService.UNDEFINED);
if (target instanceof Token) {
return QueryService.UNDEFINED;
}
Class resolutionClass = target.getClass();
Member m = getReadMember(resolutionClass);
try {
if (m instanceof Method) {
try {
return ((Method) m).invoke(target, (Object[]) null);
} catch (EntryDestroyedException e) {
// eat the Exception
return QueryService.UNDEFINED;
} catch (IllegalAccessException e) {
throw new NameNotFoundException(LocalizedStrings.AttributeDescriptor_METHOD_0_IN_CLASS_1_IS_NOT_ACCESSIBLE_TO_THE_QUERY_PROCESSOR.toLocalizedString(new Object[] { m.getName(), target.getClass().getName() }), e);
} catch (InvocationTargetException e) {
// if the target exception is Exception, wrap that,
// otherwise wrap the InvocationTargetException itself
Throwable t = e.getTargetException();
if ((t instanceof EntryDestroyedException)) {
// eat the exception
return QueryService.UNDEFINED;
}
if (t instanceof Exception)
throw new QueryInvocationTargetException(t);
throw new QueryInvocationTargetException(e);
}
} else {
try {
return ((Field) m).get(target);
} catch (IllegalAccessException e) {
throw new NameNotFoundException(LocalizedStrings.AttributeDescriptor_FIELD_0_IN_CLASS_1_IS_NOT_ACCESSIBLE_TO_THE_QUERY_PROCESSOR.toLocalizedString(new Object[] { m.getName(), target.getClass().getName() }), e);
} catch (EntryDestroyedException e) {
return QueryService.UNDEFINED;
}
}
} catch (EntryDestroyedException e) {
// eat the exception
return QueryService.UNDEFINED;
}
}
use of org.apache.geode.cache.EntryDestroyedException in project geode by apache.
the class PartitionedRegionHelper method cleanUpMetaDataForRegion.
public static void cleanUpMetaDataForRegion(final InternalCache cache, final String prName, final DistributedMember failedMemId, final Runnable postCleanupTask) {
boolean runPostCleanUp = true;
try {
final PartitionRegionConfig prConf;
Region rootReg = PartitionedRegionHelper.getPRRoot(cache, false);
if (rootReg == null) {
return;
}
try {
prConf = (PartitionRegionConfig) rootReg.get(prName);
} catch (EntryDestroyedException ignore) {
return;
}
if (prConf == null) {
// so I added this check and continue
return;
}
Set<Node> nodeList = prConf.getNodes();
if (nodeList == null) {
return;
}
for (final Node node1 : nodeList) {
if (cache.getCancelCriterion().isCancelInProgress()) {
return;
}
if (node1.getMemberId().equals(failedMemId)) {
// Do the cleanup in another thread so we don't have the advisor locked.
// Fix for #45365, we don't schedule an asynchronous task until
// we have determined the node to remove (Which includes the
// serial number).
cache.getDistributionManager().getPrMetaDataCleanupThreadPool().execute(new Runnable() {
public void run() {
cleanPartitionedRegionMetaDataForNode(cache, node1, prConf, prName);
if (postCleanupTask != null) {
postCleanupTask.run();
}
}
});
runPostCleanUp = false;
return;
}
}
} finally {
if (runPostCleanUp && postCleanupTask != null) {
postCleanupTask.run();
}
}
}
use of org.apache.geode.cache.EntryDestroyedException in project geode by apache.
the class CompiledOperation method evaluate.
public Object evaluate(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException {
CompiledValue rcvr = getReceiver(context);
Object result;
Object evalRcvr;
if (rcvr == null) {
// must be intended as implicit iterator operation
// see if it's an implicit operation name
RuntimeIterator rcvrItr = context.resolveImplicitOperationName(this.methodName, this.args.size(), true);
evalRcvr = rcvrItr.evaluate(context);
/*
* // evaluate on current iteration of collection if (rcvrItr != null) { result =
* eval0(rcvrItr.evaluate(context), rcvrItr.getElementType().resolveClass(), context); }
*
* // function call: no functions implemented except keywords in the grammar throw new
* TypeMismatchException(LocalizedStrings.CompiledOperation_COULD_NOT_RESOLVE_METHOD_NAMED_0.
* toLocalizedString(this.methodName));
*/
} else {
// if not null, then explicit receiver
evalRcvr = rcvr.evaluate(context);
}
// short circuit null immediately
if (evalRcvr == null) {
return QueryService.UNDEFINED;
}
if (context.isCqQueryContext() && evalRcvr instanceof Region.Entry) {
Region.Entry re = (Region.Entry) evalRcvr;
if (re.isDestroyed()) {
return QueryService.UNDEFINED;
}
try {
evalRcvr = re.getValue();
} catch (EntryDestroyedException ede) {
// throw EntryDestroyedException if the value becomes null.
return QueryService.UNDEFINED;
}
}
// check if the receiver is the iterator, in which
// case we resolve the method on the constraint rather
// than the runtime type of the receiver
Class resolveClass = null;
// if (resolveClass == null)
if (evalRcvr instanceof PdxInstance) {
String className = ((PdxInstance) evalRcvr).getClassName();
try {
resolveClass = InternalDataSerializer.getCachedClass(className);
} catch (ClassNotFoundException cnfe) {
throw new QueryInvocationTargetException(cnfe);
}
} else if (evalRcvr instanceof PdxString) {
resolveClass = String.class;
} else {
resolveClass = evalRcvr.getClass();
}
result = eval0(evalRcvr, resolveClass, context);
// }
// check for PR substitution
// check for BucketRegion substitution
PartitionedRegion pr = context.getPartitionedRegion();
if (pr != null && (result instanceof Region)) {
if (pr.getFullPath().equals(((Region) result).getFullPath())) {
result = context.getBucketRegion();
}
}
return result;
}
Aggregations