use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class ServiceReassignmentFunctionSelfTest method testCustomConfiguration.
/**
* @throws Exception In case of an error.
*/
@Test
public void testCustomConfiguration() throws Exception {
ServiceConfiguration cfg = new ServiceConfiguration();
cfg.setName(TEST_SERVICE_NAME);
cfg.setMaxPerNodeCount(3);
cfg.setTotalCount(10);
runTestReassignFunction(IgniteUuid.randomUuid(), cfg, null);
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class IgniteServiceReassignmentTest method serviceConfiguration.
/**
* @return Service configuration.
*/
private ServiceConfiguration serviceConfiguration() {
ServiceConfiguration svc = new ServiceConfiguration();
svc.setName("DummyService");
svc.setTotalCount(1);
svc.setService(new DummyService());
return svc;
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessor method onKernalStart.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public void onKernalStart(boolean activeOnStart) throws IgniteCheckedException {
if (ctx.isDaemon() || !ctx.state().active())
return;
cache = ctx.cache().utilityCache();
if (!ctx.clientNode())
ctx.event().addDiscoveryEventListener(topLsnr, EVTS);
try {
if (ctx.deploy().enabled())
ctx.cache().context().deploy().ignoreOwnership(true);
if (!ctx.clientNode()) {
assert cache.context().affinityNode();
cache.context().continuousQueries().executeInternalQuery(new ServiceEntriesListener(), null, true, true, false);
} else {
assert !ctx.isDaemon();
ctx.closure().runLocalSafe(new Runnable() {
@Override
public void run() {
try {
Iterable<CacheEntryEvent<?, ?>> entries = cache.context().continuousQueries().existingEntries(false, null);
onSystemCacheUpdated(entries);
} catch (IgniteCheckedException e) {
U.error(log, "Failed to load service entries: " + e, e);
}
}
});
}
} finally {
if (ctx.deploy().enabled())
ctx.cache().context().deploy().ignoreOwnership(false);
}
ServiceConfiguration[] cfgs = ctx.config().getServiceConfiguration();
if (cfgs != null) {
Collection<IgniteInternalFuture<?>> futs = new ArrayList<>();
for (ServiceConfiguration c : cfgs) {
// Deploy only on server nodes by default.
if (c.getNodeFilter() == null)
c.setNodeFilter(ctx.cluster().get().forServers().predicate());
futs.add(deploy(c));
}
// Await for services to deploy.
for (IgniteInternalFuture<?> f : futs) f.get();
}
if (log.isDebugEnabled())
log.debug("Started service processor.");
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceProcessorBatchDeploySelfTest method _testDeployAllTopologyChange.
/**
* TODO: enable when IGNITE-6259 is fixed.
*
* @throws Exception If failed.
*/
public void _testDeployAllTopologyChange() throws Exception {
Ignite client = grid(CLIENT_NODE_NAME);
final AtomicBoolean finished = new AtomicBoolean();
IgniteInternalFuture<Object> topChangeFut = runTopChanger(finished);
try {
int numServices = 500;
int batchSize = 5;
CountDownLatch latch = new CountDownLatch(numServices);
IgnitePredicate<ClusterNode> depPred = client.cluster().forServers().forPredicate(new IgnitePredicate<ClusterNode>() {
@Override
public boolean apply(ClusterNode node) {
String gridName = node.attribute(IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME);
assert gridName != null;
return gridName.startsWith(getTestIgniteInstanceName());
}
}).predicate();
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(30, 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 _testCancelAllTopologyChange.
/**
* TODO: enable when IGNITE-6259 is fixed.
*
* @throws Exception If failed.
*/
public void _testCancelAllTopologyChange() throws Exception {
Ignite 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();
}
Aggregations