Search in sources :

Example 21 with IgniteException

use of org.apache.ignite.IgniteException in project ignite by apache.

the class GridTaskSessionImpl method removeCheckpoint0.

/**
     * @param ses Session.
     * @param key Key.
     * @return {@code True} if removed.
     * @throws IgniteException If failed.
     */
protected boolean removeCheckpoint0(GridTaskSessionInternal ses, String key) throws IgniteException {
    // Internal call, so assert should be enough.
    assert ses != null;
    A.notNull(key, "key");
    if (closed)
        throw new IgniteException("Failed to remove checkpoint (session closed): " + ses);
    checkFullSupport();
    return ctx.checkpoint().removeCheckpoint(ses, key);
}
Also used : IgniteException(org.apache.ignite.IgniteException)

Example 22 with IgniteException

use of org.apache.ignite.IgniteException in project ignite by apache.

the class GridTaskSessionImpl method saveCheckpoint0.

/**
     * @param ses Session.
     * @param key Key.
     * @param state State.
     * @param scope Scope.
     * @param timeout Timeout.
     * @param overwrite Overwrite.
     * @throws IgniteException If failed.
     */
protected void saveCheckpoint0(GridTaskSessionInternal ses, String key, Object state, ComputeTaskSessionScope scope, long timeout, boolean overwrite) throws IgniteException {
    // Internal call, so assert should be enough.
    assert ses != null;
    A.notNull(key, "key");
    A.ensure(timeout >= 0, "timeout >= 0");
    if (closed)
        throw new IgniteException("Failed to save checkpoint (session closed): " + ses);
    checkFullSupport();
    try {
        ctx.checkpoint().storeCheckpoint(ses, key, state, scope, timeout, overwrite);
    } catch (IgniteCheckedException e) {
        throw U.convertException(e);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException)

Example 23 with IgniteException

use of org.apache.ignite.IgniteException in project ignite by apache.

the class BinaryContext method userTypeMapper.

/**
     * @param clsName Type name.
     * @return Instance of ID mapper.
     */
BinaryInternalMapper userTypeMapper(String clsName) {
    BinaryInternalMapper mapper = cls2Mappers.get(clsName);
    if (mapper != null)
        return mapper;
    mapper = resolveMapper(clsName, igniteCfg.getBinaryConfiguration());
    BinaryInternalMapper prevMap = cls2Mappers.putIfAbsent(clsName, mapper);
    if (prevMap != null && !mapper.equals(prevMap))
        throw new IgniteException("Different mappers [clsName=" + clsName + ", newMapper=" + mapper + ", prevMap=" + prevMap + "]");
    prevMap = typeId2Mapper.putIfAbsent(mapper.typeId(clsName), mapper);
    if (prevMap != null && !mapper.equals(prevMap))
        throw new IgniteException("Different mappers [clsName=" + clsName + ", newMapper=" + mapper + ", prevMap=" + prevMap + "]");
    return mapper;
}
Also used : IgniteException(org.apache.ignite.IgniteException)

Example 24 with IgniteException

use of org.apache.ignite.IgniteException in project ignite by apache.

the class GridTcpRouterImpl method start.

/**
     * Starts router.
     *
     * @throws IgniteException If failed.
     */
@Override
public void start() throws IgniteException {
    try {
        client = createClient(cfg);
    } catch (GridClientException e) {
        throw new IgniteException("Failed to initialise embedded client.", e);
    }
    GridNioServerListener<GridClientMessage> lsnr;
    try {
        Class<?> cls = Class.forName(ENT_NIO_LSNR_CLS);
        Constructor<?> cons = cls.getDeclaredConstructor(IgniteLogger.class, GridRouterClientImpl.class);
        cons.setAccessible(true);
        lsnr = (GridNioServerListener<GridClientMessage>) cons.newInstance(log, client);
    } catch (ClassNotFoundException ignored) {
        lsnr = new GridTcpRouterNioListenerOsImpl(log, client);
    } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
        throw new IgniteException("Failed to create NIO listener.", e);
    }
    parser = new GridTcpRouterNioParser();
    final InetAddress hostAddr;
    try {
        hostAddr = InetAddress.getByName(cfg.getHost());
    } catch (UnknownHostException e) {
        throw new IgniteException("Failed to resolve grid address for configured host: " + cfg.getHost(), e);
    }
    SSLContext sslCtx;
    try {
        GridSslContextFactory sslCtxFactory = cfg.getSslContextFactory();
        sslCtx = sslCtxFactory == null ? null : sslCtxFactory.createSslContext();
    } catch (SSLException e) {
        throw new IgniteException("Failed to create SSL context.", e);
    }
    for (int port = cfg.getPort(), last = port + cfg.getPortRange(); port <= last; port++) {
        if (startTcpServer(hostAddr, port, lsnr, parser, cfg.isNoDelay(), sslCtx, cfg.isSslClientAuth(), cfg.isSslClientAuth())) {
            if (log.isInfoEnabled())
                log.info("TCP router successfully started for endpoint: " + hostAddr.getHostAddress() + ":" + port);
            bindPort = port;
            bindHost = hostAddr.getHostName();
            break;
        } else
            U.warn(log, "TCP REST router failed to start on endpoint: " + hostAddr.getHostAddress() + ":" + port + ". Will try next port within allowed port range.");
    }
    if (bindPort == 0)
        throw new IgniteException("Failed to bind TCP router server (possibly all ports in range " + "are in use) [firstPort=" + cfg.getPort() + ", lastPort=" + (cfg.getPort() + cfg.getPortRange()) + ", addr=" + hostAddr + ']');
    try {
        ObjectName objName = U.registerMBean(ManagementFactory.getPlatformMBeanServer(), "Router", "TCP Router " + id, getClass().getSimpleName(), this, GridTcpRouterMBean.class);
        if (log.isDebugEnabled())
            log.debug("Registered MBean: " + objName);
        mbeanName = objName;
    } catch (JMException e) {
        U.error(log, "Failed to register MBean.", e);
    }
}
Also used : GridClientException(org.apache.ignite.internal.client.GridClientException) UnknownHostException(java.net.UnknownHostException) SSLContext(javax.net.ssl.SSLContext) SSLException(javax.net.ssl.SSLException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ObjectName(javax.management.ObjectName) GridSslContextFactory(org.apache.ignite.internal.client.ssl.GridSslContextFactory) IgniteException(org.apache.ignite.IgniteException) JMException(javax.management.JMException) InetAddress(java.net.InetAddress) GridClientMessage(org.apache.ignite.internal.processors.rest.client.message.GridClientMessage)

Example 25 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)414 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)114 Ignite (org.apache.ignite.Ignite)82 ClusterNode (org.apache.ignite.cluster.ClusterNode)47 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)42 ArrayList (java.util.ArrayList)40 UUID (java.util.UUID)40 CountDownLatch (java.util.concurrent.CountDownLatch)40 IOException (java.io.IOException)32 HashMap (java.util.HashMap)32 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)31 CacheException (javax.cache.CacheException)31 Transaction (org.apache.ignite.transactions.Transaction)28 CyclicBarrier (java.util.concurrent.CyclicBarrier)21 Map (java.util.Map)20 IgniteCache (org.apache.ignite.IgniteCache)19 ClusterStartNodeResult (org.apache.ignite.cluster.ClusterStartNodeResult)18 Nullable (org.jetbrains.annotations.Nullable)18 List (java.util.List)17 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)16