Search in sources :

Example 26 with IgniteException

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

the class JdbcConnection method loadConfiguration.

/**
     * @param cfgUrl Config URL.
     * @return Ignite config and Spring context.
     */
private IgniteBiTuple<IgniteConfiguration, ? extends GridSpringResourceContext> loadConfiguration(String cfgUrl) {
    try {
        IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> cfgMap = IgnitionEx.loadConfigurations(cfgUrl);
        IgniteConfiguration cfg = F.first(cfgMap.get1());
        if (cfg.getIgniteInstanceName() == null)
            cfg.setIgniteInstanceName("ignite-jdbc-driver-" + UUID.randomUUID().toString());
        // Force client mode.
        cfg.setClientMode(true);
        return new IgniteBiTuple<>(cfg, cfgMap.getValue());
    } catch (IgniteCheckedException e) {
        throw new IgniteException(e);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) IgniteException(org.apache.ignite.IgniteException) Collection(java.util.Collection)

Example 27 with IgniteException

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

the class JdbcConnection method getIgnite.

/**
     * @param cfgUrl Config url.
     */
private Ignite getIgnite(String cfgUrl) throws IgniteCheckedException {
    while (true) {
        IgniteNodeFuture fut = NODES.get(cfg);
        if (fut == null) {
            fut = new IgniteNodeFuture();
            IgniteNodeFuture old = NODES.putIfAbsent(cfg, fut);
            if (old != null)
                fut = old;
            else {
                try {
                    Ignite ignite;
                    if (NULL.equals(cfg)) {
                        Ignition.setClientMode(true);
                        ignite = Ignition.start();
                    } else {
                        IgniteBiTuple<IgniteConfiguration, ? extends GridSpringResourceContext> cfgAndCtx = loadConfiguration(cfgUrl);
                        ignite = IgnitionEx.start(cfgAndCtx.get1(), cfgAndCtx.get2());
                    }
                    fut.onDone(ignite);
                } catch (IgniteException e) {
                    fut.onDone(e);
                }
                return fut.get();
            }
        }
        if (fut.acquire())
            return fut.get();
        else
            NODES.remove(cfg, fut);
    }
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteException(org.apache.ignite.IgniteException) Ignite(org.apache.ignite.Ignite)

Example 28 with IgniteException

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

the class GridDiscoveryManager method resolveDiscoCache.

/**
     * Gets discovery cache for given topology version.
     *
     * @param cacheId Cache ID (participates in exception message).
     * @param topVer Topology version.
     * @return Discovery cache.
     */
private DiscoCache resolveDiscoCache(int cacheId, AffinityTopologyVersion topVer) {
    Snapshot snap = topSnap.get();
    DiscoCache cache = AffinityTopologyVersion.NONE.equals(topVer) || topVer.equals(snap.topVer) ? snap.discoCache : discoCacheHist.get(topVer);
    if (cache == null) {
        DynamicCacheDescriptor desc = ctx.cache().cacheDescriptor(cacheId);
        throw new IgniteException("Failed to resolve nodes topology [" + "cacheName=" + (desc != null ? desc.cacheConfiguration().getName() : "N/A") + ", topVer=" + topVer + ", history=" + discoCacheHist.keySet() + ", snap=" + snap + ", locNode=" + ctx.discovery().localNode() + ']');
    }
    return cache;
}
Also used : ClusterMetricsSnapshot(org.apache.ignite.internal.ClusterMetricsSnapshot) IgniteException(org.apache.ignite.IgniteException) DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor)

Example 29 with IgniteException

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

the class MappedFileMemoryProvider method initialize.

/** {@inheritDoc} */
@Override
public void initialize(long[] sizes) {
    this.sizes = sizes;
    mappedFiles = new ArrayList<>(sizes.length);
    if (!allocationPath.exists()) {
        if (!allocationPath.mkdirs())
            throw new IgniteException("Failed to initialize allocation path (make sure directory is " + "writable for the current user): " + allocationPath);
    }
    if (!allocationPath.isDirectory())
        throw new IgniteException("Failed to initialize allocation path (path is a file): " + allocationPath);
    File[] files = allocationPath.listFiles(ALLOCATOR_FILTER);
    if (files.length != 0) {
        log.info("Will clean up the following files upon start: " + Arrays.asList(files));
        for (File file : files) {
            if (!file.delete())
                throw new IgniteException("Failed to delete allocated file on start (make sure file is not " + "opened by another process and current user has enough rights): " + file);
        }
    }
}
Also used : IgniteException(org.apache.ignite.IgniteException) File(java.io.File)

Example 30 with IgniteException

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

the class UnsafeMemoryProvider method nextRegion.

/** {@inheritDoc} */
@Override
public DirectMemoryRegion nextRegion() {
    if (regions.size() == sizes.length)
        return null;
    long chunkSize = sizes[regions.size()];
    long ptr;
    try {
        ptr = GridUnsafe.allocateMemory(chunkSize);
    } catch (IllegalArgumentException e) {
        String msg = "Failed to allocate next memory chunk: " + U.readableSize(chunkSize, true) + ". Check if chunkSize is too large and 32-bit JVM is used.";
        if (regions.size() == 0)
            throw new IgniteException(msg, e);
        U.error(log, msg);
        return null;
    }
    if (ptr <= 0) {
        U.error(log, "Failed to allocate next memory chunk: " + U.readableSize(chunkSize, true));
        return null;
    }
    DirectMemoryRegion region = new UnsafeChunk(ptr, chunkSize);
    regions.add(region);
    return region;
}
Also used : UnsafeChunk(org.apache.ignite.internal.mem.UnsafeChunk) IgniteException(org.apache.ignite.IgniteException) DirectMemoryRegion(org.apache.ignite.internal.mem.DirectMemoryRegion)

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