public void Report(TopicFailure request) { var recoveryAction = HandleFailure(new FailureDescriptor { PathToDbFile = Connections.PathToDbFile(Connections.TopicsDir, request.Name), DbLock = Locks.TakeTopicLock(request.Name), CooperatorAddress = request.Cooperator, RecoveryCategory = "topics", DbName = request.Name }); Propagators.ScheduleTopicOperation(request.Name, recoveryAction); }
public void Create(CreateSubscription request) { var topicLock = Locks.TakeTopicLock(request.TopicName); lock (topicLock) { if (Locks.TopicsRecoveryLocks.ContainsKey(request.TopicName)) { throw new Exception($"Topic {request.TopicName} is inconsistent"); } using (var connection = Connections.ConnectToInitializedTopic(request.TopicName)) { Create(connection, request); } } }
public void Delete(DeleteTopic request) { var topicLock = Locks.TakeTopicLock(request.TopicName); lock (topicLock) { if (Locks.TopicsRecoveryLocks.ContainsKey(request.TopicName)) { throw new Exception($"Topic {request.TopicName} is inconsistent"); } Connections.RemoveTopic(request.TopicName); Monitor.PulseAll(topicLock); Propagators.ScheduleTopicOperation(request.TopicName, () => Propagate(request)); Locks.RemoveTopicLock(request.TopicName); } }
Announcement ReadFromDb(IDbConnection connection, Subscriber subscriber, ReadAnnouncement request) { var topicLock = Locks.TakeTopicLock(request.TopicName); lock (topicLock) { var query = NextAnnouncement.make(connection, subscriber); var announcement = connection.FirstOrDefault(query); while (announcement == null) { Monitor.Wait(topicLock); announcement = connection.FirstOrDefault(query); } return(announcement); } }
public void Delete(DeleteSubscription request) { var topicLock = Locks.TakeTopicLock(request.TopicName); lock (topicLock) { if (Locks.TopicsRecoveryLocks.ContainsKey(request.TopicName)) { throw new Exception($"Topic {request.TopicName} is inconsistent"); } using (var connection = Connections.ConnectToInitializedTopic(request.TopicName)) { connection.DeleteById <Subscriber>(request.SubscriberId); } Propagators.ScheduleTopicOperation(request.TopicName, () => Propagate(request)); } }
public void Create(CreateTopic request) { var topicLock = Locks.TakeTopicLock(request.Name); lock (topicLock) { if (Locks.TopicsRecoveryLocks.ContainsKey(request.Name)) { throw new Exception($"Topic {request.Name} is inconsistent"); } using (var connection = Connections.ConnectToTopic(request.Name)) { connection.CreateTableIfNotExists <Announcement>(); connection.CreateTableIfNotExists <Subscriber>(); } if (!string.IsNullOrEmpty(request.Cooperator)) { Propagators.ScheduleTopicOperation(request.Name, () => PropagateRequest(request)); } } }