/// <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); }
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($""); } }
internal void setServerPicker(IBalanceStrategy serverPicker) { this.serverPicker = serverPicker; updateBalanceData(); }