public void OnDropCollection(String database, String collection) { DatabaseStateTransferManager task = null; lock (dbStateTxferMgrMap) { if (dbStateTxferMgrMap.ContainsKey(database)) { task = dbStateTxferMgrMap[database]; } } if (task != null) { task.OnDropCollection(collection); } }
private void AllocateRunningDBs() { if (runningDBTasks != null && runningDBTasks.Count > 0) { List <String> runningTaskList = runningDBTasks.ToList <String>(); foreach (String db in runningTaskList) { if (dbStateTxferMgrMap.ContainsKey(db)) { DatabaseStateTransferManager dbMgr = dbStateTxferMgrMap[db]; if (dbMgr != null) { dbMgr.AllocateResource(); } } else { runningDBTasks.Remove(db); } } } }
public void Initialize(ICollection map, StateTransferType transferType, bool forLocal = false) { if (context.ClusterName.Equals(Common.MiscUtil.LOCAL, StringComparison.OrdinalIgnoreCase)) { return; } if (IsRunning) { if (LoggerManager.Instance.StateXferLogger != null && LoggerManager.Instance.StateXferLogger.IsInfoEnabled) { LoggerManager.Instance.StateXferLogger.Info("NodeStateTranferManager.Initialize()", "State Transfer Already Running"); } if (transferType == StateTransferType.INTRA_SHARD && TransferType == StateTransferType.INTER_SHARD) { if (LoggerManager.Instance.StateXferLogger != null && LoggerManager.Instance.StateXferLogger.IsInfoEnabled) { LoggerManager.Instance.StateXferLogger.Info("NodeStateTranferManager.Initialize()", "Stopping already running State Transfer"); } //Stopping already running state transfer as there is mis-match between already running Stop(); } } IDictionary <String, IDictionary <String, IDistribution> > distributionMaps = (IDictionary <String, IDictionary <String, IDistribution> >)map; TransferType = transferType; if (distributionMaps != null) { if (LoggerManager.Instance.StateXferLogger != null && LoggerManager.Instance.StateXferLogger.IsInfoEnabled) { LoggerManager.Instance.StateXferLogger.Info("NodeStateTranferManager.Initialize()", "State Transfer Initialize on " + this.context.LocalAddress.ToString()); } foreach (KeyValuePair <String, IDictionary <String, IDistribution> > dbInfo in distributionMaps) { try { DatabaseStateTransferManager dbMgr = null; lock (dbStateTxferMgrMap) { if (!dbStateTxferMgrMap.ContainsKey(dbInfo.Key)) { dbStateTxferMgrMap[dbInfo.Key] = new DatabaseStateTransferManager(context, dbInfo.Key, this, _resourceManager); } } dbMgr = dbStateTxferMgrMap[dbInfo.Key]; if (dbMgr != null) { dbMgr.Initialize((IDictionary)dbInfo.Value, transferType, forLocal); lock (_schMutex) { waitingDBTasks.AddLast(dbInfo.Key); } } } catch (Exception ex) { if (LoggerManager.Instance.StateXferLogger.IsErrorEnabled) { LoggerManager.Instance.StateXferLogger.Error("NodeStateTranferManager.Initialize()", ex.Message); } } } if (dbStateTxferMgrMap.Count > 0) { context.StatusLatch.SetStatusBit(Alachisoft.NosDB.Common.Stats.NodeStatus.InStateTxfer, Alachisoft.NosDB.Common.Stats.NodeStatus.None); IsTaskAvailable = true; } //if (transferType==StateTransferType.INTRA_SHARD && _replication.NextReplicationChunk == null) //{ // if (!forLocal) // _replication.NextReplicationChunk = _replication.GetLastOpLog(); // lock (_inStTxfrMutex) // { // _replication.NodeIsInStateTxfr = true; // } // _replication.Start(); // // Replication will be started from here and last operation will be settled from here //} } }