use of org.apache.ignite.internal.util.future.GridCompoundFuture in project ignite by apache.
the class GridCacheProcessor method dynamicStartCaches.
/**
* Dynamically starts multiple caches.
*
* @param ccfgList Collection of cache configuration.
* @param cacheType Cache type.
* @param failIfExists Fail if exists flag.
* @param checkThreadTx If {@code true} checks that current thread does not have active transactions.
* @return Future that will be completed when all caches are deployed.
*/
private IgniteInternalFuture<?> dynamicStartCaches(Collection<CacheConfiguration> ccfgList, CacheType cacheType, boolean failIfExists, boolean checkThreadTx) {
if (checkThreadTx)
checkEmptyTransactions();
List<DynamicCacheChangeRequest> reqList = new ArrayList<>(ccfgList.size());
try {
for (CacheConfiguration ccfg : ccfgList) {
DynamicCacheChangeRequest req = prepareCacheChangeRequest(ccfg, ccfg.getName(), null, cacheType, false, failIfExists, true);
if (req != null)
reqList.add(req);
}
} catch (Exception e) {
return new GridFinishedFuture<>(e);
}
if (!reqList.isEmpty()) {
GridCompoundFuture<?, ?> compoundFut = new GridCompoundFuture<>();
for (DynamicCacheStartFuture fut : initiateCacheChanges(reqList, failIfExists)) compoundFut.add((IgniteInternalFuture) fut);
compoundFut.markInitialized();
return compoundFut;
} else
return new GridFinishedFuture<>();
}
use of org.apache.ignite.internal.util.future.GridCompoundFuture in project ignite by apache.
the class GridCacheSharedContext method partitionReleaseFuture.
/**
* Captures all ongoing operations that we need to wait before we can proceed to the next topology version.
* This method must be called only after
* {@link GridDhtPartitionTopology#updateTopologyVersion(GridDhtPartitionExchangeId, GridDhtPartitionsExchangeFuture, long, boolean)}
* method is called so that all new updates will wait to switch to the new version.
* This method will capture:
* <ul>
* <li>All non-released cache locks</li>
* <li>All non-committed transactions (local and remote)</li>
* <li>All pending atomic updates</li>
* <li>All pending DataStreamer updates</li>
* </ul>
*
* Captured updates are wrapped in a future that will be completed once pending objects are released.
*
* @param topVer Topology version.
* @return {@code true} if waiting was successful.
*/
@SuppressWarnings({ "unchecked" })
public IgniteInternalFuture<?> partitionReleaseFuture(AffinityTopologyVersion topVer) {
GridCompoundFuture f = new GridCompoundFuture();
f.add(mvcc().finishExplicitLocks(topVer));
f.add(tm().finishTxs(topVer));
f.add(mvcc().finishAtomicUpdates(topVer));
f.add(mvcc().finishDataStreamerUpdates());
f.markInitialized();
return f;
}
use of org.apache.ignite.internal.util.future.GridCompoundFuture in project ignite by apache.
the class GridCacheMvccManager method finishExplicitLocks.
/**
* Creates a future that will wait for all explicit locks acquired on given topology
* version to be released.
*
* @param topVer Topology version to wait for.
* @return Explicit locks release future.
*/
public IgniteInternalFuture<?> finishExplicitLocks(AffinityTopologyVersion topVer) {
GridCompoundFuture<Object, Object> res = new GridCompoundFuture<>();
for (GridCacheExplicitLockSpan span : pendingExplicit.values()) {
AffinityTopologyVersion snapshot = span.topologyVersion();
if (snapshot != null && snapshot.compareTo(topVer) < 0)
res.add(span.releaseFuture());
}
res.markInitialized();
return res;
}
use of org.apache.ignite.internal.util.future.GridCompoundFuture in project ignite by apache.
the class GridCacheMvccManager method finishDataStreamerUpdates.
/**
*
* @return Finish update future.
*/
@SuppressWarnings("unchecked")
public IgniteInternalFuture<?> finishDataStreamerUpdates() {
GridCompoundFuture<Object, Object> res = new GridCompoundFuture<>();
for (IgniteInternalFuture fut : dataStreamerFuts) res.add(fut);
res.markInitialized();
return res;
}
use of org.apache.ignite.internal.util.future.GridCompoundFuture in project ignite by apache.
the class IgniteTxHandler method processDhtTxFinishRequest.
/**
* @param nodeId Node ID.
* @param req Request.
*/
@SuppressWarnings({ "unchecked" })
private void processDhtTxFinishRequest(final UUID nodeId, final GridDhtTxFinishRequest req) {
assert nodeId != null;
assert req != null;
if (req.checkCommitted()) {
boolean committed = req.waitRemoteTransactions() || !ctx.tm().addRolledbackTx(null, req.version());
if (!committed || req.syncMode() != FULL_SYNC)
sendReply(nodeId, req, committed, null);
else {
IgniteInternalFuture<?> fut = ctx.tm().remoteTxFinishFuture(req.version());
fut.listen(new CI1<IgniteInternalFuture<?>>() {
@Override
public void apply(IgniteInternalFuture<?> fut) {
sendReply(nodeId, req, true, null);
}
});
}
return;
}
final GridDhtTxRemote dhtTx = ctx.tm().tx(req.version());
GridNearTxRemote nearTx = ctx.tm().nearTx(req.version());
final GridCacheVersion nearTxId = (dhtTx != null ? dhtTx.nearXidVersion() : (nearTx != null ? nearTx.nearXidVersion() : null));
if (txFinishMsgLog.isDebugEnabled()) {
txFinishMsgLog.debug("Received dht finish request [txId=" + nearTxId + ", dhtTxId=" + req.version() + ", node=" + nodeId + ']');
}
// Safety - local transaction will finish explicitly.
if (nearTx != null && nearTx.local())
nearTx = null;
finish(nodeId, dhtTx, req);
if (nearTx != null)
finish(nodeId, nearTx, req);
if (req.replyRequired()) {
IgniteInternalFuture completeFut;
IgniteInternalFuture<IgniteInternalTx> dhtFin = dhtTx == null ? null : dhtTx.done() ? null : dhtTx.finishFuture();
final IgniteInternalFuture<IgniteInternalTx> nearFin = nearTx == null ? null : nearTx.done() ? null : nearTx.finishFuture();
if (dhtFin != null && nearFin != null) {
GridCompoundFuture fut = new GridCompoundFuture();
fut.add(dhtFin);
fut.add(nearFin);
fut.markInitialized();
completeFut = fut;
} else
completeFut = dhtFin != null ? dhtFin : nearFin;
if (completeFut != null) {
completeFut.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
@Override
public void apply(IgniteInternalFuture<IgniteInternalTx> fut) {
sendReply(nodeId, req, true, nearTxId);
}
});
} else
sendReply(nodeId, req, true, nearTxId);
} else
sendReply(nodeId, req, true, null);
IgniteInternalTx tx0 = ctx.tm().tx(req.version());
IgniteInternalTx nearTx0 = ctx.tm().nearTx(req.version());
assert req.txState() != null || (tx0 == null && nearTx0 == null) : req + " tx=" + tx0 + " nearTx=" + nearTx0;
}
Aggregations