use of io.siddhi.core.exception.SiddhiAppCreationException in project siddhi by wso2.
the class SinkMapper method buildMapperTemplate.
/**
* Method to create mapper template.
*
* @param streamDefinition Stream definition corresponding to mapper
* @param unmappedPayloadList mapper payload template list
*/
protected void buildMapperTemplate(StreamDefinition streamDefinition, List<Element> unmappedPayloadList) {
if (unmappedPayloadList != null && !unmappedPayloadList.isEmpty()) {
templateBuilderMap = new HashMap<>();
for (Element e : unmappedPayloadList) {
TemplateBuilder templateBuilder = new TemplateBuilder(streamDefinition, e.getValue());
if (templateBuilderMap.containsKey(e.getKey())) {
throw new SiddhiAppCreationException("Duplicate Keys, " + e.getKey() + ", in @payload() ");
}
templateBuilderMap.put(e.getKey(), templateBuilder);
}
}
}
use of io.siddhi.core.exception.SiddhiAppCreationException in project siddhi by wso2.
the class Sink method initOnlyTransport.
public final void initOnlyTransport(StreamDefinition streamDefinition, OptionHolder transportOptionHolder, ConfigReader sinkConfigReader, String type, DistributedTransport.ConnectionCallback connectionCallback, Map<String, String> deploymentProperties, SiddhiAppContext siddhiAppContext) {
this.type = type;
this.streamDefinition = streamDefinition;
this.connectionCallback = connectionCallback;
this.siddhiAppContext = siddhiAppContext;
init(streamDefinition, transportOptionHolder, sinkConfigReader, siddhiAppContext);
scheduledExecutorService = siddhiAppContext.getScheduledExecutorService();
serviceDeploymentInfo = exposeServiceDeploymentInfo();
if (serviceDeploymentInfo != null) {
serviceDeploymentInfo.addDeploymentProperties(deploymentProperties);
} else if (!deploymentProperties.isEmpty()) {
throw new SiddhiAppCreationException("Deployment properties '" + deploymentProperties + "' are defined for sink '" + type + "' which does not expose a service");
}
}
use of io.siddhi.core.exception.SiddhiAppCreationException in project siddhi by wso2.
the class SumIncrementalAttributeAggregator method init.
@Override
public void init(String attributeName, Attribute.Type attributeType) {
Attribute sum;
Expression sumInitialValue;
if (attributeName == null) {
throw new SiddhiAppCreationException("Sum incremental attribute aggregation cannot be executed " + "when no parameters are given");
}
if (attributeType.equals(Attribute.Type.FLOAT) || attributeType.equals(Attribute.Type.DOUBLE)) {
sum = new Attribute("AGG_SUM_".concat(attributeName), Attribute.Type.DOUBLE);
sumInitialValue = Expression.function("convert", Expression.variable(attributeName), Expression.value("double"));
returnType = Attribute.Type.DOUBLE;
} else if (attributeType.equals(Attribute.Type.INT) || attributeType.equals(Attribute.Type.LONG)) {
sum = new Attribute("AGG_SUM_".concat(attributeName), Attribute.Type.LONG);
sumInitialValue = Expression.function("convert", Expression.variable(attributeName), Expression.value("long"));
returnType = Attribute.Type.LONG;
} else {
throw new SiddhiAppRuntimeException("Sum aggregation cannot be executed on attribute type " + attributeType.toString());
}
this.baseAttributes = new Attribute[] { sum };
// Original attribute names
this.baseAttributesInitialValues = new Expression[] { sumInitialValue };
// used for initial values, since those would be executed using original meta
}
use of io.siddhi.core.exception.SiddhiAppCreationException in project siddhi by wso2.
the class AbstractStreamProcessor method initProcessor.
public void initProcessor(MetaStreamEvent metaStreamEvent, ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, boolean outputExpectsExpiredEvents, boolean findToBeExecuted, boolean groupBy, SiddhiElement siddhiElement, SiddhiQueryContext siddhiQueryContext) {
this.metaStreamEvent = metaStreamEvent;
this.siddhiQueryContext = siddhiQueryContext;
try {
this.inputDefinition = metaStreamEvent.getLastInputDefinition();
this.attributeExpressionExecutors = attributeExpressionExecutors;
this.attributeExpressionLength = attributeExpressionExecutors.length;
InputParameterValidator.validateExpressionExecutors(this, attributeExpressionExecutors);
StateFactory<S> stateFactory = init(metaStreamEvent, metaStreamEvent.getLastInputDefinition(), attributeExpressionExecutors, configReader, streamEventClonerHolder, outputExpectsExpiredEvents, findToBeExecuted, siddhiQueryContext);
this.additionalAttributes = getReturnAttributes();
this.stateHolder = siddhiQueryContext.generateStateHolder(this.getClass().getName(), groupBy, stateFactory);
siddhiQueryContext.getSiddhiAppContext().addEternalReferencedHolder(this);
if (additionalAttributes.size() > 0) {
StreamDefinition outputDefinition = StreamDefinition.id(inputDefinition.getId());
outputDefinition.setQueryContextStartIndex(siddhiElement.getQueryContextStartIndex());
outputDefinition.setQueryContextEndIndex(siddhiElement.getQueryContextEndIndex());
for (Attribute attribute : inputDefinition.getAttributeList()) {
outputDefinition.attribute(attribute.getName(), attribute.getType());
}
for (Attribute attribute : additionalAttributes) {
outputDefinition.attribute(attribute.getName(), attribute.getType());
}
metaStreamEvent.addInputDefinition(outputDefinition);
}
} catch (Throwable t) {
throw new SiddhiAppCreationException(t.getMessage(), t, siddhiElement.getQueryContextStartIndex(), siddhiElement.getQueryContextEndIndex(), siddhiQueryContext.getSiddhiAppContext());
}
}
use of io.siddhi.core.exception.SiddhiAppCreationException in project siddhi by wso2.
the class OutputParser method constructOutputCallback.
public static OutputCallback constructOutputCallback(OutputStream outStream, String key, ConcurrentMap<String, StreamJunction> streamJunctionMap, StreamDefinition outputStreamDefinition, SiddhiQueryContext siddhiQueryContext) {
String id = outStream.getId();
// Construct CallBack
if (outStream instanceof InsertIntoStream) {
StreamJunction outputStreamJunction = streamJunctionMap.get(id + key);
if (outputStreamJunction == null) {
outputStreamJunction = new StreamJunction(outputStreamDefinition, siddhiQueryContext.getSiddhiAppContext().getExecutorService(), siddhiQueryContext.getSiddhiAppContext().getBufferSize(), null, siddhiQueryContext.getSiddhiAppContext());
streamJunctionMap.putIfAbsent(id + key, outputStreamJunction);
}
InsertIntoStreamCallback insertIntoStreamCallback = new InsertIntoStreamCallback(outputStreamDefinition, siddhiQueryContext.getName());
insertIntoStreamCallback.init(streamJunctionMap.get(id + key));
return insertIntoStreamCallback;
} else {
throw new SiddhiAppCreationException(outStream.getClass().getName() + " not supported", outStream.getQueryContextStartIndex(), outStream.getQueryContextEndIndex());
}
}
Aggregations