public static Annotation getAnnotation(String annotationName, List<Annotation> annotationList) { Annotation annotation = null; for (Annotation aAnnotation : annotationList) { if (annotationName.equalsIgnoreCase(aAnnotation.getName())) { if (annotation == null) { annotation = aAnnotation; } else { throw new DuplicateAnnotationException("Annotation @" + annotationName + " is defined twice", aAnnotation.getQueryContextStartIndex(), aAnnotation.getQueryContextEndIndex()); } } } return annotation; }
public static Annotation getAnnotation(String annotationName, List<Annotation> annotationList) { Annotation annotation = null; for (Annotation aAnnotation : annotationList) { if (annotationName.equalsIgnoreCase(aAnnotation.getName())) { if (annotation == null) { annotation = aAnnotation; } else { throw new DuplicateAnnotationException("Annotation @" + annotationName + " is defined twice", aAnnotation.getQueryContextStartIndex(), aAnnotation.getQueryContextEndIndex()); } } } return annotation; }
/** * If the Stream definition string contains {@link SiddhiTopologyCreatorConstants#SINK_IDENTIFIER} or * {@link SiddhiTopologyCreatorConstants#SOURCE_IDENTIFIER} ,meta info related to Sink/Source configuration is * removed. * * @return Stream definition String after removing Sink/Source configuration */ private String removeMetaInfoStream(String streamId, String streamDefinition, String identifier) { int[] queryContextStartIndex; int[] queryContextEndIndex; for (Annotation annotation : siddhiApp.getStreamDefinitionMap().get(streamId).getAnnotations()) { if (annotation.getName().toLowerCase().equals(identifier.replace("@", ""))) { queryContextStartIndex = annotation.getQueryContextStartIndex(); queryContextEndIndex = annotation.getQueryContextEndIndex(); streamDefinition = streamDefinition.replace( ExceptionUtil.getContext(queryContextStartIndex, queryContextEndIndex, siddhiTopologyDataHolder.getUserDefinedSiddhiApp()), ""); } } return streamDefinition; }
/** * If {@link Query,Partition} string contains {@link SiddhiTopologyCreatorConstants#DISTRIBUTED_IDENTIFIER}, * meta info related to distributed deployment is removed. */ private String removeMetaInfoQuery(ExecutionElement executionElement, String queryElement) { int[] queryContextStartIndex; int[] queryContextEndIndex; for (Annotation annotation : executionElement.getAnnotations()) { if (annotation.getName().toLowerCase() .equals(SiddhiTopologyCreatorConstants.DISTRIBUTED_IDENTIFIER)) { queryContextStartIndex = annotation.getQueryContextStartIndex(); queryContextEndIndex = annotation.getQueryContextEndIndex(); queryElement = queryElement.replace( ExceptionUtil.getContext(queryContextStartIndex, queryContextEndIndex, siddhiTopologyDataHolder.getUserDefinedSiddhiApp()), ""); break; } } return queryElement; }
/** * Removes the @dist annotation from given aggregation definition. * @param aggregationDefinition Aggregation definition of which meta info to be removed. * @return String definition after the removal of @dist annotation. */ //This method is not necessary for the current design of aggregation distribution. But this left here considering // the future works on adding parallel annotation to aggregations. private String removeMetaInfoAggregation(AggregationDefinition aggregationDefinition) { int[] queryContextStartIndex; int[] queryContextEndIndex; String aggregationDef = ExceptionUtil.getContext(aggregationDefinition.getQueryContextStartIndex(), aggregationDefinition.getQueryContextEndIndex(), siddhiTopologyDataHolder.getUserDefinedSiddhiApp()); for (Annotation annotation : aggregationDefinition.getAnnotations()) { if (annotation.getName().toLowerCase() .equals(SiddhiTopologyCreatorConstants.DISTRIBUTED_IDENTIFIER)) { queryContextStartIndex = annotation.getQueryContextStartIndex(); queryContextEndIndex = annotation.getQueryContextEndIndex(); aggregationDef = aggregationDef.replace(ExceptionUtil.getContext(queryContextStartIndex, queryContextEndIndex, siddhiTopologyDataHolder.getUserDefinedSiddhiApp()), ""); break; } } return aggregationDef; }