use of com.arm.mbed.cloud.sdk.testutils.APICaller in project mbed-cloud-sdk-java by ARMmbed.
the class Engine method stopInstanceDaemons.
private void stopInstanceDaemons(String instanceId) throws ServerCacheException, MissingInstanceException {
APIModule module = cache.fetchModuleFromInstance(instanceId);
if (module != null) {
if (module.hasDaemonControlMethods()) {
ModuleInstance instance = retrieveInstance(instanceId);
APICaller caller = createAnApiCaller();
logger.logInfo("Stopping SDK module instance [" + instanceId + "] daemon threads");
List<APIMethod> stoppingMethods = module.getStopDaemonMethods();
if (stoppingMethods != null) {
stoppingMethods.forEach(m -> {
try {
caller.callAPIOnModuleInstance(instance, m.getName(), null);
} catch (UnknownAPIException | APICallException e) {
e.printStackTrace();
}
});
}
logger.logInfo("Shutting down SDK module instance [" + instanceId + "] daemon executor service");
List<APIMethod> shuttingdownMethods = module.getShutdownDaemonMethods();
if (shuttingdownMethods != null) {
shuttingdownMethods.forEach(m -> {
try {
caller.callAPIOnModuleInstance(instance, m.getName(), null);
} catch (UnknownAPIException | APICallException e) {
e.printStackTrace();
}
});
}
}
}
}
Aggregations