use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class ServiceReassignmentFunctionSelfTest method testClusterSingleton.
/**
* @throws Exception In case of an error.
*/
@Test
public void testClusterSingleton() throws Exception {
ServiceConfiguration cfg = new ServiceConfiguration();
cfg.setName(TEST_SERVICE_NAME);
cfg.setTotalCount(1);
runTestReassignFunction(IgniteUuid.randomUuid(), cfg, null);
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class ServiceReassignmentFunctionSelfTest method testNodeSingletonWithOldTop.
/**
* @throws Exception In case of an error.
*/
@Test
public void testNodeSingletonWithOldTop() throws Exception {
ServiceConfiguration cfg = new ServiceConfiguration();
cfg.setName(TEST_SERVICE_NAME);
cfg.setMaxPerNodeCount(1);
IgniteUuid srvcId = IgniteUuid.randomUuid();
TreeMap<UUID, Integer> oldTop = new TreeMap<>();
for (ClusterNode node : nodes) oldTop.put(node.id(), 1);
runTestReassignFunction(srvcId, cfg, oldTop);
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class IgniteServiceDeployment2ClassLoadersDefaultMarshallerTest method serviceConfig.
/**
* @param firstGrp First group flag.
* @return Service configuration.
* @throws Exception If failed.
*/
private ServiceConfiguration serviceConfig(final boolean firstGrp) throws Exception {
ServiceConfiguration srvCfg = new ServiceConfiguration();
srvCfg.setNodeFilter(new TestNodeFilter(firstGrp ? grp1 : grp2));
Class<Service> srvcCls;
if (firstGrp)
srvcCls = (Class<Service>) extClsLdr1.loadClass(NOOP_SERVICE_CLS_NAME);
else
srvcCls = (Class<Service>) extClsLdr2.loadClass(NOOP_SERVICE_2_CLS_NAME);
Service srvc = srvcCls.newInstance();
srvCfg.setService(srvc);
srvCfg.setName("TestDeploymentService" + (firstGrp ? 1 : 2));
srvCfg.setMaxPerNodeCount(1);
return srvCfg;
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class ReliabilityTest method testServiceMethodInvocationAfterFailover.
/**
* Test that client can invoke service method with externalizable parameter after
* cluster failover.
*/
@Test
public void testServiceMethodInvocationAfterFailover() throws Exception {
PersonExternalizable person = new PersonExternalizable("Person 1");
ServiceConfiguration testServiceConfig = new ServiceConfiguration();
testServiceConfig.setName(SERVICE_NAME);
testServiceConfig.setService(new TestService());
testServiceConfig.setTotalCount(1);
Ignite ignite = null;
IgniteClient client = null;
try {
// Initialize cluster and client
ignite = startGrid(getConfiguration().setServiceConfiguration(testServiceConfig));
client = startClient(ignite);
TestServiceInterface svc = client.services().serviceProxy(SERVICE_NAME, TestServiceInterface.class);
// Invoke the service method with Externalizable parameter for the first time.
// This triggers registration of the PersonExternalizable type in the cluter.
String result = svc.testMethod(person);
assertEquals("testMethod(PersonExternalizable person): " + person, result);
// Kill the cluster node, clean up the working directory (with cached types)
// and drop the client connection.
ignite.close();
U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), DataStorageConfiguration.DFLT_MARSHALLER_PATH, false));
dropAllThinClientConnections();
// Invoke the service.
GridTestUtils.assertThrowsWithCause(() -> svc.testMethod(person), ClientConnectionException.class);
// Restore the cluster and redeploy the service.
ignite = startGrid(getConfiguration().setServiceConfiguration(testServiceConfig));
// Invoke the service method with Externalizable parameter once again.
// This should restore the client connection and trigger registration of the
// PersonExternalizable once again.
result = svc.testMethod(person);
assertEquals("testMethod(PersonExternalizable person): " + person, result);
} finally {
if (ignite != null) {
try {
ignite.close();
} catch (Throwable ignore) {
}
}
if (client != null) {
try {
client.close();
} catch (Throwable ignore) {
}
}
}
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceContinuousQueryRedeployTest method deployService.
/**
* @param ignite Ignite.
*/
private void deployService(final Ignite ignite) {
ServiceConfiguration svcCfg = new ServiceConfiguration();
svcCfg.setService(new ManagementService());
svcCfg.setName(SERVICE_NAME);
svcCfg.setTotalCount(1);
svcCfg.setMaxPerNodeCount(1);
svcCfg.setNodeFilter((IgnitePredicate<ClusterNode>) node -> !node.isClient());
ignite.services().deploy(svcCfg);
}
Aggregations