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);
}
}
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);
}
}
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;
}
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);
}
}
}
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;
}
Aggregations