use of org.apache.ignite.internal.processors.cache.GridCacheInternal in project ignite by apache.
the class GridCacheQueryManager method remove.
/**
* @param key Key.
* @param partId Partition.
* @param val Value.
* @param ver Version.
* @throws IgniteCheckedException Thrown in case of any errors.
*/
@SuppressWarnings("SimplifiableIfStatement")
public void remove(KeyCacheObject key, int partId, CacheObject val, GridCacheVersion ver) throws IgniteCheckedException {
assert key != null;
if (!QueryUtils.isEnabled(cctx.config()) && !(key instanceof GridCacheInternal))
// No-op.
return;
if (!enterBusy())
// Ignore index update when node is stopping.
return;
try {
if (isIndexingSpiEnabled()) {
Object key0 = unwrapIfNeeded(key, cctx.cacheObjectContext());
cctx.kernalContext().indexing().remove(cacheName, key0);
}
// val may be null if we have no previous value. We should not call processor in this case.
if (qryProcEnabled && val != null)
qryProc.remove(cacheName, key, partId, val, ver);
} finally {
invalidateResultCache();
leaveBusy();
}
}
use of org.apache.ignite.internal.processors.cache.GridCacheInternal in project ignite by apache.
the class DataStructuresProcessor method onActivate.
/** {@inheritDoc} */
@Override
public void onActivate(GridKernalContext ctx) throws IgniteCheckedException {
if (log.isDebugEnabled())
log.debug("Activate data structure processor [nodeId=" + ctx.localNodeId() + " topVer=" + ctx.discovery().topologyVersionEx() + " ]");
this.initFailed = false;
this.initLatch = new CountDownLatch(1);
this.qryId = null;
ctx.event().addLocalEventListener(lsnr, EVT_NODE_LEFT, EVT_NODE_FAILED);
onKernalStart0(true);
for (Map.Entry<GridCacheInternal, GridCacheRemovable> e : dsMap.entrySet()) {
GridCacheRemovable v = e.getValue();
if (v instanceof IgniteChangeGlobalStateSupport)
((IgniteChangeGlobalStateSupport) v).onActivate(ctx);
}
}
use of org.apache.ignite.internal.processors.cache.GridCacheInternal in project ignite by apache.
the class DataStructuresProcessor method removeCountDownLatch.
/**
* Removes count down latch from cache.
*
* @param name Name of the latch.
* @throws IgniteCheckedException If operation failed.
*/
public void removeCountDownLatch(final String name) throws IgniteCheckedException {
assert name != null;
assert dsCacheCtx != null;
awaitInitialization();
removeDataStructure(new IgniteOutClosureX<Void>() {
@Override
public Void applyx() throws IgniteCheckedException {
GridCacheInternal key = new GridCacheInternalKeyImpl(name);
dsCacheCtx.gate().enter();
try (GridNearTxLocal tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
// Check correctness type of removable object.
GridCacheCountDownLatchValue val = cast(dsView.get(key), GridCacheCountDownLatchValue.class);
if (val != null) {
if (val.get() > 0) {
throw new IgniteCheckedException("Failed to remove count down latch " + "with non-zero count: " + val.get());
}
dsView.remove(key);
tx.commit();
} else
tx.setRollbackOnly();
return null;
} finally {
dsCacheCtx.gate().leave();
}
}
}, name, COUNT_DOWN_LATCH, null);
}
use of org.apache.ignite.internal.processors.cache.GridCacheInternal in project ignite by apache.
the class GridCacheStoreManagerAdapter method put.
/**
* {@inheritDoc}
*/
@Override
public final boolean put(@Nullable IgniteInternalTx tx, KeyCacheObject key, CacheObject val, GridCacheVersion ver) throws IgniteCheckedException {
if (store != null) {
// Never persist internal keys.
if (key instanceof GridCacheInternal)
return true;
Object key0 = cctx.unwrapBinaryIfNeeded(key, !convertBinary(), null);
Object val0 = cctx.unwrapBinaryIfNeeded(val, !convertBinary(), null);
if (log.isDebugEnabled()) {
log.debug(S.toString("Storing value in cache store", "key", key0, true, "val", val0, true));
}
sessionInit0(tx, StoreOperation.WRITE, false);
boolean threwEx = true;
try {
store.write(new CacheEntryImpl<>(key0, locStore ? F.t(val0, ver) : val0));
threwEx = false;
} catch (ClassCastException e) {
handleClassCastException(e);
} catch (CacheWriterException e) {
throw new IgniteCheckedException(e);
} catch (Exception e) {
throw new IgniteCheckedException(new CacheWriterException(e));
} finally {
sessionEnd0(tx, threwEx);
}
if (log.isDebugEnabled()) {
log.debug(S.toString("Stored value in cache store", "key", key0, true, "val", val0, true));
}
return true;
}
return false;
}
use of org.apache.ignite.internal.processors.cache.GridCacheInternal in project ignite by apache.
the class GridCacheQueryManager method store.
/**
* Writes key-value pair to index.
*
* @param key Key.
* @param partId Partition.
* @param prevVal Previous value.
* @param prevVer Previous version.
* @param val Value.
* @param ver Cache entry version.
* @param expirationTime Expiration time or 0 if never expires.
* @param link Link.
* @throws IgniteCheckedException In case of error.
*/
public void store(KeyCacheObject key, int partId, @Nullable CacheObject prevVal, @Nullable GridCacheVersion prevVer, CacheObject val, GridCacheVersion ver, long expirationTime, long link) throws IgniteCheckedException {
assert key != null;
assert val != null;
assert enabled();
if (key instanceof GridCacheInternal)
// No-op.
return;
if (!enterBusy())
throw new NodeStoppingException("Operation has been cancelled (node is stopping).");
try {
if (isIndexingSpiEnabled()) {
CacheObjectContext coctx = cctx.cacheObjectContext();
Object key0 = unwrapIfNeeded(key, coctx);
Object val0 = unwrapIfNeeded(val, coctx);
cctx.kernalContext().indexing().store(cacheName, key0, val0, expirationTime);
}
if (qryProcEnabled)
qryProc.store(cacheName, key, partId, prevVal, prevVer, val, ver, expirationTime, link);
} finally {
invalidateResultCache();
leaveBusy();
}
}
Aggregations