You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sirona.apache.org by rm...@apache.org on 2015/11/01 07:19:20 UTC
svn commit: r1711716 [1/2] - in /incubator/sirona/trunk: ./
agent/performance/web/src/main/java/org/apache/sirona/web/lifecycle/
agent/performance/web/src/test/java/org/apache/sirona/test/web/
agent/store/ agent/store/cube/src/main/java/org/apache/siro...
Author: rmannibucau
Date: Sun Nov 1 06:19:18 2015
New Revision: 1711716
URL: http://svn.apache.org/viewvc?rev=1711716&view=rev
Log:
SIRONA-45 migrating to johnzon (replace jackson), SIRONA-46 adding websocket protocol for collection of data (distributed mode), fixing few tests
Added:
incubator/sirona/trunk/agent/store/websocket-client/
incubator/sirona/trunk/agent/store/websocket-client/pom.xml
incubator/sirona/trunk/agent/store/websocket-client/src/
incubator/sirona/trunk/agent/store/websocket-client/src/main/
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketClient.java
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketClientBuilder.java
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketCounterDataStore.java
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketDataStoreFactory.java
- copied, changed from r1711709, incubator/sirona/trunk/agent/store/graphite/src/main/java/org/apache/sirona/graphite/GraphiteDataStoreFactory.java
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketGaugeDataStore.java
- copied, changed from r1711709, incubator/sirona/trunk/agent/store/graphite/src/main/java/org/apache/sirona/graphite/GraphiteGaugeDataStore.java
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketNodeStatusDataStore.java
- copied, changed from r1711709, incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeNodeStatusDataStore.java
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSCounter.java
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSDomain.java
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSGauge.java
incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSValidation.java
incubator/sirona/trunk/server/websocket-server/
incubator/sirona/trunk/server/websocket-server/pom.xml
incubator/sirona/trunk/server/websocket-server/src/
incubator/sirona/trunk/server/websocket-server/src/main/
incubator/sirona/trunk/server/websocket-server/src/main/java/
incubator/sirona/trunk/server/websocket-server/src/main/java/org/
incubator/sirona/trunk/server/websocket-server/src/main/java/org/apache/
incubator/sirona/trunk/server/websocket-server/src/main/java/org/apache/sirona/
incubator/sirona/trunk/server/websocket-server/src/main/java/org/apache/sirona/websocket/
incubator/sirona/trunk/server/websocket-server/src/main/java/org/apache/sirona/websocket/server/
incubator/sirona/trunk/server/websocket-server/src/main/java/org/apache/sirona/websocket/server/CounterEndpoint.java
incubator/sirona/trunk/server/websocket-server/src/main/java/org/apache/sirona/websocket/server/GaugeEndpoint.java
incubator/sirona/trunk/server/websocket-server/src/main/java/org/apache/sirona/websocket/server/ValidationEndpoint.java
incubator/sirona/trunk/server/websocket-server/src/test/
incubator/sirona/trunk/server/websocket-server/src/test/java/
incubator/sirona/trunk/server/websocket-server/src/test/java/org/
incubator/sirona/trunk/server/websocket-server/src/test/java/org/apache/
incubator/sirona/trunk/server/websocket-server/src/test/java/org/apache/sirona/
incubator/sirona/trunk/server/websocket-server/src/test/java/org/apache/sirona/websocket/
incubator/sirona/trunk/server/websocket-server/src/test/java/org/apache/sirona/websocket/WebSocketTest.java
incubator/sirona/trunk/server/websocket-server/src/test/resources/
incubator/sirona/trunk/server/websocket-server/src/test/resources/arquillian.xml
- copied, changed from r1711709, incubator/sirona/trunk/server/reporting/reporting-webapp-full/src/test/resources/arquillian.xml
incubator/sirona/trunk/server/websocket-server/src/test/resources/sirona.properties
- copied, changed from r1711709, incubator/sirona/trunk/server/reporting/reporting-webapp-full/src/test/resources/sirona.properties
Modified:
incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/lifecycle/LazyJspMonitoringFilterActivator.java
incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/JspMonitoringTest.java
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeCounterDataStore.java
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/MapBuilder.java
incubator/sirona/trunk/agent/store/graphite/src/test/java/org/apache/sirona/graphite/GraphiteTest.java
incubator/sirona/trunk/agent/store/graphite/src/test/java/org/apache/sirona/graphite/GraphiteTestBase.java
incubator/sirona/trunk/agent/store/graphite/src/test/java/org/apache/sirona/graphite/server/GraphiteMockServer.java
incubator/sirona/trunk/agent/store/pom.xml
incubator/sirona/trunk/api/src/main/java/org/apache/sirona/math/M2AwareStatisticalSummary.java
incubator/sirona/trunk/core/src/test/java/org/apache/sirona/counters/ClearAfterCollectTest.java
incubator/sirona/trunk/pom.xml
incubator/sirona/trunk/server/collector/pom.xml
incubator/sirona/trunk/server/collector/src/main/java/org/apache/sirona/collector/server/Collector.java
incubator/sirona/trunk/server/collector/src/main/java/org/apache/sirona/collector/server/Event.java
incubator/sirona/trunk/server/collector/src/test/java/org/apache/sirona/collector/server/CubeDataStoreCompatibilityTest.java
incubator/sirona/trunk/server/collector/src/test/java/org/apache/sirona/collector/server/HttpCollectorTest.java
incubator/sirona/trunk/server/pom.xml
incubator/sirona/trunk/server/reporting/pom.xml
incubator/sirona/trunk/server/reporting/reporting-ui/pom.xml
incubator/sirona/trunk/server/reporting/reporting-ui/src/test/resources/META-INF/spring-context.xml
incubator/sirona/trunk/server/reporting/reporting-webapp-full/pom.xml
incubator/sirona/trunk/server/reporting/reporting-webapp-full/src/main/resources/applicationContext.xml
incubator/sirona/trunk/server/reporting/reporting-webapp-full/src/test/java/org/apache/sirona/reporting/template/WebTest.java
incubator/sirona/trunk/server/reporting/reporting-webapp/pom.xml
incubator/sirona/trunk/server/reporting/reporting-webapp/src/main/webapp/WEB-INF/openejb-jar.xml
incubator/sirona/trunk/server/store/cassandra/src/main/java/org/apache/sirona/cassandra/collector/status/CassandraCollectorNodeStatusDataStore.java
incubator/sirona/trunk/store/memory/src/main/java/org/apache/sirona/store/memory/counter/BatchCounterDataStore.java
Modified: incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/lifecycle/LazyJspMonitoringFilterActivator.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/lifecycle/LazyJspMonitoringFilterActivator.java?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/lifecycle/LazyJspMonitoringFilterActivator.java (original)
+++ incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/lifecycle/LazyJspMonitoringFilterActivator.java Sun Nov 1 06:19:18 2015
@@ -35,7 +35,7 @@ public class LazyJspMonitoringFilterActi
public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException {
if (defaultFactory == null) {
synchronized (this) {
- if (defaultFactory == defaultFactory) {
+ if (defaultFactory == null) {
defaultFactory = JspFactory.getDefaultFactory();
if (!JspPerformanceFactory.class.isInstance(defaultFactory)) {
wrapper = new JspPerformanceFactory(defaultFactory);
Modified: incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/JspMonitoringTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/JspMonitoringTest.java?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/JspMonitoringTest.java (original)
+++ incubator/sirona/trunk/agent/performance/web/src/test/java/org/apache/sirona/test/web/JspMonitoringTest.java Sun Nov 1 06:19:18 2015
@@ -101,7 +101,7 @@ public class JspMonitoringTest {
assertEquals("Hello", newClient().getPage(testUrl + "?ignoredQuery=yes&ofcourse=itis").getWebResponse().getContentAsString());
assertFalse(Repository.INSTANCE.counters().isEmpty());
- final Counter counter = Repository.INSTANCE.counters().iterator().next();
+ final Counter counter = Repository.INSTANCE.getCounter(new Counter.Key(Role.JSP, "/ajsp/test.jsp"));
assertEquals(Role.JSP, counter.getKey().getRole());
assertEquals(url.getPath() + "test.jsp", counter.getKey().getName());
assertEquals(3, counter.getHits());
Modified: incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeCounterDataStore.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeCounterDataStore.java?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeCounterDataStore.java (original)
+++ incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeCounterDataStore.java Sun Nov 1 06:19:18 2015
@@ -24,7 +24,7 @@ import java.util.Collection;
public class CubeCounterDataStore extends BatchCounterDataStore
{
- private final Cube cube = IoCs.findOrCreateInstance(CubeBuilder.class).build();
+ protected final Cube cube = IoCs.findOrCreateInstance(CubeBuilder.class).build();
@Override
protected synchronized void pushCountersByBatch(final Collection<Counter> instances) {
Modified: incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/MapBuilder.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/MapBuilder.java?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/MapBuilder.java (original)
+++ incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/MapBuilder.java Sun Nov 1 06:19:18 2015
@@ -23,7 +23,13 @@ public class MapBuilder {
private final Map<String, Object> map = new HashMap<String, Object>();
public MapBuilder add(final String key, final Object value) {
- map.put(key, value);
+ if (Double.class.isInstance(value)) {
+ if (!Double.isNaN(Double.class.cast(value))) { // not a number so skipping
+ map.put(key, value);
+ }
+ } else {
+ map.put(key, value);
+ }
return this;
}
Modified: incubator/sirona/trunk/agent/store/graphite/src/test/java/org/apache/sirona/graphite/GraphiteTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/graphite/src/test/java/org/apache/sirona/graphite/GraphiteTest.java?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/store/graphite/src/test/java/org/apache/sirona/graphite/GraphiteTest.java (original)
+++ incubator/sirona/trunk/agent/store/graphite/src/test/java/org/apache/sirona/graphite/GraphiteTest.java Sun Nov 1 06:19:18 2015
@@ -55,7 +55,7 @@ public class GraphiteTest extends Graphi
}
{ // gauges
- Thread.sleep(400);
+ Thread.sleep(450);
final Collection<String> gauges = extract(messages(), "gauge");
Modified: incubator/sirona/trunk/agent/store/graphite/src/test/java/org/apache/sirona/graphite/GraphiteTestBase.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/graphite/src/test/java/org/apache/sirona/graphite/GraphiteTestBase.java?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/store/graphite/src/test/java/org/apache/sirona/graphite/GraphiteTestBase.java (original)
+++ incubator/sirona/trunk/agent/store/graphite/src/test/java/org/apache/sirona/graphite/GraphiteTestBase.java Sun Nov 1 06:19:18 2015
@@ -32,8 +32,11 @@ public abstract class GraphiteTestBase {
@Before
public void startGraphite() throws IOException {
- Repository.INSTANCE.clearCounters();
server = new GraphiteMockServer(Integer.getInteger("collector.server.port", 1234)).start();
+ if (System.getProperty("org.apache.sirona.graphite.GraphiteBuilder.port", "").isEmpty()) {
+ System.setProperty("org.apache.sirona.graphite.GraphiteBuilder.port", Integer.toString(server.getPort()));
+ }
+ Repository.INSTANCE.clearCounters();
gauges = new Gauge.LoaderHelper(false);
}
Modified: incubator/sirona/trunk/agent/store/graphite/src/test/java/org/apache/sirona/graphite/server/GraphiteMockServer.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/graphite/src/test/java/org/apache/sirona/graphite/server/GraphiteMockServer.java?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/store/graphite/src/test/java/org/apache/sirona/graphite/server/GraphiteMockServer.java (original)
+++ incubator/sirona/trunk/agent/store/graphite/src/test/java/org/apache/sirona/graphite/server/GraphiteMockServer.java Sun Nov 1 06:19:18 2015
@@ -40,6 +40,10 @@ public class GraphiteMockServer {
this.port = port;
}
+ public int getPort() {
+ return port;
+ }
+
public GraphiteMockServer start() throws IOException {
server = new ServerSocket(port);
thread = new GraphiteThread(server, messages);
Modified: incubator/sirona/trunk/agent/store/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/pom.xml?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/store/pom.xml (original)
+++ incubator/sirona/trunk/agent/store/pom.xml Sun Nov 1 06:19:18 2015
@@ -31,5 +31,6 @@
<modules>
<module>graphite</module>
<module>cube</module>
+ <module>websocket-client</module>
</modules>
</project>
Added: incubator/sirona/trunk/agent/store/websocket-client/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/websocket-client/pom.xml?rev=1711716&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/store/websocket-client/pom.xml (added)
+++ incubator/sirona/trunk/agent/store/websocket-client/pom.xml Sun Nov 1 06:19:18 2015
@@ -0,0 +1,53 @@
+<?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>
+ <artifactId>sirona-agent-store</artifactId>
+ <groupId>org.apache.sirona</groupId>
+ <version>0.3-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>sirona-websocket-client</artifactId>
+ <name>Apache Sirona Incubator :: Agent :: Store :: WebSocket</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-websocket-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sirona</groupId>
+ <artifactId>sirona-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-json_1.0_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-mapper</artifactId>
+ <version>${johnzon.version}</version>
+ </dependency>
+ </dependencies>
+</project>
Added: incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketClient.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketClient.java?rev=1711716&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketClient.java (added)
+++ incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketClient.java Sun Nov 1 06:19:18 2015
@@ -0,0 +1,183 @@
+/*
+ * 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.sirona.websocket.client;
+
+import org.apache.johnzon.mapper.Mapper;
+import org.apache.johnzon.mapper.MapperBuilder;
+import org.apache.sirona.Role;
+import org.apache.sirona.counters.Counter;
+import org.apache.sirona.status.NodeStatus;
+import org.apache.sirona.status.ValidationResult;
+import org.apache.sirona.store.gauge.BatchGaugeDataStoreAdapter;
+import org.apache.sirona.websocket.client.domain.WSCounter;
+import org.apache.sirona.websocket.client.domain.WSGauge;
+import org.apache.sirona.websocket.client.domain.WSValidation;
+
+import javax.websocket.ClientEndpointConfig;
+import javax.websocket.CloseReason;
+import javax.websocket.ContainerProvider;
+import javax.websocket.DeploymentException;
+import javax.websocket.Endpoint;
+import javax.websocket.EndpointConfig;
+import javax.websocket.Session;
+import javax.websocket.WebSocketContainer;
+import java.io.Closeable;
+import java.io.IOException;
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import static java.lang.Thread.sleep;
+import static java.util.Arrays.asList;
+import static java.util.Collections.singletonList;
+
+public class WebSocketClient implements Closeable {
+ private static final Logger LOGGER = Logger.getLogger(WebSocketClient.class.getName());
+
+ private final URI counterUri;
+ private final URI gaugeUri;
+ private final URI validationUri;
+ private final int maxSendTries;
+ private final String authorization;
+ private final WebSocketContainer container;
+ private final AtomicReference<Session> counterSession = new AtomicReference<Session>();
+ private final AtomicReference<Session> gaugeSession = new AtomicReference<Session>();
+ private final AtomicReference<Session> validationSession = new AtomicReference<Session>();
+ private final Mapper mapper = new MapperBuilder().build();
+ private final String marker;
+
+ public WebSocketClient(final int retries, final String uri, final String authorization, final String marker) {
+ this.counterUri = URI.create(uri + "/wsirona/counter");
+ this.gaugeUri = URI.create(uri + "/wsirona/gauge");
+ this.validationUri = URI.create(uri + "/wsirona/validation");
+ this.maxSendTries = 1 + Math.max(0, retries);
+ this.authorization = authorization;
+ this.marker = marker;
+ this.container = ContainerProvider.getWebSocketContainer();
+ }
+
+ public void push(final Counter counter) {
+ send(counterSession, counterUri, mapper.writeObjectAsString(new WSCounter(counter, marker)));
+ }
+
+ public void push(final Role key, final BatchGaugeDataStoreAdapter.Measure value) {
+ send(gaugeSession, gaugeUri, mapper.writeObjectAsString(new WSGauge(key, value, marker)));
+ }
+
+ public void push(final NodeStatus nodeStatus) {
+ for (final ValidationResult validation : nodeStatus.getResults()) {
+ send(validationSession, validationUri, mapper.writeObjectAsString(new WSValidation(validation, nodeStatus.getDate(), marker)));
+ }
+ }
+
+ private synchronized void send(final AtomicReference<Session> sessionRef, final URI uri, final String data) {
+ for (int i = 0; i < maxSendTries; i++) {
+ try {
+ Session session = sessionRef.get();
+ if (needsSession(session)) {
+ synchronized (this) {
+ session = sessionRef.get();
+ if (needsSession(session)) {
+ session = connection(uri);
+ if (!sessionRef.compareAndSet(null, session)) {
+ session.close();
+ session = sessionRef.get();
+ }
+ }
+ }
+ }
+
+ // sync to avoid issue on server and keep it simple for now
+ session.getBasicRemote().sendText(data);
+ return; // done :)
+ } catch (final Exception ex) { // on exception recreate the connection and retry
+ LOGGER.log(Level.SEVERE, "Can't send data, will retry if possible", ex);
+ synchronized (this) {
+ try {
+ final Session session = sessionRef.get();
+ if (session != null) {
+ sessionRef.set(null);
+ session.close(new CloseReason(CloseReason.CloseCodes.TRY_AGAIN_LATER, ex.getMessage()));
+ }
+ } catch (final IOException e) {
+ // no-op
+ } catch (final IllegalStateException e) {
+ // no-op
+ }
+ }
+
+ try { // retry but wait a little bit
+ sleep(100);
+ } catch (final InterruptedException e) {
+ Thread.interrupted();
+ }
+ }
+ }
+ throw new IllegalStateException("Can't send '" + data + "' in " + maxSendTries + " tries");
+ }
+
+ private boolean needsSession(final Session session) {
+ return session == null || !session.isOpen();
+ }
+
+ private Session connection(final URI uri) {
+ final ClientEndpointConfig config = ClientEndpointConfig.Builder.create()
+ .configurator(new ClientEndpointConfig.Configurator() {
+ @Override
+ public void beforeRequest(final Map<String, List<String>> headers) {
+ if (WebSocketClient.this.authorization != null) {
+ headers.put("Authorization", singletonList(WebSocketClient.this.authorization));
+ }
+ super.beforeRequest(headers);
+ }
+ })
+ .build();
+ for (int i = 0; i < maxSendTries; i++) {
+ try {
+ return container.connectToServer(new Endpoint() {
+ @Override
+ public void onOpen(final Session session, final EndpointConfig endpointConfig) {
+ // no-op
+ }
+ }, config, uri);
+ } catch (final DeploymentException e) {
+ throw new IllegalArgumentException(e);
+ } catch (final IOException e) {
+ // no-op: retry
+ }
+ }
+ throw new IllegalStateException("Cannot connect to " + uri);
+ }
+
+ @Override
+ public synchronized void close() {
+ for (final AtomicReference<Session> ref : asList(counterSession, gaugeSession, validationSession)) {
+ final Session s = ref.get();
+ if (s != null) {
+ try {
+ s.close();
+ } catch (final IOException e) {
+ // no-op
+ }
+ ref.set(null);
+ }
+ }
+ }
+}
Added: incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketClientBuilder.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketClientBuilder.java?rev=1711716&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketClientBuilder.java (added)
+++ incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketClientBuilder.java Sun Nov 1 06:19:18 2015
@@ -0,0 +1,59 @@
+/*
+ * 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.sirona.websocket.client;
+
+import org.apache.sirona.configuration.ioc.AutoSet;
+import org.apache.sirona.util.Localhosts;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+@AutoSet
+public class WebSocketClientBuilder {
+ private String uri;
+ private String marker;
+ private int retries;
+ private String authorization;
+ private AtomicReference<WebSocketClient> client = new AtomicReference<WebSocketClient>();
+
+ public void setMarker(final String marker) {
+ this.marker = marker;
+ }
+
+ public void setUri(final String uri) {
+ this.uri = uri;
+ }
+
+ public void setRetries(final int retries) {
+ this.retries = retries;
+ }
+
+ public void setAuthorization(final String authorization) {
+ this.authorization = authorization;
+ }
+
+ public WebSocketClient buildOrGet() {
+ WebSocketClient webSocketClient = client.get();
+ if (webSocketClient == null) {
+ webSocketClient = new WebSocketClient(retries, uri.endsWith("/") ? uri : (uri + '/'), authorization, marker == null ? Localhosts.get(): marker);
+ if (!client.compareAndSet(null, webSocketClient)) {
+ webSocketClient.close();
+ webSocketClient = client.get();
+ }
+ }
+ return webSocketClient;
+ }
+}
Added: incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketCounterDataStore.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketCounterDataStore.java?rev=1711716&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketCounterDataStore.java (added)
+++ incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketCounterDataStore.java Sun Nov 1 06:19:18 2015
@@ -0,0 +1,34 @@
+/*
+ * 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.sirona.websocket.client;
+
+import org.apache.sirona.configuration.ioc.IoCs;
+import org.apache.sirona.counters.Counter;
+import org.apache.sirona.store.memory.counter.BatchCounterDataStore;
+
+import java.util.Collection;
+
+public class WebSocketCounterDataStore extends BatchCounterDataStore {
+ private final WebSocketClient client = IoCs.findOrCreateInstance(WebSocketClientBuilder.class).buildOrGet();
+
+ @Override
+ protected void pushCountersByBatch(final Collection<Counter> instances) {
+ for (final Counter counter : instances) {
+ client.push(counter);
+ }
+ }
+}
Copied: incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketDataStoreFactory.java (from r1711709, incubator/sirona/trunk/agent/store/graphite/src/main/java/org/apache/sirona/graphite/GraphiteDataStoreFactory.java)
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketDataStoreFactory.java?p2=incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketDataStoreFactory.java&p1=incubator/sirona/trunk/agent/store/graphite/src/main/java/org/apache/sirona/graphite/GraphiteDataStoreFactory.java&r1=1711709&r2=1711716&rev=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/store/graphite/src/main/java/org/apache/sirona/graphite/GraphiteDataStoreFactory.java (original)
+++ incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketDataStoreFactory.java Sun Nov 1 06:19:18 2015
@@ -14,20 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sirona.graphite;
+package org.apache.sirona.websocket.client;
import org.apache.sirona.configuration.ioc.IoCs;
import org.apache.sirona.store.DelegateDataStoreFactory;
-import org.apache.sirona.store.status.EmptyStatuses;
import org.apache.sirona.store.memory.tracking.InMemoryPathTrackingDataStore;
-public class GraphiteDataStoreFactory extends DelegateDataStoreFactory {
- public GraphiteDataStoreFactory() {
+public class WebSocketDataStoreFactory extends DelegateDataStoreFactory {
+ public WebSocketDataStoreFactory() {
super(
- IoCs.processInstance(new GraphiteCounterDataStore()),
- IoCs.processInstance(new GraphiteGaugeDataStore()),
- new EmptyStatuses(),
- // FIXME real implementation in Graphite. olamy: not sure it's really supported
- new InMemoryPathTrackingDataStore());
+ IoCs.processInstance(new WebSocketCounterDataStore()),
+ IoCs.processInstance(new WebSocketGaugeDataStore()),
+ IoCs.processInstance(new WebSocketNodeStatusDataStore()),
+ new InMemoryPathTrackingDataStore() // TODO
+ );
}
}
Copied: incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketGaugeDataStore.java (from r1711709, incubator/sirona/trunk/agent/store/graphite/src/main/java/org/apache/sirona/graphite/GraphiteGaugeDataStore.java)
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketGaugeDataStore.java?p2=incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketGaugeDataStore.java&p1=incubator/sirona/trunk/agent/store/graphite/src/main/java/org/apache/sirona/graphite/GraphiteGaugeDataStore.java&r1=1711709&r2=1711716&rev=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/store/graphite/src/main/java/org/apache/sirona/graphite/GraphiteGaugeDataStore.java (original)
+++ incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketGaugeDataStore.java Sun Nov 1 06:19:18 2015
@@ -14,39 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sirona.graphite;
+package org.apache.sirona.websocket.client;
import org.apache.sirona.Role;
import org.apache.sirona.configuration.ioc.IoCs;
-import org.apache.sirona.store.gauge.AggregatedGaugeDataStoreAdapter;
-import org.apache.sirona.store.gauge.Value;
+import org.apache.sirona.store.gauge.BatchGaugeDataStoreAdapter;
-import java.io.IOException;
import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-public class GraphiteGaugeDataStore extends AggregatedGaugeDataStoreAdapter {
- private static final Logger LOGGER = Logger.getLogger(GraphiteGaugeDataStore.class.getName());
-
- private static final String GAUGE_PREFIX = "gauge-";
-
- private final Graphite graphite = IoCs.findOrCreateInstance(GraphiteBuilder.class).build();
+public class WebSocketGaugeDataStore extends BatchGaugeDataStoreAdapter {
+ private final WebSocketClient client = IoCs.findOrCreateInstance(WebSocketClientBuilder.class).buildOrGet();
@Override
- protected void pushAggregatedGauges(final Map<Role, Value> gauges) {
- try {
- graphite.open();
-
- final long ts = System.currentTimeMillis();
-
- for (final Map.Entry<Role, Value> gauge : gauges.entrySet()) {
- graphite.push(GAUGE_PREFIX + gauge.getKey().getName(), gauge.getValue().getMean(), ts);
- }
- } catch (final IOException e) {
- LOGGER.log(Level.SEVERE, e.getMessage(), e);
- } finally {
- graphite.close();
+ protected void pushGauges(final Map<Role, Measure> gauges) {
+ for (final Map.Entry<Role, Measure> gauge : gauges.entrySet()) {
+ client.push(gauge.getKey(), gauge.getValue());
}
}
}
Copied: incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketNodeStatusDataStore.java (from r1711709, incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeNodeStatusDataStore.java)
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketNodeStatusDataStore.java?p2=incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketNodeStatusDataStore.java&p1=incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeNodeStatusDataStore.java&r1=1711709&r2=1711716&rev=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeNodeStatusDataStore.java (original)
+++ incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/WebSocketNodeStatusDataStore.java Sun Nov 1 06:19:18 2015
@@ -14,17 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sirona.cube;
+package org.apache.sirona.websocket.client;
import org.apache.sirona.configuration.ioc.IoCs;
import org.apache.sirona.status.NodeStatus;
import org.apache.sirona.store.status.PeriodicNodeStatusDataStore;
-public class CubeNodeStatusDataStore extends PeriodicNodeStatusDataStore {
- private final Cube cube = IoCs.findOrCreateInstance(CubeBuilder.class).build();
+public class WebSocketNodeStatusDataStore extends PeriodicNodeStatusDataStore {
+ private final WebSocketClient client = IoCs.findOrCreateInstance(WebSocketClientBuilder.class).buildOrGet();
@Override
protected void reportStatus(final NodeStatus nodeStatus) {
- cube.post(cube.statusSnapshot(System.currentTimeMillis(), nodeStatus));
+ client.push(nodeStatus);
}
}
Added: incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSCounter.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSCounter.java?rev=1711716&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSCounter.java (added)
+++ incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSCounter.java Sun Nov 1 06:19:18 2015
@@ -0,0 +1,142 @@
+/*
+ * 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.sirona.websocket.client.domain;
+
+import org.apache.sirona.counters.Counter;
+
+// just to define the payload API explicitly
+// and not rely on our Counter which can evolve
+public class WSCounter extends WSDomain {
+ private String name;
+ private String roleName;
+ private String roleUnit;
+ private double secondMoment;
+ private long hits;
+ private int concurrency;
+ private double variance;
+ private double sum;
+ private double min;
+ private double max;
+ private double mean;
+
+ public WSCounter() {
+ // no-op
+ }
+
+ public WSCounter(final Counter counter, final String marker) {
+ super("counter", marker);
+ name = counter.getKey().getName();
+ roleName = counter.getKey().getRole().getName();
+ roleUnit = counter.getKey().getRole().getUnit().getName();
+ secondMoment = counter.getSecondMoment();
+ hits = counter.getHits();
+ variance = counter.getVariance();
+ sum = counter.getSum();
+ min = counter.getMin();
+ max = counter.getMax();
+ mean = counter.getMean();
+ concurrency = counter.currentConcurrency().get();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public String getRoleName() {
+ return roleName;
+ }
+
+ public void setRoleName(final String roleName) {
+ this.roleName = roleName;
+ }
+
+ public String getRoleUnit() {
+ return roleUnit;
+ }
+
+ public void setRoleUnit(final String roleUnit) {
+ this.roleUnit = roleUnit;
+ }
+
+ public int getConcurrency() {
+ return concurrency;
+ }
+
+ public void setConcurrency(final int concurrency) {
+ this.concurrency = concurrency;
+ }
+
+ public double getMean() {
+ return mean;
+ }
+
+ public void setMean(final double mean) {
+ this.mean = mean;
+ }
+
+ public double getSecondMoment() {
+ return secondMoment;
+ }
+
+ public void setSecondMoment(final double secondMoment) {
+ this.secondMoment = secondMoment;
+ }
+
+ public long getHits() {
+ return hits;
+ }
+
+ public void setHits(final long hits) {
+ this.hits = hits;
+ }
+
+ public double getVariance() {
+ return variance;
+ }
+
+ public void setVariance(final double variance) {
+ this.variance = variance;
+ }
+
+ public double getSum() {
+ return sum;
+ }
+
+ public void setSum(final double sum) {
+ this.sum = sum;
+ }
+
+ public double getMin() {
+ return min;
+ }
+
+ public void setMin(final double min) {
+ this.min = min;
+ }
+
+ public double getMax() {
+ return max;
+ }
+
+ public void setMax(final double max) {
+ this.max = max;
+ }
+}
Added: incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSDomain.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSDomain.java?rev=1711716&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSDomain.java (added)
+++ incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSDomain.java Sun Nov 1 06:19:18 2015
@@ -0,0 +1,47 @@
+/*
+ * 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.sirona.websocket.client.domain;
+
+public abstract class WSDomain {
+ private String type;
+ private String marker;
+
+ public WSDomain() {
+ // no-op
+ }
+
+ protected WSDomain(final String type, final String marker) {
+ this.type = type;
+ this.marker = marker;
+ }
+
+ public String getMarker() {
+ return marker;
+ }
+
+ public void setMarker(final String marker) {
+ this.marker = marker;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(final String type) {
+ this.type = type;
+ }
+}
Added: incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSGauge.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSGauge.java?rev=1711716&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSGauge.java (added)
+++ incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSGauge.java Sun Nov 1 06:19:18 2015
@@ -0,0 +1,71 @@
+/*
+ * 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.sirona.websocket.client.domain;
+
+import org.apache.sirona.Role;
+import org.apache.sirona.store.gauge.BatchGaugeDataStoreAdapter;
+
+public class WSGauge extends WSDomain {
+ private String roleName;
+ private String roleUnit;
+ private long time;
+ private double value;
+
+ public WSGauge() {
+ // no-op
+ }
+
+ public WSGauge(final Role key, final BatchGaugeDataStoreAdapter.Measure measure, final String marker) {
+ super("gauge", marker);
+ roleName = key.getName();
+ roleUnit = key.getUnit().getName();
+ time = measure.getTime();
+ value = measure.getValue();
+ }
+
+ public String getRoleName() {
+ return roleName;
+ }
+
+ public void setRoleName(final String roleName) {
+ this.roleName = roleName;
+ }
+
+ public String getRoleUnit() {
+ return roleUnit;
+ }
+
+ public void setRoleUnit(final String roleUnit) {
+ this.roleUnit = roleUnit;
+ }
+
+ public long getTime() {
+ return time;
+ }
+
+ public void setTime(final long time) {
+ this.time = time;
+ }
+
+ public double getValue() {
+ return value;
+ }
+
+ public void setValue(final double value) {
+ this.value = value;
+ }
+}
Added: incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSValidation.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSValidation.java?rev=1711716&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSValidation.java (added)
+++ incubator/sirona/trunk/agent/store/websocket-client/src/main/java/org/apache/sirona/websocket/client/domain/WSValidation.java Sun Nov 1 06:19:18 2015
@@ -0,0 +1,73 @@
+/*
+ * 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.sirona.websocket.client.domain;
+
+import org.apache.sirona.status.Status;
+import org.apache.sirona.status.ValidationResult;
+
+import java.util.Date;
+
+public class WSValidation extends WSDomain {
+ private Status status;
+ private String message;
+ private String name;
+ private Date date;
+
+ public WSValidation() {
+ // no-op
+ }
+
+ public WSValidation(final ValidationResult validation, final Date date, final String marker) {
+ super("validation", marker);
+ this.status = validation.getStatus();
+ this.message = validation.getMessage();
+ this.name = validation.getName();
+ this.date = date;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(final Date date) {
+ this.date = date;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(final Status status) {
+ this.status = status;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(final String message) {
+ this.message = message;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+}
Modified: incubator/sirona/trunk/api/src/main/java/org/apache/sirona/math/M2AwareStatisticalSummary.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/api/src/main/java/org/apache/sirona/math/M2AwareStatisticalSummary.java?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/api/src/main/java/org/apache/sirona/math/M2AwareStatisticalSummary.java (original)
+++ incubator/sirona/trunk/api/src/main/java/org/apache/sirona/math/M2AwareStatisticalSummary.java Sun Nov 1 06:19:18 2015
@@ -53,6 +53,9 @@ public class M2AwareStatisticalSummary i
if (String.class.isInstance(mean)) {
return Double.parseDouble(String.class.cast(mean));
}
+ if (mean == null) {
+ return Double.NaN;
+ }
throw new IllegalArgumentException(mean + " not supported");
}
Modified: incubator/sirona/trunk/core/src/test/java/org/apache/sirona/counters/ClearAfterCollectTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/core/src/test/java/org/apache/sirona/counters/ClearAfterCollectTest.java?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/core/src/test/java/org/apache/sirona/counters/ClearAfterCollectTest.java (original)
+++ incubator/sirona/trunk/core/src/test/java/org/apache/sirona/counters/ClearAfterCollectTest.java Sun Nov 1 06:19:18 2015
@@ -25,6 +25,7 @@ import org.junit.Test;
import java.util.Collection;
import java.util.LinkedList;
+import java.util.concurrent.atomic.AtomicBoolean;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -39,13 +40,17 @@ public class ClearAfterCollectTest {
@Test
public void clear() throws InterruptedException {
final LinkedList<Integer> size = new LinkedList<Integer>();
+ final AtomicBoolean measure = new AtomicBoolean();
final BatchCounterDataStore store = new BatchCounterDataStore() {
protected void pushCountersByBatch(final Collection<Counter> instance) {
+ if (!measure.get()) {
+ return;
+ }
size.add(instance.size());
}
protected int getPeriod(final String prefix) {
- return 100;
+ return 1000;
}
protected boolean isClearAfterCollect(final String prefix) {
@@ -53,8 +58,10 @@ public class ClearAfterCollectTest {
}
};
- Repository.INSTANCE.getCounter(new Counter.Key(Role.PERFORMANCES, "counter")).add(123);
- Thread.sleep(250);
+ store.getOrCreateCounter(new Counter.Key(Role.PERFORMANCES, "counter")).add(123);
+ measure.set(true);
+ Thread.sleep(2200);
+ measure.set(false);
store.shutdown();
assertTrue(size.size() >= 2);
Modified: incubator/sirona/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/pom.xml?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/pom.xml (original)
+++ incubator/sirona/trunk/pom.xml Sun Nov 1 06:19:18 2015
@@ -51,10 +51,11 @@
<java.runtime>16</java.runtime>
<maven.compiler.target>1.6</maven.compiler.target>
- <tomcat.version>7.0.50</tomcat.version>
+ <tomcat.version>7.0.52</tomcat.version>
<arquillian.version>1.1.3.Final</arquillian.version> <!-- for tomcat adapter -->
<openejb.version>4.5.2</openejb.version>
<slf4j.version>1.7.5</slf4j.version>
+ <johnzon.version>0.9.2-incubating</johnzon.version>
</properties>
<distributionManagement>
@@ -376,6 +377,19 @@
<dependencyManagement>
<dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-json_1.0_spec</artifactId>
+ <version>1.0-alpha-1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-websocket-api</artifactId>
+ <version>${tomcat.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
<!-- we rely on JUL but some dependencies can need slf4j, ex: EhCache -->
<dependency>
<groupId>org.slf4j</groupId>
Modified: incubator/sirona/trunk/server/collector/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/collector/pom.xml?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/server/collector/pom.xml (original)
+++ incubator/sirona/trunk/server/collector/pom.xml Sun Nov 1 06:19:18 2015
@@ -55,9 +55,14 @@
<scope>runtime</scope>
</dependency>
<dependency>
- <groupId>com.fasterxml.jackson.jaxrs</groupId>
- <artifactId>jackson-jaxrs-json-provider</artifactId>
- <version>2.2.2</version>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-json_1.0_spec</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-jaxrs</artifactId>
+ <version>${johnzon.version}</version>
</dependency>
<dependency>
Modified: incubator/sirona/trunk/server/collector/src/main/java/org/apache/sirona/collector/server/Collector.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/collector/src/main/java/org/apache/sirona/collector/server/Collector.java?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/server/collector/src/main/java/org/apache/sirona/collector/server/Collector.java (original)
+++ incubator/sirona/trunk/server/collector/src/main/java/org/apache/sirona/collector/server/Collector.java Sun Nov 1 06:19:18 2015
@@ -16,9 +16,6 @@
*/
package org.apache.sirona.collector.server;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
import com.lmax.disruptor.BusySpinWaitStrategy;
import com.lmax.disruptor.EventFactory;
import com.lmax.disruptor.EventHandler;
@@ -27,6 +24,9 @@ import com.lmax.disruptor.RingBuffer;
import com.lmax.disruptor.TimeoutException;
import com.lmax.disruptor.dsl.Disruptor;
import com.lmax.disruptor.dsl.ProducerType;
+import org.apache.johnzon.mapper.Converter;
+import org.apache.johnzon.mapper.Mapper;
+import org.apache.johnzon.mapper.MapperBuilder;
import org.apache.sirona.Role;
import org.apache.sirona.SironaException;
import org.apache.sirona.collector.server.api.SSLSocketFactoryProvider;
@@ -64,13 +64,20 @@ import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
+import java.util.Locale;
import java.util.Map;
+import java.util.Queue;
+import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -108,7 +115,7 @@ public class Collector extends HttpServl
private CollectorGaugeDataStore gaugeDataStore = null;
private CollectorNodeStatusDataStore statusDataStore;
private CollectorPathTrackingDataStore pathTrackingDataStore;
- private ObjectMapper mapper;
+ private Mapper mapper;
private final Collection<AgentNode> agents = new CopyOnWriteArraySet<AgentNode>();
private volatile BatchFuture collectionFuture = null;
@@ -160,8 +167,35 @@ public class Collector extends HttpServl
// TODO validation
}
- this.mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) //
- .configure(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS, true);
+ final MapperBuilder mapperBuilder = new MapperBuilder();
+ final Queue<DateFormat> dateFormatCache = new ConcurrentLinkedQueue<DateFormat>();
+ for (int i = 0; i < 16; i++) {
+ dateFormatCache.add(newSimpleDateFormat(null));
+ }
+ mapperBuilder.addConverter(Date.class, new Converter<Date>() {
+ @Override
+ public String toString(final Date instance) {
+ final DateFormat dateFormat = newSimpleDateFormat(dateFormatCache);
+ try {
+ return dateFormat.format(instance);
+ } finally {
+ dateFormatCache.add(dateFormat);
+ }
+ }
+
+ @Override
+ public Date fromString(final String text) {
+ final DateFormat dateFormat = newSimpleDateFormat(dateFormatCache);
+ try {
+ return dateFormat.parse(text);
+ } catch (final ParseException e) {
+ throw new IllegalArgumentException(e);
+ } finally {
+ dateFormatCache.add(dateFormat);
+ }
+ }
+ });
+ mapper = mapperBuilder.build();
{ // pulling
{
@@ -209,7 +243,7 @@ public class Collector extends HttpServl
this.disableDisruptor = Boolean.parseBoolean( Configuration.getProperty( key, "false" ) );
if ( !this.disableDisruptor )
{
- ExecutorService exec = Executors.newCachedThreadPool();
+ ExecutorService exec = Executors.newCachedThreadPool(); // FIXME: proper config
key = Configuration.CONFIG_PROPERTY_PREFIX + "collector.pathtracking.disruptor.ringBufferSize";
@@ -240,6 +274,18 @@ public class Collector extends HttpServl
}
}
+ private DateFormat newSimpleDateFormat(final Queue<DateFormat> dateFormatCache) {
+ if (dateFormatCache == null) {
+ final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH);
+ simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ return simpleDateFormat;
+ }
+ final DateFormat df = dateFormatCache.poll();
+ if (df == null) {
+ return newSimpleDateFormat(null);
+ }
+ return df;
+ }
private static class PathTrackingEntryEventHandler
implements EventHandler<PathTrackingEntry>
@@ -338,7 +384,7 @@ public class Collector extends HttpServl
}
private void slurpEvents(final InputStream inputStream) throws IOException {
- final Event[] events = mapper.readValue(inputStream, Event[].class);
+ final Event[] events = mapper.readArray(inputStream, Event.class);
if (events != null && events.length > 0) {
try {
final Collection<Event> validations = new LinkedList<Event>();
Modified: incubator/sirona/trunk/server/collector/src/main/java/org/apache/sirona/collector/server/Event.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/collector/src/main/java/org/apache/sirona/collector/server/Event.java?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/server/collector/src/main/java/org/apache/sirona/collector/server/Event.java (original)
+++ incubator/sirona/trunk/server/collector/src/main/java/org/apache/sirona/collector/server/Event.java Sun Nov 1 06:19:18 2015
@@ -16,18 +16,12 @@
*/
package org.apache.sirona.collector.server;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-
import java.util.Date;
import java.util.Map;
-@JsonIgnoreProperties(ignoreUnknown = true)
public class Event {
private String type;
private Map<String, Object> data;
-
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC")
private Date time;
public String getType() {
Modified: incubator/sirona/trunk/server/collector/src/test/java/org/apache/sirona/collector/server/CubeDataStoreCompatibilityTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/collector/src/test/java/org/apache/sirona/collector/server/CubeDataStoreCompatibilityTest.java?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/server/collector/src/test/java/org/apache/sirona/collector/server/CubeDataStoreCompatibilityTest.java (original)
+++ incubator/sirona/trunk/server/collector/src/test/java/org/apache/sirona/collector/server/CubeDataStoreCompatibilityTest.java Sun Nov 1 06:19:18 2015
@@ -21,6 +21,8 @@ import org.apache.sirona.configuration.i
import org.apache.sirona.counters.Counter;
import org.apache.sirona.counters.DefaultCounter;
import org.apache.sirona.counters.Unit;
+import org.apache.sirona.cube.Cube;
+import org.apache.sirona.cube.CubeBuilder;
import org.apache.sirona.cube.CubeCounterDataStore;
import org.apache.sirona.repositories.Repository;
import org.apache.sirona.store.counter.CollectorCounterStore;
@@ -37,7 +39,10 @@ public class CubeDataStoreCompatibilityT
@Before
public void start() {
- server = new CollectorServer("localhost",Integer.getInteger("collector.server.port", 1234)).start();
+ server = new CollectorServer("localhost", Integer.getInteger("collector.server.port", 1234)).start();
+ if ("http://localhost:".equals(System.getProperty("org.apache.sirona.cube.CubeBuilder.collector", "http://localhost:"))) {
+ System.setProperty("org.apache.sirona.cube.CubeBuilder.collector", "http://localhost:" + server.getPort());
+ }
Repository.INSTANCE.clearCounters();
}
Modified: incubator/sirona/trunk/server/collector/src/test/java/org/apache/sirona/collector/server/HttpCollectorTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/collector/src/test/java/org/apache/sirona/collector/server/HttpCollectorTest.java?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/server/collector/src/test/java/org/apache/sirona/collector/server/HttpCollectorTest.java (original)
+++ incubator/sirona/trunk/server/collector/src/test/java/org/apache/sirona/collector/server/HttpCollectorTest.java Sun Nov 1 06:19:18 2015
@@ -16,7 +16,9 @@
*/
package org.apache.sirona.collector.server;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.johnzon.mapper.Converter;
+import org.apache.johnzon.mapper.Mapper;
+import org.apache.johnzon.mapper.MapperBuilder;
import org.apache.sirona.Role;
import org.apache.sirona.configuration.ioc.IoCs;
import org.apache.sirona.counters.Counter;
@@ -39,21 +41,36 @@ import java.io.OutputStream;
import java.io.StringWriter;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
+import java.util.TimeZone;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class HttpCollectorTest {
private CollectorServer server;
- private ObjectMapper mapper;
+ private Mapper mapper;
@Before
public void start() {
server = new CollectorServer("localhost", Integer.getInteger("collector.server.port", 1234)).start();
- mapper = new ObjectMapper();
+ mapper = new MapperBuilder().addConverter(Date.class, new Converter<Date>() {
+ @Override
+ public String toString(Date instance) {
+ final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH);
+ simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ return simpleDateFormat.format(instance);
+ }
+
+ @Override
+ public Date fromString(final String text) {
+ throw new UnsupportedOperationException(text);
+ }
+ }).build();
Repository.INSTANCE.clearCounters();
}
@@ -215,7 +232,7 @@ public class HttpCollectorTest {
connection.setDoOutput(true);
final StringWriter writer = new StringWriter();
- mapper.writeValue(writer, events);
+ mapper.writeArray(events, writer);
try {
final OutputStream output = connection.getOutputStream();
Modified: incubator/sirona/trunk/server/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/pom.xml?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/server/pom.xml (original)
+++ incubator/sirona/trunk/server/pom.xml Sun Nov 1 06:19:18 2015
@@ -37,5 +37,6 @@
<module>reporting</module>
<module>store</module>
<module>boomerang</module>
+ <module>websocket-server</module>
</modules>
</project>
Modified: incubator/sirona/trunk/server/reporting/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/pom.xml?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/pom.xml (original)
+++ incubator/sirona/trunk/server/reporting/pom.xml Sun Nov 1 06:19:18 2015
@@ -33,7 +33,6 @@
<tomcatRunPath>/sirona</tomcatRunPath>
<sirona.properties.path>${basedir}/src/test/sirona.properties</sirona.properties.path>
<cxf.version>3.0.1</cxf.version>
- <jacksonVersion>2.4.1</jacksonVersion>
<spring.version>4.0.6.RELEASE</spring.version>
</properties>
Modified: incubator/sirona/trunk/server/reporting/reporting-ui/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/pom.xml?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/pom.xml (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/pom.xml Sun Nov 1 06:19:18 2015
@@ -35,6 +35,12 @@
<dependencies>
<dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-json_1.0_spec</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.sirona</groupId>
<artifactId>sirona-core</artifactId>
<scope>provided</scope> <!-- using to put it in the container to get JDBC monitoring and deploy the webapp -->
@@ -51,15 +57,9 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>com.fasterxml.jackson.jaxrs</groupId>
- <artifactId>jackson-jaxrs-json-provider</artifactId>
- <version>${jacksonVersion}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.jaxrs</groupId>
- <artifactId>jackson-jaxrs-xml-provider</artifactId>
- <version>${jacksonVersion}</version>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-jaxrs</artifactId>
+ <version>${johnzon.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/test/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/test/resources/META-INF/spring-context.xml?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/test/resources/META-INF/spring-context.xml (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/test/resources/META-INF/spring-context.xml Sun Nov 1 06:19:18 2015
@@ -34,11 +34,7 @@
<bean id="org.apache.cxf.bus.spring.Jsr250BeanPostProcessor" class="org.apache.cxf.bus.spring.Jsr250BeanPostProcessor"/>
<bean id="org.apache.cxf.bus.spring.BusExtensionPostProcessor" class="org.apache.cxf.bus.spring.BusExtensionPostProcessor"/>
- <bean id="jsonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider">
- <property name="mapper">
- <bean class="com.fasterxml.jackson.databind.ObjectMapper"/>
- </property>
- </bean>
+ <bean id="jsonProvider" class="org.apache.johnzon.jaxrs.JohnzonProvider" />
<jaxrs:server id="sironaServices" address="/sironaServices" basePackages="org.apache.sirona.reporting.web.**,org.apache.sirona.reporting.web**">
<jaxrs:providers>
Modified: incubator/sirona/trunk/server/reporting/reporting-webapp-full/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-webapp-full/pom.xml?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-webapp-full/pom.xml (original)
+++ incubator/sirona/trunk/server/reporting/reporting-webapp-full/pom.xml Sun Nov 1 06:19:18 2015
@@ -43,6 +43,12 @@
<artifactId>geronimo-servlet_3.0_spec</artifactId>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-json_1.0_spec</artifactId>
+ <scope>compile</scope>
+ </dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jaxrs_2.0_spec</artifactId>
@@ -70,10 +76,10 @@
<version>${cxf.version}</version>
<scope>compile</scope>
</dependency>
- <dependency> <!-- if someday webapp (ee artifact) moves to johnzon ensures to align it here as well -->
- <groupId>com.fasterxml.jackson.jaxrs</groupId>
- <artifactId>jackson-jaxrs-json-provider</artifactId>
- <version>${jacksonVersion}</version>
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-jaxrs</artifactId>
+ <version>${johnzon.version}</version>
</dependency>
<dependency>
<groupId>org.apache.sirona</groupId>
Modified: incubator/sirona/trunk/server/reporting/reporting-webapp-full/src/main/resources/applicationContext.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-webapp-full/src/main/resources/applicationContext.xml?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-webapp-full/src/main/resources/applicationContext.xml (original)
+++ incubator/sirona/trunk/server/reporting/reporting-webapp-full/src/main/resources/applicationContext.xml Sun Nov 1 06:19:18 2015
@@ -33,7 +33,7 @@
<jaxrs:server id="sironaServices" basePackages="org.apache.sirona.reporting.web.**" serviceClass="org.apache.sirona.reporting.web.Environment">
<jaxrs:providers>
- <bean class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider" />
+ <bean class="org.apache.johnzon.jaxrs.JohnzonProvider" />
</jaxrs:providers>
</jaxrs:server>
</beans>
Modified: incubator/sirona/trunk/server/reporting/reporting-webapp-full/src/test/java/org/apache/sirona/reporting/template/WebTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-webapp-full/src/test/java/org/apache/sirona/reporting/template/WebTest.java?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-webapp-full/src/test/java/org/apache/sirona/reporting/template/WebTest.java (original)
+++ incubator/sirona/trunk/server/reporting/reporting-webapp-full/src/test/java/org/apache/sirona/reporting/template/WebTest.java Sun Nov 1 06:19:18 2015
@@ -23,7 +23,6 @@ import java.io.IOException;
import static com.gargoylesoftware.htmlunit.WebAssert.assertElementPresent;
import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -40,6 +39,8 @@ public class WebTest extends SironaRepor
@Test
public void checkJsonEndpoint() throws IOException {
final String page = page("web/sessions/0/" + System.currentTimeMillis()).getWebResponse().getContentAsString().replace(" ", "");
- assertEquals("[]", page); // we don't deploy in this tests sessions gauges so we have nothing
+ // we don't deploy in this tests sessions gauges so we have nothing
+ assertTrue(page.contains("\"data\":[]"));
+ assertTrue(page.contains("\"label\":\"sessions-/sirona-test\""));
}
}
Modified: incubator/sirona/trunk/server/reporting/reporting-webapp/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-webapp/pom.xml?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-webapp/pom.xml (original)
+++ incubator/sirona/trunk/server/reporting/reporting-webapp/pom.xml Sun Nov 1 06:19:18 2015
@@ -37,6 +37,13 @@
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_3.0_spec</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-json_1.0_spec</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
<dependency>
<groupId>org.apache.sirona</groupId>
<artifactId>sirona-reporting-api</artifactId>
@@ -73,10 +80,10 @@
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
- <dependency> <!-- I'd love to use johnzon but would make hard the support of TomEE 1 and 7 -->
- <groupId>com.fasterxml.jackson.jaxrs</groupId>
- <artifactId>jackson-jaxrs-json-provider</artifactId>
- <version>${jacksonVersion}</version>
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-jaxrs</artifactId>
+ <version>0.9.2-incubating</version>
</dependency>
</dependencies>
Modified: incubator/sirona/trunk/server/reporting/reporting-webapp/src/main/webapp/WEB-INF/openejb-jar.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-webapp/src/main/webapp/WEB-INF/openejb-jar.xml?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-webapp/src/main/webapp/WEB-INF/openejb-jar.xml (original)
+++ incubator/sirona/trunk/server/reporting/reporting-webapp/src/main/webapp/WEB-INF/openejb-jar.xml Sun Nov 1 06:19:18 2015
@@ -20,7 +20,7 @@
<pojo-deployment class-name="org.apache.sirona.reporting.web.configuration.SironaApplication">
<properties>
cxf.jaxrs.skip-provider-scanning = true
- cxf.jaxrs.providers = com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider,org.apache.openejb.server.cxf.rs.EJBAccessExceptionMapper
+ cxf.jaxrs.providers = org.apache.johnzon.jaxrs.JohnzonProvider,org.apache.openejb.server.cxf.rs.EJBAccessExceptionMapper
</properties>
</pojo-deployment>
</openejb-jar>
Modified: incubator/sirona/trunk/server/store/cassandra/src/main/java/org/apache/sirona/cassandra/collector/status/CassandraCollectorNodeStatusDataStore.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/store/cassandra/src/main/java/org/apache/sirona/cassandra/collector/status/CassandraCollectorNodeStatusDataStore.java?rev=1711716&r1=1711715&r2=1711716&view=diff
==============================================================================
--- incubator/sirona/trunk/server/store/cassandra/src/main/java/org/apache/sirona/cassandra/collector/status/CassandraCollectorNodeStatusDataStore.java (original)
+++ incubator/sirona/trunk/server/store/cassandra/src/main/java/org/apache/sirona/cassandra/collector/status/CassandraCollectorNodeStatusDataStore.java Sun Nov 1 06:19:18 2015
@@ -35,12 +35,11 @@ import org.apache.sirona.store.status.Co
import java.util.Collection;
import java.util.Date;
-import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
+import java.util.TreeMap;
import static org.apache.sirona.cassandra.collector.CassandraSirona.column;
-import static org.apache.sirona.cassandra.collector.CassandraSirona.emptyColumn;
public class CassandraCollectorNodeStatusDataStore implements CollectorNodeStatusDataStore {
private final Keyspace keyspace;
@@ -67,7 +66,7 @@ public class CassandraCollectorNodeStatu
return null;
}
- final Map<String, NodeStatus> statuses = new HashMap<String, NodeStatus>();
+ final Map<String, NodeStatus> statuses = new TreeMap<String, NodeStatus>();
for (final Row<String, String, Date> status : result.get()) {
final Collection<ValidationResult> validations = new LinkedList<ValidationResult>();
Added: incubator/sirona/trunk/server/websocket-server/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/websocket-server/pom.xml?rev=1711716&view=auto
==============================================================================
--- incubator/sirona/trunk/server/websocket-server/pom.xml (added)
+++ incubator/sirona/trunk/server/websocket-server/pom.xml Sun Nov 1 06:19:18 2015
@@ -0,0 +1,106 @@
+<?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">
+ <parent>
+ <artifactId>sirona-server</artifactId>
+ <groupId>org.apache.sirona</groupId>
+ <version>0.3-incubating-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>sirona-websocket-server</artifactId>
+ <name>Apache Sirona Incubator :: Server :: WebSocket</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-websocket-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-json_1.0_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-websocket</artifactId>
+ <version>${johnzon.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sirona</groupId>
+ <artifactId>sirona-websocket-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.descriptors</groupId>
+ <artifactId>shrinkwrap-descriptors-impl-javaee</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.protocol</groupId>
+ <artifactId>arquillian-protocol-servlet</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-tomcat-embedded-7</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-jasper</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-logging-juli</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-websocket</artifactId>
+ <version>${tomcat.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jdt.core.compiler</groupId>
+ <artifactId>ecj</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: incubator/sirona/trunk/server/websocket-server/src/main/java/org/apache/sirona/websocket/server/CounterEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/websocket-server/src/main/java/org/apache/sirona/websocket/server/CounterEndpoint.java?rev=1711716&view=auto
==============================================================================
--- incubator/sirona/trunk/server/websocket-server/src/main/java/org/apache/sirona/websocket/server/CounterEndpoint.java (added)
+++ incubator/sirona/trunk/server/websocket-server/src/main/java/org/apache/sirona/websocket/server/CounterEndpoint.java Sun Nov 1 06:19:18 2015
@@ -0,0 +1,55 @@
+/*
+ * 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.sirona.websocket.server;
+
+import org.apache.johnzon.websocket.mapper.JohnzonTextDecoder;
+import org.apache.sirona.Role;
+import org.apache.sirona.configuration.ioc.IoCs;
+import org.apache.sirona.counters.Counter;
+import org.apache.sirona.counters.Unit;
+import org.apache.sirona.math.M2AwareStatisticalSummary;
+import org.apache.sirona.repositories.Repository;
+import org.apache.sirona.store.counter.CollectorCounterStore;
+import org.apache.sirona.websocket.client.domain.WSCounter;
+
+import javax.websocket.OnMessage;
+import javax.websocket.server.ServerEndpoint;
+
+@ServerEndpoint(value = "/wsirona/counter", decoders = JohnzonTextDecoder.class)
+public class CounterEndpoint {
+ @OnMessage
+ public void onMessage(final WSCounter counter) throws Exception {
+ LazyDataStore.COLLECTOR_COUNTER_STORE.update(
+ new Counter.Key(new Role(counter.getRoleName(), Unit.get(counter.getRoleUnit())), counter.getName()),
+ counter.getMarker(),
+ new M2AwareStatisticalSummary(
+ counter.getMean(), counter.getVariance(), counter.getHits(), counter.getMax(), counter.getMin(), counter.getSum(), counter.getSecondMoment()),
+ counter.getConcurrency()
+ );
+ }
+
+ private static class LazyDataStore {
+ private static final CollectorCounterStore COLLECTOR_COUNTER_STORE;
+ static {
+ IoCs.findOrCreateInstance(Repository.class);
+ COLLECTOR_COUNTER_STORE = IoCs.findOrCreateInstance(CollectorCounterStore.class);
+ if (COLLECTOR_COUNTER_STORE == null) {
+ throw new IllegalStateException("Collector only works with " + CollectorCounterStore.class.getName());
+ }
+ }
+ }
+}