logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r1022842 - in /logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw: ChainsawCyclicBufferTableModel.java EventContainer.java LogPanel.java LoggingEventWrapper.java RuleMediator.java
Date Fri, 15 Oct 2010 07:19:21 GMT
Author: sdeboy
Date: Fri Oct 15 07:19:21 2010
New Revision: 1022842

URL: http://svn.apache.org/viewvc?rev=1022842&view=rev
Log:
Performance improvements
 - only applying find rule filtering from mediator if find rule filtering is required
 - no longer refiltering when properties are added or removed

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/EventContainer.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggingEventWrapper.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/RuleMediator.java

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java?rev=1022842&r1=1022841&r2=1022842&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
Fri Oct 15 07:19:21 2010
@@ -86,12 +86,12 @@ class ChainsawCyclicBufferTableModel ext
   //use and increment this row counter as the ID for each received row
   int uniqueRow;
   private final Set uniquePropertyKeys = new HashSet();
-  private Rule displayRule;
+  private Rule ruleMediator;
   private final PropertyChangeSupport propertySupport = new PropertyChangeSupport(this);
   private RuleColorizer colorizer;
   private final String tableModelName;
 
-    public ChainsawCyclicBufferTableModel(int cyclicBufferSize, RuleColorizer colorizer,
String tableModelName) {
+  public ChainsawCyclicBufferTableModel(int cyclicBufferSize, RuleColorizer colorizer, String
tableModelName) {
     propertySupport.addPropertyChangeListener("cyclic", new ModelChanger());
     this.cyclicBufferSize = cyclicBufferSize;
     this.colorizer = colorizer;
@@ -106,12 +106,18 @@ class ChainsawCyclicBufferTableModel ext
    */
   public void propertyChange(PropertyChangeEvent evt) {
     if (evt.getSource() instanceof Rule) {
-      reFilter();
+      if (evt.getSource() == ruleMediator && evt.getPropertyName().equals("findRule"))
{
+        if (((RuleMediator) evt.getSource()).isFindRuleRequired()) {
+          //only refilter if find rule is required
+          reFilter();
+        }
+      } else {
+        reFilter();
+      }
     }
   }
 
   public List getMatchingEvents(Rule rule) {
-
     List list = new ArrayList();
     List unfilteredCopy;
     synchronized (mutex) {
@@ -138,7 +144,7 @@ class ChainsawCyclicBufferTableModel ext
             propertySupport.firePropertyChange("refilter", Boolean.FALSE, Boolean.TRUE);
             previousSize = filteredList.size();
             filteredList.clear();
-            if (displayRule == null) {
+            if (ruleMediator == null) {
                 LoggingEventWrapper lastEvent = null;
                 for (Iterator iter = unfilteredList.iterator();iter.hasNext();) {
                     LoggingEventWrapper loggingEventWrapper = (LoggingEventWrapper)iter.next();
@@ -153,7 +159,7 @@ class ChainsawCyclicBufferTableModel ext
                 while (iter.hasNext()) {
                   LoggingEventWrapper loggingEventWrapper = (LoggingEventWrapper) iter.next();
 
-                  if (displayRule.evaluate(loggingEventWrapper.getLoggingEvent(), null))
{
+                  if (ruleMediator.evaluate(loggingEventWrapper.getLoggingEvent(), null))
{
                     loggingEventWrapper.setDisplayed(true);
                     filteredList.add(loggingEventWrapper);
                     updateEventMillisDelta(loggingEventWrapper, lastEvent);
@@ -302,17 +308,16 @@ class ChainsawCyclicBufferTableModel ext
    *
    * In any case, the model ensures the Filtered list is made up to date in a separate thread.
    */
-  public void setDisplayRule(Rule displayRule) {
-    if (this.displayRule != null) {
-      this.displayRule.removePropertyChangeListener(this);
+  public void setRuleMediator(RuleMediator ruleMediator) {
+    if (this.ruleMediator != null) {
+      this.ruleMediator.removePropertyChangeListener(this);
     }
 
-    this.displayRule = displayRule;
+    this.ruleMediator = ruleMediator;
 
-    if (this.displayRule != null) {
-      this.displayRule.addPropertyChangeListener(this);
+    if (this.ruleMediator != null) {
+      this.ruleMediator.addPropertyChangeListener(this);
     }
-
     reFilter();
   }
 
@@ -636,7 +641,7 @@ class ChainsawCyclicBufferTableModel ext
             lastLoggingEventWrapper = (LoggingEventWrapper) unfilteredList.get(unfilteredSize
- 1);
         }
         unfilteredList.add(loggingEventWrapper);
-        if ((displayRule == null) || (displayRule.evaluate(loggingEventWrapper.getLoggingEvent(),
null))) {
+        if ((ruleMediator == null) || (ruleMediator.evaluate(loggingEventWrapper.getLoggingEvent(),
null))) {
             loggingEventWrapper.setDisplayed(true);
             updateEventMillisDelta(loggingEventWrapper, lastLoggingEventWrapper);
             filteredList.add(loggingEventWrapper);

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/EventContainer.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/EventContainer.java?rev=1022842&r1=1022841&r2=1022842&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/EventContainer.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/EventContainer.java Fri
Oct 15 07:19:21 2010
@@ -145,10 +145,10 @@ public interface EventContainer extends 
    */
   void reFilter();
   /**
-   * Sets the DisplayFilter in operation
-   * @param displayRule
+   * Sets the RuleMediator in operation
+   * @param ruleMediator
    */
-  void setDisplayRule(Rule displayRule);
+  void setRuleMediator(RuleMediator ruleMediator);
 
   /**
    * Returns the index of the LoggingEventWrapper

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java?rev=1022842&r1=1022841&r2=1022842&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java Fri Oct 15
07:19:21 2010
@@ -727,8 +727,8 @@ public class LogPanel extends DockablePa
      * Set the Display rule to use the mediator, the model will add itself as
      * a property change listener and update itself when the rule changes.
      */
-    tableModel.setDisplayRule(tableRuleMediator);
-    searchModel.setDisplayRule(searchRuleMediator);
+    tableModel.setRuleMediator(tableRuleMediator);
+    searchModel.setRuleMediator(searchRuleMediator);
 
     tableModel.addEventCountListener(
       new EventCountListener() {

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggingEventWrapper.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggingEventWrapper.java?rev=1022842&r1=1022841&r2=1022842&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggingEventWrapper.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggingEventWrapper.java
Fri Oct 15 07:19:21 2010
@@ -82,28 +82,20 @@ public class LoggingEventWrapper {
 
   public void setProperty(String propName, String propValue) {
     loggingEvent.setProperty(propName, propValue);
-    if (propName.equals(Constants.LOG4J_ID_KEY)) {
-      id = Integer.parseInt(propValue);
-    }
-    if (!propName.equals(ChainsawConstants.MILLIS_DELTA_COL_NAME_LOWERCASE)) {
-      eventContainer.reFilter();
+    if (id == 0) {
+      if (propName.equals(Constants.LOG4J_ID_KEY)) {
+        id = Integer.parseInt(propValue);
+      }
     }
     if (syncWrapper != null && !propName.equals(ChainsawConstants.MILLIS_DELTA_COL_NAME_LOWERCASE))
{
       syncWrapper.getLoggingEvent().setProperty(propName, propValue);
-      EventContainer syncWrapperEventContainer = syncWrapper.eventContainer;
-      syncWrapperEventContainer.reFilter();
     }
   }
 
   public Object removeProperty(String propName) {
     Object result = loggingEvent.removeProperty(propName);
-    if (!propName.equals(ChainsawConstants.MILLIS_DELTA_COL_NAME_LOWERCASE)) {
-      eventContainer.reFilter();
-    }
     if (syncWrapper != null && !propName.equals(ChainsawConstants.MILLIS_DELTA_COL_NAME_LOWERCASE))
{
       syncWrapper.getLoggingEvent().removeProperty(propName);
-      EventContainer syncWrapperEventContainer = syncWrapper.eventContainer;
-      syncWrapperEventContainer.reFilter();
     }
     return result;
   }
@@ -170,9 +162,6 @@ public class LoggingEventWrapper {
   public void setDisplayed(boolean b) {
     markerHeight = DEFAULT_HEIGHT;
     msgHeight = DEFAULT_HEIGHT;
-    if (!b) {
-      setProperty(ChainsawConstants.MILLIS_DELTA_COL_NAME_LOWERCASE, "");
-    }
   }
 
   public void setPreviousDisplayedEventTimestamp(long previousDisplayedEventTimeStamp) {

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/RuleMediator.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/RuleMediator.java?rev=1022842&r1=1022841&r2=1022842&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/RuleMediator.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/RuleMediator.java Fri Oct
15 07:19:21 2010
@@ -70,6 +70,10 @@ public class RuleMediator extends Abstra
     return true;
   }
 
+  public boolean isFindRuleRequired() {
+    return findRuleRequired;
+  }
+  
   public void setFilterRule(Rule r) {
     Rule oldFilterRule = this.filterRule;
     this.filterRule = r;



Mime
View raw message