Search in sources :

Example 61 with IgniteException

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);
    }
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) IgniteException(org.apache.ignite.IgniteException) BinaryObjectException(org.apache.ignite.binary.BinaryObjectException)

Example 62 with IgniteException

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.");
    }
}
Also used : IgniteInternalTx(org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx) IgniteException(org.apache.ignite.IgniteException)

Example 63 with IgniteException

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);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridKernalContext(org.apache.ignite.internal.GridKernalContext) IgniteCacheObjectProcessor(org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor) IgniteException(org.apache.ignite.IgniteException) Nullable(org.jetbrains.annotations.Nullable)

Example 64 with IgniteException

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);
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) GridResourceProcessor(org.apache.ignite.internal.processors.resource.GridResourceProcessor)

Example 65 with IgniteException

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);
        }
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable) UUID(java.util.UUID) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Aggregations

IgniteException (org.apache.ignite.IgniteException)498 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)160 Ignite (org.apache.ignite.Ignite)97 ClusterNode (org.apache.ignite.cluster.ClusterNode)54 ArrayList (java.util.ArrayList)52 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)45 CountDownLatch (java.util.concurrent.CountDownLatch)44 UUID (java.util.UUID)43 IOException (java.io.IOException)39 CacheException (javax.cache.CacheException)35 HashMap (java.util.HashMap)34 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)34 Transaction (org.apache.ignite.transactions.Transaction)34 List (java.util.List)24 CyclicBarrier (java.util.concurrent.CyclicBarrier)21 Map (java.util.Map)20 Collection (java.util.Collection)18 ClusterStartNodeResult (org.apache.ignite.cluster.ClusterStartNodeResult)18 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)18 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)17