use of org.apache.ignite.internal.client.balancer.GridClientRandomBalancer in project ignite by apache.
the class GridClientImpl method data.
/** {@inheritDoc} */
@Override
public GridClientData data(@Nullable final String cacheName) throws GridClientException {
checkClosed();
Object key = maskNull(cacheName);
GridClientDataImpl data = dataMap.get(key);
if (data == null) {
GridClientDataConfiguration dataCfg = cfg.getDataConfiguration(cacheName);
if (dataCfg == null && cacheName != null)
throw new GridClientException("Data configuration for given cache name was not provided: " + cacheName);
GridClientLoadBalancer balancer = dataCfg != null ? dataCfg.getPinnedBalancer() : new GridClientRandomBalancer();
GridClientPredicate<GridClientNode> cacheNodes = new GridClientPredicate<GridClientNode>() {
@Override
public boolean apply(GridClientNode e) {
return e.caches().containsKey(cacheName);
}
@Override
public String toString() {
return "GridClientHasCacheFilter [cacheName=" + cacheName + "]";
}
};
data = new GridClientDataImpl(cacheName, this, null, cacheNodes, balancer, null, cfg.isEnableMetricsCache());
GridClientDataImpl old = dataMap.putIfAbsent(key, data);
if (old != null)
data = old;
}
return data;
}
use of org.apache.ignite.internal.client.balancer.GridClientRandomBalancer in project ignite by apache.
the class ClientPreferDirectSelfTest method testRandomBalancer.
/**
* @throws Exception If failed.
*/
public void testRandomBalancer() throws Exception {
GridClientRandomBalancer b = new GridClientRandomBalancer();
b.setPreferDirectNodes(true);
executeTest(b);
}
Aggregations