use of org.apache.ignite.IgniteCheckedException in project ignite by apache.
the class GridCacheSetImpl method iterator0.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
private GridCloseableIterator<T> iterator0() {
try {
CacheQuery qry = new GridCacheQueryAdapter<>(ctx, SET, null, null, new GridSetQueryPredicate<>(id, collocated), null, false, false);
Collection<ClusterNode> nodes = dataNodes(ctx.affinity().affinityTopologyVersion());
qry.projection(ctx.grid().cluster().forNodes(nodes));
CacheQueryFuture<Map.Entry<T, ?>> fut = qry.execute();
CacheWeakQueryIteratorsHolder.WeakReferenceCloseableIterator it = ctx.itHolder().iterator(fut, new CacheIteratorConverter<T, Map.Entry<T, ?>>() {
@Override
protected T convert(Map.Entry<T, ?> e) {
return e.getKey();
}
@Override
protected void remove(T item) {
GridCacheSetImpl.this.remove(item);
}
});
if (rmvd) {
ctx.itHolder().removeIterator(it);
checkRemoved();
}
return it;
} catch (IgniteCheckedException e) {
throw U.convertException(e);
}
}
use of org.apache.ignite.IgniteCheckedException in project ignite by apache.
the class GridClusterStateProcessor method changeGlobalState0.
/**
*/
private IgniteInternalFuture<?> changeGlobalState0(final boolean activate, BaselineTopology blt, boolean forceChangeBaselineTopology) {
if (ctx.isDaemon() || ctx.clientNode()) {
GridFutureAdapter<Void> fut = new GridFutureAdapter<>();
sendComputeChangeGlobalState(activate, blt, forceChangeBaselineTopology, fut);
return fut;
}
if (cacheProc.transactions().tx() != null || sharedCtx.lockedTopologyVersion(null) != null) {
return new GridFinishedFuture<>(new IgniteCheckedException("Failed to " + prettyStr(activate) + " cluster (must invoke the method outside of an active transaction)."));
}
DiscoveryDataClusterState curState = globalState;
if (!curState.transition() && curState.active() == activate && BaselineTopology.equals(curState.baselineTopology(), blt))
return new GridFinishedFuture<>();
GridChangeGlobalStateFuture startedFut = null;
GridChangeGlobalStateFuture fut = stateChangeFut.get();
while (fut == null || fut.isDone()) {
fut = new GridChangeGlobalStateFuture(UUID.randomUUID(), activate, ctx);
if (stateChangeFut.compareAndSet(null, fut)) {
startedFut = fut;
break;
} else
fut = stateChangeFut.get();
}
if (startedFut == null) {
if (fut.activate != activate) {
return new GridFinishedFuture<>(new IgniteCheckedException("Failed to " + prettyStr(activate) + ", because another state change operation is currently in progress: " + prettyStr(fut.activate)));
} else
return fut;
}
List<StoredCacheData> storedCfgs = null;
if (activate && CU.isPersistenceEnabled(ctx.config())) {
try {
Map<String, StoredCacheData> cfgs = ctx.cache().context().pageStore().readCacheConfigurations();
if (!F.isEmpty(cfgs))
storedCfgs = new ArrayList<>(cfgs.values());
} catch (IgniteCheckedException e) {
U.error(log, "Failed to read stored cache configurations: " + e, e);
startedFut.onDone(e);
return startedFut;
}
}
ChangeGlobalStateMessage msg = new ChangeGlobalStateMessage(startedFut.requestId, ctx.localNodeId(), storedCfgs, activate, blt, forceChangeBaselineTopology, System.currentTimeMillis());
try {
if (log.isInfoEnabled())
U.log(log, "Sending " + prettyStr(activate) + " request with BaselineTopology " + blt);
ctx.discovery().sendCustomEvent(msg);
if (ctx.isStopping())
startedFut.onDone(new IgniteCheckedException("Failed to execute " + prettyStr(activate) + " request, " + "node is stopping."));
} catch (IgniteCheckedException e) {
U.error(log, "Failed to send global state change request: " + activate, e);
startedFut.onDone(e);
}
return wrapStateChangeFuture(startedFut, msg);
}
use of org.apache.ignite.IgniteCheckedException in project ignite by apache.
the class GridClusterStateProcessor method publicApiActiveState.
/**
* {@inheritDoc}
*/
@Override
public boolean publicApiActiveState(boolean waitForTransition) {
if (ctx.isDaemon())
return sendComputeCheckGlobalState();
DiscoveryDataClusterState globalState = this.globalState;
assert globalState != null;
if (globalState.transition() && globalState.activeStateChanging()) {
Boolean transitionRes = globalState.transitionResult();
if (transitionRes != null)
return transitionRes;
else {
if (waitForTransition) {
GridFutureAdapter<Void> fut = transitionFuts.get(globalState.transitionRequestId());
if (fut != null) {
try {
fut.get();
} catch (IgniteCheckedException ex) {
throw new IgniteException(ex);
}
}
transitionRes = globalState.transitionResult();
assert transitionRes != null;
return transitionRes;
} else
return false;
}
} else
return globalState.active();
}
use of org.apache.ignite.IgniteCheckedException in project ignite by apache.
the class HadoopV2Job method input.
/**
* {@inheritDoc}
*/
@Override
public Collection<HadoopInputSplit> input() {
ClassLoader oldLdr = HadoopCommonUtils.setContextClassLoader(jobConf.getClassLoader());
try {
String jobDirPath = jobConf.get(MRJobConfig.MAPREDUCE_JOB_DIR);
if (jobDirPath == null) {
// Assume that we have needed classes and try to generate input splits ourself.
if (jobConf.getUseNewMapper())
return HadoopV2Splitter.splitJob(jobCtx);
else
return HadoopV1Splitter.splitJob(jobConf);
}
Path jobDir = new Path(jobDirPath);
try {
FileSystem fs = fileSystem(jobDir.toUri(), jobConf);
JobSplit.TaskSplitMetaInfo[] metaInfos = SplitMetaInfoReader.readSplitMetaInfo(hadoopJobID, fs, jobConf, jobDir);
if (F.isEmpty(metaInfos))
throw new IgniteCheckedException("No input splits found.");
Path splitsFile = JobSubmissionFiles.getJobSplitFile(jobDir);
try (FSDataInputStream in = fs.open(splitsFile)) {
Collection<HadoopInputSplit> res = new ArrayList<>(metaInfos.length);
for (JobSplit.TaskSplitMetaInfo metaInfo : metaInfos) {
long off = metaInfo.getStartOffset();
String[] hosts = metaInfo.getLocations();
in.seek(off);
String clsName = Text.readString(in);
HadoopFileBlock block = HadoopV1Splitter.readFileBlock(clsName, in, hosts);
if (block == null)
block = HadoopV2Splitter.readFileBlock(clsName, in, hosts);
res.add(block != null ? block : new HadoopExternalSplit(hosts, off));
}
return res;
}
} catch (Throwable e) {
if (e instanceof Error)
throw (Error) e;
else
throw transformException(e);
}
} catch (IgniteCheckedException e) {
throw new IgniteException(e);
} finally {
HadoopCommonUtils.restoreContextClassLoader(oldLdr);
}
}
use of org.apache.ignite.IgniteCheckedException in project ignite by apache.
the class HadoopV2Job method dispose.
/**
* {@inheritDoc}
*/
@SuppressWarnings("ThrowFromFinallyBlock")
@Override
public void dispose(boolean external) throws IgniteCheckedException {
try {
if (rsrcMgr != null && !external) {
File jobLocDir = jobLocalDir(igniteWorkDirectory(), locNodeId, jobId);
if (jobLocDir.exists())
U.delete(jobLocDir);
}
} finally {
taskCtxClsPool.clear();
Throwable err = null;
// with the task class loaders:
while (true) {
Class<? extends HadoopTaskContext> cls = fullCtxClsQueue.poll();
if (cls == null)
break;
try {
final ClassLoader ldr = cls.getClassLoader();
try {
// Stop Hadoop daemons for this *task*:
stopHadoopFsDaemons(ldr);
} catch (Exception e) {
if (err == null)
err = e;
}
// Also close all the FileSystems cached in
// HadoopLazyConcurrentMap for this *task* class loader:
closeCachedTaskFileSystems(ldr);
} catch (Throwable e) {
if (err == null)
err = e;
if (e instanceof Error)
throw (Error) e;
}
}
assert fullCtxClsQueue.isEmpty();
try {
// Close all cached file systems for this *Job*:
fsMap.close();
} catch (Exception e) {
if (err == null)
err = e;
}
if (err != null)
throw U.cast(err);
}
}
Aggregations