[LOGBack-dev] svn commit: r520 - in logback/trunk: logback-classic/src/main/java/ch/qos/logback/classic logback-classic/src/main/java/ch/qos/logback/classic/boolex logback-classic/src/main/java/ch/qos/logback/classic/spi logback-classic/src/test/java/ch/qos/logback/classic/net logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders logback-core/src/main/java/ch/qos/logback/core
noreply.seb at qos.ch
noreply.seb at qos.ch
Thu Sep 7 17:40:38 CEST 2006
Author: seb
Date: Thu Sep 7 17:40:37 2006
New Revision: 520
Added:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextRemoteView.java
- copied, changed from r518, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContextRemoteView.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerRemoteView.java
- copied, changed from r518, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerRemoteView.java
Removed:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContextRemoteView.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerRemoteView.java
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/boolex/JaninoEventEvaluator.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/ExternalMockSocketServer.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventBuilder.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/MinimalSerBuilder.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java
Log:
- moved *RemoteView classes to spi
- modified ouput of performance test classes
- other minor fixes
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java Thu Sep 7 17:40:37 2006
@@ -18,6 +18,7 @@
import org.slf4j.Marker;
+import ch.qos.logback.classic.spi.LoggerRemoteView;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.filter.Filter;
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java Thu Sep 7 17:40:37 2006
@@ -15,6 +15,7 @@
import org.slf4j.ILoggerFactory;
+import ch.qos.logback.classic.spi.LoggerContextRemoteView;
import ch.qos.logback.core.ContextBase;
import ch.qos.logback.core.CoreGlobal;
import ch.qos.logback.core.status.ErrorStatus;
@@ -41,7 +42,7 @@
public LoggerContext() {
super();
this.loggerCache = new Hashtable<String, Logger>();
- this.loggerContextRemoteView = new LoggerContextRemoteView(getName(), getPropertyMap());
+ this.loggerContextRemoteView = new LoggerContextRemoteView(this);
this.root = new Logger(ROOT_NAME, null, this);
this.root.setLevel(Level.DEBUG);
loggerCache.put(ROOT_NAME, root);
@@ -54,7 +55,7 @@
* the name or propertyMap (including keys or values) changes.
*/
private void syncRemoteView() {
- loggerContextRemoteView = new LoggerContextRemoteView(getName(), getPropertyMap());
+ loggerContextRemoteView = new LoggerContextRemoteView(this);
for(Logger logger : loggerCache.values()) {
logger.buildRemoteView();
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/boolex/JaninoEventEvaluator.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/boolex/JaninoEventEvaluator.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/boolex/JaninoEventEvaluator.java Thu Sep 7 17:40:37 2006
@@ -6,7 +6,7 @@
import org.slf4j.Marker;
import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.LoggerRemoteView;
+import ch.qos.logback.classic.spi.LoggerRemoteView;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.CoreGlobal;
import ch.qos.logback.core.boolex.JaninoEventEvaluatorBase;
Copied: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextRemoteView.java (from r518, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContextRemoteView.java)
==============================================================================
--- /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContextRemoteView.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextRemoteView.java Thu Sep 7 17:40:37 2006
@@ -1,11 +1,19 @@
-package ch.qos.logback.classic;
+package ch.qos.logback.classic.spi;
import java.io.Serializable;
import java.util.Map;
+import ch.qos.logback.classic.LoggerContext;
+
/**
* LoggerContextRemoteView offers a restricted view of LoggerContext intended to be
- * exposed by LoggingEvent. This restricted view is optimiyed for serialisation.
+ * exposed by LoggingEvent. This restricted view is optimised for serialisation.
+ *
+ * Some of the LoggerContext or Logger attributes should not survive
+ * serialization, e.g appenders, level values etc, as these attributes may
+ * have other values on the remote platform. LoggerContextRemoteView class exposes
+ * the minimal (relevant) attributes to remote host, instead of having to deal with
+ * an incomplete LoggerContext with many null references.
*
* @author Ceki Gülcü
* @author Sébastien Pennec
@@ -20,13 +28,15 @@
public LoggerContextRemoteView(LoggerContext lc) {
- this(lc.getName(), lc.getPropertyMap());
+ //this(lc.getName(), lc.getPropertyMap());
+ this.name = lc.getName();
+ this.propertyMap = lc.getPropertyMap();
}
- public LoggerContextRemoteView(String name, Map<String, String> propertyMap) {
- this.name = name;
- this.propertyMap = propertyMap;
- }
+// public LoggerContextRemoteView(String name, Map<String, String> propertyMap) {
+// this.name = name;
+// this.propertyMap = propertyMap;
+// }
public String getName() {
return name;
Copied: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerRemoteView.java (from r518, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerRemoteView.java)
==============================================================================
--- /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerRemoteView.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerRemoteView.java Thu Sep 7 17:40:37 2006
@@ -8,14 +8,18 @@
* Software Foundation.
*/
-package ch.qos.logback.classic;
+package ch.qos.logback.classic.spi;
import java.io.Serializable;
+import ch.qos.logback.classic.LoggerContext;
+
/**
* An interface that allows Logger objects and LoggerSer objects to be used the
* same way be client of the LoggingEvent object.
- *
+ * <p>
+ * See {@link LoggerContextRemoteView} for the rationale of this class.
+ *
* @author Ceki Gülcü
* @author Sébastien Pennec
*/
@@ -27,7 +31,7 @@
final LoggerContextRemoteView loggerContextView;
final String name;
- LoggerRemoteView(String name, LoggerContext lc) {
+ public LoggerRemoteView(String name, LoggerContext lc) {
this.name = name;
assert lc.getLoggerContextRemoteView() != null;
loggerContextView = lc.getLoggerContextRemoteView();
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java Thu Sep 7 17:40:37 2006
@@ -21,7 +21,6 @@
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.LoggerRemoteView;
/**
* The internal representation of logging events. When an affirmative decision
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/ExternalMockSocketServer.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/ExternalMockSocketServer.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/ExternalMockSocketServer.java Thu Sep 7 17:40:37 2006
@@ -67,7 +67,7 @@
sum += a + 1;
is.skip(a);
}
- System.out.println(sum);
+ System.out.println(sum/1000 + " KB");
}
serverSocket.close();
} catch (Exception se) {
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java Thu Sep 7 17:40:37 2006
@@ -14,8 +14,8 @@
ObjectOutputStream oos;
int loopNumber = 10000;
- int resetFrequency = 500;
- int pauseFrequency = 500;
+ int resetFrequency = 100;
+ int pauseFrequency = 10;
long pauseLengthInMillis = 20;
/**
@@ -40,46 +40,58 @@
/**
* Last results:
- * Data sent mesured in bytes.
- * Avg time mesured in nanos.
+ * Data sent mesured in kilobytes.
+ * Avg time mesured in microsecs.
*
* NOPOutputStream:
* | | Runs | Avg time | Data sent |
- * | MinimalObj Ext | 10000 | 6511 | |
- * | MinimalObj Ser | 10000 | 7883 | |
- * | LoggEvent Ext | 10000 | 9641 | |
- * | LoggEvent Ser | 10000 | 25729 | |
+ * | MinimalObj Ext | 10000 | | |
+ * | MinimalObj Ser | 10000 | | |
+ * | LoggEvent Ext | 10000 | | |
+ * | LoggEvent Ser | 10000 | | |
*
- * External MockServer with 45 letters-long message:
+ * External MockServer with 45 letters-long message: on localhost
+ * (always the same message)
* | | Runs | Avg time | Data sent |
- * | MinimalObj Ext | 10000 | 70240 | 1171384 |
- * | MinimalObj Ser | 10000 | 62754 | 1157584 |
- * | LoggEvent Ext | 10000 | 198910 | 1509984 |
- * | LoggEvent Ser | 10000 | 189970 | 1715984 |
- * pauseFrequency = 200 and pauseLengthInMillis = 50
+ * | MinimalObj Ext | 10000 | - | - |
+ * | MinimalObj Ser | 10000 | 74 | 248 |
+ * | LoggEvent Ext | 10000 | - | - |
+ * | LoggEvent Ser | 10000 | 156 | 835 |
+ * pauseFrequency = 10 and pauseLengthInMillis = 20
*
- * External MockServer with 2 letters-long message:
+ * External MockServer with 45 letters-long message: on localhost
+ * (different message each time)
* | | Runs | Avg time | Data sent |
- * | MinimalObj Ext | 10000 | 43234 | 311384 |
- * | MinimalObj Ser | 10000 | 31603 | 297584 |
- * | LoggEvent Ext | 10000 | 106442 | 649984 |
- * | LoggEvent Ser | 10000 | 93467 | 855984 |
- * pauseFrequency = 200 and pauseLengthInMillis = 50
+ * | MinimalObj Ext | 10000 | | |
+ * | MinimalObj Ser | 10000 | 73 | 1139 |
+ * | LoggEvent Ext | 10000 | | |
+ * | LoggEvent Ser | 10000 | 162 | 1752 |
+ * pauseFrequency = 10 and pauseLengthInMillis = 20
*
- * External MockServer with 45 letters-long message:
- * This test was done by sending always the _same_ loggerEvent object.
+ * External MockServer with 45 letters-long message: on PIXIE
+ * (always the same message)
* | | Runs | Avg time | Data sent |
- * | MinimalObj Ext | 10000 | 28739 | 123604 |
- * | MinimalObj Ser | 10000 | 27431 | 129604 |
- * | LoggEvent Ext | 10000 | 30112 | 125604 |
- * | LoggEvent Ser | 10000 | 26059 | 153404 |
- * pauseFrequency = 500 and pauseLengthInMillis = 50
+ * | MinimalObj Ext | 10000 | - | - |
+ * | MinimalObj Ser | 10000 | 29 | 248 |
+ * | LoggEvent Ext | 10000 | - | - |
+ * | LoggEvent Ser | 10000 | 42 | 835 |
+ * pauseFrequency = 10 and pauseLengthInMillis = 20
+ *
+ * External MockServer with 45 letters-long message: on PIXIE
+ * (different message each time)
+ * | | Runs | Avg time | Data sent |
+ * | MinimalObj Ext | 10000 | | |
+ * | MinimalObj Ser | 10000 | 27 | 1139 |
+ * | LoggEvent Ext | 10000 | | |
+ * | LoggEvent Ser | 10000 | 44 | 1752 |
+ * pauseFrequency = 10 and pauseLengthInMillis = 20
+ *
*/
public void setUp() throws Exception {
super.setUp();
if (runWithExternalMockServer) {
- oos = new ObjectOutputStream(new Socket("localhost",
+ oos = new ObjectOutputStream(new Socket("pixie",
ExternalMockSocketServer.PORT).getOutputStream());
} else {
oos = new ObjectOutputStream(new NOPOutputStream());
@@ -144,8 +156,9 @@
fail(ex.getMessage());
}
}
+ total /= 1000;
System.out.println(label + " : average time = " + total / loopNumber
- + " after " + loopNumber + " writes.");
+ + " microsecs after " + loopNumber + " writes.");
// long time2 = System.nanoTime();
// System.out.println("********* -> Time needed to run the test method: " +
@@ -156,7 +169,7 @@
// Builder builder = new MinimalExtBuilder();
// runPerfTest(builder, "Minimal object externalization");
// }
-
+
public void testWithMinimalSerialization() throws Exception {
Builder builder = new MinimalSerBuilder();
runPerfTest(builder, "Minimal object serialization");
@@ -166,7 +179,7 @@
// Builder builder = new LoggingEventExtBuilder();
// runPerfTest(builder, "LoggingEvent object externalization");
// }
-
+
public void testWithSerialization() throws Exception {
Builder builder = new LoggingEventBuilder();
runPerfTest(builder, "LoggingEvent object serialization");
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java Thu Sep 7 17:40:37 2006
@@ -5,8 +5,8 @@
import junit.framework.TestCase;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.LoggerContextRemoteView;
-import ch.qos.logback.classic.LoggerRemoteView;
+import ch.qos.logback.classic.spi.LoggerContextRemoteView;
+import ch.qos.logback.classic.spi.LoggerRemoteView;
import ch.qos.logback.classic.spi.LoggingEvent;
public class SocketAppenderTest extends TestCase {
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventBuilder.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventBuilder.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventBuilder.java Thu Sep 7 17:40:37 2006
@@ -14,7 +14,7 @@
le.setLevel(Level.DEBUG);
le.setLoggerRemoteView(logger.getLoggerRemoteView());
//le.setLogger(new LoggerContext().getLogger(LoggerContext.ROOT_NAME));
- le.setMessage(MSG_PREFIX + i);
+ le.setMessage(MSG_PREFIX);
le.setThreadName("threadName");
return le;
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/MinimalSerBuilder.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/MinimalSerBuilder.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/MinimalSerBuilder.java Thu Sep 7 17:40:37 2006
@@ -18,6 +18,6 @@
String message;
public MinimalSer(int i) {
- message = Builder.MSG_PREFIX + i;
+ message = Builder.MSG_PREFIX;
}
}
\ No newline at end of file
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java Thu Sep 7 17:40:37 2006
@@ -21,7 +21,9 @@
private String name;
StatusManager sm = new BasicStatusManager();
- // FIXME must be observable
+ // TODO propertyMap should be observable so that we can be notified
+ // when it changes so that a new instance of propertyMap can be
+ // serialized. For the time being, we ignore this shortcoming.
Map<String, String> propertyMap = new HashMap<String, String>();
Map<String, Object> objectMap = new HashMap<String, Object>();
Map<String, String> converterMap = new HashMap<String, String>();
@@ -31,7 +33,6 @@
return sm;
}
- // FIXME
public Map<String, String> getPropertyMap() {
return propertyMap;
}
More information about the logback-dev
mailing list