http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/ElasticSearchSink.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/ElasticSearchSink.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/ElasticSearchSink.java deleted file mode 100644 index 7e30b82..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/ElasticSearchSink.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.metric.sink; - -import java.io.IOException; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import org.elasticsearch.metrics.ElasticsearchReporter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.codahale.metrics.MetricRegistry; -import com.typesafe.config.Config; - -public class ElasticSearchSink implements MetricSink { - private ElasticsearchReporter reporter = null; - private final static Logger LOG = LoggerFactory.getLogger(ElasticSearchSink.class); - - @Override - public void prepare(Config config, MetricRegistry registry) { - LOG.debug("Preparing elasticsearch-sink"); - try { - ElasticsearchReporter.Builder builder = ElasticsearchReporter.forRegistry(registry); - if(config.hasPath("hosts")){ - List<String> hosts = config.getStringList("hosts"); - builder.hosts(hosts.toArray(new String[hosts.size()])); - } - if(config.hasPath("index")){ - builder.index(config.getString("index")); - } - builder.indexDateFormat("yyyy-MM-dd"); - builder.timestampFieldname(config.hasPath("timestampField")?config.getString("timestampField"):"@timestamp"); - - if(config.hasPath("tags")) { - builder.additionalFields(config.getConfig("tags").root().unwrapped()); - } - - reporter = builder.build(); - } catch (IOException e) { - LOG.error(e.getMessage(),e); - } - } - - @Override - public void start(long period, TimeUnit unit) { - reporter.start(period, TimeUnit.SECONDS); - } - - @Override - public void stop() { - reporter.stop(); - reporter.close(); - } - - @Override - public void report() { - reporter.report(); - } -}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/JmxSink.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/JmxSink.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/JmxSink.java deleted file mode 100644 index fddaf19..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/JmxSink.java +++ /dev/null @@ -1,48 +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.metric.sink; - -import java.util.concurrent.TimeUnit; - -import com.codahale.metrics.JmxReporter; -import com.codahale.metrics.MetricRegistry; -import com.typesafe.config.Config; - -public class JmxSink implements MetricSink { - private JmxReporter reporter; - - @Override - public void prepare(Config config, MetricRegistry registry) { - reporter = JmxReporter.forRegistry(registry).build(); - } - - @Override - public void start(long period, TimeUnit unit) { - reporter.start(); - } - - @Override - public void stop() { - reporter.stop(); - reporter.close(); - } - - @Override - public void report() { - // do nothing - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/KafkaSink.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/KafkaSink.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/KafkaSink.java deleted file mode 100644 index 6ff000c..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/KafkaSink.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.apache.eagle.alert.metric.sink; - -import java.util.concurrent.TimeUnit; - -import org.apache.eagle.alert.metric.reporter.KafkaReporter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.codahale.metrics.MetricRegistry; -import com.typesafe.config.Config; - -/** - * 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. - */ -public class KafkaSink implements MetricSink{ - private KafkaReporter reporter; - private final static Logger LOG = LoggerFactory.getLogger(KafkaSink.class); - @Override - public void prepare(Config config, MetricRegistry registry) { - LOG.debug("Preparing kafka-sink"); - KafkaReporter.Builder builder = KafkaReporter.forRegistry(registry) - .topic(config.getString("topic")) - .config(config); - - if(config.hasPath("tags")){ - builder.addFields(config.getConfig("tags").root().unwrapped()); - } - - reporter = builder.build(); - LOG.info("Prepared kafka-sink"); - } - - @Override - public void start(long period, TimeUnit unit) { - LOG.info("Starting"); - reporter.start(period,unit); - } - - @Override - public void stop() { - LOG.info("Stopping"); - reporter.stop(); - - LOG.info("Closing"); - reporter.close(); - } - - @Override - public void report() { - reporter.report(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/MetricSink.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/MetricSink.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/MetricSink.java deleted file mode 100644 index b09eda3..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/MetricSink.java +++ /dev/null @@ -1,30 +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.metric.sink; - - -import java.util.concurrent.TimeUnit; - -import com.codahale.metrics.MetricRegistry; -import com.typesafe.config.Config; - -public interface MetricSink { - void prepare(Config config, MetricRegistry registry); - void start(long period,TimeUnit unit); - void stop(); - void report(); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/MetricSinkRepository.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/MetricSinkRepository.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/MetricSinkRepository.java deleted file mode 100644 index b4126f2..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/MetricSinkRepository.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.apache.eagle.alert.metric.sink; - -import java.util.HashMap; -import java.util.Map; - -/** - * 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. - */ -public class MetricSinkRepository { - private final static Map<String,Class<? extends MetricSink>> sinkTypeClassMapping = new HashMap<>(); - - public static void register(String sinkType,Class<? extends MetricSink> sinkClass){ - sinkTypeClassMapping.put(sinkType,sinkClass); - } - - public static MetricSink createSink(String sinkType){ - if (!sinkTypeClassMapping.containsKey(sinkType)) { - throw new IllegalArgumentException("Unknown sink type: "+sinkType); - } - try { - return sinkTypeClassMapping.get(sinkType).newInstance(); - } catch (InstantiationException | IllegalAccessException e) { - throw new IllegalStateException(e); - } - } - - static { - register("kafka",KafkaSink.class); - register("jmx",JmxSink.class); - register("elasticsearch",ElasticSearchSink.class); - register("stdout",ConsoleSink.class); - register("logger",Slf4jSink.class); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/Slf4jSink.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/Slf4jSink.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/Slf4jSink.java deleted file mode 100644 index ce465fa..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/sink/Slf4jSink.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.metric.sink; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.slf4j.LoggerFactory; - -import com.codahale.metrics.MetricRegistry; -import com.codahale.metrics.Slf4jReporter; -import com.typesafe.config.Config; - -public class Slf4jSink implements MetricSink { - private Slf4jReporter reporter; - - @SuppressWarnings("serial") - private final static Map<String,Slf4jReporter.LoggingLevel> LEVEL_MAPPING = new HashMap<String,Slf4jReporter.LoggingLevel>(){{ - put("INFO",Slf4jReporter.LoggingLevel.INFO); - put("DEBUG",Slf4jReporter.LoggingLevel.DEBUG); - put("ERROR",Slf4jReporter.LoggingLevel.ERROR); - put("TRACE",Slf4jReporter.LoggingLevel.TRACE); - put("WARN",Slf4jReporter.LoggingLevel.WARN); - }}; - - private static Slf4jReporter.LoggingLevel getLoggingLevel(String level){ - if(LEVEL_MAPPING.containsKey(level.toUpperCase())){ - return LEVEL_MAPPING.get(level.toUpperCase()); - } else{ - throw new IllegalArgumentException("Illegal logging level: "+level); - } - } - - @Override - public void prepare(Config config, MetricRegistry registry) { - reporter = Slf4jReporter.forRegistry(registry) - .outputTo(LoggerFactory.getLogger("org.apache.eagle.alert.metric")) - .withLoggingLevel(config.hasPath("level")? getLoggingLevel(config.getString("level")): Slf4jReporter.LoggingLevel.INFO) - .convertRatesTo(TimeUnit.SECONDS) - .convertDurationsTo(TimeUnit.MILLISECONDS) - .build(); - } - - @Override - public void start(long period,TimeUnit unit) { - reporter.start(period,unit); - } - - @Override - public void stop() { - reporter.stop(); - reporter.close(); - } - - @Override - public void report() { - reporter.report(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/source/JVMMetricSource.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/source/JVMMetricSource.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/source/JVMMetricSource.java deleted file mode 100644 index a5bb5f4..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/source/JVMMetricSource.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.apache.eagle.alert.metric.source; - -import com.codahale.metrics.JvmAttributeGaugeSet; -import com.codahale.metrics.MetricRegistry; -import com.codahale.metrics.jvm.MemoryUsageGaugeSet; - -/** - * 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. - */ -public class JVMMetricSource implements MetricSource{ - - private MetricRegistry registry = new MetricRegistry(); - - public JVMMetricSource(){ - registry.registerAll(new JvmAttributeGaugeSet()); - registry.registerAll(new MemoryUsageGaugeSet()); - } - - @Override - public String name() { - return "jvm"; - } - - @Override - public MetricRegistry registry() { - return registry; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/source/MetricSource.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/source/MetricSource.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/source/MetricSource.java deleted file mode 100644 index 59b7a02..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/source/MetricSource.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.apache.eagle.alert.metric.source; - -import com.codahale.metrics.MetricRegistry; - -/** - * 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. - */ -public interface MetricSource { - String name(); - MetricRegistry registry(); -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/source/MetricSourceWrapper.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/source/MetricSourceWrapper.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/source/MetricSourceWrapper.java deleted file mode 100644 index 137fc17..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/metric/source/MetricSourceWrapper.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.apache.eagle.alert.metric.source; - -import com.codahale.metrics.MetricRegistry; - -/** - * 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. - */ -public class MetricSourceWrapper implements MetricSource { - private final MetricRegistry registry; - private final String name; - - public MetricSourceWrapper(String name, MetricRegistry registry){ - this.name = name; - this.registry = registry; - } - - @Override - public String name() { - return name; - } - - @Override - public MetricRegistry registry() { - return registry; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/resource/SimpleCORSFiler.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/resource/SimpleCORSFiler.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/resource/SimpleCORSFiler.java deleted file mode 100644 index addab44..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/resource/SimpleCORSFiler.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 - * - * 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.resource; - -import java.io.IOException; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletResponse; - -/** - * A simple allow all CORS filter that works with swagger UI. Tomcat CORS filter - * doesn't support Origin: null case which is the swagger UI request. - * - * @since Apr 15, 2016 - * - */ -public class SimpleCORSFiler implements Filter { - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - - } - - @Override - public void doFilter(ServletRequest request, ServletResponse res, FilterChain chain) throws IOException, - ServletException { - HttpServletResponse response = (HttpServletResponse) res; - response.setHeader("Access-Control-Allow-Origin", "*"); - response.setHeader("Access-Control-Allow-Methods", "HEAD, POST, GET, OPTIONS, DELETE"); - response.setHeader("Access-Control-Max-Age", "3600"); - response.setHeader("Access-Control-Allow-Headers", - "Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers"); - chain.doFilter(request, response); - } - - @Override - public void destroy() { - } - -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/service/IMetadataServiceClient.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/service/IMetadataServiceClient.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/service/IMetadataServiceClient.java deleted file mode 100644 index 3609c0a..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/service/IMetadataServiceClient.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 - * * - * * 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.service; - -import java.io.Closeable; -import java.io.Serializable; -import java.util.List; - -import org.apache.eagle.alert.coordination.model.Kafka2TupleMetadata; -import org.apache.eagle.alert.coordination.model.ScheduleState; -import org.apache.eagle.alert.coordination.model.SpoutSpec; -import org.apache.eagle.alert.coordination.model.internal.Topology; -import org.apache.eagle.alert.engine.coordinator.PolicyDefinition; -import org.apache.eagle.alert.engine.coordinator.Publishment; -import org.apache.eagle.alert.engine.coordinator.StreamDefinition; -import org.apache.eagle.alert.engine.coordinator.StreamingCluster; - -/** - * service stub to get metadata from remote metadata service - */ -public interface IMetadataServiceClient extends Closeable, Serializable { - - // user metadta - void addStreamingCluster(StreamingCluster cluster); - List<StreamingCluster> listClusters(); - - List<Topology> listTopologies(); - void addTopology(Topology t); - - void addPolicy(PolicyDefinition policy); - List<PolicyDefinition> listPolicies(); - - void addStreamDefinition(StreamDefinition streamDef); - List<StreamDefinition> listStreams(); - - void addDataSource(Kafka2TupleMetadata k2t); - List<Kafka2TupleMetadata> listDataSources(); - - void addPublishment(Publishment pub); - List<Publishment> listPublishment(); - - // monitor metadata - List<SpoutSpec> listSpoutMetadata(); - - ScheduleState getVersionedSpec(); - ScheduleState getVersionedSpec(String version); - void addScheduleState(ScheduleState state); - - void clear(); - - // for topology mgmt -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/service/MetadataServiceClientImpl.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/service/MetadataServiceClientImpl.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/service/MetadataServiceClientImpl.java deleted file mode 100644 index 3460b77..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/service/MetadataServiceClientImpl.java +++ /dev/null @@ -1,235 +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.service; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.core.MediaType; - -import org.apache.eagle.alert.coordination.model.Kafka2TupleMetadata; -import org.apache.eagle.alert.coordination.model.ScheduleState; -import org.apache.eagle.alert.coordination.model.SpoutSpec; -import org.apache.eagle.alert.coordination.model.internal.Topology; -import org.apache.eagle.alert.engine.coordinator.PolicyDefinition; -import org.apache.eagle.alert.engine.coordinator.Publishment; -import org.apache.eagle.alert.engine.coordinator.StreamDefinition; -import org.apache.eagle.alert.engine.coordinator.StreamingCluster; -import org.codehaus.jackson.jaxrs.JacksonJsonProvider; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.GenericType; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.client.urlconnection.URLConnectionClientHandler; -import com.typesafe.config.Config; - -public class MetadataServiceClientImpl implements IMetadataServiceClient { - private static final long serialVersionUID = 3003976065082684128L; - - private static final Logger LOG = LoggerFactory.getLogger(MetadataServiceClientImpl.class); - - private static final String METADATA_SCHEDULESTATES_PATH = "/metadata/schedulestates"; - private static final String METADATA_PUBLISHMENTS_PATH = "/metadata/publishments"; - private static final String METADATA_DATASOURCES_PATH = "/metadata/datasources"; - private static final String METADATA_STREAMS_PATH = "/metadata/streams"; - private static final String METADATA_POLICIES_PATH = "/metadata/policies"; - private static final String METADATA_CLUSTERS_PATH = "/metadata/clusters"; - private static final String METADATA_TOPOLOGY_PATH = "/metadata/topologies"; - private static final String METADATA_CLEAR_PATH = "/metadata/clear"; - - private static final String EAGLE_CORRELATION_CONTEXT = "metadataService.context"; - private static final String EAGLE_CORRELATION_SERVICE_PORT = "metadataService.port"; - private static final String EAGLE_CORRELATION_SERVICE_HOST = "metadataService.host"; - - protected static final String CONTENT_TYPE = "Content-Type"; - - private String host; - private int port; - private String context; - private transient Client client; - private String basePath; - - public MetadataServiceClientImpl(Config config) { - this(config.getString(EAGLE_CORRELATION_SERVICE_HOST), config.getInt(EAGLE_CORRELATION_SERVICE_PORT), config - .getString(EAGLE_CORRELATION_CONTEXT)); - basePath = buildBasePath(); - } - - public MetadataServiceClientImpl(String host, int port, String context) { - this.host = host; - this.port = port; - this.context = context; - this.basePath = buildBasePath(); - ClientConfig cc = new DefaultClientConfig(); - cc.getProperties().put(DefaultClientConfig.PROPERTY_CONNECT_TIMEOUT, 60 * 1000); - cc.getProperties().put(DefaultClientConfig.PROPERTY_READ_TIMEOUT, 60 * 1000); - cc.getClasses().add(JacksonJsonProvider.class); - cc.getProperties().put(URLConnectionClientHandler.PROPERTY_HTTP_URL_CONNECTION_SET_METHOD_WORKAROUND, true); - this.client = Client.create(cc); - client.addFilter(new com.sun.jersey.api.client.filter.GZIPContentEncodingFilter()); - } - - private String buildBasePath() { - StringBuilder sb = new StringBuilder(); - sb.append("http://"); - sb.append(host); - sb.append(":"); - sb.append(port); - sb.append(context); - return sb.toString(); - } - - @Override - public void close() throws IOException { - client.destroy(); - } - - @Override - public List<SpoutSpec> listSpoutMetadata() { - ScheduleState state = getVersionedSpec(); - return new ArrayList<>(state.getSpoutSpecs().values()); - } - - @Override - public List<StreamingCluster> listClusters() { - return list(METADATA_CLUSTERS_PATH, new GenericType<List<StreamingCluster>>() { - }); - } - - @Override - public List<PolicyDefinition> listPolicies() { - return list(METADATA_POLICIES_PATH, new GenericType<List<PolicyDefinition>>() { - }); - } - - @Override - public List<StreamDefinition> listStreams() { - return list(METADATA_STREAMS_PATH, new GenericType<List<StreamDefinition>>() { - }); - } - - @Override - public List<Kafka2TupleMetadata> listDataSources() { - return list(METADATA_DATASOURCES_PATH, new GenericType<List<Kafka2TupleMetadata>>() { - }); - } - - private <T> List<T> list(String path, GenericType<List<T>> type) { - WebResource r = client.resource(basePath + path); - LOG.info("query URL {}", basePath + path); - List<T> ret = r.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON).get(type); - return ret; - } - - @Override - public List<Publishment> listPublishment() { - return list(METADATA_PUBLISHMENTS_PATH, new GenericType<List<Publishment>>() { - }); - } - - @Override - public ScheduleState getVersionedSpec(String version) { - return listOne(METADATA_SCHEDULESTATES_PATH + "/" + version, ScheduleState.class); - } - - private <T> T listOne(String path, Class<T> tClz) { - LOG.info("query URL {}", basePath + path); - WebResource r = client.resource(basePath + path); - - ClientResponse resp = r.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON) - .get(ClientResponse.class); - if (resp.getStatus() < 300) { - try { - return resp.getEntity(tClz); - } catch (Exception e) { - LOG.warn(" list one entity failed, ignored and continute, path {}, message {}!", path, e.getMessage()); - } - }else{ - LOG.warn("fail querying metadata service {} with http status {}", basePath + path, resp.getStatus()); - } - return null; - } - - @Override - public ScheduleState getVersionedSpec() { - return listOne(METADATA_SCHEDULESTATES_PATH, ScheduleState.class); - } - - @Override - public void addScheduleState(ScheduleState state) { - WebResource r = client.resource(basePath + METADATA_SCHEDULESTATES_PATH); - r.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON).post(state); - } - - @Override - public List<Topology> listTopologies() { - return list(METADATA_TOPOLOGY_PATH, new GenericType<List<Topology>>() { - }); - } - - @Override - public void addStreamingCluster(StreamingCluster cluster) { - WebResource r = client.resource(basePath + METADATA_CLUSTERS_PATH); - r.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON).post(cluster); - } - - @Override - public void addTopology(Topology t) { - WebResource r = client.resource(basePath + METADATA_TOPOLOGY_PATH); - r.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON).post(t); - } - - @Override - public void addPolicy(PolicyDefinition policy) { - WebResource r = client.resource(basePath + METADATA_POLICIES_PATH); - r.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON).post(policy); - } - - @Override - public void addStreamDefinition(StreamDefinition streamDef) { - WebResource r = client.resource(basePath + METADATA_STREAMS_PATH); - r.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON).post(streamDef); - } - - @Override - public void addDataSource(Kafka2TupleMetadata k2t) { - WebResource r = client.resource(basePath + METADATA_DATASOURCES_PATH); - r.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON).post(k2t); - } - - @Override - public void addPublishment(Publishment pub) { - WebResource r = client.resource(basePath + METADATA_PUBLISHMENTS_PATH); - r.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON).post(pub); - } - - @Override - public void clear() { - WebResource r = client.resource(basePath + METADATA_CLEAR_PATH); - r.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON).post(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/AlertConstants.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/AlertConstants.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/AlertConstants.java deleted file mode 100644 index 8512df2..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/AlertConstants.java +++ /dev/null @@ -1,27 +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; - -public class AlertConstants { - public final static String FIELD_0 = "f0"; - public final static String FIELD_1 = "f1"; - public final static String FIELD_2 = "f2"; - public final static String FIELD_3 = "f3"; - - public final static String DEFAULT_SPOUT_NAME = "alertEngineSpout"; - public final static String DEFAULT_ROUTERBOLT_NAME = "streamRouterBolt"; -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ByteUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ByteUtils.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ByteUtils.java deleted file mode 100644 index 2e5a8fe..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ByteUtils.java +++ /dev/null @@ -1,188 +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 java.io.UnsupportedEncodingException; - -public class ByteUtils { - - public static double bytesToDouble(byte[] bytes, int offset){ - return Double.longBitsToDouble(bytesToLong(bytes, offset)); - } - - public static double bytesToDouble(byte[] bytes){ - return Double.longBitsToDouble(bytesToLong(bytes)); - } - - public static void doubleToBytes(double v, byte[] bytes){ - doubleToBytes(v, bytes, 0); - } - - public static void doubleToBytes(double v, byte[] bytes, int offset){ - longToBytes(Double.doubleToLongBits(v), bytes, offset); - } - - public static byte[] doubleToBytes(double v){ - return longToBytes(Double.doubleToLongBits(v)); - } - - public static long bytesToLong(byte[] bytes){ - return bytesToLong(bytes, 0); - } - - public static long bytesToLong(byte[] bytes, int offset){ - long value = 0; - for(int i=0; i<8; i++){ - value <<= 8; - value |= (bytes[i+offset] & 0xFF); - } - return value; - } - - public static void longToBytes(long v, byte[] bytes){ - longToBytes(v, bytes, 0); - } - - public static void longToBytes(long v, byte[] bytes, int offset){ - long tmp = v; - for(int i=0; i<8; i++){ - bytes[offset + 7 - i] = (byte)(tmp & 0xFF); - tmp >>= 8; - } - } - - public static byte[] longToBytes(long v){ - long tmp = v; - byte[] b = new byte[8]; - for(int i=0; i<8; i++){ - b[7-i] = (byte)(tmp & 0xFF); - tmp >>= 8; - } - return b; - } - - public static int bytesToInt(byte[] bytes){ - return bytesToInt(bytes, 0); - } - - public static int bytesToInt(byte[] bytes, int offset){ - int value = 0; - for(int i=0; i<4; i++){ - value <<= 8; - value |= (bytes[i+offset] & 0xFF); - } - return value; - } - - public static void intToBytes(int v, byte[] bytes){ - intToBytes(v, bytes, 0); - } - - public static void intToBytes(int v, byte[] bytes, int offset){ - int tmp = v; - for(int i=0; i<4; i++){ - bytes[offset + 3 - i] = (byte)(tmp & 0xFF); - tmp >>= 8; - } - } - - public static byte[] intToBytes(int v){ - int tmp = v; - byte[] b = new byte[4]; - for(int i=0; i<4; i++){ - b[3-i] = (byte)(tmp & 0xFF); - tmp >>= 8; - } - return b; - } - - ////// - - public static short bytesToShort(byte[] bytes){ - return bytesToShort(bytes, 0); - } - - public static short bytesToShort(byte[] bytes, int offset){ - short value = 0; - for(int i=0; i < 2; i++){ - value <<= 8; - value |= (bytes[i+offset] & 0xFF); - } - return value; - } - - public static void shortToBytes(short v, byte[] bytes){ - shortToBytes(v, bytes, 0); - } - - public static void shortToBytes(short v, byte[] bytes, int offset){ - int tmp = v; - for(int i=0; i < 2; i++){ - bytes[offset + 1 - i] = (byte)(tmp & 0xFF); - tmp >>= 8; - } - } - - public static byte[] shortToBytes(short v){ - int tmp = v; - byte[] b = new byte[2]; - for(int i=0; i<2; i++){ - b[1-i] = (byte)(tmp & 0xFF); - tmp >>= 8; - } - return b; - } - - public static byte[] concat(byte[]... arrays) { - int length = 0; - for (byte[] array : arrays) { - length += array.length; - } - byte[] result = new byte[length]; - int pos = 0; - for (byte[] array : arrays) { - System.arraycopy(array, 0, result, pos, array.length); - pos += array.length; - } - return result; - } - - public static byte[] stringToBytes(String str) { - try { - return str.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new IllegalStateException(e); - } - } - -// public static void main(String[] args){ -// int a = "ThreadName".hashCode(); -// byte[] b = intToBytes(a); -// byte[] c = intToBytes(1676687583); -// String s = new String(b); -// System.out.println(s); - -// byte[] d = intToBytes(8652353); -// System.out.println(bytesToInt(d)); - -// byte[] e = longToBytes(12131513513l); -// System.out.println(bytesToLong(e)); -// if(12131513513l == bytesToLong(e)){ -// System.out.println("yes"); -// } -// } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ConfigUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ConfigUtils.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ConfigUtils.java deleted file mode 100644 index fe63fe1..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/ConfigUtils.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 - * - * 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 java.util.Properties; - -import com.typesafe.config.Config; - -/** - * 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. - */ -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/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/DateTimeUtil.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/DateTimeUtil.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/DateTimeUtil.java deleted file mode 100644 index d611b95..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/DateTimeUtil.java +++ /dev/null @@ -1,141 +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 java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.TimeZone; - -/** - * be aware that SimpleDateFormat instantiation is expensive, so if that's under a tight loop, probably we need - * a thread local SimpleDateFormat object - */ -public class DateTimeUtil { - public static final long ONESECOND = 1L * 1000L; - public static final long ONEMINUTE = 1L * 60L * 1000L; - public static final long ONEHOUR = 1L * 60L * 60L * 1000L; - public static final long ONEDAY = 24L * 60L * 60L * 1000L; - private static TimeZone CURRENT_TIME_ZONE = TimeZone.getDefault(); - - public static Date humanDateToDate(String date) throws ParseException { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - sdf.setTimeZone(CURRENT_TIME_ZONE); - return sdf.parse(date); - } - - public static long getCurrentTimestamp(){ - return System.currentTimeMillis(); - } - - public static String secondsToHumanDate(long seconds){ - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - sdf.setTimeZone(CURRENT_TIME_ZONE); - Date t = new Date(); - t.setTime(seconds*1000); - return sdf.format(t); - } - - public static String millisecondsToHumanDateWithMilliseconds(long milliseconds){ - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS"); - sdf.setTimeZone(CURRENT_TIME_ZONE); - Date t = new Date(); - t.setTime(milliseconds); - return sdf.format(t); - } - - public static String millisecondsToHumanDateWithSeconds(long milliseconds){ - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - sdf.setTimeZone(CURRENT_TIME_ZONE); - Date t = new Date(); - t.setTime(milliseconds); - return sdf.format(t); - } - - public static long humanDateToSeconds(String date) throws ParseException { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - sdf.setTimeZone(CURRENT_TIME_ZONE); - Date d = sdf.parse(date); - return d.getTime()/1000; - } - - public static long humanDateToMilliseconds(String date) throws ParseException { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS"); - sdf.setTimeZone(CURRENT_TIME_ZONE); - Date d = sdf.parse(date); - return d.getTime(); - } - - - public static long humanDateToMillisecondsWithoutException(String date){ - try{ - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS"); - sdf.setTimeZone(CURRENT_TIME_ZONE); - Date d = sdf.parse(date); - return d.getTime(); - }catch(ParseException ex){ - return 0L; - } - } - - public static long humanDateToSecondsWithoutException(String date){ - try{ - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - sdf.setTimeZone(CURRENT_TIME_ZONE); - Date d = sdf.parse(date); - return (d.getTime() / 1000); - }catch(ParseException ex){ - return 0L; - } - } - /** - * this could be accurate only when timezone is UTC - * for the timezones other than UTC, there is possibly issue, for example - * assume timezone is GMT+8 in China - * When user time is "2014-07-15 05:00:00", it will be converted to timestamp first, internally it would be "2014-07-14 21:00:00" in UTC timezone. When rounded down to day, the internal time would - * be changed to "2014-07-14 00:00:00", and that means the user time is "2014-07-14 08:00:00". But originally user wants to round it to "2014-07-15 00:00:00" - * - * @param field - * @param timeInMillis the seconds elapsed since 1970-01-01 00:00:00 - * @return - */ - public static long roundDown(int field, long timeInMillis){ - switch(field){ - case Calendar.DAY_OF_MONTH: - case Calendar.DAY_OF_WEEK: - case Calendar.DAY_OF_YEAR: - return (timeInMillis - timeInMillis % (24*60*60*1000)); - case Calendar.HOUR: - return (timeInMillis - timeInMillis % (60*60*1000)); - case Calendar.MINUTE: - return (timeInMillis - timeInMillis % (60*1000)); - case Calendar.SECOND: - return (timeInMillis - timeInMillis % (1000)); - default: - return 0L; - } - } - - public static String format(long milliseconds, String format) { - SimpleDateFormat sdf = new SimpleDateFormat(format); - sdf.setTimeZone(CURRENT_TIME_ZONE); - Date t = new Date(); - t.setTime(milliseconds); - return sdf.format(t); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/HostUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/HostUtils.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/HostUtils.java deleted file mode 100644 index fb301ac..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/HostUtils.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 - * - * 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 java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.util.Enumeration; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * 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/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/JsonUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/JsonUtils.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/JsonUtils.java deleted file mode 100644 index de0c48b..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/JsonUtils.java +++ /dev/null @@ -1,41 +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 com.fasterxml.jackson.databind.ObjectMapper; - -/** - * @since May 1, 2016 - * - */ -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 ""; - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamIdConversion.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamIdConversion.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamIdConversion.java deleted file mode 100644 index 9316637..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/StreamIdConversion.java +++ /dev/null @@ -1,52 +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; - -/** - * 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. - */ -public class StreamIdConversion { - private final static String STREAM_ID_TEMPLATE = "stream_%s_to_%s"; - private final static 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} - * - * - * @param partitionNum - * @return - */ - public static String generateStreamIdByPartition(int partitionNum){ - return String.format(STREAM_ID_NUM_TEMPLATE,partitionNum); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/TimePeriodUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/TimePeriodUtils.java b/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/TimePeriodUtils.java deleted file mode 100644 index 782188d..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/java/org/apache/eagle/alert/utils/TimePeriodUtils.java +++ /dev/null @@ -1,62 +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 - * - * @param seconds - * @param period - * - * @return formatted timestamp - */ - public static long formatSecondsByPeriod(long seconds,Seconds period){ - return seconds - (seconds % Int.int2long(period.getSeconds())); - } - - /** - * @param seconds - * @param period - * @return - */ - public static long formatSecondsByPeriod(long seconds,Period period){ - return seconds - (seconds % Int.int2long(period.toStandardSeconds().getSeconds())); - } - - /** - * @param milliseconds - * @param period - * @return milliseconds - */ - 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/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/main/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/main/resources/log4j.properties b/eagle-core/eagle-alert/alert/alert-common/src/main/resources/log4j.properties deleted file mode 100644 index fb13ad5..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/main/resources/log4j.properties +++ /dev/null @@ -1,21 +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/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/alert/config/TestConfigBus.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/alert/config/TestConfigBus.java b/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/alert/config/TestConfigBus.java deleted file mode 100644 index 8123f45..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/alert/config/TestConfigBus.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.apache.eagle.alert.config; - -import java.util.concurrent.atomic.AtomicBoolean; - -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; - -/** - * 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. - */ -public class TestConfigBus { - - @Ignore - @Test - public void testConfigChange() throws Exception { - String topic = "spout"; - ZKConfig config = new ZKConfig(); - config.zkQuorum = "localhost:2181"; - config.zkRoot = "/alert"; - config.zkRetryInterval = 1000; - config.zkRetryTimes = 3; - config.connectionTimeoutMs = 3000; - config.zkSessionTimeoutMs = 10000; - ConfigBusProducer producer = new ConfigBusProducer(config); - final AtomicBoolean validate = new AtomicBoolean(false); - ConfigBusConsumer consumer = new ConfigBusConsumer(config, topic, value -> { - validate.set(true); - System.out.println("******** get notified of config " + value); - }); - // first change - ConfigValue value = new ConfigValue(); - value.setValueVersionId(false); - value.setValue("testvalue1"); - producer.send(topic, value); - - Thread.sleep(1000); - - // second change - value.setValueVersionId(false); - value.setValue("testvalue2"); - producer.send(topic, value); - producer.close(); - Thread.sleep(1000); - consumer.close(); - Assert.assertTrue(validate.get()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/alert/metric/MetricSystemTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/alert/metric/MetricSystemTest.java b/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/alert/metric/MetricSystemTest.java deleted file mode 100644 index e96ded9..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/alert/metric/MetricSystemTest.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.apache.eagle.alert.metric; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.eagle.alert.metric.sink.KafkaSink; -import org.apache.eagle.alert.metric.source.JVMMetricSource; -import org.apache.eagle.alert.metric.source.MetricSource; -import org.junit.Ignore; -import org.junit.Test; - -import com.codahale.metrics.Gauge; -import com.codahale.metrics.JvmAttributeGaugeSet; -import com.codahale.metrics.MetricRegistry; -import com.typesafe.config.ConfigFactory; - -/** - * 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. - */ -public class MetricSystemTest { - @Test @Ignore - public void testKafkaSink(){ - KafkaSink sink = new KafkaSink(); - MetricRegistry registry = new MetricRegistry(); - registry.registerAll(new JvmAttributeGaugeSet()); - sink.prepare(ConfigFactory.load().getConfig("metric.sink.kafka"),registry); - sink.report(); - sink.stop(); - } - - @Test @Ignore - public void testMetricSystem() throws InterruptedException { - MetricSystem system = MetricSystem.load(ConfigFactory.load()); - system.register(new JVMMetricSource()); - system.register(new SampleMetricSource()); - system.start(); - system.report(); - system.stop(); - } - - private class SampleMetricSource implements MetricSource { - private MetricRegistry registry = new MetricRegistry(); - - public SampleMetricSource(){ - registry.register("sample.long", (Gauge<Long>) System::currentTimeMillis); - registry.register("sample.map", (Gauge<Map<String, Object>>) () -> new HashMap<String, Object>(){ - private static final long serialVersionUID = 3948508906655117683L; - { - put("int",1234); - put("str","text"); - put("bool",true); - }}); - } - - @Override - public String name() { - return "sampleSource"; - } - - @Override - public MetricRegistry registry() { - return registry; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/alert/service/TestMetadataServiceClientImpl.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/alert/service/TestMetadataServiceClientImpl.java b/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/alert/service/TestMetadataServiceClientImpl.java deleted file mode 100644 index 4496b8e..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/alert/service/TestMetadataServiceClientImpl.java +++ /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. - * - */ - -package org.apache.eagle.alert.service; - -import java.util.List; - -import org.apache.eagle.alert.engine.coordinator.PolicyDefinition; -import org.codehaus.jackson.map.ObjectMapper; -import org.junit.Ignore; -import org.junit.Test; - -public class TestMetadataServiceClientImpl { - @SuppressWarnings("resource") - @Ignore - @Test - public void test() throws Exception{ - MetadataServiceClientImpl impl = new MetadataServiceClientImpl("localhost", 58080, "/api/metadata/policies"); - List<PolicyDefinition> policies = impl.listPolicies(); - ObjectMapper mapper = new ObjectMapper(); - String ret = mapper.writeValueAsString(policies); - System.out.println(ret); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/correlation/meta/JsonTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/correlation/meta/JsonTest.java b/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/correlation/meta/JsonTest.java deleted file mode 100644 index 71cce51..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/test/java/org/apache/eagle/correlation/meta/JsonTest.java +++ /dev/null @@ -1,30 +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.correlation.meta; - -import org.junit.Test; - -/** - * Created on 3/11/16. - */ -public class JsonTest { - - @Test - public void policyDefTest() { - // TODO - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/test/resources/application.conf ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/test/resources/application.conf b/eagle-core/eagle-alert/alert/alert-common/src/test/resources/application.conf deleted file mode 100644 index 738c844..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/test/resources/application.conf +++ /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 -# -# 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. - -{ - metric { - sink { - kafka { - "topic":"alert_metric_test" - "bootstrap.servers": "localhost:9092" - } - logger { - level = "INFO" - } - elasticsearch { - hosts = ["10.64.223.222:9200"] - index = "alert_metric_test" - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/src/test/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/src/test/resources/log4j.properties b/eagle-core/eagle-alert/alert/alert-common/src/test/resources/log4j.properties deleted file mode 100644 index fb13ad5..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/src/test/resources/log4j.properties +++ /dev/null @@ -1,21 +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/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-coordinator/.gitignore ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-coordinator/.gitignore b/eagle-core/eagle-alert/alert/alert-coordinator/.gitignore deleted file mode 100644 index b83d222..0000000 --- a/eagle-core/eagle-alert/alert/alert-coordinator/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target/ http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-coordinator/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-coordinator/pom.xml b/eagle-core/eagle-alert/alert/alert-coordinator/pom.xml deleted file mode 100644 index fec8903..0000000 --- a/eagle-core/eagle-alert/alert/alert-coordinator/pom.xml +++ /dev/null @@ -1,107 +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>io.sherlock</groupId> - <artifactId>alert-parent</artifactId> - <version>0.0.1-SNAPSHOT</version> - </parent> - - <artifactId>alert-coordinator</artifactId> - <packaging>war</packaging> - - <name>alert-coordinator</name> - <url>http://maven.apache.org</url> - - <dependencies> - <dependency> - <groupId>io.sherlock</groupId> - <artifactId>alert-common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-server</artifactId> - </dependency> - <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-servlet</artifactId> - </dependency> - <dependency> - <groupId>com.sun.jersey.contribs</groupId> - <artifactId>jersey-multipart</artifactId> - </dependency> - <dependency> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-mapper-asl</artifactId> - </dependency> - <dependency> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-jaxrs</artifactId> - </dependency> - <dependency> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-xc</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </dependency> - <dependency> - <groupId>com.typesafe</groupId> - <artifactId>config</artifactId> - </dependency> - <dependency> - <groupId>org.apache.tomcat.embed</groupId> - <artifactId>tomcat-embed-core</artifactId> - </dependency> - <dependency> - <groupId>io.swagger</groupId> - <artifactId>swagger-jaxrs</artifactId> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-maven-plugin</artifactId> - <configuration> - <scanIntervalSeconds>5</scanIntervalSeconds> - <httpConnector> - <port>9090</port> - </httpConnector> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <version>2.6</version> - <executions> - <execution> - <goals> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project>