Search in sources :

Example 16 with DarkClusterConfigMap

use of com.linkedin.d2.DarkClusterConfigMap in project rest.li by linkedin.

the class SimpleLoadBalancer method getDarkClusterConfigMap.

@Override
public void getDarkClusterConfigMap(String clusterName, Callback<DarkClusterConfigMap> callback) {
    Callback<DarkClusterConfigMap> wrappedCallback = new TimeoutCallback<>(_executor, _timeout, _unit, callback);
    _state.listenToCluster(clusterName, (type, name) -> {
        ClusterProperties clusterProperties = _state.getClusterProperties(clusterName).getProperty();
        DarkClusterConfigMap darkClusterConfigMap = clusterProperties != null ? clusterProperties.accessDarkClusters() : new DarkClusterConfigMap();
        wrappedCallback.onSuccess(darkClusterConfigMap);
    });
}
Also used : DarkClusterConfigMap(com.linkedin.d2.DarkClusterConfigMap) ClusterProperties(com.linkedin.d2.balancer.properties.ClusterProperties) TimeoutCallback(com.linkedin.r2.transport.http.client.TimeoutCallback)

Example 17 with DarkClusterConfigMap

use of com.linkedin.d2.DarkClusterConfigMap in project rest.li by linkedin.

the class SimpleLoadBalancer method getDarkClusterConfigMap.

@Override
public DarkClusterConfigMap getDarkClusterConfigMap(String clusterName) throws ServiceUnavailableException {
    FutureCallback<DarkClusterConfigMap> darkClusterConfigMapFutureCallback = new FutureCallback<>();
    getDarkClusterConfigMap(clusterName, darkClusterConfigMapFutureCallback);
    try {
        return darkClusterConfigMapFutureCallback.get(_timeout, _unit);
    } catch (ExecutionException | TimeoutException | IllegalStateException | InterruptedException e) {
        die("ClusterInfo", "PEGA_1018, unable to retrieve dark cluster info for cluster: " + clusterName + ", exception: " + e);
        return new DarkClusterConfigMap();
    }
}
Also used : DarkClusterConfigMap(com.linkedin.d2.DarkClusterConfigMap) ExecutionException(java.util.concurrent.ExecutionException) FutureCallback(com.linkedin.common.callback.FutureCallback) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

DarkClusterConfigMap (com.linkedin.d2.DarkClusterConfigMap)17 Test (org.testng.annotations.Test)10 DarkClusterConfig (com.linkedin.d2.DarkClusterConfig)8 DarkClusterStrategyNameArray (com.linkedin.d2.DarkClusterStrategyNameArray)5 ClusterProperties (com.linkedin.d2.balancer.properties.ClusterProperties)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 D2TransportClientProperties (com.linkedin.d2.D2TransportClientProperties)2 ServiceProperties (com.linkedin.d2.balancer.properties.ServiceProperties)2 UriProperties (com.linkedin.d2.balancer.properties.UriProperties)2 MockStore (com.linkedin.d2.discovery.stores.mock.MockStore)2 Map (java.util.Map)2 FutureCallback (com.linkedin.common.callback.FutureCallback)1 DarkClusterStrategyName (com.linkedin.d2.DarkClusterStrategyName)1 DarkClusterStrategy (com.linkedin.darkcluster.api.DarkClusterStrategy)1 DataList (com.linkedin.data.DataList)1 RequestContext (com.linkedin.r2.message.RequestContext)1 RestRequest (com.linkedin.r2.message.rest.RestRequest)1 TimeoutCallback (com.linkedin.r2.transport.http.client.TimeoutCallback)1 List (java.util.List)1