labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From psm...@apache.org
Subject svn commit: r568092 - in /labs/pinpoint/trunk: ./ pinpoint-metric/src/main/java/org/apache/logging/pinpoint/metric/ pinpoint-service/ pinpoint-service/src/main/java/org/apache/logging/pinpoint/service/ pinpoint-service/src/main/resources/org/apache/log...
Date Tue, 21 Aug 2007 12:17:43 GMT
Author: psmith
Date: Tue Aug 21 05:17:42 2007
New Revision: 568092

URL: http://svn.apache.org/viewvc?rev=568092&view=rev
Log:
Pinpoint Service now exposes a series of Restlet graphs to show performance metrics.

You can browse on port 8182 on the host running the Service to monitor indexing rates
and the backlog (if any).  

I'm greatful to Dave Cheney for showing me this Restlet trick in a previous Aconex hackathon.
 Nifty!



Added:
    labs/pinpoint/trunk/pinpoint-service/src/main/resources/org/apache/logging/pinpoint/service/restlet.xml
Modified:
    labs/pinpoint/trunk/TODO.txt
    labs/pinpoint/trunk/pinpoint-metric/src/main/java/org/apache/logging/pinpoint/metric/MetricChartUtils.java
    labs/pinpoint/trunk/pinpoint-service/pom.xml
    labs/pinpoint/trunk/pinpoint-service/src/main/java/org/apache/logging/pinpoint/service/Service.java

Modified: labs/pinpoint/trunk/TODO.txt
URL: http://svn.apache.org/viewvc/labs/pinpoint/trunk/TODO.txt?rev=568092&r1=568091&r2=568092&view=diff
==============================================================================
--- labs/pinpoint/trunk/TODO.txt (original)
+++ labs/pinpoint/trunk/TODO.txt Tue Aug 21 05:17:42 2007
@@ -13,24 +13,7 @@
 
 pinpoint-core
 	bugs
-		* Getting a weird exception with some events that are being sent from the Aconex app:
-		pinpoint>search sqlexception
-				message:sqlexception
-				java.lang.RuntimeException: Failed to navigate to next hit
-				        at org.apache.logging.pinpoint.search.PinpointSearcher$HitIterator.next(PinpointSearcher.java:115)
-				        at org.apache.logging.pinpoint.search.PinpointSearcher$HitIterator.next(PinpointSearcher.java:90)
-				        at org.apache.logging.pinpoint.Shell.displayEvents(Shell.java:189)
-				        at org.apache.logging.pinpoint.Shell.searchContext(Shell.java:153)
-				        at org.apache.logging.pinpoint.Shell.main(Shell.java:73)
-				Caused by: java.lang.RuntimeException: Failed to deserialize an event at position 204460
for file '/Users/paulsmith/.pinpoint/ctx.2007-08-09/EVENTS.ser'
-				        at org.apache.logging.pinpoint.converter.SimpleEventStore.restore(SimpleEventStore.java:72)
-				        at org.apache.logging.pinpoint.search.PinpointSearcher$HitIterator.next(PinpointSearcher.java:113)
-				        ... 4 more
-				Caused by: java.io.StreamCorruptedException: invalid stream header
-				        at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:764)
-				        at java.io.ObjectInputStream.<init>(ObjectInputStream.java:277)
-				        at org.apache.logging.pinpoint.converter.SimpleEventStore.restore(SimpleEventStore.java:63)
-				        ... 5 more
+
         
 pinpoint-cli
 

Modified: labs/pinpoint/trunk/pinpoint-metric/src/main/java/org/apache/logging/pinpoint/metric/MetricChartUtils.java
URL: http://svn.apache.org/viewvc/labs/pinpoint/trunk/pinpoint-metric/src/main/java/org/apache/logging/pinpoint/metric/MetricChartUtils.java?rev=568092&r1=568091&r2=568092&view=diff
==============================================================================
--- labs/pinpoint/trunk/pinpoint-metric/src/main/java/org/apache/logging/pinpoint/metric/MetricChartUtils.java
(original)
+++ labs/pinpoint/trunk/pinpoint-metric/src/main/java/org/apache/logging/pinpoint/metric/MetricChartUtils.java
Tue Aug 21 05:17:42 2007
@@ -1,6 +1,7 @@
 package org.apache.logging.pinpoint.metric;
 
 import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.log4j.Logger;
 import org.jfree.chart.JFreeChart;
@@ -18,6 +19,7 @@
 import org.jfree.data.time.TimeSeries;
 import org.jfree.data.time.TimeSeriesCollection;
 import org.jfree.data.time.TimeSeriesDataItem;
