Skip to content

Commit

Permalink
[HWKMETRICS-683] Initial work for the vert.x conversion using the fra…
Browse files Browse the repository at this point in the history
…mework from Hawkular Commons.
  • Loading branch information
Stefan Negrea committed Aug 3, 2017
1 parent 69eeb41 commit 85f1659
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 2 deletions.
88 changes: 88 additions & 0 deletions api/metrics-api-jaxrs/pom.xml
Expand Up @@ -123,6 +123,48 @@
<version>${version.org.infinispan.wildfly}</version>
</dependency>

<dependency>
<groupId>org.hawkular.commons</groupId>
<artifactId>hawkular-rest-api</artifactId>
<version>${version.org.hawkular.commons}</version>
</dependency>

<dependency>
<groupId>org.hawkular.commons</groupId>
<artifactId>hawkular-server</artifactId>
<version>${version.org.hawkular.commons}</version>
</dependency>

<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
<version>${version.io.vertx}</version>
</dependency>

<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
<version>${version.io.vertx}</version>
</dependency>

<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-rx-java</artifactId>
<version>${version.io.vertx}</version>
</dependency>

<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
<version>4.1.8.Final</version>
</dependency>

<!-- documentation -->
<dependency>
<groupId>io.swagger</groupId>
Expand Down Expand Up @@ -151,6 +193,24 @@
<build>
<finalName>hawkular-metric-rest</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${version.org.apache.maven.plugins.maven-jar-plugin}</version>
<configuration>
<archive>
<index>true</index>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Implementation-Vendor-Id>org.hawkular.metrics</Implementation-Vendor-Id>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>

<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
Expand Down Expand Up @@ -183,6 +243,34 @@
</webResources>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<mainClass>org.hawkular.HawkularServer</mainClass>
<classpathScope>compile</classpathScope>
<arguments>
<argument>-cp</argument>
<argument>target/dependency/*</argument>
</arguments>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>install-hawkular-netty-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
@@ -0,0 +1,48 @@
/*
* Copyright 2014-2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hawkular.metrics.api;

import java.util.concurrent.ExecutorService;

import org.hawkular.commons.log.MsgLogger;
import org.hawkular.commons.log.MsgLogging;
import org.hawkular.commons.properties.HawkularProperties;
import org.hawkular.handlers.BaseApplication;

public class MetricsApp implements BaseApplication {
private static final MsgLogger log = MsgLogging.getMsgLogger(MetricsApp.class);
private static final String BASE_URL = "hawkular-merics.base-url";
private static final String BASE_URL_DEFAULT = "/hawkular/metrics";

ExecutorService executor;
String baseUrl = HawkularProperties.getProperty(BASE_URL, BASE_URL_DEFAULT);

@Override
public void start() {
log.infof("Metrics app started on [ %s ] ", baseUrl());
}

@Override
public void stop() {
log.infof("Metrics app stopped", baseUrl());
}

@Override
public String baseUrl() {
return baseUrl;
}
}
@@ -0,0 +1,51 @@
/*
* Copyright 2014-2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hawkular.metrics.api.handler;

import java.util.Date;
import java.util.Map;

import org.hawkular.handlers.RestEndpoint;
import org.hawkular.handlers.RestHandler;
import org.hawkular.metrics.api.JsonUtil;
import org.hawkular.metrics.api.jaxrs.util.StringValue;

import io.swagger.annotations.ApiOperation;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
import io.vertx.rx.java.ObservableHandler;
import io.vertx.rx.java.RxHelper;

/**
* @author Stefan Negrea
*/
@RestEndpoint(path = "/ping")
public class PingHandler implements RestHandler {

@Override
public void initRoutes(String baseUrl, Router router) {
router.get(baseUrl + "/ping").handler(ping().toHandler());
}

@ApiOperation(value = "Returns the current time and serves to check for the availability of the api.", response =
Map.class)
public ObservableHandler<RoutingContext> ping() {
ObservableHandler<RoutingContext> oh = RxHelper.observableHandler(true);
oh.subscribe(ctx -> ctx.response().end(JsonUtil.toJson(new StringValue(new Date().toString()))));
return oh;
}
}
19 changes: 19 additions & 0 deletions api/metrics-api-jaxrs/src/main/resources/hawkular.properties
@@ -0,0 +1,19 @@
#
# Copyright 2014-2017 Red Hat, Inc. and/or its affiliates
# and other contributors as indicated by the @author tags.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Internal configuration registration, used to provide default values
test = 1
12 changes: 10 additions & 2 deletions pom.xml
Expand Up @@ -99,7 +99,8 @@
<!-- Dependencies versions -->
<version.org.cassalog>0.4.2</version.org.cassalog>
<version.org.hawkular.alerts>1.7.0.Final</version.org.hawkular.alerts>
<version.org.hawkular.commons>0.9.6.Final</version.org.hawkular.commons>
<version.org.hawkular.commons>0.9.7.Final-SRC-revision-7541b05de8deb62bfef09770cc29cf4b67979c1f</version.org.hawkular.commons>
<!--version.org.hawkular.commons>0.9.7.Final-SNAPSHOT</version.org.hawkular.commons-->
<version.javax.enterprise.cdi-api>1.2</version.javax.enterprise.cdi-api>
<version.joda-time>2.9.5</version.joda-time>
<version.logback>1.1.3</version.logback>
Expand All @@ -123,7 +124,7 @@
<version.commons-cli.commons-cli>1.2</version.commons-cli.commons-cli>
<version.commons-codec>1.10</version.commons-codec>
<version.io.fabric8>2.2.16</version.io.fabric8>
<version.io.netty>4.0.47.Final</version.io.netty>
<version.io.netty>4.1.8.Final</version.io.netty>
<version.io.vertx.vertx-core>3.3.1</version.io.vertx.vertx-core>
<version.maven-surefire-report-plugin>2.6</version.maven-surefire-report-plugin>
<version.org.acplt.oncrpc>1.0.7</version.org.acplt.oncrpc>
Expand All @@ -135,6 +136,7 @@
<version.org.codehaus.mojo.dashboard-maven-plugin>1.0.0-beta-1</version.org.codehaus.mojo.dashboard-maven-plugin>
<version.org.jmxtrans.embedded.embedded-jmxtrans>1.0.15</version.org.jmxtrans.embedded.embedded-jmxtrans>
<version.fi.iki.yak.compression-gorilla>2.0.3</version.fi.iki.yak.compression-gorilla>
<version.io.vertx>3.4.1</version.io.vertx>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -288,6 +290,12 @@
* or consider adding the plugin to hawkular-parent
-->

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
</plugin>

</plugins>
</pluginManagement>
<plugins>
Expand Down

0 comments on commit 85f1659

Please sign in to comment.