public static OngoingTasksResult GetOngoingTasksFor(string dbName, ServerStore store) { var ongoingTasksResult = new OngoingTasksResult(); using (store.ContextPool.AllocateOperationContext(out TransactionOperationContext context)) { DatabaseTopology dbTopology; ClusterTopology clusterTopology; DatabaseRecord databaseRecord; using (context.OpenReadTransaction()) { databaseRecord = store.Cluster.ReadDatabase(context, dbName); if (databaseRecord == null) { return(ongoingTasksResult); } dbTopology = databaseRecord.Topology; clusterTopology = store.GetClusterTopology(context); ongoingTasksResult.OngoingTasksList.AddRange(CollectSubscriptionTasks(context, databaseRecord, clusterTopology, store)); } foreach (var tasks in new[] { CollectExternalReplicationTasks(databaseRecord.ExternalReplication, dbTopology, clusterTopology, store), CollectEtlTasks(databaseRecord, dbTopology, clusterTopology, store), CollectBackupTasks(databaseRecord, dbTopology, clusterTopology, store) }) { ongoingTasksResult.OngoingTasksList.AddRange(tasks); } if (store.DatabasesLandlord.DatabasesCache.TryGetValue(dbName, out var database) && database.Status == TaskStatus.RanToCompletion) { ongoingTasksResult.SubscriptionsCount = (int)database.Result.SubscriptionStorage.GetAllSubscriptionsCount(); } return(ongoingTasksResult); } }
public OngoingTasksResult GetOngoingTasksInternal() { var ongoingTasksResult = new OngoingTasksResult(); using (ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext context)) { DatabaseTopology dbTopology; ClusterTopology clusterTopology; DatabaseRecord databaseRecord; using (context.OpenReadTransaction()) { databaseRecord = ServerStore.Cluster.ReadDatabase(context, Database.Name); if (databaseRecord == null) { return(ongoingTasksResult); } dbTopology = databaseRecord.Topology; clusterTopology = ServerStore.GetClusterTopology(context); ongoingTasksResult.OngoingTasksList.AddRange(CollectSubscriptionTasks(context, databaseRecord, clusterTopology)); } foreach (var tasks in new[] { CollectExternalReplicationTasks(databaseRecord.ExternalReplication, dbTopology, clusterTopology), CollectEtlTasks(databaseRecord, dbTopology, clusterTopology), CollectBackupTasks(databaseRecord, dbTopology, clusterTopology) }) { ongoingTasksResult.OngoingTasksList.AddRange(tasks); } ongoingTasksResult.SubscriptionsCount = (int)Database.SubscriptionStorage.GetAllSubscriptionsCount(); return(ongoingTasksResult); } }