use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorBatchDeploySelfTest method testDeployAllTopologyChange.
/**
* @throws Exception If failed.
*/
@Test
public void testDeployAllTopologyChange() throws Exception {
Ignite client = grid(CLIENT_NODE_NAME);
final AtomicBoolean finished = new AtomicBoolean();
IgniteInternalFuture<Object> topChangeFut = runTopChanger(finished);
try {
int numServices = 50;
int batchSize = 5;
CountDownLatch latch = new CountDownLatch(numServices);
IgnitePredicate<ClusterNode> depPred = new TestPredicate(getTestIgniteInstanceName());
List<ServiceConfiguration> cfgs = getConfigs(depPred, numServices);
subscribeExeLatch(cfgs, latch);
int from = 0;
while (from < numServices) {
int to = Math.min(numServices, from + batchSize);
client.services().deployAllAsync(cfgs.subList(from, to)).get(5000);
from = to;
}
assertTrue(latch.await(120, TimeUnit.SECONDS));
assertDeployedServices(client, cfgs);
} finally {
finished.set(true);
}
topChangeFut.get();
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorBatchDeploySelfTest method testDeployAllAsync.
/**
* @throws Exception If failed.
*/
@Test
public void testDeployAllAsync() throws Exception {
Ignite client = grid(CLIENT_NODE_NAME);
CountDownLatch latch = new CountDownLatch(NUM_SERVICES);
List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES);
subscribeExeLatch(cfgs, latch);
IgniteFuture<Void> fut = client.services().deployAllAsync(cfgs);
fut.get();
assertTrue("Waiting for services deployment timed out.", latch.await(30, TimeUnit.SECONDS));
assertDeployedServices(client, cfgs);
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorBatchDeploySelfTest method testCancelAll.
/**
* @throws Exception If failed.
*/
@Test
public void testCancelAll() throws Exception {
Ignite client = grid(CLIENT_NODE_NAME);
List<ServiceConfiguration> cfgs = getConfigs(client.cluster().forServers().predicate(), NUM_SERVICES);
CountDownLatch latch = new CountDownLatch(NUM_SERVICES);
subscribeExeLatch(cfgs, latch);
client.services().deployAll(cfgs);
latch.await(30, TimeUnit.SECONDS);
client.services().cancelAll();
assertDeployedServices(client, Collections.<ServiceConfiguration>emptyList());
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorBatchDeploySelfTest method testDeployAllTopologyChangeFail.
/**
* @throws Exception If failed.
*/
@Test
public void testDeployAllTopologyChangeFail() throws Exception {
final Ignite client = grid(CLIENT_NODE_NAME);
final AtomicBoolean finished = new AtomicBoolean();
IgniteInternalFuture<Object> topChangeFut = runTopChanger(finished);
try {
int numServices = 200;
int batchSize = 5;
CountDownLatch latch = new CountDownLatch(numServices);
IgnitePredicate<ClusterNode> depPred = new TestPredicate(getTestIgniteInstanceName());
List<ServiceConfiguration> cfgs = getConfigs(depPred, numServices);
List<ServiceConfiguration> failingCfgs = new ArrayList<>();
subscribeExeLatch(cfgs, latch);
int from = 0;
while (from < numServices) {
int to = Math.min(numServices, from + batchSize);
List<ServiceConfiguration> cfgsBatch = cfgs.subList(from, to);
ServiceConfiguration failingCfg = cfgsBatch.get(0);
failingCfg.setName(null);
failingCfgs.add(failingCfg);
try {
client.services().deployAllAsync(cfgsBatch).get(5000);
fail("Should never reach here.");
} catch (ServiceDeploymentException e) {
assertEquals(1, e.getFailedConfigurations().size());
ServiceConfiguration actFailedCfg = copyService(e.getFailedConfigurations().iterator().next());
assertEquals(failingCfg, actFailedCfg);
latch.countDown();
}
from = to;
}
assertTrue(latch.await(120, TimeUnit.SECONDS));
cfgs.removeAll(failingCfgs);
assertDeployedServices(client, cfgs);
} finally {
finished.set(true);
}
topChangeFut.get();
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class IgniteServiceConfigVariationsFullApiTest method testDeploy.
/**
* Tests deployment.
*
* @throws Exception If failed.
*/
@Test
public void testDeploy() throws Exception {
runInAllDataModes(new ServiceTestRunnable(false, new DeployClosure() {
@Override
public void run(IgniteServices services, String svcName, TestService svc) throws Exception {
services.deployClusterSingleton(svcName, (Service) svc);
ServiceConfiguration cfg = new ServiceConfiguration();
cfg.setName(svcName);
cfg.setService((Service) svc);
cfg.setTotalCount(1);
cfg.setMaxPerNodeCount(1);
cfg.setNodeFilter(services.clusterGroup().predicate());
services.deploy(cfg);
waitForServiceDeploymentIfNeeded(services, svcName);
}
}));
}
Aggregations