Search in sources :

Example 1 with GroupState

use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry.GroupState in project ignite by apache.

the class CheckpointHistory method addCpGroupStatesToEarliestCpMap.

/**
 * Add last checkpoint to map of the earliest checkpoints.
 *
 * @param entry Checkpoint entry.
 * @param cacheGrpStates Group states map.
 */
private void addCpGroupStatesToEarliestCpMap(CheckpointEntry entry, Map<Integer, GroupState> cacheGrpStates) {
    for (Integer grpId : cacheGrpStates.keySet()) {
        GroupState grpState = cacheGrpStates.get(grpId);
        for (int pIdx = 0; pIdx < grpState.size(); pIdx++) {
            int part = grpState.getPartitionByIndex(pIdx);
            GroupPartitionId grpPartKey = new GroupPartitionId(grpId, part);
            addPartitionToEarliestCheckpoints(grpPartKey, entry);
        }
    }
}
Also used : GroupState(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry.GroupState) GroupPartitionId(org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId)

Example 2 with GroupState

use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry.GroupState 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 3 with GroupState

use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry.GroupState in project ignite by apache.

the class CheckpointHistory method initialize.

/**
 * @param checkpoints Checkpoints.
 * @param snapshot Earliest checkpoint map snapshot.
 */
public void initialize(List<CheckpointEntry> checkpoints, EarliestCheckpointMapSnapshot snapshot) {
    for (CheckpointEntry e : checkpoints) histMap.put(e.timestamp(), e);
    for (Long timestamp : checkpoints(false)) {
        try {
            CheckpointEntry entry = entry(timestamp);
            UUID checkpointId = entry.checkpointId();
            Map<Integer, GroupState> groupStateMap = snapshot.groupState(checkpointId);
            // states map was not persisted (that means this checkpoint wasn't a part of earliestCp map)
            if (snapshot.checkpointWasPresent(checkpointId) && groupStateMap == null)
                continue;
            if (groupStateMap != null)
                entry.fillStore(groupStateMap);
            updateEarliestCpMap(entry, groupStateMap);
        } catch (IgniteCheckedException e) {
            U.warn(log, "Failed to process checkpoint, happened at " + U.format(timestamp) + '.', e);
        }
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GroupState(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry.GroupState) UUID(java.util.UUID)

Aggregations

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