public static void deployStreams(DeployableTemplate template) { if (template.getStreams() != null) { for (String stream : template.getStreams()) { StreamDefinition streamDefinition = null; try { streamDefinition = EventDefinitionConverterUtils.convertFromJson(stream); BatchScriptDeployerValueHolder.getEventStreamService() .addEventStreamDefinition(streamDefinition); } catch (MalformedStreamDefinitionException e) { log.error("Stream definition is incorrect in domain template " + stream, e); } catch (EventStreamConfigurationException e) { log.error("Exception occurred when configuring stream " + streamDefinition.getName(), e); } catch (StreamDefinitionAlreadyDefinedException e) { log.error( "Same template stream name " + streamDefinition.getName() + " has been defined for another definition ", e); throw e; } } } }
@Override public void deployArtifact(DeployableTemplate template) throws TemplateDeploymentException { try { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); String artifactId = template.getConfiguration().getFrom() + BatchScriptDeployerConstants.CONFIG_NAME_SEPARATOR + template.getConfiguration().getName(); BatchScriptDeployerValueHolder.getAnalyticsProcessorService() .deleteScript(tenantId, artifactId); deployStreams(template); BatchScriptDeployerValueHolder.getAnalyticsProcessorService() .saveScript( tenantId, artifactId, template.getScript(), template.getConfiguration().getExecutionParameters()); } catch (AnalyticsPersistenceException e) { throw new TemplateDeploymentException( "Error when saving batch script." + template.getConfiguration().getName(), e); } }