[logback-dev] svn commit: r2093 - in logback/trunk: logback-classic/src/main/java/ch/qos/logback/classic/sift logback-core/src/main/java/ch/qos/logback/core/sift logback-core/src/test/java/ch/qos/logback/core/sift logback-core/src/test/java/ch/qos/logback/core/sift/tracker
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Fri Dec 19 19:24:52 CET 2008
Author: ceki
Date: Fri Dec 19 19:24:52 2008
New Revision: 2093
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/sift/AppenderFactory.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingAppender.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderFactoryBase.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingAppenderBase.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/sift/AppenderTrackerTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/sift/Simulator.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/AppenderTrackerTImpl.java
Log:
- The key parameter used as a sifting discriminator is now of type String
instead of a generic K. This simplifies the code without real loss
of generality. :-)
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/sift/AppenderFactory.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/sift/AppenderFactory.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/sift/AppenderFactory.java Fri Dec 19 19:24:52 2008
@@ -17,7 +17,7 @@
import ch.qos.logback.core.sift.AppenderFactoryBase;
import ch.qos.logback.core.sift.SiftingJoranConfiguratorBase;
-public class AppenderFactory extends AppenderFactoryBase<LoggingEvent, String>{
+public class AppenderFactory extends AppenderFactoryBase<LoggingEvent>{
String mdcKey;
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingAppender.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingAppender.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingAppender.java Fri Dec 19 19:24:52 2008
@@ -26,7 +26,7 @@
*
* @author Ceki Gulcu
*/
-public class SiftingAppender extends SiftingAppenderBase<LoggingEvent, String> {
+public class SiftingAppender extends SiftingAppenderBase<LoggingEvent> {
String mdcKey;
@@ -59,7 +59,7 @@
}
}
- AppenderTracker<LoggingEvent, String> getAppenderTracker() {
+ AppenderTracker<LoggingEvent> getAppenderTracker() {
return appenderTracker;
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderFactoryBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderFactoryBase.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderFactoryBase.java Fri Dec 19 19:24:52 2008
@@ -17,7 +17,7 @@
import ch.qos.logback.core.joran.event.SaxEvent;
import ch.qos.logback.core.joran.spi.JoranException;
-public abstract class AppenderFactoryBase<E, K> {
+public abstract class AppenderFactoryBase<E> {
final List<SaxEvent> eventList;
Context context;
@@ -35,9 +35,9 @@
System.out.println(eventList);
}
- public abstract SiftingJoranConfiguratorBase<E> getSiftingJoranConfigurator(K k);
+ public abstract SiftingJoranConfiguratorBase<E> getSiftingJoranConfigurator(String k);
- Appender<E> buildAppender(Context context, K k) throws JoranException {
+ Appender<E> buildAppender(Context context, String k) throws JoranException {
SiftingJoranConfiguratorBase<E> sjc = getSiftingJoranConfigurator(k);
sjc.setContext(context);
sjc.doConfigure(eventList);
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java Fri Dec 19 19:24:52 2008
@@ -13,15 +13,15 @@
import ch.qos.logback.core.Appender;
-public interface AppenderTracker<E, K> {
+public interface AppenderTracker<E> {
static int MILLIS_IN_ONE_SECOND = 1000;
static int THRESHOLD = 30 * 60 * MILLIS_IN_ONE_SECOND; // 30 minutes
- void put(K key, Appender<E> value, long timestamp);
- Appender<E> get(K key, long timestamp);
+ void put(String key, Appender<E> value, long timestamp);
+ Appender<E> get(String key, long timestamp);
void stopStaleAppenders(long timestamp);
- List<K> keyList();
+ List<String> keyList();
List<Appender<E>> valueList();
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java Fri Dec 19 19:24:52 2008
@@ -21,9 +21,9 @@
* longer than THRESHOLD, stop it.
* @author Ceki Gulcu
*/
-public class AppenderTrackerImpl<E, K> implements AppenderTracker<E, K> {
+public class AppenderTrackerImpl<E> implements AppenderTracker<E> {
- Map<K, Entry> map = new HashMap<K, Entry>();
+ Map<String, Entry> map = new HashMap<String, Entry>();
Entry head; // least recently used entries are towards the head
Entry tail; // most recently used entries are towards the tail
@@ -36,7 +36,7 @@
}
- public synchronized void put(K key, Appender<E> value, long timestamp) {
+ public synchronized void put(String key, Appender<E> value, long timestamp) {
Entry entry = map.get(key);
if (entry == null) {
entry = new Entry(key, value, timestamp);
@@ -45,7 +45,7 @@
moveToTail(entry);
}
- public synchronized Appender<E> get(K key, long timestamp) {
+ public synchronized Appender<E> get(String key, long timestamp) {
Entry existing = map.get(key);
if (existing == null) {
return null;
@@ -70,8 +70,8 @@
}
}
- public List<K> keyList() {
- List<K> result = new LinkedList<K>();
+ public List<String> keyList() {
+ List<String> result = new LinkedList<String>();
Entry e = head;
while (e != tail) {
result.add(e.key);
@@ -151,11 +151,11 @@
Entry next;
Entry prev;
- K key;
+ String key;
Appender<E> value;
long timestamp;
- Entry(K k, Appender<E> v, long timestamp) {
+ Entry(String k, Appender<E> v, long timestamp) {
this.key = k;
this.value = v;
this.timestamp = timestamp;
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingAppenderBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingAppenderBase.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingAppenderBase.java Fri Dec 19 19:24:52 2008
@@ -12,7 +12,6 @@
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.UnsynchronizedAppenderBase;
import ch.qos.logback.core.joran.spi.JoranException;
-import ch.qos.logback.core.util.OptionHelper;
/**
* This appender can contains other appenders which it can build dynamically
@@ -24,13 +23,13 @@
*
* @author Ceki Gulcu
*/
-public abstract class SiftingAppenderBase<E, K> extends
+public abstract class SiftingAppenderBase<E> extends
UnsynchronizedAppenderBase<E> {
- protected AppenderTracker<E, K> appenderTracker = new AppenderTrackerImpl<E, K>();
- AppenderFactoryBase<E, K> appenderFactory;
+ protected AppenderTracker<E> appenderTracker = new AppenderTrackerImpl<E>();
+ AppenderFactoryBase<E> appenderFactory;
- public void setAppenderFactory(AppenderFactoryBase<E, K> appenderFactory) {
+ public void setAppenderFactory(AppenderFactoryBase<E> appenderFactory) {
this.appenderFactory = appenderFactory;
}
@@ -46,7 +45,7 @@
}
}
- abstract protected K getDiscriminatingValue(E event);
+ abstract protected String getDiscriminatingValue(E event);
abstract protected long getTimestamp(E event);
@Override
@@ -55,7 +54,7 @@
return;
}
- K value = getDiscriminatingValue(event);
+ String value = getDiscriminatingValue(event);
long timestamp = getTimestamp(event);
Appender<E> appender = appenderTracker.get(value, timestamp);
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/sift/AppenderTrackerTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/sift/AppenderTrackerTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/sift/AppenderTrackerTest.java Fri Dec 19 19:24:52 2008
@@ -16,7 +16,7 @@
Context context = new ContextBase();
- AppenderTracker<Object, String> appenderTracker = new AppenderTrackerImpl<Object, String>();
+ AppenderTracker<Object> appenderTracker = new AppenderTrackerImpl<Object>();
ListAppender<Object> la = new ListAppender<Object>();
@Before
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/sift/Simulator.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/sift/Simulator.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/sift/Simulator.java Fri Dec 19 19:24:52 2008
@@ -28,7 +28,7 @@
*/
public class Simulator {
- AppenderTrackerImpl<Object, String> appenderTracker = new AppenderTrackerImpl<Object, String>();
+ AppenderTrackerImpl<Object> appenderTracker = new AppenderTrackerImpl<Object>();
AppenderTrackerTImpl t_appenderTracker = new AppenderTrackerTImpl();
List<String> keySpace = new ArrayList<String>();
@@ -79,7 +79,7 @@
}
void play(SimulationEvent simulationEvent,
- AppenderTracker<Object, String> appenderTracker) {
+ AppenderTracker<Object> appenderTracker) {
String mdcValue = simulationEvent.key;
long timestamp = simulationEvent.timestamp;
Appender<Object> appender = appenderTracker.get(mdcValue, timestamp);
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/AppenderTrackerTImpl.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/AppenderTrackerTImpl.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/AppenderTrackerTImpl.java Fri Dec 19 19:24:52 2008
@@ -23,7 +23,7 @@
*
* @author Ceki Gulcu
*/
-public class AppenderTrackerTImpl implements AppenderTracker<Object, String> {
+public class AppenderTrackerTImpl implements AppenderTracker<Object> {
List<TEntry> entryList = new LinkedList<TEntry>();
long lastCheck = 0;
More information about the logback-dev
mailing list