Search in sources :

Example 1 with GroupStateSnapshot

use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.EarliestCheckpointMapSnapshot.GroupStateSnapshot in project ignite by apache.

the class CheckpointHistory method earliestCheckpointsMapSnapshot.

/**
 * Creates a snapshot of {@link #earliestCp} map.
 * Guarded by checkpoint read lock.
 *
 * @return Snapshot of a map.
 */
public EarliestCheckpointMapSnapshot earliestCheckpointsMapSnapshot() {
    Map<UUID, Map<Integer, GroupStateSnapshot>> data = new HashMap<>();
    synchronized (earliestCp) {
        Collection<CheckpointEntry> values = earliestCp.values();
        for (CheckpointEntry cp : values) {
            UUID checkpointId = cp.checkpointId();
            if (data.containsKey(checkpointId))
                continue;
            Map<Integer, GroupState> map = cp.groupStates();
            if (map != null) {
                Map<Integer, GroupStateSnapshot> groupStates = new HashMap<>();
                map.forEach((k, v) -> groupStates.put(k, new GroupStateSnapshot(v.partitionIds(), v.partitionCounters(), v.size())));
                data.put(checkpointId, groupStates);
            }
        }
    }
    Set<UUID> ids = histMap.values().stream().map(CheckpointEntry::checkpointId).collect(Collectors.toSet());
    return new EarliestCheckpointMapSnapshot(ids, data);
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) GroupState(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry.GroupState) GroupStateSnapshot(org.apache.ignite.internal.processors.cache.persistence.checkpoint.EarliestCheckpointMapSnapshot.GroupStateSnapshot) UUID(java.util.UUID) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) NavigableMap(java.util.NavigableMap) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap)

Example 2 with GroupStateSnapshot

use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.EarliestCheckpointMapSnapshot.GroupStateSnapshot in project gridgain by gridgain.

the class CheckpointHistory method earliestCheckpointsMapSnapshot.

/**
 * Creates a snapshot of {@link #earliestCp} map.
 * Guarded by checkpoint read lock.
 *
 * @return Snapshot of a map.
 */
public EarliestCheckpointMapSnapshot earliestCheckpointsMapSnapshot() {
    Map<UUID, Map<Integer, GroupStateSnapshot>> data = new HashMap<>();
    synchronized (earliestCp) {
        Collection<CheckpointEntry> values = earliestCp.values();
        for (CheckpointEntry cp : values) {
            UUID checkpointId = cp.checkpointId();
            if (data.containsKey(checkpointId))
                continue;
            Map<Integer, GroupState> map = cp.groupStates();
            if (map != null) {
                Map<Integer, GroupStateSnapshot> groupStates = new HashMap<>();
                map.forEach((k, v) -> groupStates.put(k, new GroupStateSnapshot(v.partitionIds(), v.partitionCounters(), v.size())));
                data.put(checkpointId, groupStates);
            }
        }
    }
    Set<UUID> ids = histMap.values().stream().map(CheckpointEntry::checkpointId).collect(Collectors.toSet());
    return new EarliestCheckpointMapSnapshot(ids, data);
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) GroupState(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry.GroupState) GroupStateSnapshot(org.apache.ignite.internal.processors.cache.persistence.checkpoint.EarliestCheckpointMapSnapshot.GroupStateSnapshot) UUID(java.util.UUID) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) NavigableMap(java.util.NavigableMap) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap)

Aggregations

HashMap (java.util.HashMap)2 Map (java.util.Map)2 NavigableMap (java.util.NavigableMap)2 UUID (java.util.UUID)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)2 GroupState (org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry.GroupState)2 GroupStateSnapshot (org.apache.ignite.internal.processors.cache.persistence.checkpoint.EarliestCheckpointMapSnapshot.GroupStateSnapshot)2