Пример #1
0
        /// <summary>
        /// Initializes a load balancer.
        /// </summary>
        /// <param name="port">Port number the load balancer will run on</param>
        public LoadBalancer(int port)
        {
            checker = new CrashChecker();
            checker.SetInterval(1500);
            checker.SetServers(servers);
            checker.Crash += CrashServer;
            checker.Reboot += RebootServer;

            serverPicker = new RoundRobinBalanceStrategy();

            listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            listener.Bind(new IPEndPoint(IPAddress.Any, 8080));
            listener.Listen(5);
        }
Пример #2
0
 public void SetStrategy(string processType)
 {
     if (processType.Equals(ProcessTypeConst.CancelCreditShell))
     {
         BalanceStrategy = _balanceStrategyFactory.GetBalanceStrategy <RefundOriginalPaymentBalance>(_paymentService, _feeService, _configuration, _bookingCommiter);
     }
     else if (processType.Equals(ProcessTypeConst.AgencyCancelAndAddPayment))
     {
         BalanceStrategy = _balanceStrategyFactory.GetBalanceStrategy <AddAgencyPaymentBalance>(_paymentService);
     }
     else if (processType.Equals(ProcessTypeConst.CreateVoluntary))
     {
         BalanceStrategy = _balanceStrategyFactory.GetBalanceStrategy <AddCreditShellPaymentBalance>();
     }
     else if (processType.Equals(ProcessTypeConst.PROCLI))
     {
         BalanceStrategy = _balanceStrategyFactory.GetBalanceStrategy <AddCreditShellPaymentBalance>();
     }
     else
     {
         throw  new NotImplementedException($"");
     }
 }
Пример #3
0
 internal void setServerPicker(IBalanceStrategy serverPicker)
 {
     this.serverPicker = serverPicker;
     updateBalanceData();
 }