public void updateNodeSyncInfo(IPEndPoint node, IList<TableVersion> tvs) { lock (this) { NodeSyncInfo nsi = null; if (nodeSynchronization.ContainsKey(node)) { nsi = nodeSynchronization[node]; } // create entry for new nodes if (nsi == null) { nsi = new NodeSyncInfo(); nodeSynchronization[node] = nsi; } // reset counter for nodes which were unreachable for long period of time else if (nsi.getMsSinceLastBeat() > OUT_OF_SYNC_RESET_TIME_MS) { Logger.getInstance().log( "Node was inactive for too long - " + nsi.getMsSinceLastBeat() + " - reseting nsi - " + node.ToString(), LOGGING_NAME, Logger.Level.INFO); nsi.InSync(); } // check synchronization if (DatabaseStateImpl.getInstance().checkSync(tvs)) { nsi.InSync(); } else { if (nsi.BeatsOutOfSync > OUT_OF_SYNC_BEATS_THRESHOLD) { Logger.getInstance().log( "Node out of sync " + nsi.BeatsOutOfSync + " times - " + node.ToString(), LOGGING_NAME, Logger.Level.INFO); nsi.BeatOutOfSync(); } else if (restoreCoordinators.ContainsKey(node) == false) { Logger.getInstance().log( "Node out of sync detected creating restorator - " + node.ToString(), LOGGING_NAME, Logger.Level.INFO); // need to restore RestoreCoordinator rc = new RestoreCoordinator(node); restoreCoordinators[node] = rc; rc.addEndRestorationListener(this); Thread t = new Thread(new ThreadStart(rc.run)); t.Name = "RESTORE_COORDINATOR"; t.Start(); } } } }
public void onEndRestoration(RestoreCoordinator coordinator) { lock (this) { IPEndPoint node = coordinator.getTargetNode(); NodeSyncInfo nsi = null; if (nodeSynchronization.ContainsKey(node)) { nsi = nodeSynchronization[node]; } // mark node as synchronized if (nsi == null) { Logger.getInstance().log( "onEndRestoration nsi missing (should not happen)", LOGGING_NAME, Logger.Level.WARNING); } else { nsi.InSync(); } // remove coordinator if (restoreCoordinators.Remove(node) == false) { Logger.getInstance().log( "onEndRestoration deleted wrong coordinator (should not happen)", LOGGING_NAME, Logger.Level.WARNING); } Logger.getInstance().log( "Restoration ended for node: " + node.ToString(), LOGGING_NAME, Logger.Level.INFO); } }