Examples of TogglingLoadBalancer


Examples of com.linkedin.d2.balancer.util.TogglingLoadBalancer

    SimpleLoadBalancerState state = new SimpleLoadBalancerState(
            executorService, uriBus, clusterBus, serviceBus, _clientFactories, _loadBalancerStrategyFactories,
            _sslContext, _sslParameters, _isSSLEnabled, _clientServicesConfig);
    SimpleLoadBalancer balancer = new SimpleLoadBalancer(state, _lbTimeout, _lbTimeoutUnit);

    TogglingLoadBalancer togLB = _factory.createBalancer(balancer, state, clusterToggle, serviceToggle, uriToggle);
    togLB.start(new Callback<None>() {

      @Override
      public void onError(Throwable e)
      {
        _log.warn("Failed to run start on the TogglingLoadBalancer, may not have registered " +
View Full Code Here

Examples of com.linkedin.d2.balancer.util.TogglingLoadBalancer

                                             SimpleLoadBalancerState state,
                                             TogglingPublisher<ClusterProperties> clusterToggle,
                                             TogglingPublisher<ServiceProperties> serviceToggle,
                                             TogglingPublisher<UriProperties> uriToggle)
  {
    return new TogglingLoadBalancer(balancer, clusterToggle, serviceToggle, uriToggle);
  }
View Full Code Here

Examples of com.linkedin.d2.balancer.util.TogglingLoadBalancer

      LOG.info("ZK flag file: {}", _zkFlagFile.getAbsolutePath());
      LOG.info("ZK currently suppressed by flag file: {}", suppressZK());
    }

    _zkConnection = new ZKConnection(_connectString, _sessionTimeout, _shutdownAsynchronously, _isSymlinkAware);
    final TogglingLoadBalancer balancer = _loadBalancerFactory.createLoadBalancer(_zkConnection, _executor);

    // _currentLoadBalancer will never be null except the first time this method is called.
    // In this case we want the not-yet-started load balancer to service client requests.  In
    // all other cases, we service requests from the old LoadBalancer until the new one is started
    if (_currentLoadBalancer == null)
    {
      _currentLoadBalancer = balancer;
    }

    Callback<None> wrapped = new Callback<None>()
    {
      @Override
      public void onSuccess(None none)
      {
        _currentLoadBalancer = balancer;
        callback.onSuccess(none);
      }

      @Override
      public void onError(Throwable e)
      {
        callback.onError(e);
      }
    };
    if (!_startupCallback.compareAndSet(null, wrapped))
    {
      throw new IllegalStateException("Startup already in progress");
    }
    _executor.execute(new PropertyEventThread.PropertyEvent("startup")
    {

      @Override
      public void innerRun()
      {
        _zkConnection.addStateListener(new ZKListener(balancer));
        try
        {
          _zkConnection.start();
        }
        catch (Exception e)
        {
          LOG.error("Failed to start ZooKeeper (bad configuration?), enabling backup stores", e);
          Callback<None> startupCallback = _startupCallback.getAndSet(null);
          // TODO this should never be null
          balancer.enableBackup(startupCallback);
          return;
        }

        LOG.info("Started ZooKeeper");
        _executor.schedule(new Runnable()
        {
          @Override
          public void run()
          {
            Callback<None> startupCallback = _startupCallback.getAndSet(null);
            if (startupCallback != null)
            {
              // Noone has enabled the stores yet either way
              LOG.error("No response from ZooKeeper within {}ms, enabling backup stores", _initialZKTimeout);
              balancer.enableBackup(startupCallback);
            }
          }
        }, _initialZKTimeout, TimeUnit.MILLISECONDS);
      }
    });
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.