use of org.apache.ignite.internal.processors.cache.persistence.defragmentation.CachePartitionDefragmentationManager.Status in project ignite by apache.
the class IgniteDefragmentationImpl method status.
/**
* {@inheritDoc}
*/
@Override
public DefragmentationStatus status() throws IgniteCheckedException {
final MaintenanceRegistry maintenanceRegistry = ctx.maintenanceRegistry();
if (!maintenanceRegistry.isMaintenanceMode())
throw new IgniteCheckedException("Node is not in maintenance mode.");
IgniteCacheDatabaseSharedManager dbMgr = ctx.cache().context().database();
assert dbMgr instanceof GridCacheDatabaseSharedManager;
CachePartitionDefragmentationManager defrgMgr = ((GridCacheDatabaseSharedManager) dbMgr).defragmentationManager();
if (defrgMgr == null)
throw new IgniteCheckedException("There's no active defragmentation process on the node.");
final Status status = defrgMgr.status();
final long startTs = status.getStartTs();
final long finishTs = status.getFinishTs();
final long elapsedTime = finishTs != 0 ? finishTs - startTs : System.currentTimeMillis() - startTs;
Map<String, CompletedDefragmentationInfo> completedCaches = new HashMap<>();
Map<String, InProgressDefragmentationInfo> progressCaches = new HashMap<>();
status.getFinishedGroups().forEach((context, progress) -> {
final String name = context.cacheOrGroupName();
final long oldSize = progress.getOldSize();
final long newSize = progress.getNewSize();
final long cgElapsedTime = progress.getFinishTs() - progress.getStartTs();
final CompletedDefragmentationInfo info = new CompletedDefragmentationInfo(cgElapsedTime, oldSize, newSize);
completedCaches.put(name, info);
});
status.getProgressGroups().forEach((context, progress) -> {
final String name = context.cacheOrGroupName();
final long cgElapsedTime = System.currentTimeMillis() - progress.getStartTs();
final int partsTotal = progress.getPartsTotal();
final int partsCompleted = progress.getPartsCompleted();
final InProgressDefragmentationInfo info = new InProgressDefragmentationInfo(cgElapsedTime, partsCompleted, partsTotal);
progressCaches.put(name, info);
});
return new DefragmentationStatus(completedCaches, progressCaches, status.getScheduledGroups(), status.getSkippedGroups(), status.getTotalPartitionCount(), status.getDefragmentedPartitionCount(), startTs, elapsedTime);
}
Aggregations