+import org.jfree.data.xy.XYDataset;
 
 public class MetricChartUtils {
 
@@ -38,8 +40,8 @@
 
         collection.addSeries(series);
         boolean urls = false;
-        boolean tooltips = true;
-        boolean legend = true;
+        boolean tooltips = false;
+        boolean legend = false;
         String valueAxisLabel = "# Received Events not yet indexed";
         String timeAxisLabel = "";
 
@@ -66,5 +68,26 @@
                 legend);
         return chart;
 
+    }
+
+    public static XYDataset createRateTimeSeries(Counter counter) {
+        TimeSeries series = new TimeSeries(counter.getMetricName(), FixedMillisecond.class);
+        ObservedValue lastValue = null;
+        for (ObservedValue observedValue : new CopyOnWriteArrayList<ObservedValue>(counter
+                .getObservations())) {
+            if (lastValue != null) {
+                long difference = observedValue.getObservedValue() - lastValue.getObservedValue();
+                double timeInterval = observedValue.getTimestamp() - lastValue.getTimestamp();
+
+                double rate = ((double) difference) / (timeInterval / 1000);
+
+                series.add(new TimeSeriesDataItem(
+                        new FixedMillisecond(observedValue.getTimestamp()), rate));
+            } else {
+                lastValue = observedValue;
+            }
+
+        }
+        return new TimeSeriesCollection(series);
     }
 }

Modified: labs/pinpoint/trunk/pinpoint-service/pom.xml
URL: http://svn.apache.org/viewvc/labs/pinpoint/trunk/pinpoint-service/pom.xml?rev=568092&r1=568091&r2=568092&view=diff
==============================================================================
--- labs/pinpoint/trunk/pinpoint-service/pom.xml (original)
+++ labs/pinpoint/trunk/pinpoint-service/pom.xml Tue Aug 21 05:17:42 2007
@@ -42,12 +42,6 @@
       </plugin>
       <plugin>
         <artifactId>maven-assembly-plugin</artifactId>
-        <configuration>
-          <descriptors>
-            <descriptor>src/assembly/service.xml</descriptor>
-          </descriptors>
-          <appendAssemblyId>false</appendAssemblyId>
-        </configuration>
         <executions>
           <execution>
             <id>make-assembly</id>
@@ -57,9 +51,30 @@
             </goals>
           </execution>
         </executions>
+        <configuration>
+          <descriptors>
+            <descriptor>src/assembly/service.xml</descriptor>
+          </descriptors>
+          <appendAssemblyId>false</appendAssemblyId>
+        </configuration>
       </plugin>
     </plugins>
   </build>
+  <repositories>
+    <repository>
+      <id>maven-restlet</id>
+      <name>Public online Restlet repository</name>
+      <url>http://maven.restlet.org</url>
+    </repository>
+    <repository>
+      <releases>
+        <enabled>false</enabled>
+      </releases>
+      <snapshots />
+      <id>Codehaus Snapshots</id>
+      <url>http://snapshots.repository.codehaus.org/</url>
+    </repository>
+  </repositories>
   <dependencies>
     <dependency>
       <groupId>org.apache.logging</groupId>
@@ -112,6 +127,21 @@
       <artifactId>derby</artifactId>
       <version>10.2.2.0</version>
     </dependency>
+    <dependency>
+      <groupId>org.restlet</groupId>
+      <artifactId>org.restlet</artifactId>
+      <version>1.0.1</version>
+    </dependency>
+    <dependency>
+      <groupId>com.noelios.restlet</groupId>
+      <artifactId>com.noelios.restlet</artifactId>
+      <version>1.0.1</version>
+    </dependency>
+    <dependency>
+      <groupId>com.noelios.restlet</groupId>
+      <artifactId>com.noelios.restlet.ext.simple</artifactId>
+      <version>1.0.1</version>
+    </dependency>
   </dependencies>
   <properties>
     <log4j.receivers.version>1.1-SNAPSHOT</log4j.receivers.version>
@@ -121,3 +151,4 @@
     <lucene.version>2.2.0</lucene.version>
   </properties>
 </project>
+

Modified: labs/pinpoint/trunk/pinpoint-service/src/main/java/org/apache/logging/pinpoint/service/Service.java
URL: http://svn.apache.org/viewvc/labs/pinpoint/trunk/pinpoint-service/src/main/java/org/apache/logging/pinpoint/service/Service.java?rev=568092&r1=568091&r2=568092&view=diff
==============================================================================
--- labs/pinpoint/trunk/pinpoint-service/src/main/java/org/apache/logging/pinpoint/service/Service.java
(original)
+++ labs/pinpoint/trunk/pinpoint-service/src/main/java/org/apache/logging/pinpoint/service/Service.java
Tue Aug 21 05:17:42 2007
@@ -8,8 +8,6 @@
  */
 package org.apache.logging.pinpoint.service;
 
