use of org.apache.ignite.internal.client.GridClientPartitionAffinity in project ignite by apache.
the class ClientAbstractMultiNodeSelfTest method clientConfiguration.
/**
* @return Client configuration for the test.
*/
protected GridClientConfiguration clientConfiguration() throws GridClientException {
GridClientConfiguration cfg = new GridClientConfiguration();
cfg.setBalancer(getBalancer());
cfg.setTopologyRefreshFrequency(TOP_REFRESH_FREQ);
cfg.setProtocol(protocol());
cfg.setServers(Arrays.asList(serverAddress()));
cfg.setSslContextFactory(sslContextFactory());
GridClientDataConfiguration loc = new GridClientDataConfiguration();
GridClientDataConfiguration partitioned = new GridClientDataConfiguration();
partitioned.setName(PARTITIONED_CACHE_NAME);
partitioned.setAffinity(new GridClientPartitionAffinity());
GridClientDataConfiguration replicated = new GridClientDataConfiguration();
replicated.setName(REPLICATED_CACHE_NAME);
GridClientDataConfiguration replicatedAsync = new GridClientDataConfiguration();
replicatedAsync.setName(REPLICATED_ASYNC_CACHE_NAME);
cfg.setDataConfigurations(Arrays.asList(loc, partitioned, replicated, replicatedAsync));
return cfg;
}
use of org.apache.ignite.internal.client.GridClientPartitionAffinity in project ignite by apache.
the class ClientCacheBenchmark method configuration.
/**
* @return Test client configuration.
*/
private GridClientConfiguration configuration() {
GridClientConfiguration cfg = new GridClientConfiguration();
cfg.setServers(Collections.singleton("localhost:11211"));
GridClientDataConfiguration cacheCfg = new GridClientDataConfiguration();
cacheCfg.setName("partitioned");
cacheCfg.setAffinity(new GridClientPartitionAffinity());
cfg.setDataConfigurations(Collections.singletonList(cacheCfg));
return cfg;
}
use of org.apache.ignite.internal.client.GridClientPartitionAffinity in project ignite by apache.
the class GridClientImpl method tryInitTopology.
/**
* Tries to init client topology using configured set of servers or routers.
*
* @throws GridClientException If initialisation failed.
* @throws InterruptedException If initialisation was interrupted.
*/
private void tryInitTopology() throws GridClientException, InterruptedException {
boolean hasSrvs = routers.isEmpty();
final Collection<InetSocketAddress> connSrvs = (hasSrvs) ? new LinkedHashSet<>(srvs) : routers;
if (hasSrvs) {
// Add REST endpoints for all nodes from previous topology snapshot.
try {
for (GridClientNodeImpl node : top.nodes()) {
Collection<InetSocketAddress> endpoints = node.availableAddresses(cfg.getProtocol(), true);
List<InetSocketAddress> resolvedEndpoints = new ArrayList<>(endpoints.size());
for (InetSocketAddress endpoint : endpoints) if (!endpoint.isUnresolved())
resolvedEndpoints.add(endpoint);
boolean sameHost = node.attributes().isEmpty() || F.containsAny(U.allLocalMACs(), node.attribute(ATTR_MACS).toString().split(", "));
if (sameHost) {
Collections.sort(resolvedEndpoints, U.inetAddressesComparator(true));
connSrvs.addAll(resolvedEndpoints);
} else {
for (InetSocketAddress endpoint : resolvedEndpoints) if (!endpoint.getAddress().isLoopbackAddress())
connSrvs.add(endpoint);
}
}
} catch (GridClientDisconnectedException ignored) {
// Ignore if latest topology update failed.
}
}
connMgr.init(connSrvs);
Map<String, GridClientCacheMode> overallCaches = new HashMap<>();
for (GridClientNodeImpl node : top.nodes()) overallCaches.putAll(node.caches());
for (Map.Entry<String, GridClientCacheMode> entry : overallCaches.entrySet()) {
GridClientDataAffinity affinity = affinity(entry.getKey());
if (affinity instanceof GridClientPartitionAffinity && entry.getValue() != GridClientCacheMode.PARTITIONED)
log.warning(GridClientPartitionAffinity.class.getSimpleName() + " is used for a cache configured " + "for non-partitioned mode [cacheName=" + entry.getKey() + ", cacheMode=" + entry.getValue() + ']');
}
}
use of org.apache.ignite.internal.client.GridClientPartitionAffinity in project ignite by apache.
the class GridClientImpl method tryInit.
/**
* Tries to init connection manager using configured set of servers or routers.
*
* @throws GridClientException If initialisation failed.
* @throws InterruptedException If initialisation was interrupted.
*/
private void tryInit() throws GridClientException, InterruptedException {
connMgr.init(addresses());
Map<String, GridClientCacheMode> overallCaches = new HashMap<>();
for (GridClientNodeImpl node : top.nodes()) overallCaches.putAll(node.caches());
for (Map.Entry<String, GridClientCacheMode> entry : overallCaches.entrySet()) {
GridClientDataAffinity affinity = affinity(entry.getKey());
if (affinity instanceof GridClientPartitionAffinity && entry.getValue() != GridClientCacheMode.PARTITIONED)
log.warning(GridClientPartitionAffinity.class.getSimpleName() + " is used for a cache configured " + "for non-partitioned mode [cacheName=" + entry.getKey() + ", cacheMode=" + entry.getValue() + ']');
}
}
Aggregations