public static TimePeriod.Duration normalizeDuration(String value) { switch (value.toLowerCase()) { case "sec": case "seconds": case "second": return TimePeriod.Duration.SECONDS; case "min": case "minutes": case "minute": return TimePeriod.Duration.MINUTES; case "h": case "hour": case "hours": return TimePeriod.Duration.HOURS; case "days": case "day": return TimePeriod.Duration.DAYS; case "month": case "months": return TimePeriod.Duration.MONTHS; case "year": case "years": return TimePeriod.Duration.YEARS; default: throw new SiddhiAppValidationException("Duration '" + value + "' does not exists "); } }
public SiddhiAppValidationException(String message, Throwable throwable, int[] queryContextStartIndex, int[] queryContextEndIndex, String siddhiAppName, String siddhiAppString) { super(message, throwable); this.message = message; setQueryContextIndexIfAbsent(queryContextStartIndex, queryContextEndIndex, siddhiAppName, siddhiAppString); }
public SiddhiApp defineStream(StreamDefinition streamDefinition) { if (streamDefinition == null) { throw new SiddhiAppValidationException("Stream Definition should not be null"); } else if (streamDefinition.getId() == null) { throw new SiddhiAppValidationException("Stream Id should not be null for Stream Definition", streamDefinition.getQueryContextStartIndex(), streamDefinition.getQueryContextEndIndex()); } checkDuplicateDefinition(streamDefinition); this.streamDefinitionMap.put(streamDefinition.getId(), streamDefinition); return this; }
public SiddhiAppValidationException(String message, Throwable throwable, int[] queryContextStartIndex, int[] queryContextEndIndex) { super(message, throwable); this.message = message; setQueryContextIndexIfAbsent(queryContextStartIndex, queryContextEndIndex, siddhiAppName, null); }
public SiddhiApp defineAggregation(AggregationDefinition aggregationDefinition) { if (aggregationDefinition == null) { throw new SiddhiAppValidationException("Aggregation Definition should not be null"); } if (aggregationDefinition.getId() == null) { throw new SiddhiAppValidationException("Aggregation Id should not be null for Aggregation Definition", aggregationDefinition.getQueryContextStartIndex(), aggregationDefinition.getQueryContextEndIndex()); } checkDuplicateDefinition(aggregationDefinition); this.aggregationDefinitionMap.put(aggregationDefinition.getId(), aggregationDefinition); return this; }
public SiddhiAppValidationException(String message, int[] queryContextStartIndex, int[] queryContextEndIndex, String siddhiAppName, String siddhiAppString) { super(message); this.message = message; setQueryContextIndexIfAbsent(queryContextStartIndex, queryContextEndIndex, siddhiAppName, siddhiAppString); }
public SiddhiApp defineTable(TableDefinition tableDefinition) { if (tableDefinition == null) { throw new SiddhiAppValidationException("Table Definition should not be null"); } else if (tableDefinition.getId() == null) { throw new SiddhiAppValidationException("Table Id should not be null for Table Definition", tableDefinition.getQueryContextStartIndex(), tableDefinition.getQueryContextEndIndex()); } checkDuplicateDefinition(tableDefinition); this.tableDefinitionMap.put(tableDefinition.getId(), tableDefinition); return this; }
public SiddhiAppValidationException(String message, int[] queryContextStartIndex, int[] queryContextEndIndex) { super(message); this.message = message; setQueryContextIndexIfAbsent(queryContextStartIndex, queryContextEndIndex, siddhiAppName, null); }
public SiddhiApp defineWindow(WindowDefinition windowDefinition) { if (windowDefinition == null) { throw new SiddhiAppValidationException("Window Definition should not be null"); } else if (windowDefinition.getId() == null) { throw new SiddhiAppValidationException("Window Id should not be null for Window Definition", windowDefinition.getQueryContextStartIndex(), windowDefinition.getQueryContextEndIndex()); } checkDuplicateDefinition(windowDefinition); this.windowDefinitionMap.put(windowDefinition.getId(), windowDefinition); return this; }
public SiddhiAppValidationException(String message, Throwable throwable, int[] queryContextStartIndex, int[] queryContextEndIndex) { super(message, throwable); this.message = message; setQueryContextIndexIfAbsent(queryContextStartIndex, queryContextEndIndex, siddhiAppName, null); }
private void addPartitionType(PartitionType partitionType) { String partitionedStream = partitionType.getStreamId(); if (partitionTypeMap.containsKey(partitionedStream)) { throw new SiddhiAppValidationException("Duplicate partition for Stream " + partitionedStream + "!, " + partitionType.toString() + " cannot be added as " + partitionTypeMap.get(partitionType .getStreamId()) + " already exist.", partitionType.getQueryContextStartIndex(), partitionType.getQueryContextEndIndex()); } partitionTypeMap.put(partitionType.getStreamId(), partitionType); }
public SiddhiAppValidationException(String message, int[] queryContextStartIndex, int[] queryContextEndIndex, String siddhiAppName, String siddhiAppString) { super(message); this.message = message; setQueryContextIndexIfAbsent(queryContextStartIndex, queryContextEndIndex, siddhiAppName, siddhiAppString); }
public Partition addQuery(Query query) { if (query == null) { throw new SiddhiAppValidationException("Query should not be null"); } String name = null; Element element = AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_INFO, SiddhiConstants .ANNOTATION_ELEMENT_NAME, query.getAnnotations()); if (element != null) { name = element.getValue(); } if (name != null && queryNameList.contains(name)) { throw new SiddhiAppValidationException("Cannot add Query as another Execution Element already uses " + "its name=" + name + " within the same Partition", element.getQueryContextStartIndex(), element.getQueryContextEndIndex()); } queryNameList.add(name); this.queryList.add(query); return this; }
public SiddhiAppValidationException(String message, int[] queryContextStartIndex, int[] queryContextEndIndex) { super(message); this.message = message; setQueryContextIndexIfAbsent(queryContextStartIndex, queryContextEndIndex, siddhiAppName, null); }
public SiddhiApp addQuery(Query query) { if (query == null) { throw new SiddhiAppValidationException("Query should not be null"); } String name = null; Element element = AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_INFO, SiddhiConstants .ANNOTATION_ELEMENT_NAME, query.getAnnotations()); if (element != null) { name = element.getValue(); } if (name != null && executionElementNameList.contains(name)) { throw new SiddhiAppValidationException( "Cannot add Query as another Execution Element already uses " + "its name=" + name, element.getQueryContextStartIndex(), element.getQueryContextEndIndex()); } executionElementNameList.add(name); this.executionElementList.add(query); return this; }
public SiddhiAppValidationException(String message, Throwable throwable, int[] queryContextStartIndex, int[] queryContextEndIndex, String siddhiAppName, String siddhiAppString) { super(message, throwable); this.message = message; setQueryContextIndexIfAbsent(queryContextStartIndex, queryContextEndIndex, siddhiAppName, siddhiAppString); }
public SiddhiApp addPartition(Partition partition) { if (partition == null) { throw new SiddhiAppValidationException("Partition should not be null"); } String name = null; Element element = AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_INFO, SiddhiConstants .ANNOTATION_ELEMENT_NAME, partition.getAnnotations()); if (element != null) { name = element.getValue(); } if (name != null && executionElementNameList.contains(name)) { throw new SiddhiAppValidationException( "Cannot add Partition as another Execution Element already " + "uses its name=" + name, element.getQueryContextStartIndex(), element.getQueryContextEndIndex()); } executionElementNameList.add(name); this.executionElementList.add(partition); return this; }
public void defineFunction(FunctionDefinition functionDefinition) { if (functionDefinition == null) { throw new SiddhiAppValidationException("Function Definition should not be null"); } else if (functionDefinition.getId() == null) { throw new SiddhiAppValidationException("Function Id should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex()); } else if (functionDefinition.getReturnType() == null) { throw new SiddhiAppValidationException("Return type should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex()); } else if (functionDefinition.getBody() == null) { throw new SiddhiAppValidationException("Body should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex()); } else if (functionDefinition.getLanguage() == null) { throw new SiddhiAppValidationException("Language should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex()); } checkDuplicateFunctionExist(functionDefinition); this.functionDefinitionMap.put(functionDefinition.getId(), functionDefinition); }
public AnonymousInputStream(Query query) { super("Anonymous-" + UUID.randomUUID()); if (query.getOutputStream() != null && !(query.getOutputStream() instanceof ReturnStream)) { throw new SiddhiAppValidationException("OutputStream of the query is not on type Return!", query.getOutputStream().getQueryContextStartIndex(), query.getOutputStream().getQueryContextEndIndex()); } this.query = query; }
public static Long timeToLong(String value) { Pattern timeValuePattern = Pattern.compile("\\d+"); Pattern durationPattern = Pattern.compile("\\D+"); Matcher timeMatcher = timeValuePattern.matcher(value); Matcher durationMatcher = durationPattern.matcher(value); int timeValue; TimePeriod.Duration duration; if (timeMatcher.find() && durationMatcher.find()) { duration = normalizeDuration(durationMatcher.group(0).trim()); timeValue = Integer.parseInt(timeMatcher.group(0)); switch (duration) { case SECONDS: return Expression.Time.sec(timeValue).value(); case MINUTES: return Expression.Time.minute(timeValue).value(); case HOURS: return Expression.Time.hour(timeValue).value(); case DAYS: return Expression.Time.day(timeValue).value(); case YEARS: return Expression.Time.year(timeValue).value(); default: return Expression.Time.month(timeValue).value(); } } else { throw new SiddhiAppValidationException("Provided retention value cannot be identified. retention " + "period: " + value + "."); } }