public void AreEqualToVersionsValuesTest() { var dic1 = new Dictionary<string, int>() { { "a", 1 } }; var dic2 = new Dictionary<string, int>() { { "a", 2 } }; Assert.IsFalse(dic1.AreEqualToVersions(dic2)); }
private void OnSynchronizationFinished(ExtendedNodeInfo nodeInfo, Dictionary<string, int> writtenVersions) { // todo: wrap this into transaction lock (m_SyncRoot) { try { Core.Server.Log.Debug("Sync with {0} almost finished. Switching to readonly mode", nodeInfo.InternalAddress); Core.Server.Configuration.EnterReadonlyMode(); try { var syncedNode = ProxyHelper.TranslateNodeInfo(nodeInfo); syncedNode.CreateProxy(); syncedNode.Proxy.Open(); Core.Server.Log.Debug("Handling last updates..."); var currentVersions = AggregateRepository.Instance.GetLastVersions(); if (!writtenVersions.AreEqualToVersions(currentVersions)) writtenVersions = DoSync(syncedNode.Proxy, currentVersions); Core.Server.Log.Debug("Introducing {0} to everyone, including myself...", nodeInfo.InternalAddress); foreach (var node in Core.Server.Configuration.Nodes.Siblings) node.Proxy.IntroduceNewNode(nodeInfo); Core.Server.Configuration.Nodes.AddNewNode(syncedNode); Core.Server.Log.Debug("Checking current configuration..."); ProxyHelper.EnsureNodesConfigurationIsValid(); Core.Server.Log.Debug("Notifying {0} about finish of sync", nodeInfo.InternalAddress); if (!syncedNode.Proxy.NotificateSynchronizationFinished(writtenVersions)) throw new ApplicationException( "Synced node version didn't match current version, after all the sync process"); Core.Server.Log.Debug("Sync with {0} has finished successfully. Exiting readonly mode", nodeInfo.InternalAddress); } finally { Core.Server.Configuration.ExitReadonlyMode(); } } catch (Exception ex) { Core.Server.Log.Error("Error while finishing sync: {0}{1}{0}{2}", Environment.NewLine, ex.Message, ex.StackTrace); } } }