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);
}
}
}
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);
}
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);
}
}
}
Aggregations