use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorBatchDeploySelfTest method copyService.
/**
* @param cfg Config.
* @return Copy of provided configuration.
*/
private ServiceConfiguration copyService(ServiceConfiguration cfg) {
ServiceConfiguration cfgCp = new ServiceConfiguration();
cfgCp.setName(cfg.getName());
cfgCp.setMaxPerNodeCount(cfg.getMaxPerNodeCount());
cfgCp.setTotalCount(cfg.getTotalCount());
cfgCp.setAffinityKey(cfg.getAffinityKey());
cfgCp.setCacheName(cfg.getCacheName());
cfgCp.setName(cfg.getName());
cfgCp.setService(cfg.getService());
cfgCp.setNodeFilter(cfg.getNodeFilter());
return cfgCp;
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorBatchDeploySelfTest method testClashingNameDifferentConfig.
/**
* @throws Exception If failed.
*/
@Test
public void testClashingNameDifferentConfig() throws Exception {
Ignite client = grid(CLIENT_NODE_NAME);
List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES);
int numDepSvcs = NUM_SERVICES - 1;
CountDownLatch latch = new CountDownLatch(numDepSvcs);
List<ServiceConfiguration> fstBatch = cfgs.subList(0, NUM_SERVICES / 2);
List<ServiceConfiguration> sndBatch = cfgs.subList(NUM_SERVICES / 4, NUM_SERVICES - 1);
subscribeExeLatch(cfgs, latch);
client.services().deployAll(fstBatch);
ServiceConfiguration failingCfg = copyService(cfgs.get(NUM_SERVICES - 1));
// Same name, different config.
failingCfg.setName(fstBatch.get(0).getName());
failingCfg.setTotalCount(fstBatch.get(0).getTotalCount() + 1);
sndBatch.add(failingCfg);
assertFailingDeploy(client, false, sndBatch, failingCfg);
assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS));
assertDeployedServices(client, cfgs.subList(0, numDepSvcs));
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorBatchDeploySelfTest method testCancelAllTopologyChange.
/**
* @throws Exception If failed.
*/
@Test
public void testCancelAllTopologyChange() throws Exception {
IgniteEx client = grid(CLIENT_NODE_NAME);
int numServices = 500;
List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), numServices);
CountDownLatch latch = new CountDownLatch(numServices);
subscribeExeLatch(cfgs, latch);
client.services().deployAll(cfgs);
latch.await(30, TimeUnit.SECONDS);
final AtomicBoolean finished = new AtomicBoolean();
IgniteInternalFuture<Object> topChangeFut = runTopChanger(finished);
List<String> names = new ArrayList<>();
for (ServiceConfiguration cfg : cfgs) names.add(cfg.getName());
try {
int batchSize = 5;
int from = 0;
while (from < numServices) {
int to = Math.min(numServices, from + batchSize);
log.info("Trying to cancel services [" + from + ".." + to + ")");
client.services().cancelAllAsync(names.subList(from, to)).get(5000);
from = to;
}
assertDeployedServices(client, Collections.<ServiceConfiguration>emptyList());
} finally {
finished.set(true);
}
topChangeFut.get();
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorBatchDeploySelfTest method assertDeployedServices.
/**
* @param client Client Ignite instance.
* @param expCfgs Configurations of services that are expected to be deployed.
*/
private void assertDeployedServices(Ignite client, Collection<ServiceConfiguration> expCfgs) {
Set<String> expNames = new HashSet<>();
Set<String> actNames = new HashSet<>();
for (ServiceConfiguration cfg : expCfgs) expNames.add(cfg.getName());
for (ServiceDescriptor desc : client.services().serviceDescriptors()) actNames.add(desc.name());
assertEquals(expNames, actNames);
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorBatchDeploySelfTest method getConfigs.
/**
* @param nodePred Node predicate.
* @param numServices Number of configurations to generate.
* @return Generated services configurations.
*/
private List<ServiceConfiguration> getConfigs(IgnitePredicate<ClusterNode> nodePred, int numServices) {
List<ServiceConfiguration> cfgs = new ArrayList<>(numServices);
for (int i = 0; i < numServices; i++) {
String name = "testService-" + i;
ServiceConfiguration cfg = new ServiceConfiguration();
cfg.setName(name);
cfg.setTotalCount(1);
cfg.setMaxPerNodeCount(1);
cfg.setService(new DummyService());
cfg.setNodeFilter(nodePred);
cfgs.add(cfg);
}
return cfgs;
}
Aggregations