Search in sources :

Example 31 with IgniteException

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

the class WebSessionV2 method getAttribute.

/**
 * {@inheritDoc}
 */
@Override
public Object getAttribute(final String name) {
    assertValid();
    Object attr = attributes().get(name);
    if (attr == REMOVED_ATTR)
        return null;
    if (attr == null) {
        final byte[] bytes = entity.attributes().get(name);
        if (bytes != null) {
            // deserialize
            try {
                attr = unmarshal(bytes);
            } catch (IOException e) {
                throw new IgniteException(e);
            }
            attributes().put(name, attr);
        }
    }
    return attr;
}
Also used : IgniteException(org.apache.ignite.IgniteException) IOException(java.io.IOException)

Example 32 with IgniteException

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

the class ServletContextListenerStartup method contextInitialized.

/**
 * {@inheritDoc}
 */
@Override
public void contextInitialized(ServletContextEvent evt) {
    ServletContext ctx = evt.getServletContext();
    String cfgFile = ctx.getInitParameter(IGNITE_CFG_FILE_PATH_PARAM);
    Collection<IgniteConfiguration> cfgs;
    GridSpringResourceContext rsrcCtx = null;
    if (cfgFile != null) {
        URL cfgUrl = null;
        try {
            cfgUrl = evt.getServletContext().getResource("/META-INF/" + cfgFile);
        } catch (MalformedURLException ignored) {
        // Ignore, we still need to try with IGNITE_HOME.
        }
        if (cfgUrl == null)
            // Try with IGNITE_HOME and with context class loader.
            cfgUrl = U.resolveIgniteUrl(cfgFile);
        if (cfgUrl == null)
            throw new IgniteException("Failed to find Spring configuration file (path provided should be " + "either absolute, relative to IGNITE_HOME, or relative to META-INF folder): " + cfgFile);
        IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> t;
        try {
            t = IgnitionEx.loadConfigurations(cfgUrl);
        } catch (IgniteCheckedException e) {
            throw new IgniteException("Failed to load Ignite configuration.", e);
        }
        cfgs = t.get1();
        rsrcCtx = t.get2();
        if (cfgs.isEmpty())
            throw new IgniteException("Can't find grid factory configuration in: " + cfgUrl);
    } else
        cfgs = Collections.<IgniteConfiguration>singleton(new IgniteConfiguration());
    try {
        assert !cfgs.isEmpty();
        for (IgniteConfiguration cfg : cfgs) {
            assert cfg != null;
            Ignite ignite;
            synchronized (ServletContextListenerStartup.class) {
                try {
                    ignite = G.ignite(cfg.getIgniteInstanceName());
                } catch (IgniteIllegalStateException ignored) {
                    ignite = IgnitionEx.start(new IgniteConfiguration(cfg), rsrcCtx);
                }
            }
            // Check if grid is not null - started properly.
            if (ignite != null)
                igniteInstanceNames.add(ignite.name());
        }
    } catch (IgniteCheckedException e) {
        // Stop started grids only.
        for (String name : igniteInstanceNames) G.stop(name, true);
        throw new IgniteException("Failed to start Ignite.", e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) URL(java.net.URL) IgniteIllegalStateException(org.apache.ignite.IgniteIllegalStateException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteException(org.apache.ignite.IgniteException) GridSpringResourceContext(org.apache.ignite.internal.processors.resource.GridSpringResourceContext) ServletContext(javax.servlet.ServletContext) Collection(java.util.Collection) Ignite(org.apache.ignite.Ignite)

Example 33 with IgniteException

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

the class IgniteIoTestAbstractBenchmark method setUp.

/**
 * {@inheritDoc}
 */
@Override
public void setUp(BenchmarkConfiguration cfg) throws Exception {
    super.setUp(cfg);
    ignite = (IgniteKernal) ignite();
    ClusterNode loc = ignite().cluster().localNode();
    Collection<ClusterNode> nodes = ignite().cluster().forServers().nodes();
    for (ClusterNode node : nodes) {
        if (!loc.equals(node))
            targetNodes.add(node);
    }
    if (targetNodes.isEmpty())
        throw new IgniteException("Failed to find remote server nodes [nodes=" + nodes + ']');
    BenchmarkUtils.println(cfg, "Initialized target nodes: " + F.nodeIds(targetNodes) + ']');
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteException(org.apache.ignite.IgniteException)

Example 34 with IgniteException

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

the class IgniteJdbcSqlQueryBenchmark method createStatement.

/**
 * @return Prepared statement.
 * @throws Exception
 */
private PreparedStatement createStatement() throws Exception {
    Class.forName("org.apache.ignite.IgniteJdbcDriver");
    Connection conn = null;
    try {
        conn = DriverManager.getConnection(args.jdbcUrl());
        return conn.prepareStatement("select * from Person where salary >= ? and salary <= ?");
    } catch (Exception e) {
        if (conn != null)
            conn.close();
        throw new IgniteException("Failed to create prepare statement.", e);
    }
}
Also used : IgniteException(org.apache.ignite.IgniteException) Connection(java.sql.Connection) IgniteException(org.apache.ignite.IgniteException)

Example 35 with IgniteException

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

the class RocketMQStreamer method start.

/**
 * Starts streamer.
 *
 * @throws IgniteException If failed.
 */
public void start() {
    if (!stopped)
        throw new IgniteException("Attempted to start an already started RocketMQ streamer");
    // validate parameters.
    A.notNull(getStreamer(), "streamer");
    A.notNull(getIgnite(), "ignite");
    A.notNull(topic, "topic");
    A.notNull(consumerGrp, "consumer group");
    A.notNullOrEmpty(nameSrvAddr, "nameserver address");
    A.ensure(null != getMultipleTupleExtractor(), "Multiple tuple extractor must be configured");
    log = getIgnite().log();
    consumer = new DefaultMQPushConsumer(consumerGrp);
    consumer.setNamesrvAddr(nameSrvAddr);
    consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
    try {
        consumer.subscribe(topic, "*");
    } catch (MQClientException e) {
        throw new IgniteException("Failed to subscribe to " + topic, e);
    }
    consumer.registerMessageListener(this);
    try {
        consumer.start();
    } catch (MQClientException e) {
        throw new IgniteException("Failed to start the streamer", e);
    }
    stopped = false;
}
Also used : IgniteException(org.apache.ignite.IgniteException) DefaultMQPushConsumer(org.apache.rocketmq.client.consumer.DefaultMQPushConsumer) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

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