You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by ps...@apache.org on 2007/08/22 05:37:52 UTC

svn commit: r568396 - in /labs/pinpoint/trunk: pinpoint-cli/src/main/java/org/apache/logging/pinpoint/ pinpoint-core/src/main/java/org/apache/logging/pinpoint/converter/ pinpoint-metric/src/main/java/org/apache/logging/pinpoint/metric/ pinpoint-search/...

Author: psmith
Date: Tue Aug 21 20:37:51 2007
New Revision: 568396

URL: http://svn.apache.org/viewvc?rev=568396&view=rev
Log:
Fixed COMPLETELY stupid logic error in rate calculations.  Was never rolling over the previous observed value..  Stupid me!

Added support for ignoring some event properties.  Currently hard coded to my set that I need, will introduce a
configuration element to allow that to be customised.

Still occasionally getting a corrupted binary event stream, and I'm not sure why, so for now I'm treating it as a bad hit
and still able to see other results.  You'll get a note on screen if you hit that.

Added the ability to fix on a specific point in time, can now go "setTimeContext 10:53" and it defaults to searching
a minute either side of that point.   This window duration is still hard-coded for now to 1 minute.


Modified:
    labs/pinpoint/trunk/pinpoint-cli/src/main/java/org/apache/logging/pinpoint/Shell.java
    labs/pinpoint/trunk/pinpoint-core/src/main/java/org/apache/logging/pinpoint/converter/EventWriter.java
    labs/pinpoint/trunk/pinpoint-core/src/main/java/org/apache/logging/pinpoint/converter/PinpointEventWriterHandler.java
    labs/pinpoint/trunk/pinpoint-metric/src/main/java/org/apache/logging/pinpoint/metric/MetricChartUtils.java
    labs/pinpoint/trunk/pinpoint-search/src/main/java/org/apache/logging/pinpoint/search/PinpointSearchResults.java
    labs/pinpoint/trunk/pinpoint-search/src/main/java/org/apache/logging/pinpoint/search/PinpointSearcher.java
    labs/pinpoint/trunk/pinpoint-service/src/main/resources/org/apache/logging/pinpoint/service/pinpoint-context.xml

Modified: labs/pinpoint/trunk/pinpoint-cli/src/main/java/org/apache/logging/pinpoint/Shell.java
URL: http://svn.apache.org/viewvc/labs/pinpoint/trunk/pinpoint-cli/src/main/java/org/apache/logging/pinpoint/Shell.java?rev=568396&r1=568395&r2=568396&view=diff
==============================================================================
--- labs/pinpoint/trunk/pinpoint-cli/src/main/java/org/apache/logging/pinpoint/Shell.java (original)
+++ labs/pinpoint/trunk/pinpoint-cli/src/main/java/org/apache/logging/pinpoint/Shell.java Tue Aug 21 20:37:51 2007
@@ -1,27 +1,22 @@
 /**
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements.  See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- **/
+ * 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.logging.pinpoint;
 
 import java.io.IOException;
+import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import jline.ArgumentCompletor;
@@ -39,12 +34,12 @@
 import org.apache.commons.cli.Options;
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.BasicConfigurator;
-import org.apache.log4j.Layout;
 import org.apache.log4j.Level;
 import org.apache.log4j.LogManager;
 import org.apache.log4j.PatternLayout;
 import org.apache.log4j.spi.LoggingEvent;
 import org.apache.logging.pinpoint.analyser.DefaultAnalyzerFactory;
+import org.apache.logging.pinpoint.converter.EventWriter;
 import org.apache.logging.pinpoint.search.PinpointSearchResults;
 import org.apache.logging.pinpoint.search.PinpointSearchUtils;
 import org.apache.logging.pinpoint.search.PinpointSearcher;
@@ -52,10 +47,18 @@
 import org.apache.logging.pinpoint.store.SimpleEventStore;
 import org.apache.logging.pinpoint.utils.PinpointUtils;
 import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.index.Term;
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.lucene.queryParser.QueryParser;
 import org.apache.lucene.queryParser.QueryParser.Operator;
