public CmdVerbs() { GetToolVersion = new CmdArgsGetToolVersion(); NewSubscriber = new CmdArgsNewSub(); GetSubscriber = new CmdArgsSubIdOpt(); RemoveSubscriber = new CmdArgsSubIdReq(); SyncSubscriber = new CmdArgsSubIdOpt(); PublishDirectory = new CmdArgsPublishDirectory(); SyncDirectory = new CmdArgsSyncDirectory(); InitalizeSyncState = new CmdArgsInitalizeSyncState(); KuduSync = new KuduSyncOptions(); GetHelp = new CmdArgsGetHelpCommand(); SetSubscriberSiteStatus = new CmdArgsSetSubscriberSiteStatus(); WatchSyncState = new CmdArgsWatchSyncState(); }
public void WatchSyncState(CmdArgsWatchSyncState args) { var ops = GetOperations(); var stopWatch = System.Diagnostics.Stopwatch.StartNew(); HashSet <string> lastWaitSet = new HashSet <string>(); Func <SubscriberState, bool> filter = ignored => true; if (args.PublicUpdateNotifyUrl != null) { var pubUri = new Uri(args.PublicUpdateNotifyUrl); filter = (s) => { return(pubUri.Equals(s.PublicUpdateNotifyUri)); }; } IEnumerable <SubscriberState> outOfSync = ops.NotAtTargetState().Where(filter); while (outOfSync.Any()) { var ids = outOfSync.Select(sub => sub.Id); var currWaitSet = new HashSet <string>(ids); if (!currWaitSet.SequenceEqual(lastWaitSet)) { WriteToOutput("Waiting for the following subscribers to catch up."); WriteToOutput("==================================================="); foreach (var sub in outOfSync) { WriteToOutput("Id : {0}", sub.Id); WriteToOutput("PublicUri : {0}", sub.PublicUpdateNotifyUri); WriteToOutput("PrivateUri : {0}", sub.PrivateUpdateNotifyUri); } WriteToOutput("==================================================="); lastWaitSet = currWaitSet; } if (args.PollInterval <= 0) { return; } ops.WaitForStateChange(TimeSpan.FromSeconds(args.PollInterval)); outOfSync = ops.NotAtTargetState().Where(filter); } WriteToOutput("Subscribers all up to date."); }