Repository: ambari Updated Branches: refs/heads/branch-3.0-ams e196358ca -> 67524d399
AMBARI-22192. Setup an application server for hosting the AD System Manager. Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/67524d39 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/67524d39 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/67524d39 Branch: refs/heads/branch-3.0-ams Commit: 67524d399a375508e8d537af5a34e455834b6952 Parents: e196358 Author: Siddharth Wagle <swa...@hortonworks.com> Authored: Thu Oct 12 12:09:49 2017 -0700 Committer: Siddharth Wagle <swa...@hortonworks.com> Committed: Thu Oct 12 12:09:49 2017 -0700 ---------------------------------------------------------------------- .../pom.xml | 569 ++++++++++++------- .../src/main/resources/config.yml | 12 + .../adservice/app/AnomalyDetectionApp.scala | 69 +++ .../app/AnomalyDetectionAppConfig.scala | 24 + .../app/AnomalyDetectionAppModule.scala | 38 ++ .../adservice/app/DefaultHealthCheck.scala | 25 + .../metrics/adservice/app/GuiceInjector.scala | 56 ++ .../common/PhoenixQueryConstants.scala | 2 +- .../adservice/resource/AnomalyResource.scala | 35 ++ .../adservice/resource/RootResource.scala | 35 ++ .../adservice/service/ADQueryService.scala | 22 + .../adservice/service/ADQueryServiceImpl.scala | 22 + .../app/DefaultADResourceSpecTest.scala | 54 ++ .../adservice/app/DropwizardAppRuleHelper.scala | 39 ++ .../app/DropwizardResourceTestRuleHelper.scala | 33 ++ .../common/ADManagerConfigurationTest.scala | 17 + ambari-metrics/ambari-metrics-common/pom.xml | 12 +- ambari-metrics/pom.xml | 1 + ambari-utility/pom.xml | 4 +- 19 files changed, 857 insertions(+), 212 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/pom.xml b/ambari-metrics/ambari-metrics-anomaly-detection-service/pom.xml index 6f8f8c1..c9bb7b7 100644 --- a/ambari-metrics/ambari-metrics-anomaly-detection-service/pom.xml +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/pom.xml @@ -20,217 +20,370 @@ <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"> - <parent> - <artifactId>ambari-metrics</artifactId> - <groupId>org.apache.ambari</groupId> - <version>2.0.0.0-SNAPSHOT</version> - </parent> - <modelVersion>4.0.0</modelVersion> - <artifactId>ambari-metrics-anomaly-detection-service</artifactId> + <parent> + <artifactId>ambari-metrics</artifactId> + <groupId>org.apache.ambari</groupId> <version>2.0.0.0-SNAPSHOT</version> - <properties> - <scala.version>2.11.1</scala.version> - <scala.binary.version>2.11</scala.binary.version> - <hadoop.version>2.7.3.2.6.0.3-8</hadoop.version> - </properties> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>ambari-metrics-anomaly-detection-service</artifactId> + <version>2.0.0.0-SNAPSHOT</version> + <name>Ambari Metrics Anomaly Detection Service</name> + <packaging>jar</packaging> - <repositories> - <repository> - <id>scala-tools.org</id> - <name>Scala-Tools Maven2 Repository</name> - <url>http://scala-tools.org/repo-releases</url> - </repository> - </repositories> + <properties> + <scala.version>2.12.3</scala.version> + <scala.binary.version>2.11</scala.binary.version> + <hadoop.version>2.7.3.2.6.0.3-8</hadoop.version> + <jackson.version>2.8.9</jackson.version> + <dropwizard.version>1.2.0</dropwizard.version> + <spark.version>2.2.0</spark.version> + </properties> + + <repositories> + <repository> + <id>scala-tools.org</id> + <name>Scala-Tools Maven2 Repository</name> + <url>http://scala-tools.org/repo-releases</url> + </repository> + </repositories> - <pluginRepositories> - <pluginRepository> - <id>scala-tools.org</id> - <name>Scala-Tools Maven2 Repository</name> - <url>http://scala-tools.org/repo-releases</url> - </pluginRepository> - </pluginRepositories> + <pluginRepositories> + <pluginRepository> + <id>scala-tools.org</id> + <name>Scala-Tools Maven2 Repository</name> + <url>http://scala-tools.org/repo-releases</url> + </pluginRepository> + </pluginRepositories> - <build> - <plugins> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <source>1.8</source> - <target>1.8</target> - </configuration> - </plugin> - <plugin> - <groupId>org.scala-tools</groupId> - <artifactId>maven-scala-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>compile</goal> - <goal>testCompile</goal> - </goals> - </execution> - </executions> - <configuration> - <scalaVersion>${scala.version}</scalaVersion> - <args> - <arg>-target:jvm-1.5</arg> - </args> - </configuration> - </plugin> - </plugins> - </build> - <name>Ambari Metrics Anomaly Detection Service</name> - <packaging>jar</packaging> + <build> + <finalName>${project.artifactId}</finalName> + <resources> + <resource> + <filtering>true</filtering> + <directory>src/main/resources</directory> + <includes> + <include>**/*.yml</include> + <include>**/*.txt</include> + </includes> + </resource> + </resources> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + <plugin> + <groupId>net.alchim31.maven</groupId> + <artifactId>scala-maven-plugin</artifactId> + <version>3.3.1</version> + <executions> + <execution> + <id>scala-compile-first</id> + <phase>process-resources</phase> + <goals> + <goal>add-source</goal> + <goal>compile</goal> + </goals> + </execution> + <execution> + <id>scala-test-compile</id> + <phase>process-test-resources</phase> + <goals> + <goal>testCompile</goal> + </goals> + </execution> + </executions> + <configuration> + <jvmArgs> + <jvmArg>-Xms512m</jvmArg> + <jvmArg>-Xmx2048m</jvmArg> + </jvmArgs> + </configuration> + </plugin> + <plugin> + <groupId>org.scalatest</groupId> + <artifactId>scalatest-maven-plugin</artifactId> + <version>1.0</version> + </plugin> + <plugin> + <groupId>org.scala-tools</groupId> + <artifactId>maven-scala-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>compile</goal> + <goal>testCompile</goal> + </goals> + </execution> + </executions> + <configuration> + <scalaVersion>${scala.version}</scalaVersion> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.5</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>3.1.0</version> + <configuration> + <createDependencyReducedPom>false</createDependencyReducedPom> + <minimizeJar>true</minimizeJar> + <filters> + <filter> + <artifact>*:*</artifact> + <excludes> + <exclude>META-INF/*.SF</exclude> + <exclude>META-INF/*.DSA</exclude> + <exclude>META-INF/*.RSA</exclude> + </excludes> + </filter> + </filters> + </configuration> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <transformers> + <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> + <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <mainClass> + org.apache.ambari.metrics.adservice.app.AnomalyDetectionApp + </mainClass> + </transformer> + </transformers> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> - <dependencies> - - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.5</version> - </dependency> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>1.7.2</version> - </dependency> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>1.7.2</version> - </dependency> - - <dependency> - <groupId>com.github.lucarosellini.rJava</groupId> - <artifactId>JRI</artifactId> - <version>0.9-7</version> - </dependency> - <dependency> - <groupId>org.apache.spark</groupId> - <artifactId>spark-streaming_2.11</artifactId> - <version>2.1.1</version> - </dependency> - <dependency> - <groupId>org.apache.kafka</groupId> - <artifactId>kafka_2.10</artifactId> - <version>0.10.1.0</version> - <exclusions> - <exclusion> - <groupId>com.sun.jdmk</groupId> - <artifactId>jmxtools</artifactId> - </exclusion> - <exclusion> - <groupId>com.sun.jmx</groupId> - <artifactId>jmxri</artifactId> - </exclusion> - <exclusion> - <groupId>javax.mail</groupId> - <artifactId>mail</artifactId> - </exclusion> - <exclusion> - <groupId>javax.jms</groupId> - <artifactId>jmx</artifactId> - </exclusion> - <exclusion> - <groupId>javax.jms</groupId> - <artifactId>jms</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.kafka</groupId> - <artifactId>kafka-clients</artifactId> - <version>0.10.1.0</version> - </dependency> - <dependency> - <groupId>org.apache.kafka</groupId> - <artifactId>connect-json</artifactId> - <version>0.10.1.0</version> - </dependency> - <dependency> - <groupId>org.apache.spark</groupId> - <artifactId>spark-streaming-kafka_2.10</artifactId> - <version>1.6.3</version> - </dependency> - <dependency> - <groupId>org.apache.spark</groupId> - <artifactId>spark-sql_2.10</artifactId> - <version>1.6.3</version> - </dependency> - <dependency> - <groupId>org.apache.phoenix</groupId> - <artifactId>phoenix-spark</artifactId> - <version>4.10.0-HBase-1.1</version> - </dependency> - <dependency> - <groupId>org.apache.spark</groupId> - <artifactId>spark-mllib_2.10</artifactId> - <version>1.3.0</version> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - <version>4.10</version> - </dependency> - <dependency> - <groupId>org.apache.ambari</groupId> - <artifactId>ambari-metrics-common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpclient</artifactId> - <version>4.2.5</version> - </dependency> - <dependency> - <groupId>org.scala-lang</groupId> - <artifactId>scala-library</artifactId> - <version>${scala.version}</version> - </dependency> - <dependency> - <groupId>org.apache.spark</groupId> - <artifactId>spark-core_${scala.binary.version}</artifactId> - <version>2.1.1</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.spark</groupId> - <artifactId>spark-mllib_${scala.binary.version}</artifactId> - <version>2.1.1</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.hadoop</groupId> - <artifactId>hadoop-common</artifactId> - <version>${hadoop.version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>commons-el</groupId> - <artifactId>commons-el</artifactId> - </exclusion> - <exclusion> - <groupId>tomcat</groupId> - <artifactId>jasper-runtime</artifactId> - </exclusion> - <exclusion> - <groupId>tomcat</groupId> - <artifactId>jasper-compiler</artifactId> - </exclusion> - <exclusion> - <groupId>org.mortbay.jetty</groupId> - <artifactId>jsp-2.1-jetty</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.scalatest</groupId> - <artifactId>scalatest_2.11</artifactId> - <version>3.0.1</version> - <scope>test</scope> - </dependency> - </dependencies> + <dependencies> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.5</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.2</version> + </dependency> + <dependency> + <groupId>com.github.lucarosellini.rJava</groupId> + <artifactId>JRI</artifactId> + <version>0.9-7</version> + </dependency> + <dependency> + <groupId>org.apache.spark</groupId> + <artifactId>spark-streaming_${scala.binary.version}</artifactId> + <version>${spark.version}</version> + </dependency> + <dependency> + <groupId>org.apache.kafka</groupId> + <artifactId>kafka_2.10</artifactId> + <version>0.10.1.0</version> + <exclusions> + <exclusion> + <groupId>com.sun.jdmk</groupId> + <artifactId>jmxtools</artifactId> + </exclusion> + <exclusion> + <groupId>com.sun.jmx</groupId> + <artifactId>jmxri</artifactId> + </exclusion> + <exclusion> + <groupId>javax.mail</groupId> + <artifactId>mail</artifactId> + </exclusion> + <exclusion> + <groupId>javax.jms</groupId> + <artifactId>jmx</artifactId> + </exclusion> + <exclusion> + <groupId>javax.jms</groupId> + <artifactId>jms</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.kafka</groupId> + <artifactId>kafka-clients</artifactId> + <version>0.10.1.0</version> + </dependency> + <dependency> + <groupId>org.apache.kafka</groupId> + <artifactId>connect-json</artifactId> + <version>0.10.1.0</version> + </dependency> + <dependency> + <groupId>org.apache.spark</groupId> + <artifactId>spark-streaming-kafka_2.10</artifactId> + <version>1.6.3</version> + </dependency> + <dependency> + <groupId>org.apache.phoenix</groupId> + <artifactId>phoenix-spark</artifactId> + <version>4.10.0-HBase-1.1</version> + </dependency> + <dependency> + <groupId>org.apache.ambari</groupId> + <artifactId>ambari-metrics-common</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>4.2.5</version> + </dependency> + <dependency> + <groupId>org.scala-lang</groupId> + <artifactId>scala-library</artifactId> + <version>${scala.version}</version> + </dependency> + <dependency> + <groupId>org.apache.spark</groupId> + <artifactId>spark-core_${scala.binary.version}</artifactId> + <version>${spark.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.spark</groupId> + <artifactId>spark-mllib_${scala.binary.version}</artifactId> + <version>${spark.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.hadoop</groupId> + <artifactId>hadoop-common</artifactId> + <version>${hadoop.version}</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>commons-el</groupId> + <artifactId>commons-el</artifactId> + </exclusion> + <exclusion> + <groupId>tomcat</groupId> + <artifactId>jasper-runtime</artifactId> + </exclusion> + <exclusion> + <groupId>tomcat</groupId> + <artifactId>jasper-compiler</artifactId> + </exclusion> + <exclusion> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jsp-2.1-jetty</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.scalatest</groupId> + <artifactId>scalatest_2.12</artifactId> + <version>3.0.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.dropwizard</groupId> + <artifactId>dropwizard-core</artifactId> + <version>${dropwizard.version}</version> + <exclusions> + <exclusion> + <groupId>org.glassfish.hk2.external</groupId> + <artifactId>javax.inject</artifactId> + </exclusion> + <exclusion> + <groupId>org.glassfish.hk2.external</groupId> + <artifactId>aopalliance-repackaged</artifactId> + </exclusion> + <exclusion> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + </exclusion> + <exclusion> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-access</artifactId> + </exclusion> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>log4j-over-slf4j</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.17</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.7.21</version> + </dependency> + <dependency> + <groupId>io.dropwizard</groupId> + <artifactId>dropwizard-testing</artifactId> + <version>${dropwizard.version}</version> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.glassfish.hk2.external</groupId> + <artifactId>javax.inject</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>joda-time</groupId> + <artifactId>joda-time</artifactId> + <version>2.9.4</version> + </dependency> + <dependency> + <groupId>org.joda</groupId> + <artifactId>joda-convert</artifactId> + <version>1.8.1</version> + </dependency> + <dependency> + <groupId>com.google.inject</groupId> + <artifactId>guice</artifactId> + <version>4.1.0</version> + </dependency> + <dependency> + <groupId>com.google.inject.extensions</groupId> + <artifactId>guice-multibindings</artifactId> + <version>4.1.0</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.module</groupId> + <artifactId>jackson-module-scala_2.12</artifactId> + <version>${jackson.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.datatype</groupId> + <artifactId>jackson-datatype-jdk8</artifactId> + <version>${jackson.version}</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>21.0</version> + <scope>test</scope> + </dependency> + </dependencies> </project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/resources/config.yml ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/resources/config.yml b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/resources/config.yml new file mode 100644 index 0000000..9ca9e95 --- /dev/null +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/resources/config.yml @@ -0,0 +1,12 @@ +server: + applicationConnectors: + - type: http + port: 9999 + adminConnectors: + - type: http + port: 9990 + requestLog: + type: external + +logging: + type: external http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/AnomalyDetectionApp.scala ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/AnomalyDetectionApp.scala b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/AnomalyDetectionApp.scala new file mode 100644 index 0000000..2cf0fc5 --- /dev/null +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/AnomalyDetectionApp.scala @@ -0,0 +1,69 @@ +/** + * 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.ambari.metrics.adservice.app + +import javax.ws.rs.Path +import javax.ws.rs.container.{ContainerRequestFilter, ContainerResponseFilter} + +import org.apache.ambari.metrics.adservice.app.GuiceInjector.{withInjector, wrap} +import org.glassfish.jersey.filter.LoggingFilter + +import com.codahale.metrics.health.HealthCheck +import com.fasterxml.jackson.databind.{ObjectMapper, SerializationFeature} +import com.fasterxml.jackson.datatype.joda.JodaModule +import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider +import com.fasterxml.jackson.module.scala.DefaultScalaModule +import io.dropwizard.Application +import io.dropwizard.setup.Environment + +class AnomalyDetectionApp extends Application[AnomalyDetectionAppConfig] { + override def getName = "anomaly-detection-service" + + override def run(t: AnomalyDetectionAppConfig, env: Environment): Unit = { + configure(t, env) + } + + def configure(config: AnomalyDetectionAppConfig, env: Environment) { + withInjector(new AnomalyDetectionAppModule(config, env)) { injector => + injector.instancesWithAnnotation(classOf[Path]).foreach { r => env.jersey().register(r) } + injector.instancesOfType(classOf[HealthCheck]).foreach { h => env.healthChecks.register(h.getClass.getName, h) } + injector.instancesOfType(classOf[ContainerRequestFilter]).foreach { f => env.jersey().register(f) } + injector.instancesOfType(classOf[ContainerResponseFilter]).foreach { f => env.jersey().register(f) } + } + env.jersey.register(jacksonJaxbJsonProvider) + env.jersey.register(new LoggingFilter) + } + + private def jacksonJaxbJsonProvider: JacksonJaxbJsonProvider = { + val provider = new JacksonJaxbJsonProvider() + val objectMapper = new ObjectMapper() + objectMapper.registerModule(DefaultScalaModule) + objectMapper.registerModule(new JodaModule) + objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false) + objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false) + objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) + objectMapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, true) + provider.setMapper(objectMapper) + provider + } +} + + +object AnomalyDetectionApp { + def main(args: Array[String]): Unit = new AnomalyDetectionApp().run(args: _*) +} http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/AnomalyDetectionAppConfig.scala ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/AnomalyDetectionAppConfig.scala b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/AnomalyDetectionAppConfig.scala new file mode 100644 index 0000000..9e6cc6d --- /dev/null +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/AnomalyDetectionAppConfig.scala @@ -0,0 +1,24 @@ +package org.apache.ambari.metrics.adservice.app + +import io.dropwizard.Configuration + +/** + * 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. + */ +class AnomalyDetectionAppConfig extends Configuration { + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/AnomalyDetectionAppModule.scala ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/AnomalyDetectionAppModule.scala b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/AnomalyDetectionAppModule.scala new file mode 100644 index 0000000..338c97b --- /dev/null +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/AnomalyDetectionAppModule.scala @@ -0,0 +1,38 @@ +/** + * 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.ambari.metrics.adservice.app + +import org.apache.ambari.metrics.adservice.resource.{AnomalyResource, RootResource} +import org.apache.ambari.metrics.adservice.service.{ADQueryService, ADQueryServiceImpl} + +import com.codahale.metrics.health.HealthCheck +import com.google.inject.AbstractModule +import com.google.inject.multibindings.Multibinder +import io.dropwizard.setup.Environment + +class AnomalyDetectionAppModule(config: AnomalyDetectionAppConfig, env: Environment) extends AbstractModule { + override def configure() { + bind(classOf[AnomalyDetectionAppConfig]).toInstance(config) + bind(classOf[Environment]).toInstance(env) + val healthCheckBinder = Multibinder.newSetBinder(binder(), classOf[HealthCheck]) + healthCheckBinder.addBinding().to(classOf[DefaultHealthCheck]) + bind(classOf[AnomalyResource]) + bind(classOf[RootResource]) + bind(classOf[ADQueryService]).to(classOf[ADQueryServiceImpl]) + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/DefaultHealthCheck.scala ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/DefaultHealthCheck.scala b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/DefaultHealthCheck.scala new file mode 100644 index 0000000..c36e8d2 --- /dev/null +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/DefaultHealthCheck.scala @@ -0,0 +1,25 @@ +/** + * 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.ambari.metrics.adservice.app + +import com.codahale.metrics.health.HealthCheck +import com.codahale.metrics.health.HealthCheck.Result + +class DefaultHealthCheck extends HealthCheck { + override def check(): Result = Result.healthy() +} http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/GuiceInjector.scala ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/GuiceInjector.scala b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/GuiceInjector.scala new file mode 100644 index 0000000..37da5f9 --- /dev/null +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/app/GuiceInjector.scala @@ -0,0 +1,56 @@ +/** + * 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.ambari.metrics.adservice.app + +import java.lang.annotation.Annotation + +import com.google.inject.{Guice, Injector, Module, TypeLiteral} + +import scala.collection.JavaConversions._ +import scala.language.implicitConversions +import scala.reflect._ + +object GuiceInjector { + + def withInjector(modules: Module*)(fn: (Injector) => Unit) = { + val injector = Guice.createInjector(modules.toList: _*) + fn(injector) + } + + implicit def wrap(injector: Injector): InjectorWrapper = new InjectorWrapper(injector) +} + +class InjectorWrapper(injector: Injector) { + def instancesWithAnnotation[T <: Annotation](annotationClass: Class[T]): List[AnyRef] = { + injector.getAllBindings.filter { case (k, v) => + !k.getTypeLiteral.getRawType.getAnnotationsByType[T](annotationClass).isEmpty + }.map { case (k, v) => injector.getInstance(k).asInstanceOf[AnyRef] }.toList + } + + def instancesOfType[T: ClassTag](typeClass: Class[T]): List[T] = { + injector.findBindingsByType(TypeLiteral.get(classTag[T].runtimeClass)).map { b => + injector.getInstance(b.getKey).asInstanceOf[T] + }.toList + } + + def dumpBindings(): Unit = { + injector.getBindings.keySet() foreach { k => + println(s"bind key = ${k.toString}") + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/common/PhoenixQueryConstants.scala ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/common/PhoenixQueryConstants.scala b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/common/PhoenixQueryConstants.scala index 5e90d2b..17173ec 100644 --- a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/common/PhoenixQueryConstants.scala +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/common/PhoenixQueryConstants.scala @@ -72,7 +72,7 @@ object PhoenixQueryConstants { "METHOD_NAME VARCHAR, " + "METHOD_TYPE VARCHAR, " + "PARAMETERS VARCHAR " + - "SNAPSHOT_TIME UNSIGNED LONG NOT NULL " + "SNAPSHOT_TIME UNSIGNED LONG NOT NULL " + "CONSTRAINT pk PRIMARY KEY (METRIC_UUID, METHOD_NAME)) " + "DATA_BLOCK_ENCODING='FAST_DIFF', IMMUTABLE_ROWS=true, COMPRESSION='SNAPPY'" http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/resource/AnomalyResource.scala ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/resource/AnomalyResource.scala b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/resource/AnomalyResource.scala new file mode 100644 index 0000000..fb9921a --- /dev/null +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/resource/AnomalyResource.scala @@ -0,0 +1,35 @@ +/** + * 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.ambari.metrics.adservice.resource + +import javax.ws.rs.{GET, Path, Produces} +import javax.ws.rs.core.Response +import javax.ws.rs.core.MediaType.APPLICATION_JSON + +import org.joda.time.DateTime + +@Path("/topNAnomalies") +class AnomalyResource { + + @GET + @Produces(Array(APPLICATION_JSON)) + def default: Response = { + Response.ok.entity(Map("message" -> "Anomaly Detection Service!", + "today" -> DateTime.now.toString("MM-dd-yyyy hh:mm"))).build() + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/resource/RootResource.scala ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/resource/RootResource.scala b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/resource/RootResource.scala new file mode 100644 index 0000000..b92a145 --- /dev/null +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/resource/RootResource.scala @@ -0,0 +1,35 @@ +/** + * 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.ambari.metrics.adservice.resource + +import javax.ws.rs.{GET, Path, Produces} +import javax.ws.rs.core.Response +import javax.ws.rs.core.MediaType.APPLICATION_JSON + +import org.joda.time.DateTime + +@Path("/") +class RootResource { + + @Produces(Array(APPLICATION_JSON)) + @GET + def default: Response = { + Response.ok.entity(Map("name" -> "anomaly-detection-service", "today" -> DateTime.now.toString("MM-dd-yyyy hh:mm"))).build() + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/service/ADQueryService.scala ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/service/ADQueryService.scala b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/service/ADQueryService.scala new file mode 100644 index 0000000..0161166 --- /dev/null +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/service/ADQueryService.scala @@ -0,0 +1,22 @@ +/** + * 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.ambari.metrics.adservice.service + +trait ADQueryService { + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/service/ADQueryServiceImpl.scala ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/service/ADQueryServiceImpl.scala b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/service/ADQueryServiceImpl.scala new file mode 100644 index 0000000..fe00f58 --- /dev/null +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/main/scala/org/apache/ambari/metrics/adservice/service/ADQueryServiceImpl.scala @@ -0,0 +1,22 @@ +/** + * 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.ambari.metrics.adservice.service + +class ADQueryServiceImpl extends ADQueryService { + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/app/DefaultADResourceSpecTest.scala ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/app/DefaultADResourceSpecTest.scala b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/app/DefaultADResourceSpecTest.scala new file mode 100644 index 0000000..c088855 --- /dev/null +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/app/DefaultADResourceSpecTest.scala @@ -0,0 +1,54 @@ +/** + * 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.ambari.metrics.adservice.app + +import javax.ws.rs.client.Client +import javax.ws.rs.core.MediaType.APPLICATION_JSON + +import org.apache.ambari.metrics.adservice.app.DropwizardAppRuleHelper.withAppRunning +import org.glassfish.jersey.client.{ClientConfig, JerseyClientBuilder} +import org.glassfish.jersey.client.ClientProperties.{CONNECT_TIMEOUT, READ_TIMEOUT} +import org.glassfish.jersey.filter.LoggingFilter +import org.glassfish.jersey.jaxb.internal.XmlJaxbElementProvider +import org.joda.time.DateTime +import org.scalatest.{FunSpec, Matchers} + +import com.google.common.io.Resources + +class DefaultADResourceSpecTest extends FunSpec with Matchers { + + describe("/topNAnomalies") { + it("Must return default message") { + withAppRunning(classOf[AnomalyDetectionApp], Resources.getResource("config.yml").getPath) { rule => + val json = client.target(s"http://localhost:${rule.getLocalPort}/topNAnomalies") + .request().accept(APPLICATION_JSON).buildGet().invoke(classOf[String]) + val now = DateTime.now.toString("MM-dd-yyyy hh:mm") + assert(json == "{\"message\":\"Anomaly Detection Service!\"," + "\"today\":\"" + now + "\"}") + } + } + } + + def client: Client = { + val config = new ClientConfig() + config.register(classOf[LoggingFilter]) + config.register(classOf[XmlJaxbElementProvider.App]) + config.property(CONNECT_TIMEOUT, 5000) + config.property(READ_TIMEOUT, 10000) + JerseyClientBuilder.createClient(config) + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/app/DropwizardAppRuleHelper.scala ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/app/DropwizardAppRuleHelper.scala b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/app/DropwizardAppRuleHelper.scala new file mode 100644 index 0000000..6017bb4 --- /dev/null +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/app/DropwizardAppRuleHelper.scala @@ -0,0 +1,39 @@ +/** + * 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.ambari.metrics.adservice.app + +import org.junit.runner.Description + +import io.dropwizard.Configuration +import io.dropwizard.testing.ConfigOverride +import io.dropwizard.testing.junit.DropwizardAppRule + +import scala.collection.mutable + +object DropwizardAppRuleHelper { + + def withAppRunning[C <: Configuration](serviceClass: Class[_ <: io.dropwizard.Application[C]], + configPath: String, configOverrides: ConfigOverride*) + (fn: (DropwizardAppRule[C]) => Unit) { + val overrides = new mutable.ListBuffer[ConfigOverride] + configOverrides.foreach { o => overrides += o } + val rule = new DropwizardAppRule(serviceClass, configPath, overrides.toList: _*) + rule.apply(() => fn(rule), Description.EMPTY).evaluate() + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/app/DropwizardResourceTestRuleHelper.scala ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/app/DropwizardResourceTestRuleHelper.scala b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/app/DropwizardResourceTestRuleHelper.scala new file mode 100644 index 0000000..f896db4 --- /dev/null +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/app/DropwizardResourceTestRuleHelper.scala @@ -0,0 +1,33 @@ +/** + * 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.ambari.metrics.adservice.app + +import org.junit.runner.Description + +import io.dropwizard.testing.junit.ResourceTestRule + +object DropwizardResourceTestRuleHelper { + def withResourceTestRule(configBlock: (ResourceTestRule.Builder) => Unit)(testBlock: (ResourceTestRule) => Unit) { + val builder = new ResourceTestRule.Builder() + configBlock(builder) + val rule = builder.build() + rule.apply(() => { + testBlock(rule) + }, Description.EMPTY).evaluate() + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/common/ADManagerConfigurationTest.scala ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/common/ADManagerConfigurationTest.scala b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/common/ADManagerConfigurationTest.scala index 535dc9e..40b9d6a 100644 --- a/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/common/ADManagerConfigurationTest.scala +++ b/ambari-metrics/ambari-metrics-anomaly-detection-service/src/test/scala/org/apache/ambari/metrics/adservice/common/ADManagerConfigurationTest.scala @@ -1,3 +1,20 @@ +/** + * 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.ambari.metrics.adservice.common import org.scalatest.FlatSpec http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/ambari-metrics-common/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-common/pom.xml b/ambari-metrics/ambari-metrics-common/pom.xml index e868557..de49235 100644 --- a/ambari-metrics/ambari-metrics-common/pom.xml +++ b/ambari-metrics/ambari-metrics-common/pom.xml @@ -63,7 +63,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> - <version>2.3</version> + <version>3.1.0</version> <executions> <!-- Run shade goal on package phase --> <execution> @@ -124,6 +124,16 @@ <shadedPattern>org.apache.hadoop.metrics2.sink.relocated.apache.http</shadedPattern> </relocation> </relocations> + <filters> + <filter> + <artifact>*:*</artifact> + <excludes> + <exclude>META-INF/*.SF</exclude> + <exclude>META-INF/*.DSA</exclude> + <exclude>META-INF/*.RSA</exclude> + </excludes> + </filter> + </filters> </configuration> </execution> </executions> http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-metrics/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-metrics/pom.xml b/ambari-metrics/pom.xml index fb2997a..4848084 100644 --- a/ambari-metrics/pom.xml +++ b/ambari-metrics/pom.xml @@ -280,6 +280,7 @@ <exclude>derby.log</exclude> <exclude>**/*.nuspec</exclude> <exclude>**/*.json</exclude> + <exclude>**/out</exclude> </excludes> </configuration> <executions> http://git-wip-us.apache.org/repos/asf/ambari/blob/67524d39/ambari-utility/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-utility/pom.xml b/ambari-utility/pom.xml index 1e86d40..1cc4b44 100644 --- a/ambari-utility/pom.xml +++ b/ambari-utility/pom.xml @@ -81,8 +81,8 @@ <artifactId>maven-compiler-plugin</artifactId> <version>3.2</version> <configuration> - <source>1.7</source> - <target>1.7</target> + <source>1.8</source> + <target>1.8</target> <useIncrementalCompilation>false</useIncrementalCompilation> </configuration> </plugin>