+import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.search.RangeQuery;
+import org.apache.lucene.search.BooleanClause.Occur;
+import org.joda.time.Duration;
+import org.joda.time.MutablePeriod;
+import org.joda.time.format.PeriodFormatter;
+import org.joda.time.format.PeriodFormatterBuilder;
 
 public class Shell {
 
@@ -66,9 +69,19 @@
     private Analyzer analyzer;
     private QueryParser queryParser;
     private PinpointSearchUtils searchUtils;
+    private PatternLayout layout = new PatternLayout("[%d{ISO8601} %-5p][%20.20c][%t] %m%n");
+
+    private MutablePeriod timeContext = null;
+    private Duration timeDurationContext = new Duration(60000);
+    private PeriodFormatterBuilder timePeriodFormatterBuilder;
 
     public Shell(PinpointContext ctx) {
         this.ctx = ctx;
+
+        this.timePeriodFormatterBuilder = new PeriodFormatterBuilder();
+        timePeriodFormatterBuilder.printZeroAlways().minimumPrintedDigits(2).appendHours()
+                .appendSeparator(":").appendMinutes();
+
     }
 
     /**
@@ -119,10 +132,8 @@
     }
 
     private void showContextInfo() {
-        Map<String, Collection<String>> values = PinpointContextUtils
-                .listContextPointValues(ctx);
-        System.out.format("Context: %s\n", ctx.getContextRoot()
-                .getAbsoluteFile());
+        Map<String, Collection<String>> values = PinpointContextUtils.listContextPointValues(ctx);
+        System.out.format("Context: %s\n", ctx.getContextRoot().getAbsoluteFile());
         for (Map.Entry<String, Collection<String>> entry : values.entrySet()) {
             System.out.format("%s: ", entry.getKey());
             System.out.format("%s", entry.getValue());
@@ -136,27 +147,23 @@
         Completor fieldNameCompletor = new PinpointContextCompleter(ctx);
 
         /*
-         * this is one of the most confusing aspects of jLine.... I think these
-         * names need to be in sorted order too...?
+         * this is one of the most confusing aspects of jLine.... I think these names need to be in
+         * sorted order too...?
          */
-        consoleReader.addCompletor(new ArgumentCompletor(
-                new Completor[] {
-                        new SimpleCompletor(new String[] { "exit", "info",
-                                "next", "previous", "search", "set",
-                                "showInContext", "quit" }), fieldNameCompletor,
-                        new NullCompletor() }));
+        consoleReader.addCompletor(new ArgumentCompletor(new Completor[] {
+                new SimpleCompletor(new String[] { "exit", "info", "next", "previous", "search",
+                        "set", "setTimeContext", "showInContext", "quit" }), fieldNameCompletor,
+                new NullCompletor() }));
 
-        consoleReader
-                .setCompletionHandler(new CandidateListCompletionHandler());
+        consoleReader.setCompletionHandler(new CandidateListCompletionHandler());
 
         consoleReader.setDefaultPrompt("pinpoint>");
 
         String input = "";
 
         /*
-         * IMPORTANT NOTE: jline 0.9.90 DOES NOT WORK properly with the command
-         * prompt so it's important that at least jline 0.9.91 is used. I WASTED
-         * OVER AN HOUR tracking that down.
+         * IMPORTANT NOTE: jline 0.9.90 DOES NOT WORK properly with the command prompt so it's
+         * important that at least jline 0.9.91 is used. I WASTED OVER AN HOUR tracking that down.
          */
         analyzer = new DefaultAnalyzerFactory().createAnalyser();
         queryParser = new QueryParser("message", analyzer);
@@ -168,8 +175,7 @@
 
         currentResults = null;
         try {
-            while (!Arrays.asList("exit", "quit").contains(
-                    (input = consoleReader.readLine()))) {
+            while (!Arrays.asList("exit", "quit").contains((input = consoleReader.readLine()))) {
                 try {
                     String[] cmd = StringUtils.split(input);
 
@@ -177,8 +183,9 @@
                     if (StringUtils.equalsIgnoreCase("search", arg)) {
                         input = StringUtils.removeStart(input, arg);
                         Query query = queryParser.parse(input);
-                        System.out.println(query);
-                        currentResults = pinpointSearcher.search(query);
+                        currentResults = search(query);
+                        currentResults.setPageSize(Math.min(10, Math.min(50, consoleReader
+                                .getTermheight() - 5)));
                         displayEvents();
                     } else if (StringUtils.equalsIgnoreCase("next", arg)) {
                         currentResults.nextPage();
@@ -186,11 +193,11 @@
                     } else if (StringUtils.equalsIgnoreCase("previous", arg)) {
                         currentResults.previousPage();
                         displayEvents();
-                    } else if (StringUtils.equalsIgnoreCase("showInContext",
-                            arg)) {
+                    } else if (StringUtils.equalsIgnoreCase("showInContext", arg)) {
                         int selectedEvent = Integer.valueOf(cmd[1]);
                         showInContext(selectedEvent);
-
+                    } else if (StringUtils.equalsIgnoreCase("setTimeContext", arg)) {
+                        setTimeRange(cmd[1]);
                     } else if (StringUtils.equalsIgnoreCase("info", arg)) {
                         showContextInfo();
                     } else {
@@ -198,8 +205,8 @@
                     }
                 } catch (Exception e) {
                     /*
-                     * This is deliberately not logged using log4j, designed to
-                     * go straight to the console unhindered.
+                     * This is deliberately not logged using log4j, designed to go straight to the
+                     * console unhindered.
                      */
                     e.printStackTrace();
                 }
@@ -210,17 +217,61 @@
 
     }
 
+    private PinpointSearchResults search(Query query) throws IOException {
+        if (this.timeContext != null) {
+            BooleanQuery booleanQuery = new BooleanQuery();
+            booleanQuery.add(query, Occur.MUST);
+            MutablePeriod startPoint = new MutablePeriod(this.timeContext);
+            startPoint.add(-this.timeDurationContext.getMillis());
+            MutablePeriod endPoint = new MutablePeriod(this.timeContext);
+            endPoint.add(this.timeDurationContext.getMillis());
+
+            PeriodFormatterBuilder builder = new PeriodFormatterBuilder().printZeroAlways()
+                    .minimumPrintedDigits(2).appendHours().appendMinutes().appendSeconds();
+            String startPointString = builder.toFormatter().print(startPoint);
+            String endPointString = builder.toFormatter().print(endPoint);
+            // System.out.println(startPointString + "->" + endPointString);
+            RangeQuery rangeQuery = new RangeQuery(new Term(EventWriter.FIELD_EVENT_TIME,
+                    startPointString), new Term(EventWriter.FIELD_EVENT_TIME, endPointString), true);
+            booleanQuery.add(rangeQuery, Occur.MUST);
+            query = booleanQuery;
+        }
+        System.out.println(query);
+        return pinpointSearcher.search(query);
+    }
+
+    private void setTimeRange(String timeRange) {
+        // TODO more options for time Range arguments?
+
+        MutablePeriod period = new MutablePeriod();
+        timePeriodFormatterBuilder.toParser().parseInto(period, timeRange, 0, Locale.getDefault());
+        this.timeContext = period;
+        StringWriter writer = new StringWriter();
+        writer.append("Queries restricted to time context ");
+        try {
+            PeriodFormatter formatter = timePeriodFormatterBuilder.toFormatter();
+            formatter.printTo(writer, period);
+            writer.append(" +/-");
+            new PeriodFormatterBuilder().appendMinutes().appendSuffix(" minute", " minutes")
+                    .appendSeconds().appendSuffix(" second", " seconds").toFormatter().printTo(
+                            writer, this.timeDurationContext.toPeriod());
+
+            System.out.println(writer.toString());
+        } catch (IOException e) {
+            throw new RuntimeException("Failed to convert Period or Duration", e);
+        }
+
+    }
+
     private void displayEvents() {
         if (currentResults.size() == 0) {
             System.out.println("No Results found");
             return;
         }
         System.out.println(currentResults.size() + " results found. ");
-        System.out.println("Displaying events from page " +
-                currentResults.getCurrentPage());
+        System.out.println("Displaying events from page " + currentResults.getCurrentPage());
 
-        List<LoggingEvent> pageEvents = new ArrayList<LoggingEvent>(
-                currentResults.getPageSize());
+        List<LoggingEvent> pageEvents = new ArrayList<LoggingEvent>(currentResults.getPageSize());
         List<String> pageResults = currentResults.getPageResults();
         for (String eventLocation : pageResults) {
             pageEvents.add(eventStore.restore(eventLocation));
@@ -230,24 +281,24 @@
     }
 
     private void showInContext(int eventIndexOnCurrentPage) throws IOException {
-        Iterable<LoggingEvent> contextEvents = searchUtils.showEventInContext(
-                currentResults, eventIndexOnCurrentPage);
+        Iterable<LoggingEvent> contextEvents = searchUtils.showEventInContext(currentResults,
+                eventIndexOnCurrentPage);
         displayEvents(contextEvents);
     }
 
-    private static void displayEvents(Iterable<LoggingEvent> iterable) {
+    private void displayEvents(Iterable<LoggingEvent> iterable) {
         if (!iterable.iterator().hasNext()) {
             System.out.println("No results found");
             return;
         }
 
-        // TODO customized layout
-        Layout layout = new PatternLayout(
-                "[%d{ISO8601} %-5p][%20.20c][%t] %m%n");
-
         int counter = 1;
+
         for (LoggingEvent loggingEvent : iterable) {
-            System.out.print(counter + ">" + layout.format(loggingEvent));
+            String eventString = loggingEvent != null
+                    ? layout.format(loggingEvent)
+                    : "<Invalid/Corrupt LoggingEvent encountered here -- sorry, still haven't worked out why!>";
+            System.out.print(counter + ">" + eventString);
             counter++;
         }
     }
@@ -262,11 +313,9 @@
         Options options = PinpointUtils.getCommonCommandLineOptions();
 
         OptionGroup actionGroup = new OptionGroup();
-        Option browseOption = new Option("b", "browse", false,
-                "Browse the context");
+        Option browseOption = new Option("b", "browse", false, "Browse the context");
 
-        Option searchOption = new Option("s", "search", false,
-                "Search the contex");
+        Option searchOption = new Option("s", "search", false, "Search the contex");
 
         // TODO is this a standard Pinpoint option?
         Option verboseLogging = new Option("v", "verbosity", true,

Modified: labs/pinpoint/trunk/pinpoint-core/src/main/java/org/apache/logging/pinpoint/converter/EventWriter.java
URL: http://svn.apache.org/viewvc/labs/pinpoint/trunk/pinpoint-core/src/main/java/org/apache/logging/pinpoint/converter/EventWriter.java?rev=568396&r1=568395&r2=568396&view=diff
==============================================================================
--- labs/pinpoint/trunk/pinpoint-core/src/main/java/org/apache/logging/pinpoint/converter/EventWriter.java (original)
+++ labs/pinpoint/trunk/pinpoint-core/src/main/java/org/apache/logging/pinpoint/converter/EventWriter.java Tue Aug 21 20:37:51 2007
@@ -13,8 +13,10 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 import java.util.Map.Entry;
 
 import org.apache.commons.io.FileUtils;
@@ -44,8 +46,7 @@
 
     private static final String FIELD_EVENT_DATE = "eventdate";
 
-    private static final Logger LOG = PinpointUtils
-            .getLogger(EventWriter.class);
+    private static final Logger LOG = PinpointUtils.getLogger(EventWriter.class);
 
     private final File indexDirectory;
     private final Analyzer analyser;
@@ -56,20 +57,18 @@
 
     private IndexWriter indexWriter;
 
-    public static final DateTimeFormatter dateFormatter = DateTimeFormat
-            .forPattern("yyyyMMdd");
-    public static final DateTimeFormatter timeFormatter = DateTimeFormat
-            .forPattern("HHmmss");
+    public static final DateTimeFormatter dateFormatter = DateTimeFormat.forPattern("yyyyMMdd");
+    public static final DateTimeFormatter timeFormatter = DateTimeFormat.forPattern("HHmmss");
 
     private boolean optimizeOnClose;
+    private Set<String> ignoredProperties = Collections.EMPTY_SET;
 
     public EventWriter(EventStore eventStore, File indexDirectory,
-            IndexWriterFactory indexWriterFactory,
-            AnalyzerFactory analyserFactory) throws IOException {
+            IndexWriterFactory indexWriterFactory, AnalyzerFactory analyserFactory)
+            throws IOException {
         if (!indexDirectory.exists()) {
-            throw new IllegalArgumentException(
-                    "Index directory does not exist: " +
-                            indexDirectory.getAbsolutePath());
+            throw new IllegalArgumentException("Index directory does not exist: "
+                    + indexDirectory.getAbsolutePath());
         }
         if (analyserFactory == null) {
             throw new IllegalArgumentException("analyserFactory cannot be null");
@@ -86,18 +85,15 @@
         // TODO check that directories can be created
         boolean createIndex = false;
 
-        Collection luceneIndexFiles = FileUtils.listFiles(indexDirectory,
-                FileFilterUtils.asFileFilter(new IndexFileNameFilter()),
-                FileFilterUtils.trueFileFilter());
+        Collection luceneIndexFiles = FileUtils.listFiles(indexDirectory, FileFilterUtils
+                .asFileFilter(new IndexFileNameFilter()), FileFilterUtils.trueFileFilter());
         createIndex = luceneIndexFiles.size() == 0;
         if (createIndex) {
-            LOG.info("Creating new Lucene Index @ " +
-                    indexDirectory.getAbsolutePath());
+            LOG.info("Creating new Lucene Index @ " + indexDirectory.getAbsolutePath());
 
         }
 
-        indexWriter = indexWriterFactory.create(indexDirectory, analyser,
-                createIndex);
+        indexWriter = indexWriterFactory.create(indexDirectory, analyser, createIndex);
 
         LOG.debug("Initialized EventWriter: " + this.toString());
     }
@@ -118,36 +114,36 @@
 
     private Document convertDocument(LoggingEvent event, String loc) {
         Document doc = new Document();
-        doc.add(new Field("level", StringUtils.defaultString(event.getLevel()
-                .toString().toLowerCase()), Store.NO, Index.UN_TOKENIZED));
+        doc.add(new Field("level", StringUtils.defaultString(event.getLevel().toString()
+                .toLowerCase()), Store.NO, Index.UN_TOKENIZED));
 
-        doc.add(new Field("message", StringUtils.defaultString(event
-                .getMessage().toString()), Store.NO, Index.TOKENIZED));
-        doc.add(new Field("thread", StringUtils.defaultString(event
-                .getThreadName().toLowerCase()), Store.NO, Index.UN_TOKENIZED));
-        doc.add(new Field("logger", StringUtils.defaultString(event
-                .getLoggerName()), Store.NO, Index.TOKENIZED));
-        doc.add(new Field("ndc", StringUtils.defaultString(event.getNDC()),
+        doc.add(new Field("message", StringUtils.defaultString(event.getMessage().toString()),
                 Store.NO, Index.TOKENIZED));
+        doc.add(new Field("thread", StringUtils.defaultString(event.getThreadName().toLowerCase()),
+                Store.NO, Index.UN_TOKENIZED));
+        doc.add(new Field("logger", StringUtils.defaultString(event.getLoggerName()), Store.NO,
+                Index.TOKENIZED));
+        doc.add(new Field("ndc", StringUtils.defaultString(event.getNDC()), Store.NO,
+                Index.TOKENIZED));
 
         LocationInfo info = event.getLocationInformation();
         StringBuilder buf = new StringBuilder(128);
-        buf.append(info.getClassName()).append(" ").append(info.getFileName())
-                .append(" ").append(info.getMethodName()).append(" ").append(
-                        info.getLineNumber()).append(" ");
-        doc.add(new Field("locationinfo", StringUtils.defaultString(buf
-                .toString()), Store.NO, Index.TOKENIZED));
+        buf.append(info.getClassName()).append(" ").append(info.getFileName()).append(" ").append(
+                info.getMethodName()).append(" ").append(info.getLineNumber()).append(" ");
+        doc.add(new Field("locationinfo", StringUtils.defaultString(buf.toString()), Store.NO,
+                Index.TOKENIZED));
 
         addTimestamp(event, doc);
 
         // TODO others
 
         Map properties = event.getProperties();
-        for (Iterator iterator = properties.entrySet().iterator(); iterator
-                .hasNext();) {
+        for (Iterator iterator = properties.entrySet().iterator(); iterator.hasNext();) {
             Entry entry = (Map.Entry) iterator.next();
-            doc.add(new Field(entry.getKey().toString(), entry.getValue()
-                    .toString(), Store.NO, Index.TOKENIZED));
+            if (!ignoredProperties.contains(entry.getKey())) {
+                doc.add(new Field(entry.getKey().toString(), entry.getValue().toString(), Store.NO,
+                        Index.TOKENIZED));
+            }
         }
 
         // TODO add generic content field
@@ -162,12 +158,8 @@
         String date = dateFormatter.print(timestamp);
         String time = timeFormatter.print(timestamp);
 
-        doc
-                .add(new Field(FIELD_EVENT_DATE, date, Store.YES,
-                        Index.UN_TOKENIZED));
-        doc
-                .add(new Field(FIELD_EVENT_TIME, time, Store.YES,
-                        Index.UN_TOKENIZED));
+        doc.add(new Field(FIELD_EVENT_DATE, date, Store.YES, Index.UN_TOKENIZED));
+        doc.add(new Field(FIELD_EVENT_TIME, time, Store.YES, Index.UN_TOKENIZED));
         //        
     }
 
@@ -178,9 +170,7 @@
                 LOG.info("Optimizing index");
                 indexWriter.optimize();
             }
-            LOG
-                    .info("Closing indexWriter: " +
-                            indexDirectory.getAbsolutePath());
+            LOG.info("Closing indexWriter: " + indexDirectory.getAbsolutePath());
             indexWriter.close();
 
         } catch (Exception e) {
@@ -189,10 +179,9 @@
     }
 
     public String toString() {
-        return new ToStringBuilder(this).append("eventStore", eventStore)
-                .append("indexDirectory", indexDirectory.getAbsolutePath())
-                .append("analyserClass", analyser.getClass().getName())
-                .toString();
+        return new ToStringBuilder(this).append("eventStore", eventStore).append("indexDirectory",
+                indexDirectory.getAbsolutePath()).append("analyserClass",
+                analyser.getClass().getName()).toString();
 
     }
 
@@ -203,4 +192,13 @@
     public final void setOptimizeOnClose(boolean optimizeOnClose) {
         this.optimizeOnClose = optimizeOnClose;
     }
+
+    public final Set<String> getIgnoredProperties() {
+        return ignoredProperties;
+    }
+
+    public final void setIgnoredProperties(Set<String> ignoredProperties) {
+        this.ignoredProperties = ignoredProperties;
+    }
+
 }

Modified: labs/pinpoint/trunk/pinpoint-core/src/main/java/org/apache/logging/pinpoint/converter/PinpointEventWriterHandler.java
URL: http://svn.apache.org/viewvc/labs/pinpoint/trunk/pinpoint-core/src/main/java/org/apache/logging/pinpoint/converter/PinpointEventWriterHandler.java?rev=568396&r1=568395&r2=568396&view=diff
==============================================================================
--- labs/pinpoint/trunk/pinpoint-core/src/main/java/org/apache/logging/pinpoint/converter/PinpointEventWriterHandler.java (original)
+++ labs/pinpoint/trunk/pinpoint-core/src/main/java/org/apache/logging/pinpoint/converter/PinpointEventWriterHandler.java Tue Aug 21 20:37:51 2007
@@ -9,8 +9,10 @@
 package org.apache.logging.pinpoint.converter;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.log4j.spi.LoggingEvent;
 import org.apache.logging.pinpoint.LoggingEventHandler;
@@ -43,6 +45,9 @@
 
     private boolean useExceptionallySlowIndexing = false;
 
+    // private IgnornedKeyFactory ignoredMDCKeys
+    private Set<String> ignoredProperties = Collections.EMPTY_SET;
+
     public PinpointEventWriterHandler(PinpointContextSelector selector,
             IndexWriterFactory indexWriterFactory, AnalyzerFactory analyzerFactory, Counter counter) {
         this.selector = selector;
@@ -79,6 +84,7 @@
 
                 writer = new EventWriter(store, ctx.getIndexDirectory(), indexWriterFactor,
                         analyserFactory);
+                writer.setIgnoredProperties(getIgnoredProperties());
                 contextMap.put(ctx, writer);
             }
             writer.writeEvent(event);
@@ -111,6 +117,14 @@
     @ManagedAttribute(description = "Set to true if you would like to throttle this writer to a point where you can observe events being backlogged/buffered.  QA/DEBUG ONLY!")
     public final void setUseExceptionallySlowIndexing(boolean useExceptionallySlowIndexing) {
         this.useExceptionallySlowIndexing = useExceptionallySlowIndexing;
+    }
+
+    public final Set<String> getIgnoredProperties() {
+        return ignoredProperties;
+    }
+
+    public final void setIgnoredProperties(Set<String> ignoredProperties) {
+        this.ignoredProperties = ignoredProperties;
     }
 
 }

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=568396&r1=568395&r2=568396&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 20:37:51 2007
@@ -83,9 +83,8 @@
 
                 series.add(new TimeSeriesDataItem(
                         new FixedMillisecond(observedValue.getTimestamp()), rate));
-            } else {
-                lastValue = observedValue;
             }
+            lastValue = observedValue;
 
         }
         return new TimeSeriesCollection(series);

Modified: labs/pinpoint/trunk/pinpoint-search/src/main/java/org/apache/logging/pinpoint/search/PinpointSearchResults.java
URL: http://svn.apache.org/viewvc/labs/pinpoint/trunk/pinpoint-search/src/main/java/org/apache/logging/pinpoint/search/PinpointSearchResults.java?rev=568396&r1=568395&r2=568396&view=diff
==============================================================================
--- labs/pinpoint/trunk/pinpoint-search/src/main/java/org/apache/logging/pinpoint/search/PinpointSearchResults.java (original)
+++ labs/pinpoint/trunk/pinpoint-search/src/main/java/org/apache/logging/pinpoint/search/PinpointSearchResults.java Tue Aug 21 20:37:51 2007
@@ -1,20 +1,13 @@
 /**
- 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.
-
- **/
+ * 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.logging.pinpoint.search;
 
 import java.util.Collections;
@@ -28,19 +21,18 @@
 // TODO test cases for this, because I _alway_ screw up pagination
 
 /**
- * Container bean that holds the event location keys for a given search result,
- * with pagination support.
- * 
- * This class does not hold the events themselves, just the locations in the
- * {@link EventStore} in the order in which they were returned from the search.
- * 
+ * Container bean that holds the event location keys for a given search result, with pagination
+ * support. This class does not hold the events themselves, just the locations in the
+ * {@link EventStore} in the order in which they were returned from the search. Implementation Note:
+ * It _could_ be valid to have a <code>null</code> event location row because if an event was not
+ * able to be retrieved, rather than prevent ALL read access for that query, usesrs of this data
+ * should handle this condition gracefully.
  */
 public class PinpointSearchResults {
 
-    private static Logger LOG = PinpointUtils
-            .getLogger(PinpointSearchUtils.class);
+    private static Logger LOG = PinpointUtils.getLogger(PinpointSearchUtils.class);
 
-    private static final int DEFAULT_PAGE_SIZE = 10;
+    private static final int DEFAULT_PAGE_SIZE = 25;
     private final List<String> results;
     private int currentPage = 1;
     private int pageSize = DEFAULT_PAGE_SIZE;

Modified: labs/pinpoint/trunk/pinpoint-search/src/main/java/org/apache/logging/pinpoint/search/PinpointSearcher.java
URL: http://svn.apache.org/viewvc/labs/pinpoint/trunk/pinpoint-search/src/main/java/org/apache/logging/pinpoint/search/PinpointSearcher.java?rev=568396&r1=568395&r2=568396&view=diff
==============================================================================
--- labs/pinpoint/trunk/pinpoint-search/src/main/java/org/apache/logging/pinpoint/search/PinpointSearcher.java (original)
+++ labs/pinpoint/trunk/pinpoint-search/src/main/java/org/apache/logging/pinpoint/search/PinpointSearcher.java Tue Aug 21 20:37:51 2007
@@ -1,17 +1,10 @@
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 1999-2005 The Apache Software Foundation. Licensed under the Apache License, Version
+ * 2.0 (the "License"); you may not use this file except in compliance with the License. You may
+ * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ * applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
+ * the License for the specific language governing permissions and limitations under the License.
  */
 package org.apache.logging.pinpoint.search;
 
@@ -20,10 +13,12 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.log4j.Logger;
 import org.apache.log4j.spi.LoggingEvent;
 import org.apache.logging.pinpoint.PinpointContext;
 import org.apache.logging.pinpoint.resolver.OffsetAndLength;
 import org.apache.logging.pinpoint.store.EventStore;
+import org.apache.logging.pinpoint.utils.PinpointUtils;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.search.Hit;
 import org.apache.lucene.search.Hits;
@@ -34,25 +29,25 @@
 
 public class PinpointSearcher {
 
+    private static final Logger LOG = PinpointUtils.getLogger(PinpointSearcher.class);
+
     private final PinpointContext ctx;
     private IndexSearcher searcher;
 
-    private final Sort defaultSort = new Sort(new SortField[] {
-            new SortField("eventdate"), new SortField("eventtime") });
+    private final Sort defaultSort = new Sort(new SortField[] { new SortField("eventdate"),
+            new SortField("eventtime") });
     private EventStore eventStore;
 
     private ReloadPolicy reloadPolicy = new ReloadPolicyAlways();
 
-    public PinpointSearcher(PinpointContext ctx, EventStore eventStore)
-            throws IOException {
+    public PinpointSearcher(PinpointContext ctx, EventStore eventStore) throws IOException {
         this.ctx = ctx;
         reload();
         this.eventStore = eventStore;
     }
 
     private void reload() throws IOException {
-        this.searcher = new IndexSearcher(ctx.getIndexDirectory()
-                .getAbsolutePath());
+        this.searcher = new IndexSearcher(ctx.getIndexDirectory().getAbsolutePath());
         // TODO background thread to warm up the seaerches? Some sort of
         // pre-filter sort by
         // date/time?
@@ -88,11 +83,11 @@
         for (Iterator iterator = hits.iterator(); iterator.hasNext();) {
             Hit hit = (Hit) iterator.next();
             try {
-                results.add(OffsetAndLength.resolveLocationFromDocument(hit
-                        .getDocument()));
+                results.add(OffsetAndLength.resolveLocationFromDocument(hit.getDocument()));
             } catch (Exception e) {
-                throw new RuntimeException("Failed to navigate to next hit: " +
-                        debugHit(hit), e);
+                LOG.error("Failed to navigate to next hit: " + debugHit(hit), e);
+                results.add(null); // until we can debug why this ever occurs, we'll have to live
+                // with it to stop it preventing other legitimate reads
             }
         }
         return new PinpointSearchResults(results);
@@ -135,12 +130,11 @@
             Hit hit = (Hit) internalHitIterator.next();
             try {
                 Document document = hit.getDocument();
-                String eventLocationKey = OffsetAndLength
-                        .resolveLocationFromDocument(document);
+                String eventLocationKey = OffsetAndLength.resolveLocationFromDocument(document);
                 return eventStore.restore(eventLocationKey);
             } catch (Exception e) {
-                throw new RuntimeException("Failed to navigate to next hit: " +
-                        debugHit(hit), e);
+                LOG.error("Failed to navigate to next hit: " + debugHit(hit), e);
+                return null;
             }
         }
 

Modified: labs/pinpoint/trunk/pinpoint-service/src/main/resources/org/apache/logging/pinpoint/service/pinpoint-context.xml
URL: http://svn.apache.org/viewvc/labs/pinpoint/trunk/pinpoint-service/src/main/resources/org/apache/logging/pinpoint/service/pinpoint-context.xml?rev=568396&r1=568395&r2=568396&view=diff
==============================================================================
--- labs/pinpoint/trunk/pinpoint-service/src/main/resources/org/apache/logging/pinpoint/service/pinpoint-context.xml (original)
+++ labs/pinpoint/trunk/pinpoint-service/src/main/resources/org/apache/logging/pinpoint/service/pinpoint-context.xml Tue Aug 21 20:37:51 2007
@@ -51,6 +51,12 @@
   	<constructor-arg ref="indexWriterFactory" />
   	<constructor-arg ref="analyserFactory" />
   	<constructor-arg ref="eventsWrittenCounter" />
+  	<property name="ignoredProperties">
+  		<set>
+  			<value>forward.begin</value>
+  			<value>forward.end</value>
+  		</set>
+  	</property>
   </bean>
 
   <bean id="receivedEventsCounter" class="org.apache.logging.pinpoint.metric.Counter" >



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