use of org.apache.ignite.IgniteException in project ignite by apache.
the class BinaryObjectExImpl method hasCircularReferences.
/**
* Check if object graph has circular references.
*
* @return {@code true} if object has circular references.
*/
public boolean hasCircularReferences() {
try {
BinaryReaderHandles ctx = new BinaryReaderHandles();
ctx.put(start(), this);
return hasCircularReferences(ctx, new IdentityHashMap<BinaryObject, Integer>());
} catch (BinaryObjectException e) {
throw new IgniteException("Failed to check binary object for circular references", e);
}
}
use of org.apache.ignite.IgniteException in project ignite by apache.
the class GridCacheMapEntry method wrap.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public <K, V> Cache.Entry<K, V> wrap() {
try {
IgniteInternalTx tx = cctx.tm().userTx();
CacheObject val;
if (tx != null) {
GridTuple<CacheObject> peek = tx.peek(cctx, false, key);
val = peek == null ? rawGet() : peek.get();
} else
val = rawGet();
return new CacheEntryImpl<>(key.<K>value(cctx.cacheObjectContext(), false), CU.<V>value(val, cctx, false), ver);
} catch (GridCacheFilterFailedException ignored) {
throw new IgniteException("Should never happen.");
}
}
use of org.apache.ignite.IgniteException in project ignite by apache.
the class CacheObjectImpl method value.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Nullable
@Override
public <T> T value(CacheObjectValueContext ctx, boolean cpy) {
cpy = cpy && needCopy(ctx);
try {
GridKernalContext kernalCtx = ctx.kernalContext();
IgniteCacheObjectProcessor proc = ctx.kernalContext().cacheObjects();
if (cpy) {
if (valBytes == null) {
assert val != null;
valBytes = proc.marshal(ctx, val);
}
ClassLoader clsLdr;
if (val != null)
clsLdr = val.getClass().getClassLoader();
else if (kernalCtx.config().isPeerClassLoadingEnabled())
clsLdr = kernalCtx.cache().context().deploy().globalLoader();
else
clsLdr = null;
return (T) proc.unmarshal(ctx, valBytes, clsLdr);
}
if (val != null)
return (T) val;
assert valBytes != null;
Object val = proc.unmarshal(ctx, valBytes, kernalCtx.config().isPeerClassLoadingEnabled() ? kernalCtx.cache().context().deploy().globalLoader() : null);
if (ctx.storeValue())
this.val = val;
return (T) val;
} catch (IgniteCheckedException e) {
throw new IgniteException("Failed to unmarshall object.", e);
}
}
use of org.apache.ignite.IgniteException in project ignite by apache.
the class EntryProcessorResourceInjectorProxy method process.
/**
* {@inheritDoc}
*/
@Override
public T process(MutableEntry<K, V> entry, Object... arguments) throws EntryProcessorException {
if (!injected) {
GridCacheContext cctx = entry.unwrap(GridCacheContext.class);
GridResourceProcessor rsrc = cctx.kernalContext().resource();
try {
rsrc.inject(delegate, GridResourceIoc.AnnotationSet.ENTRY_PROCESSOR, cctx.name());
} catch (IgniteCheckedException e) {
throw new IgniteException(e);
}
injected = true;
}
return delegate.process(entry, arguments);
}
use of org.apache.ignite.IgniteException in project ignite by apache.
the class GridIoManager method addMessageListener.
/**
* @param topic Listener's topic.
* @param lsnr Listener to add.
*/
@SuppressWarnings({ "deprecation", "SynchronizationOnLocalVariableOrMethodParameter" })
public void addMessageListener(Object topic, final GridMessageListener lsnr) {
assert lsnr != null;
assert topic != null;
// Make sure that new topic is not in the list of closed topics.
closedTopics.remove(topic);
GridMessageListener lsnrs;
for (; ; ) {
lsnrs = listenerPutIfAbsent0(topic, lsnr);
if (lsnrs == null) {
lsnrs = lsnr;
break;
}
assert lsnrs != null;
if (!(lsnrs instanceof ArrayListener)) {
// We are putting the second listener, creating array.
GridMessageListener arrLsnr = new ArrayListener(lsnrs, lsnr);
if (listenerReplace0(topic, lsnrs, arrLsnr)) {
lsnrs = arrLsnr;
break;
}
} else {
if (((ArrayListener) lsnrs).add(lsnr))
break;
// Add operation failed because array is already empty and is about to be removed, helping and retrying.
listenerRemove0(topic, lsnrs);
}
}
Map<UUID, GridCommunicationMessageSet> map = msgSetMap.get(topic);
Collection<GridCommunicationMessageSet> msgSets = map != null ? map.values() : null;
if (msgSets != null) {
final GridMessageListener lsnrs0 = lsnrs;
try {
for (final GridCommunicationMessageSet msgSet : msgSets) {
pools.poolForPolicy(msgSet.policy()).execute(new Runnable() {
@Override
public void run() {
unwindMessageSet(msgSet, lsnrs0);
}
});
}
} catch (RejectedExecutionException e) {
U.error(log, "Failed to process delayed message due to execution rejection. Increase the upper bound " + "on executor service provided in 'IgniteConfiguration.getPublicThreadPoolSize()'). Will attempt to " + "process message in the listener thread instead.", e);
for (GridCommunicationMessageSet msgSet : msgSets) unwindMessageSet(msgSet, lsnr);
} catch (IgniteCheckedException ice) {
throw new IgniteException(ice);
}
}
}
Aggregations