http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ConfigUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ConfigUtils.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ConfigUtils.java deleted file mode 100644 index e9634e2..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ConfigUtils.java +++ /dev/null @@ -1,32 +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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.alert.utils; - -import com.typesafe.config.Config; -import java.util.Properties; - -public class ConfigUtils { - - @SuppressWarnings("serial") - public static Properties toProperties(Config config) { - return new Properties() { - { - putAll(config.root().unwrapped()); - } - }; - } -}
http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/HostUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/HostUtils.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/HostUtils.java deleted file mode 100644 index e3f72e2..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/HostUtils.java +++ /dev/null @@ -1,87 +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.alert.utils; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.util.Enumeration; - -/** - * http://stackoverflow.com/questions/7348711/recommended-way-to-get-hostname-in-java. - */ -public class HostUtils { - private static final Logger logger = LoggerFactory - .getLogger(HostUtils.class); - - public static String getHostName() { - try { - String hostName = InetAddress.getLocalHost().getHostName(); - if (hostName != null && !hostName.isEmpty()) { - return hostName; - } - } catch (UnknownHostException e) { - logger.error("get hostName error!", e); - } - - String host = System.getenv("COMPUTERNAME"); - if (host != null) { - return host; - } - host = System.getenv("HOSTNAME"); - if (host != null) { - return host; - } - - return null; - } - - public static String getNotLoopbackAddress() { - String hostName = null; - Enumeration<NetworkInterface> interfaces; - try { - interfaces = NetworkInterface.getNetworkInterfaces(); - while (interfaces.hasMoreElements()) { - NetworkInterface nic = interfaces.nextElement(); - Enumeration<InetAddress> addresses = nic.getInetAddresses(); - while (hostName == null && addresses.hasMoreElements()) { - InetAddress address = addresses.nextElement(); - if (!address.isLoopbackAddress()) { - hostName = address.getHostName(); - } - } - } - } catch (SocketException e) { - logger.error("getNotLoopbackAddress error!", e); - } - return hostName; - } - - public static String getHostAddress() { - try { - return InetAddress.getLocalHost().getHostAddress(); - } catch (UnknownHostException e) { - logger.error("get hostAddress error!", e); - } - - return null; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/JsonUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/JsonUtils.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/JsonUtils.java deleted file mode 100644 index cc75d34..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/JsonUtils.java +++ /dev/null @@ -1,56 +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.alert.utils; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.codehaus.jettison.json.JSONArray; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; - -public class JsonUtils { - - public static final ObjectMapper mapper = new ObjectMapper(); - private static final Logger LOG = LoggerFactory.getLogger(JsonUtils.class); - - public static String writeValueAsString(Object o) { - try { - return mapper.writeValueAsString(o); - } catch (Exception e) { - LOG.error("write object as string failed {} !", o); - } - return ""; - } - - public static List<String> jsonStringToList(String message) { - List<String> result = new ArrayList<>(); - try { - if (!message.isEmpty()) { - JSONArray jsonArray = new JSONArray(message); - for (int i = 0; i < jsonArray.length(); ++i) { - result.add(jsonArray.getString(i)); - } - } - } catch (Exception e) { - LOG.warn("exception found {}", e); - } - - return result; - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/KafkaEmbedded.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/KafkaEmbedded.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/KafkaEmbedded.java deleted file mode 100644 index 46ca0a7..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/KafkaEmbedded.java +++ /dev/null @@ -1,98 +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.alert.utils; - -import kafka.server.KafkaConfig; -import kafka.server.KafkaServerStartable; -import org.apache.commons.io.FileUtils; -import org.apache.curator.test.InstanceSpec; - -import java.io.File; -import java.util.Properties; - -public class KafkaEmbedded { - - private int port; - private KafkaServerStartable kafka; - private ZookeeperEmbedded zk; - - private File logDir; - - public KafkaEmbedded() { - this(InstanceSpec.getRandomPort(), InstanceSpec.getRandomPort()); - } - - public KafkaEmbedded(Integer kafkaPort, Integer zookeeperPort) { - try { - zk = new ZookeeperEmbedded(zookeeperPort); - zk.start(); - - this.port = null != kafkaPort ? kafkaPort : InstanceSpec.getRandomPort(); - logDir = new File(System.getProperty("java.io.tmpdir"), "kafka/logs/kafka-test-" + kafkaPort); - FileUtils.deleteQuietly(logDir); - - KafkaConfig config = buildKafkaConfig(zk.getConnectionString()); - kafka = new KafkaServerStartable(config); - kafka.startup(); - } catch (Exception ex) { - throw new RuntimeException("Could not start test broker", ex); - } - } - - public KafkaEmbedded(String kafkaUrl, String zkUrl) { - this(extractKafkaPort(kafkaUrl), extractKafkaPort(zkUrl)); - - } - - public static Integer extractKafkaPort(String url) { - String portString = url.substring(url.indexOf(":") + 1, url.length()); - return Integer.valueOf(portString); - } - - private KafkaConfig buildKafkaConfig(String zookeeperConnectionString) { - Properties p = new Properties(); - p.setProperty("zookeeper.connect", zookeeperConnectionString); - p.setProperty("broker.id", "0"); - p.setProperty("port", "" + port); - p.setProperty("log.dirs", logDir.getAbsolutePath()); - return new KafkaConfig(p); - } - - public String getZkConnectionString() { - return zk.getConnectionString(); - } - - public String getBrokerConnectionString() { - return "localhost:" + port; - } - - public int getPort() { - return port; - } - - public void shutdown() { - try { - kafka.shutdown(); - } catch (Throwable t) { - t.printStackTrace(); - } finally { - FileUtils.deleteQuietly(logDir); - } - zk.shutdown(); - } - -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamIdConversion.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamIdConversion.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamIdConversion.java deleted file mode 100644 index 7ef54f4..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamIdConversion.java +++ /dev/null @@ -1,33 +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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.alert.utils; - -public class StreamIdConversion { - public static final String STREAM_ID_TEMPLATE = "stream_%s_to_%s"; - public static final String STREAM_ID_NUM_TEMPLATE = "stream_%s"; - - public static String generateStreamIdBetween(String sourceId, String targetId) { - return String.format(STREAM_ID_TEMPLATE, sourceId, targetId); - } - - /** - * Hard-coded stream format in stream_${partitionNum}. - */ - public static String generateStreamIdByPartition(int partitionNum) { - return String.format(STREAM_ID_NUM_TEMPLATE, partitionNum); - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamValidationException.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamValidationException.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamValidationException.java deleted file mode 100644 index 2f08506..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamValidationException.java +++ /dev/null @@ -1,39 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.alert.utils; - -public class StreamValidationException extends Exception { - public StreamValidationException() { - super(); - } - - public StreamValidationException(String message) { - super(message); - } - - public StreamValidationException(String message, Throwable cause) { - super(message, cause); - } - - public StreamValidationException(Throwable cause) { - super(cause); - } - - protected StreamValidationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamValidator.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamValidator.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamValidator.java deleted file mode 100644 index a1f64d9..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamValidator.java +++ /dev/null @@ -1,57 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.alert.utils; - -import org.apache.commons.lang3.StringUtils; -import org.apache.eagle.alert.engine.coordinator.StreamColumn; -import org.apache.eagle.alert.engine.coordinator.StreamDefinition; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -public class StreamValidator { - private final StreamDefinition streamDefinition; - private final Map<String, StreamColumn> streamColumnMap; - - public StreamValidator(StreamDefinition streamDefinition) { - this.streamDefinition = streamDefinition; - this.streamColumnMap = new HashMap<>(); - for (StreamColumn column : this.streamDefinition.getColumns()) { - streamColumnMap.put(column.getName(), column); - } - } - - public void validateMap(Map<String, Object> event) throws StreamValidationException { - final List<String> errors = new LinkedList<>(); - this.streamDefinition.getColumns().forEach((column -> { - if (column.isRequired() && !event.containsKey(column.getName())) { - errors.add("[" + column.getName() + "]: required but absent"); - } - })); - for (Object eventKey : event.keySet()) { - if (!streamColumnMap.containsKey(eventKey)) { - errors.add("[" + eventKey + "]: invalid column"); - } - } - - if (errors.size() > 0) { - throw new StreamValidationException(errors.size() + " validation errors: " + StringUtils.join(errors.toArray(), "; ")); - } - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/TimePeriodUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/TimePeriodUtils.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/TimePeriodUtils.java deleted file mode 100644 index 10f2cb2..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/TimePeriodUtils.java +++ /dev/null @@ -1,49 +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.alert.utils; - -import org.joda.time.Period; -import org.joda.time.Seconds; - -import scala.Int; - -public class TimePeriodUtils { - /** - * For example: timestamp stands for time: 1990/01/07 12:45 and period is PT30, then result is 1990/01/07 12:30. - * - * @return formatted timestamp - */ - public static long formatSecondsByPeriod(long seconds, Seconds period) { - return seconds - (seconds % Int.int2long(period.getSeconds())); - } - - public static long formatSecondsByPeriod(long seconds, Period period) { - return seconds - (seconds % Int.int2long(period.toStandardSeconds().getSeconds())); - } - - public static long formatMillisecondsByPeriod(long milliseconds, Period period) { - return formatSecondsByPeriod(milliseconds / 1000, period) * 1000; - } - - public static int getSecondsOfPeriod(Period period) { - return period.toStandardSeconds().getSeconds(); - } - - public static int getMillisecondsOfPeriod(Period period) { - return getSecondsOfPeriod(period) * 1000; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ZookeeperEmbedded.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ZookeeperEmbedded.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ZookeeperEmbedded.java deleted file mode 100644 index ecaa276..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ZookeeperEmbedded.java +++ /dev/null @@ -1,113 +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.alert.utils; - -import org.apache.commons.io.FileUtils; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.CuratorFrameworkFactory; -import org.apache.curator.framework.imps.CuratorFrameworkState; -import org.apache.curator.retry.ExponentialBackoffRetry; -import org.apache.curator.test.TestingServer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.net.BindException; - -public class ZookeeperEmbedded { - private static final Logger LOG = LoggerFactory.getLogger(ZookeeperEmbedded.class); - private static final int MAX_RETRIES = 3; - private TestingServer server; - private CuratorFramework zookeeper; - private int port; - private File logDir; - - /** - * Create zookeeper testing server. - * - * @param port initial zookeeper port - */ - public ZookeeperEmbedded(int port) { - this.port = port; - this.logDir = new File(System.getProperty("java.io.tmpdir"), "zk/logs/zookeeper-test-" + port); - } - - /** - * Try to start zookeeper, if failed, retry with <code>port+1</code>. - * - * @return finally bound port - */ - public int start() throws Exception { - FileUtils.deleteQuietly(logDir); - - int i = 0; - boolean success = false; - Exception lastException = null; - while (!success && i < MAX_RETRIES) { - try { - server = new TestingServer(this.port, this.logDir); - ExponentialBackoffRetry retryPolicy = new ExponentialBackoffRetry(1000, 3); - zookeeper = CuratorFrameworkFactory.newClient(server.getConnectString(), retryPolicy); - zookeeper.start(); - success = true; - } catch (BindException exception) { - lastException = exception; - i++; - LOG.warn("Port {} was taken, trying {}", this.port, this.port + i); - this.port = this.port + i; - try { - server.close(); - zookeeper.close(); - } catch (Throwable throwable) { - // ignored - } - } - } - if (!success) { - LOG.error("Failed to start zookeeper after trying {} times", MAX_RETRIES); - throw lastException; - } - return this.port; - } - - public String getConnectionString() { - return server.getConnectString(); - } - - public void shutdown() { - try { - if (zookeeper != null) { - if (!zookeeper.getState().equals(CuratorFrameworkState.STOPPED)) { - zookeeper.close(); - } - } - } catch (Throwable e) { - e.printStackTrace(); - } finally { - try { - if (server != null) { - server.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - FileUtils.deleteQuietly(logDir); - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/resources/log4j.properties b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/resources/log4j.properties deleted file mode 100644 index ba06033..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/resources/log4j.properties +++ /dev/null @@ -1,19 +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. -log4j.rootLogger=DEBUG, stdout -# standard output -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %p [%t] %c{2}[%L]: %m%n \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/resources/string.siddhiext ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/resources/string.siddhiext b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/resources/string.siddhiext deleted file mode 100644 index 7176611..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/resources/string.siddhiext +++ /dev/null @@ -1,20 +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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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. - */ - -empty=org.apache.eagle.alert.siddhiext.StringEmptyFunctionExtension -subtract=org.apache.eagle.alert.siddhiext.StringSubtractFunctionExtension -listSize=org.apache.eagle.alert.siddhiext.StringListSizeFunctionExtension \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/config/TestConfigBus.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/config/TestConfigBus.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/config/TestConfigBus.java deleted file mode 100644 index e37e9be..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/config/TestConfigBus.java +++ /dev/null @@ -1,85 +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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.alert.config; - -import java.io.IOException; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; - -import org.apache.curator.test.TestingServer; -import org.apache.curator.utils.CloseableUtils; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -public class TestConfigBus { - protected TestingServer server; - protected ConfigBusProducer producer; - protected ConfigBusConsumer consumer; - protected String topic = "spout"; - protected ZKConfig config; - final AtomicBoolean validate = new AtomicBoolean(false); - final AtomicReference<String> configValue = new AtomicReference<>(); - - @Before - public void setUp() throws Exception { - server = new TestingServer(); - config = new ZKConfig(); - config.zkQuorum = server.getConnectString(); - config.zkRoot = "/alert"; - config.zkRetryInterval = 1000; - config.zkRetryTimes = 3; - config.connectionTimeoutMs = 3000; - config.zkSessionTimeoutMs = 10000; - producer = new ConfigBusProducer(config); - consumer = new ConfigBusConsumer(config, topic, value -> { - validate.set(value.isValueVersionId()); - configValue.set((String) value.getValue()); - System.out.println("******** get notified of config " + value); - }); - } - - @Test - public void testConfigChange() throws Exception { - // first change - producer.send(topic, createConfigValue(false, "testvalue1")); - - Thread.sleep(1000); - Assert.assertFalse(validate.get()); - Assert.assertEquals("testvalue1", configValue.get()); - - // second change - producer.send(topic, createConfigValue(true, "testvalue2")); - Thread.sleep(1000); - Assert.assertEquals("testvalue2", configValue.get()); - } - - @After - public void shutdown() throws IOException { - server.stop(); - producer.close(); - consumer.close(); - } - - private ConfigValue createConfigValue(boolean isValueVersionId, String value) { - ConfigValue configValue = new ConfigValue(); - configValue.setValueVersionId(isValueVersionId); - configValue.setValue(value); - return configValue; - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/config/TestZKConfigBuilder.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/config/TestZKConfigBuilder.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/config/TestZKConfigBuilder.java deleted file mode 100644 index 64edeb7..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/config/TestZKConfigBuilder.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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.alert.config; - -import com.typesafe.config.Config; -import com.typesafe.config.ConfigFactory; -import org.junit.Assert; -import org.junit.Test; - -public class TestZKConfigBuilder { - @Test - public void testZKConfigBuilder() { - Config config = ConfigFactory.load(); - ZKConfig zKConfig = ZKConfigBuilder.getZKConfig(config); - Assert.assertEquals("localhost:2181", zKConfig.zkQuorum); - Assert.assertEquals("/alert", zKConfig.zkRoot); - Assert.assertEquals(10000, zKConfig.zkSessionTimeoutMs); - Assert.assertEquals(10000, zKConfig.connectionTimeoutMs); - Assert.assertEquals(3, zKConfig.zkRetryTimes); - Assert.assertEquals(3000, zKConfig.zkRetryInterval); - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/Kafka2TupleMetadataTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/Kafka2TupleMetadataTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/Kafka2TupleMetadataTest.java deleted file mode 100644 index a252fae..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/Kafka2TupleMetadataTest.java +++ /dev/null @@ -1,49 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.alert.coordination.model; - -import org.junit.Assert; -import org.junit.Test; - -public class Kafka2TupleMetadataTest { - @Test - public void testKafka2TupleMetadata() { - Kafka2TupleMetadata kafka2TupleMetadata = new Kafka2TupleMetadata(); - kafka2TupleMetadata.setName("setName"); - kafka2TupleMetadata.setCodec(new Tuple2StreamMetadata()); - kafka2TupleMetadata.setType("setType"); - kafka2TupleMetadata.setTopic("setTopic"); - kafka2TupleMetadata.setSchemeCls("org.apache.eagle.alert.engine.scheme.PlainStringScheme"); - - Kafka2TupleMetadata kafka2TupleMetadata1 = new Kafka2TupleMetadata(); - kafka2TupleMetadata1.setName("setName"); - kafka2TupleMetadata1.setCodec(new Tuple2StreamMetadata()); - kafka2TupleMetadata1.setType("setType"); - kafka2TupleMetadata1.setTopic("setTopic"); - kafka2TupleMetadata1.setSchemeCls("org.apache.eagle.alert.engine.scheme.PlainStringScheme"); - - Assert.assertFalse(kafka2TupleMetadata1 == kafka2TupleMetadata); - Assert.assertTrue(kafka2TupleMetadata1.equals(kafka2TupleMetadata)); - Assert.assertTrue(kafka2TupleMetadata1.hashCode() == kafka2TupleMetadata.hashCode()); - - kafka2TupleMetadata1.setType("setType1"); - - Assert.assertFalse(kafka2TupleMetadata1.equals(kafka2TupleMetadata)); - Assert.assertFalse(kafka2TupleMetadata1.hashCode() == kafka2TupleMetadata.hashCode()); - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/PolicyWorkerQueueTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/PolicyWorkerQueueTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/PolicyWorkerQueueTest.java deleted file mode 100644 index 71f3188..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/PolicyWorkerQueueTest.java +++ /dev/null @@ -1,63 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.alert.coordination.model; - -import org.apache.eagle.alert.engine.coordinator.StreamPartition; -import org.apache.eagle.alert.engine.coordinator.StreamSortSpec; -import org.junit.Assert; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -public class PolicyWorkerQueueTest { - @Test - public void testPolicyWorkerQueue() { - - List<WorkSlot> workers = new ArrayList<>(); - WorkSlot workSlot1 = new WorkSlot("setTopologyName1", "setBoltId1"); - WorkSlot workSlot2 = new WorkSlot("setTopologyName1", "setBoltId2"); - workers.add(workSlot1); - workers.add(workSlot2); - PolicyWorkerQueue policyWorkerQueue = new PolicyWorkerQueue(workers); - Assert.assertEquals(null, policyWorkerQueue.getPartition()); - Assert.assertEquals(workSlot1, policyWorkerQueue.getWorkers().get(0)); - Assert.assertEquals(workSlot2, policyWorkerQueue.getWorkers().get(1)); - Assert.assertEquals("[(setTopologyName1:setBoltId1),(setTopologyName1:setBoltId2)]", policyWorkerQueue.toString()); - - PolicyWorkerQueue policyWorkerQueue1 = new PolicyWorkerQueue(); - policyWorkerQueue1.setWorkers(workers); - - Assert.assertTrue(policyWorkerQueue.equals(policyWorkerQueue1)); - Assert.assertTrue(policyWorkerQueue.hashCode() == policyWorkerQueue1.hashCode()); - - StreamSortSpec streamSortSpec = new StreamSortSpec(); - streamSortSpec.setWindowPeriod("PT10S"); - StreamPartition streamPartition = new StreamPartition(); - List<String> columns = new ArrayList<>(); - columns.add("jobId"); - streamPartition.setColumns(columns); - streamPartition.setSortSpec(streamSortSpec); - streamPartition.setStreamId("test"); - streamPartition.setType(StreamPartition.Type.GROUPBY); - policyWorkerQueue1.setPartition(streamPartition); - - Assert.assertFalse(policyWorkerQueue.equals(policyWorkerQueue1)); - Assert.assertFalse(policyWorkerQueue.hashCode() == policyWorkerQueue1.hashCode()); - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/StreamRepartitionStrategyTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/StreamRepartitionStrategyTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/StreamRepartitionStrategyTest.java deleted file mode 100644 index c416a49..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/StreamRepartitionStrategyTest.java +++ /dev/null @@ -1,74 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.alert.coordination.model; - -import org.apache.eagle.alert.engine.coordinator.StreamPartition; -import org.apache.eagle.alert.engine.coordinator.StreamSortSpec; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.util.ArrayList; -import java.util.List; - -public class StreamRepartitionStrategyTest { - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void testStreamRepartitionStrategy() { - thrown.expect(NullPointerException.class); - StreamRepartitionStrategy streamRepartitionStrategy = new StreamRepartitionStrategy(); - streamRepartitionStrategy.hashCode(); - } - - @Test - public void testStreamRepartitionStrategy1() { - thrown.expect(NullPointerException.class); - StreamRepartitionStrategy streamRepartitionStrategy = new StreamRepartitionStrategy(); - streamRepartitionStrategy.equals(streamRepartitionStrategy); - } - - @Test - public void testStreamRepartitionStrategy2() { - - StreamSortSpec streamSortSpec = new StreamSortSpec(); - streamSortSpec.setWindowPeriod("PT10S"); - StreamPartition streamPartition = new StreamPartition(); - List<String> columns = new ArrayList<>(); - columns.add("jobId"); - streamPartition.setColumns(columns); - streamPartition.setSortSpec(streamSortSpec); - streamPartition.setStreamId("test"); - streamPartition.setType(StreamPartition.Type.GROUPBY); - - - StreamRepartitionStrategy streamRepartitionStrategy = new StreamRepartitionStrategy(); - Assert.assertEquals(null, streamRepartitionStrategy.getPartition()); - Assert.assertEquals(0, streamRepartitionStrategy.getNumTotalParticipatingRouterBolts()); - Assert.assertEquals(0, streamRepartitionStrategy.getStartSequence()); - streamRepartitionStrategy.setPartition(streamPartition); - StreamRepartitionStrategy streamRepartitionStrategy1 = new StreamRepartitionStrategy(); - streamRepartitionStrategy1.setPartition(streamPartition); - - Assert.assertTrue(streamRepartitionStrategy.equals(streamRepartitionStrategy1)); - Assert.assertTrue(streamRepartitionStrategy.hashCode() == streamRepartitionStrategy1.hashCode()); - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/StreamRouterSpecTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/StreamRouterSpecTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/StreamRouterSpecTest.java deleted file mode 100644 index 88e72cb..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/StreamRouterSpecTest.java +++ /dev/null @@ -1,59 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.alert.coordination.model; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -public class StreamRouterSpecTest { - @Test - public void testStreamRouterSpec() { - StreamRouterSpec streamRouterSpec = new StreamRouterSpec(); - Assert.assertEquals(null, streamRouterSpec.getPartition()); - Assert.assertEquals(null, streamRouterSpec.getStreamId()); - Assert.assertTrue(streamRouterSpec.getTargetQueue().isEmpty()); - - List<WorkSlot> workers = new ArrayList<>(); - WorkSlot workSlot1 = new WorkSlot("setTopologyName1", "setBoltId1"); - WorkSlot workSlot2 = new WorkSlot("setTopologyName1", "setBoltId2"); - workers.add(workSlot1); - workers.add(workSlot2); - PolicyWorkerQueue policyWorkerQueue = new PolicyWorkerQueue(workers); - streamRouterSpec.addQueue(policyWorkerQueue); - streamRouterSpec.setStreamId("streamRouterSpec"); - - Assert.assertEquals("streamRouterSpec", streamRouterSpec.getStreamId()); - Assert.assertEquals(1, streamRouterSpec.getTargetQueue().size()); - Assert.assertEquals(2, streamRouterSpec.getTargetQueue().get(0).getWorkers().size()); - - StreamRouterSpec streamRouterSpec1 = new StreamRouterSpec(); - streamRouterSpec1.addQueue(policyWorkerQueue); - streamRouterSpec1.setStreamId("streamRouterSpec1"); - - Assert.assertFalse(streamRouterSpec.equals(streamRouterSpec1)); - - streamRouterSpec1.setStreamId("streamRouterSpec"); - - Assert.assertTrue(streamRouterSpec.equals(streamRouterSpec1)); - Assert.assertTrue(streamRouterSpec.hashCode() == streamRouterSpec1.hashCode()); - - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/Tuple2StreamMetadataTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/Tuple2StreamMetadataTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/Tuple2StreamMetadataTest.java deleted file mode 100644 index 8bbfc41..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/Tuple2StreamMetadataTest.java +++ /dev/null @@ -1,50 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.alert.coordination.model; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.*; - -public class Tuple2StreamMetadataTest { - @Test - public void testTuple2StreamMetadata() { - Tuple2StreamMetadata metadata = new Tuple2StreamMetadata(); - Set activeStreamNames = new HashSet<>(); - activeStreamNames.add("defaultStringStream"); - metadata.setStreamNameSelectorCls("org.apache.eagle.alert.engine.scheme.PlainStringStreamNameSelector"); - metadata.setStreamNameSelectorProp(new Properties()); - metadata.getStreamNameSelectorProp().put("userProvidedStreamName", "defaultStringStream"); - metadata.setActiveStreamNames(activeStreamNames); - metadata.setTimestampColumn("timestamp"); - - Tuple2StreamMetadata metadata1 = new Tuple2StreamMetadata(); - Set activeStreamNames1 = new HashSet<>(); - activeStreamNames1.add("defaultStringStream"); - metadata1.setStreamNameSelectorCls("org.apache.eagle.alert.engine.scheme.PlainStringStreamNameSelector"); - metadata1.setStreamNameSelectorProp(new Properties()); - metadata1.getStreamNameSelectorProp().put("userProvidedStreamName", "defaultStringStream"); - metadata1.setActiveStreamNames(activeStreamNames1); - metadata1.setTimestampColumn("timestamp"); - - Assert.assertFalse(metadata == metadata1); - Assert.assertFalse(metadata.equals(metadata1)); - Assert.assertFalse(metadata.hashCode() == metadata1.hashCode()); - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/WorkSlotTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/WorkSlotTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/WorkSlotTest.java deleted file mode 100644 index 48ee73b..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/WorkSlotTest.java +++ /dev/null @@ -1,43 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.alert.coordination.model; - -import org.junit.Assert; -import org.junit.Test; - -public class WorkSlotTest { - @Test - public void testWorkSlot() { - WorkSlot workSlot = new WorkSlot(); - Assert.assertEquals("(null:null)", workSlot.toString()); - Assert.assertEquals(null, workSlot.getBoltId()); - Assert.assertEquals(null, workSlot.getTopologyName()); - workSlot.setBoltId("setBoltId"); - workSlot.setTopologyName("setTopologyName"); - Assert.assertEquals("(setTopologyName:setBoltId)", workSlot.toString()); - Assert.assertEquals("setBoltId", workSlot.getBoltId()); - Assert.assertEquals("setTopologyName", workSlot.getTopologyName()); - - WorkSlot workSlot1 = new WorkSlot("setTopologyName", "setBoltId"); - Assert.assertEquals("(setTopologyName:setBoltId)", workSlot1.toString()); - Assert.assertEquals("setBoltId", workSlot1.getBoltId()); - Assert.assertEquals("setTopologyName", workSlot1.getTopologyName()); - Assert.assertTrue(workSlot1.equals(workSlot)); - Assert.assertTrue(workSlot1.hashCode() == workSlot.hashCode()); - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/AlertDefinitionTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/AlertDefinitionTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/AlertDefinitionTest.java deleted file mode 100644 index 4ebf37f..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/AlertDefinitionTest.java +++ /dev/null @@ -1,50 +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.alert.coordination.model.internal; - -import org.apache.eagle.alert.engine.coordinator.AlertDefinition; -import org.apache.eagle.alert.engine.coordinator.AlertSeverity; -import org.junit.Assert; -import org.junit.Test; - -public class AlertDefinitionTest { - - @Test - public void testEqual() { - AlertDefinition ad1 = new AlertDefinition(); - ad1.setBody("body1"); - ad1.setCategory("email"); - ad1.setSeverity(AlertSeverity.CRITICAL); - ad1.setSubject(""); - - AlertDefinition ad2 = new AlertDefinition(); - ad2.setBody("body1"); - ad2.setCategory("email"); - ad2.setSeverity(AlertSeverity.CRITICAL); - ad2.setSubject(""); - - Assert.assertTrue(ad1.equals(ad2)); - - ad1.setBody("body1"); - ad1.setCategory("email"); - ad1.setSeverity(AlertSeverity.FATAL); - ad1.setSubject(""); - - Assert.assertTrue(!ad1.equals(ad2)); - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/MonitoredStreamTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/MonitoredStreamTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/MonitoredStreamTest.java deleted file mode 100644 index a2c0d6e..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/MonitoredStreamTest.java +++ /dev/null @@ -1,69 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.alert.coordination.model.internal; - -import org.apache.eagle.alert.coordination.model.WorkSlot; -import org.apache.eagle.alert.engine.coordinator.StreamPartition; -import org.apache.eagle.alert.engine.coordinator.StreamSortSpec; -import org.junit.Assert; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -public class MonitoredStreamTest { - - @Test - public void testMonitoredStream() { - - StreamGroup streamGroup = new StreamGroup(); - StreamSortSpec streamSortSpec = new StreamSortSpec(); - streamSortSpec.setWindowPeriod("PT10S"); - StreamPartition streamPartition = new StreamPartition(); - List<String> columns = new ArrayList<>(); - columns.add("jobId"); - streamPartition.setColumns(columns); - streamPartition.setSortSpec(streamSortSpec); - streamPartition.setStreamId("test"); - streamPartition.setType(StreamPartition.Type.GROUPBY); - streamGroup.addStreamPartition(streamPartition); - WorkSlot workSlot = new WorkSlot("setTopologyName", "setBoltId"); - List<WorkSlot> workSlots = new ArrayList<>(); - workSlots.add(workSlot); - StreamWorkSlotQueue streamWorkSlotQueue = new StreamWorkSlotQueue(streamGroup, false, new HashMap<>(), workSlots); - - MonitoredStream monitoredStream = new MonitoredStream(streamGroup); - Assert.assertEquals(null, monitoredStream.getVersion()); - Assert.assertTrue(monitoredStream.getQueues().isEmpty()); - Assert.assertEquals(streamGroup, monitoredStream.getStreamGroup()); - monitoredStream.addQueues(streamWorkSlotQueue); - Assert.assertEquals(streamWorkSlotQueue, monitoredStream.getQueues().get(0)); - - MonitoredStream monitoredStream1 = new MonitoredStream(streamGroup); - Assert.assertTrue(monitoredStream.equals(monitoredStream1)); - Assert.assertTrue(monitoredStream.hashCode() == monitoredStream1.hashCode()); - - monitoredStream.removeQueue(streamWorkSlotQueue); - Assert.assertTrue(monitoredStream.getQueues().isEmpty()); - - Assert.assertTrue(monitoredStream.equals(monitoredStream1)); - Assert.assertTrue(monitoredStream.hashCode() == monitoredStream1.hashCode()); - - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/PolicyAssignmentTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/PolicyAssignmentTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/PolicyAssignmentTest.java deleted file mode 100644 index 1491c77..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/PolicyAssignmentTest.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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.alert.coordination.model.internal; - -import org.junit.Assert; -import org.junit.Test; - -public class PolicyAssignmentTest { - @Test - public void testPolicyAssignment() { - PolicyAssignment policyAssignment = new PolicyAssignment("policy", "queue"); - Assert.assertEquals("policy", policyAssignment.getPolicyName()); - Assert.assertEquals("queue", policyAssignment.getQueueId()); - Assert.assertEquals(null, policyAssignment.getVersion()); - Assert.assertEquals("PolicyAssignment of policy policy, queueId queue, version null !", policyAssignment.toString()); - - Assert.assertFalse(policyAssignment.equals(new PolicyAssignment("policy", "queue"))); - Assert.assertFalse(policyAssignment == new PolicyAssignment("policy", "queue")); - Assert.assertFalse(policyAssignment.hashCode() == new PolicyAssignment("policy", "queue").hashCode()); - - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/StreamGroupTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/StreamGroupTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/StreamGroupTest.java deleted file mode 100644 index 467100c..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/StreamGroupTest.java +++ /dev/null @@ -1,68 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.alert.coordination.model.internal; - -import org.apache.eagle.alert.engine.coordinator.StreamPartition; -import org.apache.eagle.alert.engine.coordinator.StreamSortSpec; -import org.junit.Assert; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -public class StreamGroupTest { - @Test - public void testStreamGroup() { - StreamGroup streamGroup = new StreamGroup(); - Assert.assertEquals("StreamGroup dedicated=: false partitions=: [] ", streamGroup.toString()); - Assert.assertEquals("SG[]", streamGroup.getStreamId()); - - StreamSortSpec streamSortSpec = new StreamSortSpec(); - streamSortSpec.setWindowPeriod("PT10S"); - StreamPartition streamPartition = new StreamPartition(); - List<String> columns = new ArrayList<>(); - columns.add("jobId"); - streamPartition.setColumns(columns); - streamPartition.setSortSpec(streamSortSpec); - streamPartition.setStreamId("test"); - streamPartition.setType(StreamPartition.Type.GROUPBY); - streamGroup.addStreamPartition(streamPartition); - Assert.assertEquals("SG[test-]", streamGroup.getStreamId()); - Assert.assertEquals("StreamGroup dedicated=: false partitions=: [StreamPartition[streamId=test,type=GROUPBY,columns=[jobId],sortSpec=[StreamSortSpec[windowPeriod=PT10S,windowMargin=30000]]]] ", - streamGroup.toString()); - - List<StreamPartition> streamPartitions = new ArrayList<>(); - streamPartition.setStreamId("test1"); - streamPartitions.add(streamPartition); - streamGroup.addStreamPartitions(streamPartitions); - Assert.assertEquals("SG[test1-test1-]", streamGroup.getStreamId()); - - - streamPartitions = new ArrayList<>(); - StreamPartition streamPartition1 = new StreamPartition(); - streamPartition1.setStreamId("test2"); - streamPartitions.add(streamPartition1); - streamGroup.addStreamPartitions(streamPartitions); - Assert.assertEquals("SG[test1-test1-test2-]", streamGroup.getStreamId()); - Assert.assertEquals("StreamGroup dedicated=: false partitions=: [StreamPartition[streamId=test1,type=GROUPBY,columns=[jobId],sortSpec=[StreamSortSpec[windowPeriod=PT10S,windowMargin=30000]]], StreamPartition[streamId=test1,type=GROUPBY,columns=[jobId],sortSpec=[StreamSortSpec[windowPeriod=PT10S,windowMargin=30000]]], StreamPartition[streamId=test2,type=null,columns=[],sortSpec=[null]]] ", streamGroup.toString()); - - StreamGroup streamGroup1 = new StreamGroup(); - streamGroup1.addStreamPartitions(streamGroup.getStreamPartitions()); - Assert.assertTrue(streamGroup.equals(streamGroup1)); - Assert.assertTrue(streamGroup.hashCode() == streamGroup1.hashCode()); - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/StreamWorkSlotQueueTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/StreamWorkSlotQueueTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/StreamWorkSlotQueueTest.java deleted file mode 100644 index bc2f74e..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/StreamWorkSlotQueueTest.java +++ /dev/null @@ -1,61 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.alert.coordination.model.internal; - -import org.apache.eagle.alert.coordination.model.WorkSlot; -import org.apache.eagle.alert.engine.coordinator.StreamPartition; -import org.apache.eagle.alert.engine.coordinator.StreamSortSpec; -import org.junit.Assert; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -public class StreamWorkSlotQueueTest { - @Test - public void testStreamWorkSlotQueue() { - StreamGroup streamGroup = new StreamGroup(); - StreamSortSpec streamSortSpec = new StreamSortSpec(); - streamSortSpec.setWindowPeriod("PT10S"); - StreamPartition streamPartition = new StreamPartition(); - List<String> columns = new ArrayList<>(); - columns.add("jobId"); - streamPartition.setColumns(columns); - streamPartition.setSortSpec(streamSortSpec); - streamPartition.setStreamId("test"); - streamPartition.setType(StreamPartition.Type.GROUPBY); - streamGroup.addStreamPartition(streamPartition); - WorkSlot workSlot = new WorkSlot("setTopologyName", "setBoltId"); - List<WorkSlot> workSlots = new ArrayList<>(); - workSlots.add(workSlot); - StreamWorkSlotQueue streamWorkSlotQueue = new StreamWorkSlotQueue(streamGroup, false, new HashMap<>(), workSlots); - - Assert.assertTrue(streamWorkSlotQueue.getQueueId().startsWith("SG[test-]")); - Assert.assertTrue(streamWorkSlotQueue.getDedicateOption().isEmpty()); - Assert.assertEquals(0, streamWorkSlotQueue.getNumberOfGroupBolts()); - Assert.assertEquals(1, streamWorkSlotQueue.getQueueSize()); - Assert.assertTrue(streamWorkSlotQueue.getTopoGroupStartIndex().isEmpty()); - Assert.assertEquals(-1, streamWorkSlotQueue.getTopologyGroupStartIndex("")); - Assert.assertEquals(workSlot, streamWorkSlotQueue.getWorkingSlots().get(0)); - - StreamWorkSlotQueue streamWorkSlotQueue1 = new StreamWorkSlotQueue(streamGroup, false, new HashMap<>(), workSlots); - Assert.assertFalse(streamWorkSlotQueue.equals(streamWorkSlotQueue1)); - Assert.assertFalse(streamWorkSlotQueue == streamWorkSlotQueue1); - Assert.assertFalse(streamWorkSlotQueue.hashCode() == streamWorkSlotQueue1.hashCode()); - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/TopologyTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/TopologyTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/TopologyTest.java deleted file mode 100644 index 760657a..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/coordination/model/internal/TopologyTest.java +++ /dev/null @@ -1,47 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.alert.coordination.model.internal; - -import org.junit.Assert; -import org.junit.Test; - -public class TopologyTest { - @Test - public void testTopology() { - Topology topology = new Topology("test", 2, 3); - Assert.assertEquals(null, topology.getClusterName()); - Assert.assertEquals("test", topology.getName()); - Assert.assertEquals(null, topology.getPubBoltId()); - Assert.assertEquals(null, topology.getSpoutId()); - Assert.assertEquals(0, topology.getAlertBoltIds().size()); - Assert.assertEquals(1, topology.getAlertParallelism()); - Assert.assertEquals(0, topology.getGroupNodeIds().size()); - Assert.assertEquals(1, topology.getGroupParallelism()); - Assert.assertEquals(3, topology.getNumOfAlertBolt()); - Assert.assertEquals(2, topology.getNumOfGroupBolt()); - Assert.assertEquals(0, topology.getNumOfPublishBolt()); - Assert.assertEquals(1, topology.getNumOfSpout()); - Assert.assertEquals(1, topology.getSpoutParallelism()); - - Topology topology1 = new Topology("test", 2, 3); - - Assert.assertFalse(topology1.equals(topology)); - Assert.assertFalse(topology1.hashCode() == topology.hashCode()); - Assert.assertFalse(topology1 == topology); - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/engine/coordinator/OverrideDeduplicatorSpecTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/engine/coordinator/OverrideDeduplicatorSpecTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/engine/coordinator/OverrideDeduplicatorSpecTest.java deleted file mode 100644 index cc84c56..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/engine/coordinator/OverrideDeduplicatorSpecTest.java +++ /dev/null @@ -1,61 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.alert.engine.coordinator; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - -public class OverrideDeduplicatorSpecTest { - - @Test - public void testOverrideDeduplicatorSpec() { - Map<String, String> properties = new HashMap<>(); - properties.put("kafka_broker", "localhost:9092"); - properties.put("topic", "TEST_TOPIC_NAME"); - OverrideDeduplicatorSpec overrideDeduplicatorSpec = new OverrideDeduplicatorSpec(); - overrideDeduplicatorSpec.setClassName("testClass"); - overrideDeduplicatorSpec.setProperties(properties); - - OverrideDeduplicatorSpec overrideDeduplicatorSpec1 = new OverrideDeduplicatorSpec(); - overrideDeduplicatorSpec1.setClassName("testClass"); - overrideDeduplicatorSpec1.setProperties(properties); - - Assert.assertFalse(overrideDeduplicatorSpec1 == overrideDeduplicatorSpec); - Assert.assertTrue(overrideDeduplicatorSpec1.equals(overrideDeduplicatorSpec)); - Assert.assertTrue(overrideDeduplicatorSpec1.hashCode() == overrideDeduplicatorSpec.hashCode()); - - overrideDeduplicatorSpec1.setClassName("testClass1"); - - Assert.assertFalse(overrideDeduplicatorSpec1 == overrideDeduplicatorSpec); - Assert.assertFalse(overrideDeduplicatorSpec1.equals(overrideDeduplicatorSpec)); - Assert.assertFalse(overrideDeduplicatorSpec1.hashCode() == overrideDeduplicatorSpec.hashCode()); - - overrideDeduplicatorSpec1.setClassName("testClass"); - Map<String, String> properties1 = new HashMap<>(); - properties.put("kafka_broker", "localhost:9092"); - overrideDeduplicatorSpec1.setProperties(properties1); - - Assert.assertFalse(overrideDeduplicatorSpec1 == overrideDeduplicatorSpec); - Assert.assertFalse(overrideDeduplicatorSpec1.equals(overrideDeduplicatorSpec)); - Assert.assertFalse(overrideDeduplicatorSpec1.hashCode() == overrideDeduplicatorSpec.hashCode()); - } - -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/engine/coordinator/PolicyDefinitionTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/engine/coordinator/PolicyDefinitionTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/engine/coordinator/PolicyDefinitionTest.java deleted file mode 100644 index 77b3517..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/test/java/org/apache/eagle/alert/engine/coordinator/PolicyDefinitionTest.java +++ /dev/null @@ -1,140 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.alert.engine.coordinator; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.Arrays; -import java.util.HashMap; - -public class PolicyDefinitionTest { - - @Test - public void testPolicyInnerDefinition() { - PolicyDefinition.Definition def = new PolicyDefinition.Definition(); - def.setValue("test"); - def.setType("siddhi"); - def.setHandlerClass("setHandlerClass"); - def.setProperties(new HashMap<>()); - def.setOutputStreams(Arrays.asList("outputStream")); - def.setInputStreams(Arrays.asList("inputStream")); - Assert.assertEquals("{type=\"siddhi\",value=\"test\", inputStreams=\"[inputStream]\", outputStreams=\"[outputStream]\" }", def.toString()); - - PolicyDefinition.Definition def1 = new PolicyDefinition.Definition(); - def1.setValue("test"); - def1.setType("siddhi"); - def1.setHandlerClass("setHandlerClass"); - def1.setProperties(new HashMap<>()); - def1.setOutputStreams(Arrays.asList("outputStream")); - def1.setInputStreams(Arrays.asList("inputStream")); - - Assert.assertFalse(def == def1); - Assert.assertTrue(def.equals(def1)); - Assert.assertTrue(def.hashCode() == def1.hashCode()); - - def1.setInputStreams(Arrays.asList("inputStream1")); - - Assert.assertFalse(def.equals(def1)); - Assert.assertTrue(def.hashCode() == def1.hashCode());//problem equals() and hashCode() be inconsistent - - } - - @Test - public void testPolicyDefinition() { - PolicyDefinition pd = new PolicyDefinition(); - PolicyDefinition.Definition def = new PolicyDefinition.Definition(); - def.setValue("test"); - def.setType("siddhi"); - def.setHandlerClass("setHandlerClass"); - def.setProperties(new HashMap<>()); - def.setOutputStreams(Arrays.asList("outputStream")); - def.setInputStreams(Arrays.asList("inputStream")); - pd.setDefinition(def); - pd.setInputStreams(Arrays.asList("inputStream"));//confuse with PolicyDefinition.Definition InputStreams - pd.setOutputStreams(Arrays.asList("outputStream"));//confuse with PolicyDefinition.Definition OutputStreams - pd.setName("policyName"); - pd.setDescription(String.format("Test policy for stream %s", "streamName")); - - StreamPartition sp = new StreamPartition(); - sp.setStreamId("streamName"); - sp.setColumns(Arrays.asList("host")); - sp.setType(StreamPartition.Type.GROUPBY); - pd.addPartition(sp); - Assert.assertEquals("{site=\"default\", name=\"policyName\",definition={type=\"siddhi\",value=\"test\", inputStreams=\"[inputStream]\", outputStreams=\"[outputStream]\" }}", pd.toString()); - - PolicyDefinition pd1 = new PolicyDefinition(); - PolicyDefinition.Definition def1 = new PolicyDefinition.Definition(); - def1.setValue("test"); - def1.setType("siddhi"); - def1.setHandlerClass("setHandlerClass"); - def1.setProperties(new HashMap<>()); - def1.setOutputStreams(Arrays.asList("outputStream")); - def1.setInputStreams(Arrays.asList("inputStream")); - pd1.setDefinition(def1); - pd1.setInputStreams(Arrays.asList("inputStream"));//confuse with PolicyDefinition.Definition InputStreams - pd1.setOutputStreams(Arrays.asList("outputStream"));//confuse with PolicyDefinition.Definition OutputStreams - pd1.setName("policyName"); - pd1.setDescription(String.format("Test policy for stream %s", "streamName")); - - StreamPartition sp1 = new StreamPartition(); - sp1.setStreamId("streamName"); - sp1.setColumns(Arrays.asList("host")); - sp1.setType(StreamPartition.Type.GROUPBY); - pd1.addPartition(sp1); - - - Assert.assertFalse(pd == pd1); - Assert.assertTrue(pd.equals(pd1)); - Assert.assertTrue(pd.hashCode() == pd1.hashCode()); - sp1.setStreamId("streamName1"); - - Assert.assertFalse(pd == pd1); - Assert.assertFalse(pd.equals(pd1)); - Assert.assertFalse(pd.hashCode() == pd1.hashCode()); - - sp1.setStreamId("streamName"); - def1.setOutputStreams(Arrays.asList("outputStream1")); - - Assert.assertFalse(pd == pd1); - Assert.assertFalse(pd.equals(pd1)); - - Assert.assertTrue(pd.hashCode() == pd1.hashCode());//problem equals() and hashCode() be inconsistent - - } - - @Test - public void testPolicyDefinitionEqualByPolicyStatus() { - PolicyDefinition.Definition definition = new PolicyDefinition.Definition(); - PolicyDefinition policy1 = new PolicyDefinition(); - policy1.setName("policy1"); - policy1.setDefinition(definition); - - PolicyDefinition policy2 = new PolicyDefinition(); - policy2.setName("policy1"); - policy2.setPolicyStatus(PolicyDefinition.PolicyStatus.DISABLED); - policy2.setDefinition(definition); - - PolicyDefinition policy3 = new PolicyDefinition(); - policy3.setName("policy1"); - policy3.setDefinition(definition); - - Assert.assertTrue(policy1.equals(policy3)); - Assert.assertFalse(policy1.equals(policy2)); - } -}
