public static void stopSetAdapter(String baseUrl, AdapterSetDescription adapterSetDescription) throws AdapterException { String url = baseUrl + "worker/set/stop"; stopAdapter(adapterSetDescription.getUri(), adapterSetDescription, url); }
@POST @JsonLdSerialized @Path("/set/invoke") // @Consumes(SpMediaType.JSONLD) @Produces(MediaType.APPLICATION_JSON) public Response invokeSetAdapter(String adapterDescription) { AdapterSetDescription adapterSetDescription = null; try { adapterSetDescription = (AdapterSetDescription) AdapterDeserializer.getAdapterDescription(adapterDescription); adapterManagement.invokeSetAdapter(adapterSetDescription); } catch (AdapterException e) { logger.error("Error while starting adapter with id " + adapterSetDescription.getUri(), e); return ok(Notifications.error(e.getMessage())); } String responseMessage = "Set adapter with id " + adapterSetDescription.getUri() + " successfully started"; logger.info(responseMessage); return ok(Notifications.success(responseMessage)); }
@POST @JsonLdSerialized @Path("/set/stop") // @Consumes(SpMediaType.JSONLD) @Produces(MediaType.APPLICATION_JSON) public Response stopSetAdapter(String adapterDescription){ AdapterSetDescription adapterSetDescription = null; try { adapterSetDescription = (AdapterSetDescription) AdapterDeserializer.getAdapterDescription(adapterDescription); adapterManagement.stopSetAdapter(adapterSetDescription); } catch (AdapterException e) { logger.error("Error while stopping adapter with id " + adapterSetDescription.getUri(), e); return ok(Notifications.error(e.getMessage())); } String responseMessage = "Set adapter with id " + adapterSetDescription.getUri() + " successfully stopped"; logger.info(responseMessage); return ok(Notifications.success(responseMessage)); }
public void detachAdapter(String baseUrl, String streamId, String runningInstanceId) throws AdapterException { AdapterSetDescription adapterDescription = (AdapterSetDescription) getAdapterDescriptionById(streamId); String newId = adapterDescription.getUri() + "/streams/" + runningInstanceId; adapterDescription.setUri(newId); adapterDescription.setId(newId); WorkerRestClient.stopSetAdapter(baseUrl, adapterDescription); }
public void invokeSetAdapter (AdapterSetDescription adapterSetDescription) throws AdapterException { SpDataSet dataSet = adapterSetDescription.getDataSet(); Adapter adapter = AdapterRegistry.getAdapter(adapterSetDescription); RunningAdapterInstances.INSTANCE.addAdapter(adapterSetDescription.getUri(), adapter); // Set adapters run the whole set in one thread, once all data is processed the corresponding pipeline is stopped Runnable r = () -> { try { adapter.startAdapter(); } catch (AdapterException e) { e.printStackTrace(); } // TODO wait till all components are done with their calculations try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } String url = AdapterUtils.getUrl(ConnectContainerConfig.INSTANCE.getBackendApiUrl(), dataSet.getCorrespondingPipeline()); String result = AdapterUtils.stopPipeline(url); logger.info(result); }; new Thread(r).start(); }
public void addAdapter(String baseUrl, String streamId, SpDataSet dataSet) throws AdapterException { AdapterSetDescription adapterDescription = (AdapterSetDescription) getAdapterDescriptionById(streamId); adapterDescription.setDataSet(dataSet); String newId = adapterDescription.getUri() + "/streams/" + dataSet.getDatasetInvocationId(); adapterDescription.setUri(newId); adapterDescription.setId(newId); WorkerRestClient.invokeSetAdapter(baseUrl, adapterDescription); }