use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceDeploymentCompoundFutureSelfTest method testWaitForCompletionOnFailingFuture.
/**
* @throws Exception If failed.
*/
@Test
public void testWaitForCompletionOnFailingFuture() throws Exception {
GridServiceDeploymentCompoundFuture<IgniteUuid> compFut = new GridServiceDeploymentCompoundFuture<>();
int failingFutsNum = 2;
int completingFutsNum = 5;
Collection<GridServiceDeploymentFuture> failingFuts = new ArrayList<>(completingFutsNum);
for (int i = 0; i < failingFutsNum; i++) {
ServiceConfiguration failingCfg = config("Failed-" + i);
GridServiceDeploymentFuture<IgniteUuid> failingFut = new GridServiceDeploymentFuture<>(failingCfg, IgniteUuid.randomUuid());
failingFuts.add(failingFut);
compFut.add(failingFut);
}
List<GridFutureAdapter<Object>> futs = new ArrayList<>(completingFutsNum);
for (int i = 0; i < completingFutsNum; i++) {
GridServiceDeploymentFuture<IgniteUuid> fut = new GridServiceDeploymentFuture<>(config(String.valueOf(i)), IgniteUuid.randomUuid());
futs.add(fut);
compFut.add(fut);
}
compFut.markInitialized();
List<Exception> causes = new ArrayList<>();
for (GridServiceDeploymentFuture fut : failingFuts) {
Exception cause = new Exception("Test error");
causes.add(cause);
fut.onDone(cause);
}
try {
compFut.get(100);
fail("Should never reach here.");
} catch (IgniteFutureTimeoutCheckedException e) {
log.info("Expected exception: " + e.getMessage());
}
for (GridFutureAdapter<Object> fut : futs) fut.onDone();
try {
compFut.get();
fail("Should never reach here.");
} catch (IgniteCheckedException ce) {
log.info("Expected exception: " + ce.getMessage());
IgniteException e = U.convertException(ce);
assertTrue(e instanceof ServiceDeploymentException);
Throwable[] supErrs = e.getSuppressed();
assertEquals(failingFutsNum, supErrs.length);
for (int i = 0; i < failingFutsNum; i++) assertEquals(causes.get(i), supErrs[i].getCause());
}
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class IgniteServiceDeploymentClassLoadingDefaultMarshallerTest method serviceConfig.
/**
* @return Service configuration.
* @throws Exception If failed.
*/
private ServiceConfiguration serviceConfig() throws Exception {
ServiceConfiguration srvCfg = new ServiceConfiguration();
srvCfg.setNodeFilter(new TestNodeFilter(extClsLdrGrids));
Class<Service> srvcCls = (Class<Service>) extClsLdr.loadClass(NOOP_SERVICE_CLS_NAME);
Service srvc = srvcCls.newInstance();
srvCfg.setService(srvc);
srvCfg.setName("TestDeploymentService");
srvCfg.setMaxPerNodeCount(1);
return srvCfg;
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class IgniteServiceProxyTimeoutInitializedTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(final String igniteInstanceName) throws Exception {
final IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
final ServiceConfiguration scfg = new ServiceConfiguration();
if (igniteInstanceName.endsWith("0")) {
scfg.setName("testService");
scfg.setService(srvc);
scfg.setMaxPerNodeCount(1);
scfg.setTotalCount(1);
scfg.setNodeFilter(new NodeFilter());
final Map<String, String> attrs = new HashMap<>();
attrs.put("clusterGroup", "0");
cfg.setUserAttributes(attrs);
cfg.setServiceConfiguration(scfg);
}
cfg.setMarshaller(null);
final BinaryConfiguration binCfg = new BinaryConfiguration();
// Despite defaults explicitly set to lower case.
binCfg.setIdMapper(new BinaryBasicIdMapper(true));
cfg.setBinaryConfiguration(binCfg);
return cfg;
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class ServiceAuthorizationTest method serviceConfiguration.
/**
* @return Test service configuration.
*/
private ServiceConfiguration serviceConfiguration() {
ServiceConfiguration srvcCfg = new ServiceConfiguration();
srvcCfg.setMaxPerNodeCount(1);
srvcCfg.setName(TEST_SERVICE_NAME);
srvcCfg.setService(new TestServiceImpl());
return srvcCfg;
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorBatchDeploySelfTest method testCancelAllClashingNames.
/**
* @throws Exception If failed.
*/
@Test
public void testCancelAllClashingNames() 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);
List<String> names = new ArrayList<>();
for (ServiceConfiguration cfg : cfgs) names.add(cfg.getName());
int batchSize = 5;
int from = 0;
while (from < NUM_SERVICES) {
int to = Math.min(NUM_SERVICES, from + batchSize);
List<String> toCancel = new ArrayList<>(names.subList(from, to));
toCancel.add(toCancel.get(0));
client.services().cancelAll(toCancel);
from = to;
}
assertDeployedServices(client, Collections.<ServiceConfiguration>emptyList());
}
Aggregations