/** {@inheritDoc} */ @Override public Set<Long> call() throws IgniteCheckedException { assert ignite != null; if (log.isInfoEnabled()) log.info("Running GetAndIncrementJob on node: " + ignite.cluster().localNode().id()); IgniteAtomicSequence seq = ignite.atomicSequence(seqName, 0, true); assert seq != null; // Result set. Set<Long> resSet = new HashSet<>(); // Get sequence value and try to put it result set. for (int i = 0; i < retries; i++) { long val = seq.getAndIncrement(); assert !resSet.contains(val) : "Element already in set : " + val; resSet.add(val); } return resSet; }
/** Checks consistency after all operations. */ private void consistencyCheck() { if (CONSISTENCY_CHECK) { assert lock.writeLock().isHeldByCurrentThread(); if (node2part == null) return; for (Map.Entry<UUID, GridDhtPartitionMap> e : node2part.entrySet()) { for (Integer p : e.getValue().keySet()) { Set<UUID> nodeIds = part2node.get(p); assert nodeIds != null : "Failed consistency check [part=" + p + ", nodeId=" + e.getKey() + ']'; assert nodeIds.contains(e.getKey()) : "Failed consistency check [part=" + p + ", nodeId=" + e.getKey() + ", nodeIds=" + nodeIds + ']'; } } for (Map.Entry<Integer, Set<UUID>> e : part2node.entrySet()) { for (UUID nodeId : e.getValue()) { GridDhtPartitionMap map = node2part.get(nodeId); assert map != null : "Failed consistency check [part=" + e.getKey() + ", nodeId=" + nodeId + ']'; assert map.containsKey(e.getKey()) : "Failed consistency check [part=" + e.getKey() + ", nodeId=" + nodeId + ']'; } } } }