public ElectionBasedMembershipStrategy(IShard shard, NodeContext context, LocalShardHeartbeatReporting heartbeatTable, ClusterConfigurationManager clusterConfigMgr) { this._shard = shard; this._context = context; this._clusterConfigMgr = clusterConfigMgr; Initialize(); }
public LocalShardCheckHeartbeatTask(IShard shard, NodeContext context, MembershipManager membershipManager, ClusterConfigurationManager clusterConfigMgr) { this._shard = shard; this._context = context; this._clusterConfigMgr = clusterConfigMgr; _localShardHeartbeatReporter = new LocalShardHeartbeatReporting(_context.LocalAddress); this._membershipManager = membershipManager; this._membershipManager.HeartbeatReport = _localShardHeartbeatReporter; ShardConfiguration sConfig = null; if (_clusterConfigMgr != null) { sConfig = _clusterConfigMgr.GetShardConfiguration(context.LocalShardName); } if (sConfig != null && sConfig.NodeHeartbeatInterval > 0) { this._poolingThreshold = (sConfig.NodeHeartbeatInterval * 2) * 1000; } _running = false; _startSignal = new ManualResetEvent(false); //with the initialization of the heartbeat receiver, we start the send heart beat task. _sendHearbeatTask = new LocalShardSendHeartbeatTask(context, shard, _membershipManager, clusterConfigMgr); }
public NodeToCSHeartbeatTask(NodeContext context, MembershipManager manager, IConnectionRestoration connectionRestoration, ClusterConfigurationManager clusterConfigMgr) { this._context = context; this._clusterConfigMgr = clusterConfigMgr; ShardConfiguration sConfig = null; if (_clusterConfigMgr != null) { sConfig = _clusterConfigMgr.GetShardConfiguration(_context.LocalShardName); if (_clusterConfigMgr.LatestConfiguration != null && _clusterConfigMgr.LatestConfiguration.Deployment != null) { _heartbeatInterval = 1000 * _clusterConfigMgr.LatestConfiguration.Deployment.HeartbeatInterval; } } if (sConfig != null && sConfig.Servers != null) { _node = sConfig.Servers.GetServerNode(_context.LocalAddress.IpAddress.ToString()); } this._membershipManager = manager; this._connectionRestoration = connectionRestoration; _running = false; _startSignal = new System.Threading.ManualResetEvent(false); }
public LocalShardSendHeartbeatTask(NodeContext nodeContext, IShard shard, MembershipManager membershipManager, ClusterConfigurationManager clusterConfigMgr) { this._nodeContext = nodeContext; this._clusterConfigMgr = clusterConfigMgr; ShardConfiguration config = _clusterConfigMgr.GetShardConfiguration(_nodeContext.LocalShardName);//_nodeContext.ConfigurationSession.GetDatabaseClusterConfiguration(_nodeContext.ClusterName).Deployment.GetShardConfiguration(_nodeContext.LocalShardName); if (config == null) { if (LoggerManager.Instance.ShardLogger != null && LoggerManager.Instance.ShardLogger.IsErrorEnabled) { LoggerManager.Instance.ShardLogger.Error("LocalShardSendHeartTask", "shard configuration is null"); } throw new Alachisoft.NosDB.Common.Exceptions.DatabaseException(" shard configuration is null"); } if (config.NodeHeartbeatInterval > 0) { this._poolingThreshold = (config.NodeHeartbeatInterval) * 1000; } this._shard = shard; this._membershipManager = membershipManager; _running = false; _startSignal = new System.Threading.ManualResetEvent(false); }
public ElectionManager(IShard shard, NodeContext context, ClusterConfigurationManager clusterConfigMgr) { this._shard = shard; this._context = context; this._clusterConfigMgr = clusterConfigMgr; //if (_context != null) // _clusterConfig = _context.ConfigurationSession.GetDatabaseClusterConfiguration(_context.ClusterName); }
public MembershipManager(IShard shard, NodeContext context, ClusterConfigurationManager clusterConfigMgr) { this._shard = shard; this._context = context; this._clusterConfigMgr = clusterConfigMgr; this._strategy = new ElectionBasedMembershipStrategy(shard, context, _heartbeatReporting, _clusterConfigMgr); shard.RegisterShardListener(Common.MiscUtil.MEMBERSHIP_MANAGER, this); _heartbeatManager = new HeartbeatManager(); _latestMembership.Cluster = _context.ClusterName; _latestMembership.Shard = _context.LocalShardName; }
public LocalShard(NodeContext context, IConnectionRestoration connectionRestoration, ClusterConfigurationManager clusterConfigMgr) { this.context = context; this._connectionRestoration = connectionRestoration; this._clusterConfigMgr = clusterConfigMgr; }
////RTD: Needs to be moved. //public ShardInfo ThisShard //{ // get { return _localShardInfo; } //} //public IDictionary<String, ShardInfo> Shards //{ // get { return _remoteShardsInfo; } //} public bool Initialize(ClusterConfiguration configuration) //public bool Initialize(String clusterName, DeploymentConfiguration configuration) { #region Getting Local Address Logic; might be replace with getting address from service config if (configuration == null) { throw new ArgumentNullException("cluster configuration can not be null"); } if (configuration.Deployment == null) { throw new ArgumentNullException("deployment configuration can not be null"); } if (configuration.Deployment.Shards == null) { throw new ArgumentNullException("topology configuration can not be null"); } if (context != null) { context.ClusterName = configuration.Name; } if (string.IsNullOrWhiteSpace(context.LocalShardName)) { //Get Local Shard Name from config //string shardName = ConfigurationManager.AppSettings["ShardName"]; //if (String.IsNullOrEmpty(shardName)) //{ throw new ArgumentNullException("Shard Name Can not be null or empty"); //} //RTD: Needs to be moved. //context.LocalShardName = shardName; } //Get Base Data Path from config string basePath = ConfigurationSettings <DBHostSettings> .Current.BasePath; if (String.IsNullOrEmpty(basePath)) { throw new ArgumentNullException("Data Path Can not be null or empty"); } context.DataPath = basePath; context.BasePath = basePath + context.LocalShardName + Common.MiscUtil.DATA_FOLDERS_SEPERATION; //Get Base Data Path from config string deploymentPath = ConfigurationSettings <DBHostSettings> .Current.DeploymentPath; if (String.IsNullOrEmpty(deploymentPath)) { throw new ArgumentNullException("Deployment Path Can not be null or empty"); } context.DeploymentPath = deploymentPath; ShardConfiguration localShardConfig = null; IDictionary <String, ShardConfiguration> remoteShardConfigs = null; SetShardConfigs(configuration.Deployment, out localShardConfig, out remoteShardConfigs); _clusterConfigMgr = new ClusterConfigurationManager(context.ConfigurationSession, configuration); _connectionRestoration = new ConnectionRestorationManager(); _connectionRestoration.Initialize(context); if (localShardConfig != null) { _localShard = new LocalShard(context, _connectionRestoration, _clusterConfigMgr); _localShard.Initialize(localShardConfig); _localShard.RegisterShardListener(Common.MiscUtil.CLUSTER_MANAGER, this); } if (context != null) { context.ShardServer.RegisterSessionListener(SessionTypes.Shard, this); } if (remoteShardConfigs != null && remoteShardConfigs.Keys.Count > 0) { foreach (KeyValuePair <String, ShardConfiguration> pair in remoteShardConfigs) { IShard remoteShard = new RemoteShard(new DualChannelFactory(), new ShardChannelFormatter(), context, _connectionRestoration); remoteShard.Initialize(pair.Value); remoteShard.RegisterShardListener(Common.MiscUtil.CLUSTER_MANAGER, this); lock (_remoteShards) { _remoteShards.Add(pair.Key, remoteShard); } } } return(true); #endregion }
/// <summary> /// All the heartbeat tasks begin here. /// </summary> /// <param name="context"></param> /// <param name="shard"></param> public void BeginTasks(NodeContext context, IShard shard, MembershipManager manager, IConnectionRestoration connectionRestoration, ClusterConfigurationManager clusterConfigMgr) { _nodeToCSReportingTask = new NodeToCSHeartbeatTask(context, manager, connectionRestoration, clusterConfigMgr); _nodeToCSReportingTask.Start(); //Start the shard level heartbeat tasks. _checkHeartbeatTask = new LocalShardCheckHeartbeatTask(shard, context, manager, clusterConfigMgr); _checkHeartbeatTask.Start(); }