use of org.apache.ignite.internal.processors.resource.GridSpringResourceContext in project ignite by apache.
the class IgniteAwareApplicationService method main.
/**
* @param args Args.
*/
public static void main(String[] args) throws Exception {
log.info("Starting Application... [params=" + args[0] + "]");
String[] params = args[0].split(",");
IgniteServiceType svcType = IgniteServiceType.valueOf(params[0]);
Class<?> clazz = Class.forName(params[1]);
String cfgPath = params[2];
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode = params.length > 3 ? mapper.readTree(Base64.getDecoder().decode(params[3])) : mapper.createObjectNode();
IgniteAwareApplication app = (IgniteAwareApplication) clazz.getConstructor().newInstance();
app.cfgPath = cfgPath;
if (svcType == IgniteServiceType.NODE) {
log.info("Starting Ignite node...");
IgniteBiTuple<IgniteConfiguration, GridSpringResourceContext> cfgs = IgnitionEx.loadConfiguration(cfgPath);
IgniteConfiguration cfg = cfgs.get1();
try (Ignite ignite = Ignition.start(cfg)) {
app.ignite = ignite;
app.start(jsonNode);
} finally {
log.info("Ignite instance closed. [interrupted=" + Thread.currentThread().isInterrupted() + "]");
}
} else if (svcType == IgniteServiceType.THIN_CLIENT) {
log.info("Starting thin client...");
ClientConfiguration cfg = IgnitionEx.loadSpringBean(cfgPath, "thin.client.cfg");
try (IgniteClient client = Ignition.startClient(cfg)) {
app.client = client;
app.start(jsonNode);
} finally {
log.info("Thin client instance closed. [interrupted=" + Thread.currentThread().isInterrupted() + "]");
}
} else if (svcType == IgniteServiceType.NONE)
app.start(jsonNode);
else
throw new IllegalArgumentException("Unknown service type " + svcType);
}
Aggregations