http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiPolicyEvaluator.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiPolicyEvaluator.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiPolicyEvaluator.java deleted file mode 100644 index 1929b16..0000000 --- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiPolicyEvaluator.java +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.eagle.policy.siddhi; - -import com.typesafe.config.Config; -import org.apache.eagle.alert.entity.AbstractPolicyDefinitionEntity; -import org.apache.eagle.alert.entity.AlertStreamSchemaEntity; -import org.apache.eagle.dataproc.core.JsonSerDeserUtils; -import org.apache.eagle.dataproc.core.ValuesArray; -import org.apache.eagle.datastream.Collector; -import org.apache.eagle.policy.PolicyEvaluationContext; -import org.apache.eagle.policy.PolicyEvaluator; -import org.apache.eagle.policy.PolicyManager; -import org.apache.eagle.policy.common.Constants; -import org.apache.eagle.policy.config.AbstractPolicyDefinition; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.wso2.siddhi.core.ExecutionPlanRuntime; -import org.wso2.siddhi.core.SiddhiManager; -import org.wso2.siddhi.core.query.output.callback.QueryCallback; -import org.wso2.siddhi.core.stream.input.InputHandler; -import org.wso2.siddhi.query.api.execution.query.Query; -import org.wso2.siddhi.query.api.execution.query.selection.OutputAttribute; -import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; - -import java.lang.reflect.Field; -import java.util.*; - -/** - * when policy is updated or deleted, SiddhiManager.shutdown should be invoked to release resources. - * during this time, synchronization is important - */ -public class SiddhiPolicyEvaluator<T extends AbstractPolicyDefinitionEntity, K> implements PolicyEvaluator<T> { - - private final static String EXECUTION_PLAN_NAME = "query"; - private final static Logger LOG = LoggerFactory.getLogger(SiddhiPolicyEvaluator.class); - - private volatile SiddhiRuntime siddhiRuntime; - private final String[] sourceStreams; - private final boolean needValidation; - private final Config config; - private final PolicyEvaluationContext<T, K> context; - - /** - * everything dependent on policyDef should be together and switched in runtime - */ - public static class SiddhiRuntime { - QueryCallback queryCallback; - Map<String, InputHandler> siddhiInputHandlers; - SiddhiManager siddhiManager; - SiddhiPolicyDefinition policyDef; - List<String> outputFields; - String executionPlanName; - boolean markdownEnabled; - String markdownReason; - } - - public SiddhiPolicyEvaluator(Config config, PolicyEvaluationContext<T, K> context, AbstractPolicyDefinition policyDef, String[] sourceStreams) { - this(config, context, policyDef, sourceStreams, false); - } - - public SiddhiPolicyEvaluator(Config config, PolicyEvaluationContext<T, K> context, AbstractPolicyDefinition policyDef, String[] sourceStreams, boolean needValidation) { - this.config = config; - this.context = context; - this.context.evaluator = this; - this.needValidation = needValidation; - this.sourceStreams = sourceStreams; - init(policyDef); - } - - public void init(AbstractPolicyDefinition policyDef) { - siddhiRuntime = createSiddhiRuntime((SiddhiPolicyDefinition) policyDef); - } - - public static String addContextFieldIfNotExist(String expression) { - // select fieldA, fieldB --> select eagleAlertContext, fieldA, fieldB - int pos = expression.indexOf("select ") + 7; - int index = pos; - boolean isSelectStarPattern = true; - while (index < expression.length()) { - if (expression.charAt(index) == ' ') index++; - else if (expression.charAt(index) == '*') break; - else { - isSelectStarPattern = false; - break; - } - } - if (isSelectStarPattern) return expression; - StringBuilder sb = new StringBuilder(); - sb.append(expression.substring(0, pos)); - sb.append(SiddhiStreamMetadataUtils.EAGLE_ALERT_CONTEXT_FIELD + ","); - sb.append(expression.substring(pos, expression.length())); - return sb.toString(); - } - - private SiddhiRuntime createSiddhiRuntime(SiddhiPolicyDefinition policyDef) { - SiddhiManager siddhiManager = new SiddhiManager(); - Map<String, InputHandler> siddhiInputHandlers = new HashMap<String, InputHandler>(); - SiddhiRuntime runtime = new SiddhiRuntime(); - - // compose execution plan sql - String executionPlan = policyDef.getExpression(); - if (!policyDef.isContainsDefinition()) { - StringBuilder sb = new StringBuilder(); - for (String sourceStream : sourceStreams) { - String streamDef = SiddhiStreamMetadataUtils.convertToStreamDef(sourceStream); - LOG.info("Siddhi stream definition : " + streamDef); - sb.append(streamDef); - } - - String expression = policyDef.getExpression(); - executionPlan = sb.toString() + " @info(name = '" + EXECUTION_PLAN_NAME + "') " + expression; - } - - ExecutionPlanRuntime executionPlanRuntime = null; - - try { - executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan); - - for (String sourceStream : sourceStreams) { - siddhiInputHandlers.put(sourceStream, executionPlanRuntime.getInputHandler(sourceStream)); - } - - executionPlanRuntime.start(); - LOG.info("Siddhi query: " + executionPlan); - attachCallback(runtime, executionPlanRuntime, context); - - runtime.markdownEnabled = false; - runtime.markdownReason = null; - } catch (SiddhiParserException exception) { // process is not interrupted in case of an invalid policy defined by marking down - LOG.error("Exception in parsing Siddhi query: " + executionPlan + ", reason being: " + exception.getMessage()); - runtime.queryCallback = null; - runtime.outputFields = null; - runtime.markdownEnabled = true; - runtime.markdownReason = exception.getMessage(); - } - - runtime.siddhiInputHandlers = siddhiInputHandlers; - runtime.siddhiManager = siddhiManager; - runtime.policyDef = policyDef; - runtime.executionPlanName = (null != executionPlanRuntime) ? executionPlanRuntime.getName() : null; // executionPlanRuntime will be set to null in case of an invalid policy - return runtime; - } - - private void attachCallback(SiddhiRuntime runtime, ExecutionPlanRuntime executionPlanRuntime, PolicyEvaluationContext<T, K> context) { - List<String> outputFields = new ArrayList<>(); -// String outputStreamName = config.getString("alertExecutorConfigs." + executorId + "." + "outputStream"); -// if (StringUtils.isNotEmpty(outputStreamName)) { -// StreamCallback streamCallback = new SiddhiOutputStreamCallback<>(config, this); -// executionPlanRuntime.addCallback(outputStreamName, streamCallback); -// runtime.outputStreamCallback = streamCallback; -// // find output attribute from stream call back -// try { -// Field field = StreamCallback.class.getDeclaredField("streamDefinition"); -// field.setAccessible(true); -// AbstractDefinition outStreamDef = (AbstractDefinition) field.get(streamCallback); -// outputFields = Arrays.asList(outStreamDef.getAttributeNameArray()); -// } catch (Exception ex) { -// LOG.error("Got an Exception when initial outputFields ", ex); -// } -// } else { - QueryCallback callback = new SiddhiQueryCallbackImpl<T, K>(config, context); - executionPlanRuntime.addCallback(EXECUTION_PLAN_NAME, callback); - runtime.queryCallback = callback; - // find output attribute from query call back - try { - Field field = QueryCallback.class.getDeclaredField(EXECUTION_PLAN_NAME); - field.setAccessible(true); - Query query = (Query) field.get(callback); - List<OutputAttribute> list = query.getSelector().getSelectionList(); - for (OutputAttribute output : list) { - outputFields.add(output.getRename()); - } - } catch (Exception ex) { - LOG.error("Got an Exception when initial outputFields ", ex); - } -// } - runtime.outputFields = outputFields; - } - - /** - * 1. input has 3 fields, first is siddhi context, second is streamName, the last one is map of attribute name/value - * 2. runtime check for input data (This is very expensive, so we ignore for now) - * the size of input map should be equal to size of attributes which stream metadata defines - * the attribute names should be equal to attribute names which stream metadata defines - * the input field cannot be null - */ - @SuppressWarnings({"rawtypes"}) - @Override - public void evaluate(ValuesArray data) throws Exception { - if (!siddhiRuntime.markdownEnabled) { - if (LOG.isDebugEnabled()) LOG.debug("Siddhi policy evaluator consumers data :" + data); - Collector outputCollector = (Collector) data.get(0); - String streamName = (String) data.get(1); - SortedMap map = (SortedMap) data.get(2); - validateEventInRuntime(streamName, map); - synchronized (siddhiRuntime) { - // retain the collector in the context. This assignment is idempotent - context.outputCollector = outputCollector; - - List<Object> input = new ArrayList<>(); - putAttrsIntoInputStream(input, streamName, map); - siddhiRuntime.siddhiInputHandlers.get(streamName).send(input.toArray(new Object[0])); - } - } - } - - /** - * This is a heavy operation, we should avoid to use. - * <p/> - * This validation method will skip invalid fields in event which are not declared in stream schema otherwise it will cause exception for siddhi engine. - * - * @param sourceStream source steam id - * @param data input event - * @see <a href="https://issues.apache.org/jira/browse/EAGLE-49">https://issues.apache.org/jira/browse/EAGLE-49</a> - */ - private void validateEventInRuntime(String sourceStream, SortedMap data) { - if (!needValidation) - return; - SortedMap<String, AlertStreamSchemaEntity> map = StreamMetadataManager.getInstance().getMetadataEntityMapForStream(sourceStream); - if (!map.keySet().equals(data.keySet())) { - Set<Object> badKeys = new TreeSet<>(); - for (Object key : data.keySet()) if (!map.containsKey(key)) badKeys.add(key); - LOG.warn(String.format("Ignore invalid fields %s in event: %s from stream: %s, valid fields are: %s", badKeys.toString(), data.toString(), sourceStream, map.keySet().toString())); - for (Object key : badKeys) data.remove(key); - } - } - - private void putAttrsIntoInputStream(List<Object> input, String streamName, SortedMap map) { - if (!needValidation) { - input.addAll(map.values()); - return; - } - for (Object key : map.keySet()) { - Object value = map.get(key); - if (value == null) { - input.add(SiddhiStreamMetadataUtils.getAttrDefaultValue(streamName, (String) key)); - } else input.add(value); - } - } - - @Override - public void onPolicyUpdate(T newAlertDef) { - AbstractPolicyDefinition policyDef = null; - try { - policyDef = JsonSerDeserUtils.deserialize(newAlertDef.getPolicyDef(), - AbstractPolicyDefinition.class, PolicyManager.getInstance().getPolicyModules(newAlertDef.getTags().get(Constants.POLICY_TYPE))); - } catch (Exception ex) { - LOG.error("Initial policy def error, ", ex); - } - SiddhiRuntime previous = siddhiRuntime; - siddhiRuntime = createSiddhiRuntime((SiddhiPolicyDefinition) policyDef); - synchronized (previous) { - if (!previous.markdownEnabled) // condition to check if previous SiddhiRuntime was started after policy validation - previous.siddhiManager.getExecutionPlanRuntime(previous.executionPlanName).shutdown(); - } - } - - @Override - public void onPolicyDelete() { - synchronized (siddhiRuntime) { - LOG.info("Going to shutdown siddhi execution plan, planName: " + siddhiRuntime.executionPlanName); - if (!siddhiRuntime.markdownEnabled) // condition to check if previous SiddhiRuntime was started after policy validation - siddhiRuntime.siddhiManager.getExecutionPlanRuntime(siddhiRuntime.executionPlanName).shutdown(); - LOG.info("Siddhi execution plan " + siddhiRuntime.executionPlanName + " is successfully shutdown "); - } - } - - @Override - public String toString() { - return siddhiRuntime.policyDef.toString(); - } - - public String[] getStreamNames() { - return sourceStreams; - } - - public Map<String, String> getAdditionalContext() { - Map<String, String> context = new HashMap<String, String>(); - StringBuilder sourceStreams = new StringBuilder(); - for (String streamName : getStreamNames()) { - sourceStreams.append(streamName + ","); - } - if (sourceStreams.length() > 0) { - sourceStreams.deleteCharAt(sourceStreams.length() - 1); - } - context.put(Constants.SOURCE_STREAMS, sourceStreams.toString()); - context.put(Constants.POLICY_ID, this.context.policyId); - return context; - } - - public List<String> getOutputStreamAttrNameList() { - return siddhiRuntime.outputFields; - } - - @Override - public boolean isMarkdownEnabled() { return siddhiRuntime.markdownEnabled; } - - @Override - public String getMarkdownReason() { return siddhiRuntime.markdownReason; } -}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiPolicyEvaluatorServiceProviderImpl.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiPolicyEvaluatorServiceProviderImpl.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiPolicyEvaluatorServiceProviderImpl.java deleted file mode 100644 index 1bd5830..0000000 --- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiPolicyEvaluatorServiceProviderImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.eagle.policy.siddhi; - -import java.util.Arrays; -import java.util.List; - -import org.apache.eagle.policy.common.Constants; -import org.apache.eagle.alert.entity.AbstractPolicyDefinitionEntity; -import org.apache.eagle.policy.PolicyEvaluatorServiceProvider; - -import com.fasterxml.jackson.databind.Module; -import com.fasterxml.jackson.databind.jsontype.NamedType; -import com.fasterxml.jackson.databind.module.SimpleModule; - -public class SiddhiPolicyEvaluatorServiceProviderImpl<T extends AbstractPolicyDefinitionEntity> implements PolicyEvaluatorServiceProvider<T> { - @Override - public String getPolicyType() { - return Constants.policyType.siddhiCEPEngine.name(); - } - - @Override - public Class getPolicyEvaluator() { - return SiddhiPolicyEvaluator.class; - } - - @Override - public List<Module> getBindingModules() { - Module module1 = new SimpleModule(Constants.POLICY_DEFINITION).registerSubtypes(new NamedType(SiddhiPolicyDefinition.class, getPolicyType())); - return Arrays.asList(module1); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiQueryCallbackImpl.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiQueryCallbackImpl.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiQueryCallbackImpl.java deleted file mode 100644 index 43422f8..0000000 --- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiQueryCallbackImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.eagle.policy.siddhi; - -import com.typesafe.config.Config; -import org.apache.eagle.alert.entity.AbstractPolicyDefinitionEntity; -import org.apache.eagle.policy.PolicyEvaluationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.wso2.siddhi.core.event.Event; -import org.wso2.siddhi.core.query.output.callback.QueryCallback; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Siddhi call back implementation - * - * @param <T> - The policy definition type - * @param <K> - K the alert entity type - */ -public class SiddhiQueryCallbackImpl<T extends AbstractPolicyDefinitionEntity, K> extends QueryCallback{ - - private static final Logger LOG = LoggerFactory.getLogger(SiddhiQueryCallbackImpl.class); - - private final Config config; - private final PolicyEvaluationContext<T, K> siddhiEvaluateContext; - - public SiddhiQueryCallbackImpl(Config config, PolicyEvaluationContext<T, K> siddhiContext) { - this.config = config; - this.siddhiEvaluateContext = siddhiContext; - } - - public static List<String> convertToString(List<Object> data) { - List<String> rets = new ArrayList<String>(); - for (Object object : data) { - String value = null; - if (object instanceof Double) { - value = String.valueOf((Double)object); - } - else if (object instanceof Integer) { - value = String.valueOf((Integer)object); - } - else if (object instanceof Long) { - value = String.valueOf((Long)object); - } - else if (object instanceof String) { - value = (String)object; - } - else if (object instanceof Boolean) { - value = String.valueOf((Boolean)object); - } - rets.add(value); - } - return rets; - } - - public static List<Object> getOutputObject(Object[] data) { - List<Object> rets = new ArrayList<>(data.length); -// boolean isFirst = true; - for (Object object : data) { -// // The first field is siddhiAlertContext, skip it -// if (isFirst) { -// isFirst = false; -// continue; -// } - rets.add(object); - } - return rets; - } - - @SuppressWarnings("unchecked") - @Override - public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { - List<Object> rets = getOutputObject(inEvents[0].getData()); - K alert = siddhiEvaluateContext.resultRender.render(config, rets, siddhiEvaluateContext, timeStamp); - SiddhiEvaluationHandler<T, K> handler = siddhiEvaluateContext.alertExecutor; - handler.onEvalEvents(siddhiEvaluateContext, Arrays.asList(alert)); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiStreamMetadataUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiStreamMetadataUtils.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiStreamMetadataUtils.java deleted file mode 100644 index e4c3481..0000000 --- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiStreamMetadataUtils.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.eagle.policy.siddhi; - -import org.apache.eagle.alert.entity.AlertStreamSchemaEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Map; -import java.util.SortedMap; - -/** - * convert metadata entities for a stream to stream definition for siddhi cep engine - * define stream HeapUsage (metric string, host string, value double, timestamp long) - */ -public class SiddhiStreamMetadataUtils { - private final static Logger LOG = LoggerFactory.getLogger(SiddhiStreamMetadataUtils.class); - - public final static String EAGLE_ALERT_CONTEXT_FIELD = "eagleAlertContext"; - - public static SortedMap<String, AlertStreamSchemaEntity> getAttrMap(String streamName) { - SortedMap<String, AlertStreamSchemaEntity> map = StreamMetadataManager.getInstance().getMetadataEntityMapForStream(streamName); - if(map == null || map.size() == 0){ - throw new IllegalStateException("Alert stream schema ["+streamName+"] should never be empty"); - } - return map; - } - - /** - * @see org.wso2.siddhi.query.api.definition.Attribute.Type - * make sure StreamMetadataManager.init is invoked before this method - * @param streamName - * @return - */ - public static String convertToStreamDef(String streamName){ - SortedMap<String, AlertStreamSchemaEntity> map = getAttrMap(streamName); - StringBuilder sb = new StringBuilder(); -// sb.append(EAGLE_ALERT_CONTEXT_FIELD + " object, "); - for(Map.Entry<String, AlertStreamSchemaEntity> entry : map.entrySet()){ - appendAttributeNameType(sb, entry.getKey(), entry.getValue().getAttrType()); - } - if(sb.length() > 0){ - sb.deleteCharAt(sb.length()-1); - } - - String siddhiStreamDefFormat = "define stream " + streamName + "(" + "%s" + ");"; - return String.format(siddhiStreamDefFormat, sb.toString()); - } - - public static String convertToStreamDef(String streamName, Map<String, String> eventSchema){ - StringBuilder sb = new StringBuilder(); - sb.append("context" + " object,"); - for(Map.Entry<String, String> entry : eventSchema.entrySet()){ - appendAttributeNameType(sb, entry.getKey(), entry.getValue()); - } - if(sb.length() > 0){ - sb.deleteCharAt(sb.length()-1); - } - - String siddhiStreamDefFormat = "define stream " + streamName + "(" + "%s" + ");"; - return String.format(siddhiStreamDefFormat, sb.toString()); - } - - private static void appendAttributeNameType(StringBuilder sb, String attrName, String attrType){ - sb.append(attrName); - sb.append(" "); - if(attrType.equalsIgnoreCase(AttributeType.STRING.name())){ - sb.append("string"); - }else if(attrType.equalsIgnoreCase(AttributeType.INTEGER.name())){ - sb.append("int"); - }else if(attrType.equalsIgnoreCase(AttributeType.LONG.name())){ - sb.append("long"); - }else if(attrType.equalsIgnoreCase(AttributeType.BOOL.name())){ - sb.append("bool"); - }else if(attrType.equalsIgnoreCase(AttributeType.FLOAT.name())){ - sb.append("float"); - }else if(attrType.equalsIgnoreCase(AttributeType.DOUBLE.name())){ - sb.append("double"); - }else{ - LOG.warn("AttrType is not recognized, ignore : " + attrType); - } - sb.append(","); - } - - public static Object getAttrDefaultValue(String streamName, String attrName){ - SortedMap<String, AlertStreamSchemaEntity> map = getAttrMap(streamName); - AlertStreamSchemaEntity entity = map.get(attrName); - if (entity.getDefaultValue() != null) { - return entity.getDefaultValue(); - } - else { - String attrType = entity.getAttrType(); - if (attrType.equalsIgnoreCase(AttributeType.STRING.name())) { - return "NA"; - } else if (attrType.equalsIgnoreCase(AttributeType.INTEGER.name()) || attrType.equalsIgnoreCase(AttributeType.LONG.name())) { - return -1; - } else if (attrType.equalsIgnoreCase(AttributeType.BOOL.name())) { - return true; - } else { - LOG.warn("AttrType is not recognized: " + attrType + ", treat it as string"); - return "N/A"; - } - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/StreamMetadataManager.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/StreamMetadataManager.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/StreamMetadataManager.java deleted file mode 100644 index 83d30e0..0000000 --- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/StreamMetadataManager.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.eagle.policy.siddhi; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.eagle.policy.common.Constants; -import org.apache.eagle.alert.entity.AlertStreamSchemaEntity; -import com.typesafe.config.Config; -import org.apache.eagle.policy.dao.AlertStreamSchemaDAO; -import org.apache.eagle.common.config.EagleConfigConstants; -import org.apache.commons.collections.map.UnmodifiableMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * centralized memory where all stream metadata sit on, it is not mutable data - */ -public class StreamMetadataManager { - private static final Logger LOG = LoggerFactory.getLogger(StreamMetadataManager.class); - - private static StreamMetadataManager instance = new StreamMetadataManager(); - private Map<String, List<AlertStreamSchemaEntity>> map = new HashMap<String, List<AlertStreamSchemaEntity>>(); - private Map<String, SortedMap<String, AlertStreamSchemaEntity>> map2 = new HashMap<String, SortedMap<String, AlertStreamSchemaEntity>>(); - private volatile boolean initialized = false; - - private StreamMetadataManager(){ - } - - public static StreamMetadataManager getInstance(){ - return instance; - } - - private void internalInit(Config config, AlertStreamSchemaDAO dao){ - try{ - String application = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.APPLICATION); - List<AlertStreamSchemaEntity> list = dao.findAlertStreamSchemaByApplication(application); - if(list == null) - return; - for (AlertStreamSchemaEntity entity : list) { - String streamName = entity.getTags().get(Constants.STREAM_NAME); - if (map.get(streamName) == null) { - map.put(streamName, new ArrayList<AlertStreamSchemaEntity>()); - map2.put(streamName, new TreeMap<String, AlertStreamSchemaEntity>()); - } - map.get(streamName).add(entity); - map2.get(streamName).put(entity.getTags().get(Constants.ATTR_NAME), entity); - } - }catch(Exception ex){ - LOG.error("Fail building metadata manger", ex); - throw new IllegalStateException(ex); - } - } - - /** - * singleton with init would be good for unit test as well, and it ensures that - * initialization happens only once before you use it. - * @param config - * @param dao - */ - public void init(Config config, AlertStreamSchemaDAO dao){ - if(!initialized){ - synchronized(this){ - if(!initialized){ - if(LOG.isDebugEnabled()) LOG.debug("Initializing ..."); - internalInit(config, dao); - initialized = true; - LOG.info("Successfully initialized"); - } - } - }else{ - LOG.info("Already initialized, skip"); - } - } - - // Only for unit test purpose - public void reset() { - synchronized (this) { - initialized = false; - map.clear(); - map2.clear(); - } - } - - private void ensureInitialized(){ - if(!initialized) - throw new IllegalStateException("StreamMetadataManager should be initialized before using it"); - } - - public List<AlertStreamSchemaEntity> getMetadataEntitiesForStream(String streamName){ - ensureInitialized(); - return getMetadataEntitiesForAllStreams().get(streamName); - } - - public Map<String, List<AlertStreamSchemaEntity>> getMetadataEntitiesForAllStreams(){ - ensureInitialized(); - return UnmodifiableMap.decorate(map); - } - - public SortedMap<String, AlertStreamSchemaEntity> getMetadataEntityMapForStream(String streamName){ - ensureInitialized(); - return getMetadataEntityMapForAllStreams().get(streamName); - } - - public Map<String, SortedMap<String, AlertStreamSchemaEntity>> getMetadataEntityMapForAllStreams(){ - ensureInitialized(); - return UnmodifiableMap.decorate(map2); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/ContainsIgnoreCaseExtension.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/ContainsIgnoreCaseExtension.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/ContainsIgnoreCaseExtension.java deleted file mode 100644 index 6d3a0e4..0000000 --- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/ContainsIgnoreCaseExtension.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eagle.policy.siddhi.extension; - -import org.wso2.siddhi.core.config.ExecutionPlanContext; -import org.wso2.siddhi.core.exception.ExecutionPlanRuntimeException; -import org.wso2.siddhi.core.executor.ExpressionExecutor; -import org.wso2.siddhi.core.executor.function.FunctionExecutor; -import org.wso2.siddhi.query.api.definition.Attribute; -import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException; - -public class ContainsIgnoreCaseExtension extends FunctionExecutor { - - Attribute.Type returnType = Attribute.Type.BOOL; - - @Override - protected void init(ExpressionExecutor[] attributeExpressionExecutors, ExecutionPlanContext executionPlanContext) { - if (attributeExpressionExecutors.length != 2) { - throw new ExecutionPlanValidationException("Invalid no of arguments passed to str:containsIgnoreCase() function, required 2, " + - "but found " + attributeExpressionExecutors.length); - } - if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) { - throw new ExecutionPlanValidationException("Invalid parameter type found for the first argument of str:containsIgnoreCase() function, " + - "required "+ Attribute.Type.STRING+", but found "+attributeExpressionExecutors[0].getReturnType().toString()); - } - if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) { - throw new ExecutionPlanValidationException("Invalid parameter type found for the second argument of str:containsIgnoreCase() function, " + - "required "+ Attribute.Type.STRING+", but found "+attributeExpressionExecutors[1].getReturnType().toString()); - } - } - - @Override - protected Object execute(Object[] data) { - if (data[0] == null) { - throw new ExecutionPlanRuntimeException("Invalid input given to str:containsIgnoreCase() function. First argument cannot be null"); - } - if (data[1] == null) { - throw new ExecutionPlanRuntimeException("Invalid input given to str:containsIgnoreCase() function. Second argument cannot be null"); - } - String str1 = (String)data[0]; - String str2 = (String)data[1]; - return str1.toUpperCase().contains(str2.toUpperCase()); - } - - @Override - protected Object execute(Object data) { - return null; //Since the containsIgnoreCase function takes in 2 parameters, this method does not get called. Hence, not implemented. - } - - @Override - public void start() { - //Nothing to start - } - - @Override - public void stop() { - //Nothing to stop - } - - @Override - public Attribute.Type getReturnType() { - return returnType; - } - - @Override - public Object[] currentState() { - return new Object[]{}; - } - - @Override - public void restoreState(Object[] state) { - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/EqualsIgnoreCaseExtension.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/EqualsIgnoreCaseExtension.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/EqualsIgnoreCaseExtension.java deleted file mode 100644 index 3a622e2..0000000 --- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/EqualsIgnoreCaseExtension.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eagle.policy.siddhi.extension; - -import org.wso2.siddhi.core.config.ExecutionPlanContext; -import org.wso2.siddhi.core.exception.ExecutionPlanRuntimeException; -import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; -import org.wso2.siddhi.core.executor.ExpressionExecutor; -import org.wso2.siddhi.core.executor.function.FunctionExecutor; -import org.wso2.siddhi.query.api.definition.Attribute; -import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class EqualsIgnoreCaseExtension extends FunctionExecutor { - - Attribute.Type returnType = Attribute.Type.BOOL; - - @Override - protected void init(ExpressionExecutor[] attributeExpressionExecutors, ExecutionPlanContext executionPlanContext) { - if (attributeExpressionExecutors.length != 2) { - throw new ExecutionPlanValidationException("Invalid no of arguments passed to str:equalsIgnoreCase() function, required 2, " + - "but found " + attributeExpressionExecutors.length); - } - if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) { - throw new ExecutionPlanValidationException("Invalid parameter type found for the first argument of str:equalsIgnoreCase() function, " + - "required "+ Attribute.Type.STRING+", but found "+attributeExpressionExecutors[0].getReturnType().toString()); - } - if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) { - throw new ExecutionPlanValidationException("Invalid parameter type found for the second argument of str:equalsIgnoreCase() function, " + - "required "+ Attribute.Type.STRING+", but found "+attributeExpressionExecutors[1].getReturnType().toString()); - } - } - - @Override - protected Object execute(Object[] data) { - if (data[0] == null) { - throw new ExecutionPlanRuntimeException("Invalid input given to str:equalsIgnoreCase() function. First argument cannot be null"); - } - if (data[1] == null) { - throw new ExecutionPlanRuntimeException("Invalid input given to str:equalsIgnoreCase() function. Second argument cannot be null"); - } - String str1 = (String)data[0]; - String str2 = (String)data[1]; - return str1.equalsIgnoreCase(str2); - } - - @Override - protected Object execute(Object data) { - return null; //Since the equalsIgnoreCase function takes in 2 parameters, this method does not get called. Hence, not implemented. - } - - @Override - public void start() { - //Nothing to start - } - - @Override - public void stop() { - //Nothing to stop - } - - @Override - public Attribute.Type getReturnType() { - return returnType; - } - - @Override - public Object[] currentState() { - return new Object[]{}; - } - - @Override - public void restoreState(Object[] state) { - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/ExternalTimeBatchWindowProcessor.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/ExternalTimeBatchWindowProcessor.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/ExternalTimeBatchWindowProcessor.java deleted file mode 100644 index c70d1a1..0000000 --- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/ExternalTimeBatchWindowProcessor.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.eagle.policy.siddhi.extension; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.wso2.siddhi.core.config.ExecutionPlanContext; -import org.wso2.siddhi.core.event.ComplexEvent; -import org.wso2.siddhi.core.event.ComplexEventChunk; -import org.wso2.siddhi.core.event.MetaComplexEvent; -import org.wso2.siddhi.core.event.stream.StreamEvent; -import org.wso2.siddhi.core.event.stream.StreamEventCloner; -import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; -import org.wso2.siddhi.core.executor.ExpressionExecutor; -import org.wso2.siddhi.core.executor.VariableExpressionExecutor; -import org.wso2.siddhi.core.query.processor.Processor; -import org.wso2.siddhi.core.query.processor.stream.window.FindableProcessor; -import org.wso2.siddhi.core.query.processor.stream.window.WindowProcessor; -import org.wso2.siddhi.core.table.EventTable; -import org.wso2.siddhi.core.util.collection.operator.Finder; -import org.wso2.siddhi.core.util.parser.CollectionOperatorParser; -import org.wso2.siddhi.query.api.definition.Attribute; -import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException; -import org.wso2.siddhi.query.api.expression.Expression; - -import java.util.List; -import java.util.Map; - -/** - * @since Dec 23, 2015 - * - */ - -public class ExternalTimeBatchWindowProcessor extends WindowProcessor implements FindableProcessor { - - private long timeToKeep; - - private ComplexEventChunk<StreamEvent> currentEventChunk = new ComplexEventChunk<StreamEvent>(); - private ComplexEventChunk<StreamEvent> expiredEventChunk = new ComplexEventChunk<StreamEvent>(); - - static final Logger log = LoggerFactory.getLogger(ExternalTimeBatchWindowProcessor.class); - private VariableExpressionExecutor timeStampVariableExpressionExecutor; - - private long lastSendTime = -1; - - @Override - protected void init(ExpressionExecutor[] attributeExpressionExecutors, ExecutionPlanContext executionPlanContext) { - this.expiredEventChunk = new ComplexEventChunk<StreamEvent>(); - if (attributeExpressionExecutors.length == 2) { - if (attributeExpressionExecutors[1].getReturnType() == Attribute.Type.INT) { - timeToKeep = Integer.parseInt(String.valueOf(((ConstantExpressionExecutor) attributeExpressionExecutors[1]).getValue())); - } else { - timeToKeep = Long.parseLong(String.valueOf(((ConstantExpressionExecutor) attributeExpressionExecutors[1]).getValue())); - } - if (!(attributeExpressionExecutors[0] instanceof VariableExpressionExecutor)) { - throw new ExecutionPlanValidationException("ExternalTime window's 1st parameter timeStamp should be a type long stream attribute but found " + attributeExpressionExecutors[0].getClass()); - } - timeStampVariableExpressionExecutor = ((VariableExpressionExecutor) attributeExpressionExecutors[0]); - if (timeStampVariableExpressionExecutor.getReturnType() != Attribute.Type.LONG) { - throw new ExecutionPlanValidationException("ExternalTime window's 1st parameter timeStamp should be type long, but found " + timeStampVariableExpressionExecutor.getReturnType()); - } - } else { - throw new ExecutionPlanValidationException("ExternalTime window should only have two parameter (<long> timeStamp, <int|long|time> windowTime), but found " + attributeExpressionExecutors.length + " input attributes"); - } - } - - /** - * Here an assumption is taken: - * Parameter: timestamp: The time which the window determines as current time and will act upon, - * the value of this parameter should be monotonically increasing. - * from https://docs.wso2.com/display/CEP400/Inbuilt+Windows#InbuiltWindows-externalTime - * - */ - @Override - protected synchronized void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner) { - // event incoming trigger process. No events means no action - if (!streamEventChunk.hasNext()) { - return; - } - - // for window beginning, if window is empty, set lastSendTime to incomingChunk first. - if (currentEventChunk.getFirst() == null && lastSendTime < 0) { - lastSendTime = (Long) streamEventChunk.getFirst().getAttribute(timeStampVariableExpressionExecutor.getPosition()); - } - - while(streamEventChunk.hasNext()) { - StreamEvent currStreamEvent = streamEventChunk.next(); - if (currStreamEvent.getType() != ComplexEvent.Type.CURRENT) { - continue; - } - - long currentTime = (Long) currStreamEvent.getAttribute(timeStampVariableExpressionExecutor.getPosition()); - if (currentTime < lastSendTime + timeToKeep) { - cloneAppend(streamEventCloner, currStreamEvent); - } else if (currentTime >= lastSendTime + timeToKeep) { - flushCurentChunk(nextProcessor, streamEventCloner, currentTime); - cloneAppend(streamEventCloner, currStreamEvent); - } - } - } - - private void cloneAppend(StreamEventCloner streamEventCloner, StreamEvent currStreamEvent) { - StreamEvent clonedStreamEvent = streamEventCloner.copyStreamEvent(currStreamEvent); - currentEventChunk.add(clonedStreamEvent); - } - - private void flushCurentChunk(Processor nextProcessor, StreamEventCloner streamEventCloner, long currentTime) { - // need flush the currentEventChunk - currentEventChunk.reset(); - ComplexEventChunk<StreamEvent> newEventChunk = new ComplexEventChunk<StreamEvent>(); - - // mark the timestamp for the expiredType event - while (expiredEventChunk.hasNext()) { - StreamEvent expiredEvent = expiredEventChunk.next(); - expiredEvent.setTimestamp(currentTime); - } - // add expired event to newEventChunk too. - if (expiredEventChunk.getFirst() != null) { - newEventChunk.add(expiredEventChunk.getFirst()); - } - - // make current event chunk as expired in expiredChunk - expiredEventChunk.clear(); - while (currentEventChunk.hasNext()) { - StreamEvent currentEvent = currentEventChunk.next(); - StreamEvent toExpireEvent = streamEventCloner.copyStreamEvent(currentEvent); - toExpireEvent.setType(StreamEvent.Type.EXPIRED); - expiredEventChunk.add(toExpireEvent); - } - - // add current event chunk to next processor - if (currentEventChunk.getFirst() != null) { - newEventChunk.add(currentEventChunk.getFirst()); - } - currentEventChunk.clear(); - - // update timestamp, call next processor - lastSendTime = currentTime; - if (newEventChunk.getFirst() != null) { - nextProcessor.process(newEventChunk); - } - } - - public void start() { - //Do nothing - } - - public void stop() { - //Do nothing - } - - public Object[] currentState() { - return new Object[]{currentEventChunk, expiredEventChunk}; - } - - @SuppressWarnings("unchecked") - public void restoreState(Object[] state) { - currentEventChunk = (ComplexEventChunk<StreamEvent>) state[0]; - expiredEventChunk = (ComplexEventChunk<StreamEvent>) state[1]; - } - - public synchronized StreamEvent find(ComplexEvent matchingEvent, Finder finder) { - return finder.find(matchingEvent, expiredEventChunk, streamEventCloner); - } - - public Finder constructFinder(Expression expression, MetaComplexEvent metaComplexEvent, ExecutionPlanContext executionPlanContext, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, EventTable> eventTableMap, int matchingStreamIndex, long withinTime) { - return CollectionOperatorParser.parse(expression, metaComplexEvent, executionPlanContext, variableExpressionExecutors, eventTableMap, matchingStreamIndex, inputDefinition, withinTime); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/RegexpIgnoreCaseFunctionExtension.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/RegexpIgnoreCaseFunctionExtension.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/RegexpIgnoreCaseFunctionExtension.java deleted file mode 100644 index 14e98cc..0000000 --- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/extension/RegexpIgnoreCaseFunctionExtension.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eagle.policy.siddhi.extension; - -import org.wso2.siddhi.core.config.ExecutionPlanContext; -import org.wso2.siddhi.core.exception.ExecutionPlanRuntimeException; -import org.wso2.siddhi.core.executor.ConstantExpressionExecutor; -import org.wso2.siddhi.core.executor.ExpressionExecutor; -import org.wso2.siddhi.extension.string.RegexpFunctionExtension; -import org.wso2.siddhi.query.api.definition.Attribute; -import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * regexpIgnoreCase(string, regex) - * Tells whether or not this 'string' matches the given regular expression 'regex'. - * Accept Type(s): (STRING,STRING) - * Return Type(s): BOOLEAN - */ -public class RegexpIgnoreCaseFunctionExtension extends RegexpFunctionExtension { - - //state-variables - boolean isRegexConstant = false; - String regexConstant; - Pattern patternConstant; - - @Override - protected void init(ExpressionExecutor[] attributeExpressionExecutors, ExecutionPlanContext executionPlanContext) { - if (attributeExpressionExecutors.length != 2) { - throw new ExecutionPlanValidationException("Invalid no of arguments passed to str:regexpIgnoreCase() function, required 2, " + - "but found " + attributeExpressionExecutors.length); - } - if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) { - throw new ExecutionPlanValidationException("Invalid parameter type found for the first argument of str:regexpIgnoreCase() function, " + - "required "+ Attribute.Type.STRING+", but found "+attributeExpressionExecutors[0].getReturnType().toString()); - } - if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) { - throw new ExecutionPlanValidationException("Invalid parameter type found for the second argument of str:regexpIgnoreCase() function, " + - "required "+ Attribute.Type.STRING+", but found "+attributeExpressionExecutors[1].getReturnType().toString()); - } - if(attributeExpressionExecutors[1] instanceof ConstantExpressionExecutor){ - isRegexConstant = true; - regexConstant = (String) ((ConstantExpressionExecutor) attributeExpressionExecutors[1]).getValue(); - patternConstant = Pattern.compile(regexConstant, Pattern.CASE_INSENSITIVE); - } - } - - @Override - protected Object execute(Object[] data) { - String regex; - Pattern pattern; - Matcher matcher; - - if (data[0] == null) { - throw new ExecutionPlanRuntimeException("Invalid input given to str:regexpIgnoreCase() function. First argument cannot be null"); - } - if (data[1] == null) { - throw new ExecutionPlanRuntimeException("Invalid input given to str:regexpIgnoreCase() function. Second argument cannot be null"); - } - String source = (String) data[0]; - - if(!isRegexConstant){ - regex = (String) data[1]; - pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); - matcher = pattern.matcher(source); - return matcher.matches(); - - } else { - matcher = patternConstant.matcher(source); - return matcher.matches(); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-policy/eagle-policy-base/src/main/resources/META-INF/services/org.apache.eagle.policy.PolicyEvaluatorServiceProvider ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/resources/META-INF/services/org.apache.eagle.policy.PolicyEvaluatorServiceProvider b/eagle-core/eagle-policy/eagle-policy-base/src/main/resources/META-INF/services/org.apache.eagle.policy.PolicyEvaluatorServiceProvider deleted file mode 100644 index eac2bfd..0000000 --- a/eagle-core/eagle-policy/eagle-policy-base/src/main/resources/META-INF/services/org.apache.eagle.policy.PolicyEvaluatorServiceProvider +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -org.apache.eagle.policy.siddhi.SiddhiPolicyEvaluatorServiceProviderImpl \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-policy/eagle-policy-base/src/main/resources/eagle.siddhiext ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/resources/eagle.siddhiext b/eagle-core/eagle-policy/eagle-policy-base/src/main/resources/eagle.siddhiext deleted file mode 100644 index 2671c31..0000000 --- a/eagle-core/eagle-policy/eagle-policy-base/src/main/resources/eagle.siddhiext +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -externalTimeBatch=org.apache.eagle.policy.siddhi.extension.ExternalTimeBatchWindowProcessor \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-policy/eagle-policy-base/src/main/resources/str.siddhiext ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/resources/str.siddhiext b/eagle-core/eagle-policy/eagle-policy-base/src/main/resources/str.siddhiext deleted file mode 100644 index 479cdb0..0000000 --- a/eagle-core/eagle-policy/eagle-policy-base/src/main/resources/str.siddhiext +++ /dev/null @@ -1,40 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -charAt=org.wso2.siddhi.extension.string.CharAtFunctionExtension -coalesce=org.wso2.siddhi.extension.string.CoalesceFunctionExtension -concat=org.wso2.siddhi.extension.string.ConcatFunctionExtension -length=org.wso2.siddhi.extension.string.LengthFunctionExtension -lower=org.wso2.siddhi.extension.string.LowerFunctionExtension -regexp=org.wso2.siddhi.extension.string.RegexpFunctionExtension -repeat=org.wso2.siddhi.extension.string.RepeatFunctionExtension -replaceAll=org.wso2.siddhi.extension.string.ReplaceAllFunctionExtension -replaceFirst=org.wso2.siddhi.extension.string.ReplaceFirstFunctionExtension -reverse=org.wso2.siddhi.extension.string.ReverseFunctionExtension -strcmp=org.wso2.siddhi.extension.string.StrcmpFunctionExtension -substr=org.wso2.siddhi.extension.string.SubstrFunctionExtension -trim=org.wso2.siddhi.extension.string.TrimFunctionExtension -upper=org.wso2.siddhi.extension.string.UpperFunctionExtension -hex=org.wso2.siddhi.extension.string.HexFunctionExtension -unhex=org.wso2.siddhi.extension.string.UnhexFunctionExtension -contains=org.wso2.siddhi.extension.string.ContainsFunctionExtension - -# Eagle Siddhi Extension -equalsIgnoreCase=org.apache.eagle.policy.siddhi.extension.EqualsIgnoreCaseExtension -containsIgnoreCase=org.apache.eagle.policy.siddhi.extension.ContainsIgnoreCaseExtension -regexpIgnoreCase=org.apache.eagle.policy.siddhi.extension.RegexpIgnoreCaseFunctionExtension - http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-policy/eagle-policy-base/src/test/java/org/apache/eagle/policy/dao/TestSchemaDao.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/test/java/org/apache/eagle/policy/dao/TestSchemaDao.java b/eagle-core/eagle-policy/eagle-policy-base/src/test/java/org/apache/eagle/policy/dao/TestSchemaDao.java deleted file mode 100644 index c88d9bb..0000000 --- a/eagle-core/eagle-policy/eagle-policy-base/src/test/java/org/apache/eagle/policy/dao/TestSchemaDao.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.eagle.policy.dao; - -import org.apache.eagle.alert.entity.AlertStreamSchemaEntity; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.List; - -/** - * Created on 12/31/15. - */ -public class TestSchemaDao { - - @Ignore - @Test - public void test() throws Exception { - AlertStreamSchemaDAO dao = new AlertStreamSchemaDAOImpl("localhost", 9099, "admin", "secret"); - List<AlertStreamSchemaEntity> entities = dao.findAlertStreamSchemaByApplication("hdfsAuditLog"); - System.out.print(entities); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-policy/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-policy/pom.xml b/eagle-core/eagle-policy/pom.xml deleted file mode 100644 index ab104a6..0000000 --- a/eagle-core/eagle-policy/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one or more - ~ contributor license agreements. See the NOTICE file distributed with - ~ this work for additional information regarding copyright ownership. - ~ The ASF licenses this file to You under the Apache License, Version 2.0 - ~ (the "License"); you may not use this file except in compliance with - ~ the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>eagle</groupId> - <artifactId>eagle-core</artifactId> - <version>0.3.0</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <artifactId>eagle-policy-parent</artifactId> - <packaging>pom</packaging> - - <name>eagle-policy-parent</name> - <modules> - <module>eagle-policy-base</module> - </modules> - -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-antlr/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-query/eagle-antlr/pom.xml b/eagle-core/eagle-query/eagle-antlr/pom.xml deleted file mode 100644 index c0d519f..0000000 --- a/eagle-core/eagle-query/eagle-antlr/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one or more - ~ contributor license agreements. See the NOTICE file distributed with - ~ this work for additional information regarding copyright ownership. - ~ The ASF licenses this file to You under the Apache License, Version 2.0 - ~ (the "License"); you may not use this file except in compliance with - ~ the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>eagle</groupId> - <artifactId>eagle-query-parent</artifactId> - <version>0.3.0</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <artifactId>eagle-antlr</artifactId> - <packaging>jar</packaging> - <name>eagle-antlr</name> - - <dependencies> - <dependency> - <groupId>org.antlr</groupId> - <artifactId>antlr4-runtime</artifactId> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - </dependency> - </dependencies> -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-antlr/src/main/java/EagleFilter.g4 ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/EagleFilter.g4 b/eagle-core/eagle-query/eagle-antlr/src/main/java/EagleFilter.g4 deleted file mode 100755 index a146aac..0000000 --- a/eagle-core/eagle-query/eagle-antlr/src/main/java/EagleFilter.g4 +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -grammar EagleFilter; - -@header{ -// package org.apache.eagle.query.antlr.generated; -} - -/*------------------------------------------------------------------ - * PARSER RULES - *------------------------------------------------------------------*/ - -filter - : combine EOF - ; -combine - : LPAREN combine RPAREN - | equation - | combine AND combine - | combine OR combine - ; -equation - : VALUE OP VALUE - | ID OP VALUE - ; - -/*------------------------------------------------------------------ - * LEXER RULES - *------------------------------------------------------------------*/ -WHITESPACE - : ( '\t' | ' ' | '\r' | '\n'| '\u000C' )+ - -> skip - ; -OP - : '=' | '!=' - | '>' | '<' - | '>=' | '<=' - | '=~' | '!=~' - | 'in' | 'IN' - | 'not' (' ')+ 'in' - | 'NOT' (' ')+ 'IN' - | 'contains' - | 'CONTAINS' - | 'not' (' ')+ 'contains' - | 'NOT' (' ')+ 'CONTAINS' - | 'is' | 'IS' - | 'is' (' ')+ 'not' - | 'IS' (' ')+ 'NOT' - ; - -AND - : 'AND' - | 'and' - ; -OR - : 'OR' - | 'or' - ; - -ID : '@' (~[ "=()<>])+ - ; -VALUE : EXPR - | SINGLE_VALUE - | SET - ; -SINGLE_VALUE - : DOUBLEQUOTED_STRING - | NUMBER - | NULL - ; -EXPR : ('EXP'|'exp') LBRACE (~('}'))+ RBRACE - ; -NUMBER - : '-'? UNSIGN_INT ('.' UNSIGN_INT)? - ; -NULL - : 'NULL' - | 'null' - ; -SET - : LPAREN SINGLE_VALUE? (',' SINGLE_VALUE)* RPAREN - ; -DOUBLEQUOTED_STRING - : '"' STRING '"' - | '""' - ; - -fragment UNSIGN_INT : ('0'..'9')+ - ; -// Fully support string including escaped quotes -fragment STRING : (~('"')| '\\"')+ - ; -LPAREN : '(' - ; -RPAREN : ')' - ; -LBRACE : '{' - ; -RBRACE : '}' - ; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilter.tokens ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilter.tokens b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilter.tokens deleted file mode 100755 index 5ebca36..0000000 --- a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilter.tokens +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -WHITESPACE=1 -OP=2 -AND=3 -OR=4 -ID=5 -VALUE=6 -SINGLE_VALUE=7 -EXPR=8 -NUMBER=9 -NULL=10 -SET=11 -DOUBLEQUOTED_STRING=12 -LPAREN=13 -RPAREN=14 -LBRACE=15 -RBRACE=16 -'('=13 -')'=14 -'{'=15 -'}'=16 http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterBaseListener.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterBaseListener.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterBaseListener.java deleted file mode 100755 index 65fa321..0000000 --- a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterBaseListener.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// Generated from EagleFilter.g4 by ANTLR 4.5 -package org.apache.eagle.query.antlr.generated; - -import org.antlr.v4.runtime.ParserRuleContext; -import org.antlr.v4.runtime.tree.ErrorNode; -import org.antlr.v4.runtime.tree.TerminalNode; - -/** - * This class provides an empty implementation of {@link EagleFilterListener}, - * which can be extended to create a listener which only needs to handle a subset - * of the available methods. - */ -public class EagleFilterBaseListener implements EagleFilterListener { - /** - * {@inheritDoc} - * - * <p>The default implementation does nothing.</p> - */ - @Override public void enterFilter(EagleFilterParser.FilterContext ctx) { } - /** - * {@inheritDoc} - * - * <p>The default implementation does nothing.</p> - */ - @Override public void exitFilter(EagleFilterParser.FilterContext ctx) { } - /** - * {@inheritDoc} - * - * <p>The default implementation does nothing.</p> - */ - @Override public void enterCombine(EagleFilterParser.CombineContext ctx) { } - /** - * {@inheritDoc} - * - * <p>The default implementation does nothing.</p> - */ - @Override public void exitCombine(EagleFilterParser.CombineContext ctx) { } - /** - * {@inheritDoc} - * - * <p>The default implementation does nothing.</p> - */ - @Override public void enterEquation(EagleFilterParser.EquationContext ctx) { } - /** - * {@inheritDoc} - * - * <p>The default implementation does nothing.</p> - */ - @Override public void exitEquation(EagleFilterParser.EquationContext ctx) { } - - /** - * {@inheritDoc} - * - * <p>The default implementation does nothing.</p> - */ - @Override public void enterEveryRule(ParserRuleContext ctx) { } - /** - * {@inheritDoc} - * - * <p>The default implementation does nothing.</p> - */ - @Override public void exitEveryRule(ParserRuleContext ctx) { } - /** - * {@inheritDoc} - * - * <p>The default implementation does nothing.</p> - */ - @Override public void visitTerminal(TerminalNode node) { } - /** - * {@inheritDoc} - * - * <p>The default implementation does nothing.</p> - */ - @Override public void visitErrorNode(ErrorNode node) { } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterLexer.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterLexer.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterLexer.java deleted file mode 100755 index 0899732..0000000 --- a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterLexer.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// Generated from EagleFilter.g4 by ANTLR 4.5 -package org.apache.eagle.query.antlr.generated; - -import org.antlr.v4.runtime.Lexer; -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.Token; -import org.antlr.v4.runtime.TokenStream; -import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.atn.*; -import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.misc.*; - -@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) -public class EagleFilterLexer extends Lexer { - static { RuntimeMetaData.checkVersion("4.5", RuntimeMetaData.VERSION); } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - WHITESPACE=1, OP=2, AND=3, OR=4, ID=5, VALUE=6, SINGLE_VALUE=7, EXPR=8, - NUMBER=9, NULL=10, SET=11, DOUBLEQUOTED_STRING=12, LPAREN=13, RPAREN=14, - LBRACE=15, RBRACE=16; - public static String[] modeNames = { - "DEFAULT_MODE" - }; - - public static final String[] ruleNames = { - "WHITESPACE", "OP", "AND", "OR", "ID", "VALUE", "SINGLE_VALUE", "EXPR", - "NUMBER", "NULL", "SET", "DOUBLEQUOTED_STRING", "UNSIGN_INT", "STRING", - "LPAREN", "RPAREN", "LBRACE", "RBRACE" - }; - - private static final String[] _LITERAL_NAMES = { - null, null, null, null, null, null, null, null, null, null, null, null, - null, "'('", "')'", "'{'", "'}'" - }; - private static final String[] _SYMBOLIC_NAMES = { - null, "WHITESPACE", "OP", "AND", "OR", "ID", "VALUE", "SINGLE_VALUE", - "EXPR", "NUMBER", "NULL", "SET", "DOUBLEQUOTED_STRING", "LPAREN", "RPAREN", - "LBRACE", "RBRACE" - }; - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } - - if (tokenNames[i] == null) { - tokenNames[i] = "<INVALID>"; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - - public EagleFilterLexer(CharStream input) { - super(input); - _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - - @Override - public String getGrammarFileName() { return "EagleFilter.g4"; } - - @Override - public String[] getRuleNames() { return ruleNames; } - - @Override - public String getSerializedATN() { return _serializedATN; } - - @Override - public String[] getModeNames() { return modeNames; } - - @Override - public ATN getATN() { return _ATN; } - - public static final String _serializedATN = - "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2\22\u010c\b\1\4\2"+ - "\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4"+ - "\13\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22"+ - "\t\22\4\23\t\23\3\2\6\2)\n\2\r\2\16\2*\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3"+ - "\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\6\3E"+ - "\n\3\r\3\16\3F\3\3\3\3\3\3\3\3\3\3\3\3\3\3\6\3P\n\3\r\3\16\3Q\3\3\3\3"+ - "\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3"+ - "\3\3\3\3\3\3\3\6\3k\n\3\r\3\16\3l\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3"+ - "\3\3\3\3\3\3\3\3\6\3|\n\3\r\3\16\3}\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3"+ - "\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\6\3\u0090\n\3\r\3\16\3\u0091\3\3\3\3\3"+ - "\3\3\3\3\3\3\3\3\3\6\3\u009b\n\3\r\3\16\3\u009c\3\3\3\3\3\3\5\3\u00a2"+ - "\n\3\3\4\3\4\3\4\3\4\3\4\3\4\5\4\u00aa\n\4\3\5\3\5\3\5\3\5\5\5\u00b0\n"+ - "\5\3\6\3\6\6\6\u00b4\n\6\r\6\16\6\u00b5\3\7\3\7\3\7\5\7\u00bb\n\7\3\b"+ - "\3\b\3\b\5\b\u00c0\n\b\3\t\3\t\3\t\3\t\3\t\3\t\5\t\u00c8\n\t\3\t\3\t\6"+ - "\t\u00cc\n\t\r\t\16\t\u00cd\3\t\3\t\3\n\5\n\u00d3\n\n\3\n\3\n\3\n\5\n"+ - "\u00d8\n\n\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\5\13\u00e2\n\13\3\f"+ - "\3\f\5\f\u00e6\n\f\3\f\3\f\7\f\u00ea\n\f\f\f\16\f\u00ed\13\f\3\f\3\f\3"+ - "\r\3\r\3\r\3\r\3\r\3\r\5\r\u00f7\n\r\3\16\6\16\u00fa\n\16\r\16\16\16\u00fb"+ - "\3\17\3\17\3\17\6\17\u0101\n\17\r\17\16\17\u0102\3\20\3\20\3\21\3\21\3"+ - "\22\3\22\3\23\3\23\2\2\24\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25"+ - "\f\27\r\31\16\33\2\35\2\37\17!\20#\21%\22\3\2\7\5\2\13\f\16\17\"\"\4\2"+ - ">>@@\6\2\"\"$$*+>@\3\2\177\177\3\2$$\u0134\2\3\3\2\2\2\2\5\3\2\2\2\2\7"+ - "\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2"+ - "\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\37\3\2\2\2\2"+ - "!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\3(\3\2\2\2\5\u00a1\3\2\2\2\7\u00a9\3\2"+ - "\2\2\t\u00af\3\2\2\2\13\u00b1\3\2\2\2\r\u00ba\3\2\2\2\17\u00bf\3\2\2\2"+ - "\21\u00c7\3\2\2\2\23\u00d2\3\2\2\2\25\u00e1\3\2\2\2\27\u00e3\3\2\2\2\31"+ - "\u00f6\3\2\2\2\33\u00f9\3\2\2\2\35\u0100\3\2\2\2\37\u0104\3\2\2\2!\u0106"+ - "\3\2\2\2#\u0108\3\2\2\2%\u010a\3\2\2\2\')\t\2\2\2(\'\3\2\2\2)*\3\2\2\2"+ - "*(\3\2\2\2*+\3\2\2\2+,\3\2\2\2,-\b\2\2\2-\4\3\2\2\2.\u00a2\7?\2\2/\60"+ - "\7#\2\2\60\u00a2\7?\2\2\61\u00a2\t\3\2\2\62\63\7@\2\2\63\u00a2\7?\2\2"+ - "\64\65\7>\2\2\65\u00a2\7?\2\2\66\67\7?\2\2\67\u00a2\7\u0080\2\289\7#\2"+ - "\29:\7?\2\2:\u00a2\7\u0080\2\2;<\7k\2\2<\u00a2\7p\2\2=>\7K\2\2>\u00a2"+ - "\7P\2\2?@\7p\2\2@A\7q\2\2AB\7v\2\2BD\3\2\2\2CE\7\"\2\2DC\3\2\2\2EF\3\2"+ - "\2\2FD\3\2\2\2FG\3\2\2\2GH\3\2\2\2HI\7k\2\2I\u00a2\7p\2\2JK\7P\2\2KL\7"+ - "Q\2\2LM\7V\2\2MO\3\2\2\2NP\7\"\2\2ON\3\2\2\2PQ\3\2\2\2QO\3\2\2\2QR\3\2"+ - "\2\2RS\3\2\2\2ST\7K\2\2T\u00a2\7P\2\2UV\7e\2\2VW\7q\2\2WX\7p\2\2XY\7v"+ - "\2\2YZ\7c\2\2Z[\7k\2\2[\\\7p\2\2\\\u00a2\7u\2\2]^\7E\2\2^_\7Q\2\2_`\7"+ - "P\2\2`a\7V\2\2ab\7C\2\2bc\7K\2\2cd\7P\2\2d\u00a2\7U\2\2ef\7p\2\2fg\7q"+ - "\2\2gh\7v\2\2hj\3\2\2\2ik\7\"\2\2ji\3\2\2\2kl\3\2\2\2lj\3\2\2\2lm\3\2"+ - "\2\2mn\3\2\2\2no\7e\2\2op\7q\2\2pq\7p\2\2qr\7v\2\2rs\7c\2\2st\7k\2\2t"+ - "u\7p\2\2u\u00a2\7u\2\2vw\7P\2\2wx\7Q\2\2xy\7V\2\2y{\3\2\2\2z|\7\"\2\2"+ - "{z\3\2\2\2|}\3\2\2\2}{\3\2\2\2}~\3\2\2\2~\177\3\2\2\2\177\u0080\7E\2\2"+ - "\u0080\u0081\7Q\2\2\u0081\u0082\7P\2\2\u0082\u0083\7V\2\2\u0083\u0084"+ - "\7C\2\2\u0084\u0085\7K\2\2\u0085\u0086\7P\2\2\u0086\u00a2\7U\2\2\u0087"+ - "\u0088\7k\2\2\u0088\u00a2\7u\2\2\u0089\u008a\7K\2\2\u008a\u00a2\7U\2\2"+ - "\u008b\u008c\7k\2\2\u008c\u008d\7u\2\2\u008d\u008f\3\2\2\2\u008e\u0090"+ - "\7\"\2\2\u008f\u008e\3\2\2\2\u0090\u0091\3\2\2\2\u0091\u008f\3\2\2\2\u0091"+ - "\u0092\3\2\2\2\u0092\u0093\3\2\2\2\u0093\u0094\7p\2\2\u0094\u0095\7q\2"+ - "\2\u0095\u00a2\7v\2\2\u0096\u0097\7K\2\2\u0097\u0098\7U\2\2\u0098\u009a"+ - "\3\2\2\2\u0099\u009b\7\"\2\2\u009a\u0099\3\2\2\2\u009b\u009c\3\2\2\2\u009c"+ - "\u009a\3\2\2\2\u009c\u009d\3\2\2\2\u009d\u009e\3\2\2\2\u009e\u009f\7P"+ - "\2\2\u009f\u00a0\7Q\2\2\u00a0\u00a2\7V\2\2\u00a1.\3\2\2\2\u00a1/\3\2\2"+ - "\2\u00a1\61\3\2\2\2\u00a1\62\3\2\2\2\u00a1\64\3\2\2\2\u00a1\66\3\2\2\2"+ - "\u00a18\3\2\2\2\u00a1;\3\2\2\2\u00a1=\3\2\2\2\u00a1?\3\2\2\2\u00a1J\3"+ - "\2\2\2\u00a1U\3\2\2\2\u00a1]\3\2\2\2\u00a1e\3\2\2\2\u00a1v\3\2\2\2\u00a1"+ - "\u0087\3\2\2\2\u00a1\u0089\3\2\2\2\u00a1\u008b\3\2\2\2\u00a1\u0096\3\2"+ - "\2\2\u00a2\6\3\2\2\2\u00a3\u00a4\7C\2\2\u00a4\u00a5\7P\2\2\u00a5\u00aa"+ - "\7F\2\2\u00a6\u00a7\7c\2\2\u00a7\u00a8\7p\2\2\u00a8\u00aa\7f\2\2\u00a9"+ - "\u00a3\3\2\2\2\u00a9\u00a6\3\2\2\2\u00aa\b\3\2\2\2\u00ab\u00ac\7Q\2\2"+ - "\u00ac\u00b0\7T\2\2\u00ad\u00ae\7q\2\2\u00ae\u00b0\7t\2\2\u00af\u00ab"+ - "\3\2\2\2\u00af\u00ad\3\2\2\2\u00b0\n\3\2\2\2\u00b1\u00b3\7B\2\2\u00b2"+ - "\u00b4\n\4\2\2\u00b3\u00b2\3\2\2\2\u00b4\u00b5\3\2\2\2\u00b5\u00b3\3\2"+ - "\2\2\u00b5\u00b6\3\2\2\2\u00b6\f\3\2\2\2\u00b7\u00bb\5\21\t\2\u00b8\u00bb"+ - "\5\17\b\2\u00b9\u00bb\5\27\f\2\u00ba\u00b7\3\2\2\2\u00ba\u00b8\3\2\2\2"+ - "\u00ba\u00b9\3\2\2\2\u00bb\16\3\2\2\2\u00bc\u00c0\5\31\r\2\u00bd\u00c0"+ - "\5\23\n\2\u00be\u00c0\5\25\13\2\u00bf\u00bc\3\2\2\2\u00bf\u00bd\3\2\2"+ - "\2\u00bf\u00be\3\2\2\2\u00c0\20\3\2\2\2\u00c1\u00c2\7G\2\2\u00c2\u00c3"+ - "\7Z\2\2\u00c3\u00c8\7R\2\2\u00c4\u00c5\7g\2\2\u00c5\u00c6\7z\2\2\u00c6"+ - "\u00c8\7r\2\2\u00c7\u00c1\3\2\2\2\u00c7\u00c4\3\2\2\2\u00c8\u00c9\3\2"+ - "\2\2\u00c9\u00cb\5#\22\2\u00ca\u00cc\n\5\2\2\u00cb\u00ca\3\2\2\2\u00cc"+ - "\u00cd\3\2\2\2\u00cd\u00cb\3\2\2\2\u00cd\u00ce\3\2\2\2\u00ce\u00cf\3\2"+ - "\2\2\u00cf\u00d0\5%\23\2\u00d0\22\3\2\2\2\u00d1\u00d3\7/\2\2\u00d2\u00d1"+ - "\3\2\2\2\u00d2\u00d3\3\2\2\2\u00d3\u00d4\3\2\2\2\u00d4\u00d7\5\33\16\2"+ - "\u00d5\u00d6\7\60\2\2\u00d6\u00d8\5\33\16\2\u00d7\u00d5\3\2\2\2\u00d7"+ - "\u00d8\3\2\2\2\u00d8\24\3\2\2\2\u00d9\u00da\7P\2\2\u00da\u00db\7W\2\2"+ - "\u00db\u00dc\7N\2\2\u00dc\u00e2\7N\2\2\u00dd\u00de\7p\2\2\u00de\u00df"+ - "\7w\2\2\u00df\u00e0\7n\2\2\u00e0\u00e2\7n\2\2\u00e1\u00d9\3\2\2\2\u00e1"+ - "\u00dd\3\2\2\2\u00e2\26\3\2\2\2\u00e3\u00e5\5\37\20\2\u00e4\u00e6\5\17"+ - "\b\2\u00e5\u00e4\3\2\2\2\u00e5\u00e6\3\2\2\2\u00e6\u00eb\3\2\2\2\u00e7"+ - "\u00e8\7.\2\2\u00e8\u00ea\5\17\b\2\u00e9\u00e7\3\2\2\2\u00ea\u00ed\3\2"+ - "\2\2\u00eb\u00e9\3\2\2\2\u00eb\u00ec\3\2\2\2\u00ec\u00ee\3\2\2\2\u00ed"+ - "\u00eb\3\2\2\2\u00ee\u00ef\5!\21\2\u00ef\30\3\2\2\2\u00f0\u00f1\7$\2\2"+ - "\u00f1\u00f2\5\35\17\2\u00f2\u00f3\7$\2\2\u00f3\u00f7\3\2\2\2\u00f4\u00f5"+ - "\7$\2\2\u00f5\u00f7\7$\2\2\u00f6\u00f0\3\2\2\2\u00f6\u00f4\3\2\2\2\u00f7"+ - "\32\3\2\2\2\u00f8\u00fa\4\62;\2\u00f9\u00f8\3\2\2\2\u00fa\u00fb\3\2\2"+ - "\2\u00fb\u00f9\3\2\2\2\u00fb\u00fc\3\2\2\2\u00fc\34\3\2\2\2\u00fd\u0101"+ - "\n\6\2\2\u00fe\u00ff\7^\2\2\u00ff\u0101\7$\2\2\u0100\u00fd\3\2\2\2\u0100"+ - "\u00fe\3\2\2\2\u0101\u0102\3\2\2\2\u0102\u0100\3\2\2\2\u0102\u0103\3\2"+ - "\2\2\u0103\36\3\2\2\2\u0104\u0105\7*\2\2\u0105 \3\2\2\2\u0106\u0107\7"+ - "+\2\2\u0107\"\3\2\2\2\u0108\u0109\7}\2\2\u0109$\3\2\2\2\u010a\u010b\7"+ - "\177\2\2\u010b&\3\2\2\2\33\2*FQl}\u0091\u009c\u00a1\u00a9\u00af\u00b5"+ - "\u00ba\u00bf\u00c7\u00cd\u00d2\u00d7\u00e1\u00e5\u00eb\u00f6\u00fb\u0100"+ - "\u0102\3\b\2\2"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file