Пример #1
0
        private void ServiceTracker_OnStatusChange(object sender, ServiceStatusEventArgs args)
        {
            // If it's a manager service, and the new status is UP
            if (args.ServiceType == ServiceType.Manager &&
                args.NewStatus == ServiceStatus.Up) {
                // Init and load all pending paths,
                ProcessInitQueue();
                LoadAllPendingPaths();
            }

            // If it's a root service, and the new status is UP
            if (args.ServiceType == ServiceType.Root) {
                if (args.NewStatus == ServiceStatus.Up) {
                    // Load all pending paths,
                    LoadAllPendingPaths();
                }
                    // If a root server went down,
                else if (args.NewStatus == ServiceStatus.DownShutdown ||
                         args.NewStatus == ServiceStatus.DownClientReport ||
                         args.NewStatus == ServiceStatus.DownHeartbeat) {
                    // Scan the paths managed by this root server and desynchronize
                    // any not connected to a majority of servers.
                    DesyncPathsDependentOn(address);
                }
            }
        }
Пример #2
0
 private void TrackerOnStatusChange(object sender, ServiceStatusEventArgs args)
 {
     if (args.ServiceType == ServiceType.Manager) {
         // If we detected that a manager is now available,
         if (args.NewStatus == ServiceStatus.Up) {
             // If this is not connected, initialize,
             if (!connected) {
                 Initialize();
             } else {
                 // Retry any pending messages on this service,
                 comm.RetryMessagesFor(address);
             }
         } else if (args.NewStatus != ServiceStatus.Up) {
             // If it's connected,
             if (connected) {
                 int clusterSize;
                 lock (cluster) {
                     clusterSize = cluster.Count;
                 }
                 // Set connected to false if availability check fails,
                 CheckClusterAvailability(clusterSize);
             }
         }
         // If a manager server goes down,
     }
 }