use of org.apache.ignite.internal.processors.cache.CacheInvalidStateException in project ignite by apache.
the class GridDhtPartitionsExchangeFuture method validateCache.
/** {@inheritDoc} */
@Nullable
@Override
public Throwable validateCache(GridCacheContext cctx, boolean recovery, boolean read, @Nullable Object key, @Nullable Collection<?> keys) {
assert isDone() : this;
Throwable err = error();
if (err != null)
return err;
if (!cctx.shared().kernalContext().state().active())
return new CacheInvalidStateException("Failed to perform cache operation (cluster is not activated): " + cctx.name());
PartitionLossPolicy partLossPlc = cctx.config().getPartitionLossPolicy();
if (cctx.needsRecovery() && !recovery) {
if (!read && (partLossPlc == READ_ONLY_SAFE || partLossPlc == READ_ONLY_ALL))
return new IgniteCheckedException("Failed to write to cache (cache is moved to a read-only state): " + cctx.name());
}
if (cctx.needsRecovery() || cctx.config().getTopologyValidator() != null) {
CacheValidation validation = cacheValidRes.get(cctx.cacheId());
if (validation == null)
return null;
if (!validation.valid && !read)
return new IgniteCheckedException("Failed to perform cache operation " + "(cache topology is not valid): " + cctx.name());
if (recovery || !cctx.needsRecovery())
return null;
if (key != null) {
int p = cctx.affinity().partition(key);
CacheInvalidStateException ex = validatePartitionOperation(cctx.name(), read, key, p, validation.lostParts, partLossPlc);
if (ex != null)
return ex;
}
if (keys != null) {
for (Object k : keys) {
int p = cctx.affinity().partition(k);
CacheInvalidStateException ex = validatePartitionOperation(cctx.name(), read, k, p, validation.lostParts, partLossPlc);
if (ex != null)
return ex;
}
}
}
return null;
}
Aggregations