-import java.io.File;
-
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.GnuParser;
 import org.apache.commons.cli.HelpFormatter;
@@ -18,14 +16,8 @@
 import org.apache.commons.daemon.Daemon;
 import org.apache.commons.daemon.DaemonContext;
 import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.SystemUtils;
 import org.apache.log4j.net.SocketHubReceiver;
 import org.apache.log4j.spi.LoggerRepository;
-import org.apache.logging.pinpoint.metric.Counter;
-import org.apache.logging.pinpoint.metric.MetricChartUtils;
-import org.apache.logging.pinpoint.metric.MetricRegistry;
-import org.jfree.chart.ChartUtilities;
-import org.jfree.chart.JFreeChart;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
 import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
@@ -46,18 +38,9 @@
 
         service.start();
 
-        MetricRegistry registry = (MetricRegistry) service.ctx.getBean("metricRegistry");
-
-        File graphLocation = new File(SystemUtils.USER_DIR, "metricGraph.jpg");
-        while (true) {
-
-            Thread.sleep(1000);
-            JFreeChart chart = MetricChartUtils.createBacklogChart((Counter) service.ctx
-                    .getBean("receivedEventsCounter"), (Counter) service.ctx
-                    .getBean("eventsWrittenCounter"));
-            ChartUtilities.saveChartAsJPEG(graphLocation, chart, 640, 480);
+        synchronized (service) {
+            service.wait();
         }
-
     }
 
     private void configure(String[] args) {
@@ -90,7 +73,7 @@
 
         System.setProperty("log4j.debug", "true");
 
-        this.configs = new String[] { "logger-repository.xml", "amq.xml", "jmx.xml",
+        this.configs = new String[] { "logger-repository.xml", "amq.xml", "jmx.xml", "restlet.xml",
                 "pinpoint-context.xml", config };
 
         for (int i = 0; i < configs.length; i++) {
@@ -121,6 +104,9 @@
 
         public void postProcessBeanFactory(ConfigurableListableBeanFactory factory)
                 throws BeansException {
+            if (socketHubReceivers == null) {
+                return;
+            }
             LoggerRepository loggerRepository = (LoggerRepository) ctx.getBean("loggerRepository");
             for (String socketHubReceiver : socketHubReceivers) {
                 int port = 4560; // TODO constant

Added: labs/pinpoint/trunk/pinpoint-service/src/main/resources/org/apache/logging/pinpoint/service/restlet.xml
URL: http://svn.apache.org/viewvc/labs/pinpoint/trunk/pinpoint-service/src/main/resources/org/apache/logging/pinpoint/service/restlet.xml?rev=568092&view=auto
==============================================================================
--- labs/pinpoint/trunk/pinpoint-service/src/main/resources/org/apache/logging/pinpoint/service/restlet.xml
(added)
+++ labs/pinpoint/trunk/pinpoint-service/src/main/resources/org/apache/logging/pinpoint/service/restlet.xml
Tue Aug 21 05:17:42 2007
@@ -0,0 +1,45 @@
+<!--
+ 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.
+
+-->
+<beans 
+  xmlns="http://www.springframework.org/schema/beans" 
+  xmlns:amq="http://activemq.org/config/1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

+">
+
+    <bean id="restletApplication" class="org.apache.logging.pinpoint.restlet.PinpointRestletApplication"
init-method="go" >
+    	<constructor-arg ref="component" />
+    	<constructor-arg ref="rootRestlet" />
+    	<constructor-arg ref="pinpointGraphRestlet" />
+    	<constructor-arg ref="backlogGraphRestlet" />
+    </bean>
+    
+    <bean id="pinpointGraphRestlet" class="org.apache.logging.pinpoint.restlet.PinpointGraphRestlet"
>
+    </bean>
+
+    <bean id="rootRestlet" class="org.apache.logging.pinpoint.restlet.RootRestlet" >
+    </bean>    
+    
+    <bean id="backlogGraphRestlet" class="org.apache.logging.pinpoint.restlet.BacklogGraphReslet"
>
+    	<constructor-arg ref="receivedEventsCounter" />
+    	<constructor-arg ref="eventsWrittenCounter" />
+    </bean>
+    
+	<bean id="component" class="org.restlet.Component" >
+	</bean>
+</beans>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message