コード例 #1
0
        static void InitService()
        {
            AutoInit.Init();

            zkAdaptor = new ZkAdaptor();
            amqpAdaptor = new AmqpAdaptor(ConfigManager.MQIP(), ConfigManager.AMQPPort(),
                ConfigManager.MQUser(), ConfigManager.MQPass());

            ServiceImplementStub.Bind<IWatcherServiceNotifyImpl>(amqpAdaptor, new WatcherServiceImpl());

            //dbClientNotifyDelegate = new DbClientNotifyDelegate(zkAdaptor);
            watcherServiceNotifyDelegate = new WatcherServiceNotifyDelegate(amqpAdaptor);

            amqpAdaptor.BeginReceive();
            zkAdaptor.BeginReceive();

            var toWatch = ConfigManager.Instance.Read<int>("WatcherService", "WatchNum");
            var watchGroups = new List<WatchGroup>();

            for (int i = 1; i <= toWatch; i++)
            {
                var group = new WatchGroup()
                {
                    GroupName = ConfigManager.Instance.Read<string>("WatcherService", "WatchName" + i),
                    Quorum = ConfigManager.Instance.Read<int>("WatcherService", "WatchQuorum" + i),
                    DownAfterPeriod = ConfigManager.Instance.Read<int>("WatcherService", "WatchDownAfter" + i),
                    ParallelSync = ConfigManager.Instance.Read<int>("WatcherService", "WatchParallelSync" + i),
                    FailoverTime = ConfigManager.Instance.Read<int>("WatcherService", "WatchFailoverTimeout" + i),
                };

                group.SetCurrentMaster(new MasterInstance(group)
                {
                    EndPoint = ConfigManager.Instance.Read<EndPoint>("WatcherService", "WatchAddr" + i),
                });

                watchGroups.Add(group);
            }

            watcherManager = new WatcherManager(watchGroups);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: code-rover/Phial.Fantasy
        static void InitService()
        {
            AutoInit.Init();

            zkAdaptor   = new ZkAdaptor();
            amqpAdaptor = new AmqpAdaptor(ConfigManager.MQIP(), ConfigManager.AMQPPort(),
                                          ConfigManager.MQUser(), ConfigManager.MQPass());

            ServiceImplementStub.Bind <IWatcherServiceNotifyImpl>(amqpAdaptor, new WatcherServiceImpl());

            //dbClientNotifyDelegate = new DbClientNotifyDelegate(zkAdaptor);
            watcherServiceNotifyDelegate = new WatcherServiceNotifyDelegate(amqpAdaptor);

            amqpAdaptor.BeginReceive();
            zkAdaptor.BeginReceive();

            var toWatch     = ConfigManager.Instance.Read <int>("WatcherService", "WatchNum");
            var watchGroups = new List <WatchGroup>();

            for (int i = 1; i <= toWatch; i++)
            {
                var group = new WatchGroup()
                {
                    GroupName       = ConfigManager.Instance.Read <string>("WatcherService", "WatchName" + i),
                    Quorum          = ConfigManager.Instance.Read <int>("WatcherService", "WatchQuorum" + i),
                    DownAfterPeriod = ConfigManager.Instance.Read <int>("WatcherService", "WatchDownAfter" + i),
                    ParallelSync    = ConfigManager.Instance.Read <int>("WatcherService", "WatchParallelSync" + i),
                    FailoverTime    = ConfigManager.Instance.Read <int>("WatcherService", "WatchFailoverTimeout" + i),
                };

                group.SetCurrentMaster(new MasterInstance(group)
                {
                    EndPoint = ConfigManager.Instance.Read <EndPoint>("WatcherService", "WatchAddr" + i),
                });

                watchGroups.Add(group);
            }

            watcherManager = new WatcherManager(watchGroups);
        }