[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.28-39-gb5914a4
added by portage for gitosis-gentoo
git-noreply at pixie.qos.ch
Tue Apr 19 14:39:07 CEST 2011
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, master has been updated
via b5914a4afe4887e0d22a085ca8435cc0d60e8b07 (commit)
via 6db2f74bec21015ce88c54376e4b4b1c2a5214c8 (commit)
from e4aa27eb1dae6b6278ab139444d769edf1280411 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=b5914a4afe4887e0d22a085ca8435cc0d60e8b07
http://github.com/ceki/logback/commit/b5914a4afe4887e0d22a085ca8435cc0d60e8b07
commit b5914a4afe4887e0d22a085ca8435cc0d60e8b07
Merge: 6db2f74 e4aa27e
Author: Ceki Gulcu <ceki at qos.ch>
Date: Tue Apr 19 14:36:09 2011 +0200
Merge branch 'master' of git.qos.ch:/logback
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=6db2f74bec21015ce88c54376e4b4b1c2a5214c8
http://github.com/ceki/logback/commit/6db2f74bec21015ce88c54376e4b4b1c2a5214c8
commit 6db2f74bec21015ce88c54376e4b4b1c2a5214c8
Author: Ceki Gulcu <ceki at qos.ch>
Date: Tue Feb 22 13:53:53 2011 +0100
improved recovery in ResilientOutputStreamBase
diff --git a/logback-core/src/main/java/ch/qos/logback/core/recovery/RecoveryCoordinator.java b/logback-core/src/main/java/ch/qos/logback/core/recovery/RecoveryCoordinator.java
index 25bfb7b..e879008 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/recovery/RecoveryCoordinator.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/recovery/RecoveryCoordinator.java
@@ -21,7 +21,7 @@ public class RecoveryCoordinator {
private long backOffCoefficient = BACKOFF_COEFFICIENT_MIN;
private static long UNSET = -1;
- private long currentTime = UNSET;
+ private long injectedTime = UNSET;
long next = System.currentTimeMillis()+getBackoffCoefficient();
public boolean isTooSoon() {
@@ -34,13 +34,13 @@ public class RecoveryCoordinator {
}
}
- void setCurrentTime(long forcedTime) {
- currentTime = forcedTime;
+ void injectTime(long injectedTime) {
+ this.injectedTime = injectedTime;
}
private long getCurrentTime() {
- if(currentTime != UNSET) {
- return currentTime;
+ if(injectedTime != UNSET) {
+ return injectedTime;
}
return System.currentTimeMillis();
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java
index 27331e2..9a60570 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java
@@ -28,7 +28,7 @@ public class ResilientFileOutputStream extends ResilientOutputStreamBase {
throws FileNotFoundException {
this.file = file;
this.os = new FileOutputStream(file, append);
- this.presumedClean = true;
+ this.presumedUp = true;
}
public FileChannel getChannel() {
@@ -43,6 +43,12 @@ public class ResilientFileOutputStream extends ResilientOutputStreamBase {
return file;
}
+ // A successful WRITE operation confirms recovery
+ @Override
+ boolean isRecoveryConfirmingOperation(OpType opType) {
+ return opType == ResilientOutputStreamBase.OpType.WRITE;
+ }
+
@Override
String getDescription() {
diff --git a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientOutputStreamBase.java b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientOutputStreamBase.java
index 8cb9b6d..8d7be5b 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientOutputStreamBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientOutputStreamBase.java
@@ -1,13 +1,13 @@
/**
* Logback: the reliable, generic, fast and flexible logging framework.
* Copyright (C) 1999-2010, QOS.ch. All rights reserved.
- *
+ *
* This program and the accompanying materials are dual-licensed under either
* the terms of the Eclipse Public License v1.0 as published by the Eclipse
* Foundation
- *
+ *
* or (per the licensee's choosing)
- *
+ *
* under the terms of the GNU Lesser General Public License version 2.1 as
* published by the Free Software Foundation.
*/
@@ -15,6 +15,7 @@ package ch.qos.logback.core.recovery;
import java.io.IOException;
import java.io.OutputStream;
+import java.io.WriteAbortedException;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.status.ErrorStatus;
@@ -24,6 +25,8 @@ import ch.qos.logback.core.status.StatusManager;
abstract public class ResilientOutputStreamBase extends OutputStream {
+ enum OpType {WRITE, FLUSH;}
+
final static int STATUS_COUNT_LIMIT = 2 * 4;
private int noContextWarning = 0;
@@ -33,11 +36,11 @@ abstract public class ResilientOutputStreamBase extends OutputStream {
private RecoveryCoordinator recoveryCoordinator;
protected OutputStream os;
- protected boolean presumedClean = true;
+ protected boolean presumedUp = true;
final private boolean isPresumedInError() {
// existence of recoveryCoordinator indicates failed state
- return (recoveryCoordinator != null && !presumedClean);
+ return (recoveryCoordinator != null && !presumedUp);
}
public void write(byte b[], int off, int len) {
@@ -50,7 +53,7 @@ abstract public class ResilientOutputStreamBase extends OutputStream {
try {
os.write(b, off, len);
- postSuccessfulWrite();
+ postSuccessfulWrite(OpType.WRITE);
} catch (IOException e) {
postIOFailure(e);
}
@@ -66,7 +69,7 @@ abstract public class ResilientOutputStreamBase extends OutputStream {
}
try {
os.write(b);
- postSuccessfulWrite();
+ postSuccessfulWrite(OpType.WRITE);
} catch (IOException e) {
postIOFailure(e);
}
@@ -77,7 +80,7 @@ abstract public class ResilientOutputStreamBase extends OutputStream {
if (os != null) {
try {
os.flush();
- postSuccessfulWrite();
+ postSuccessfulWrite(OpType.FLUSH);
} catch (IOException e) {
postIOFailure(e);
}
@@ -88,19 +91,22 @@ abstract public class ResilientOutputStreamBase extends OutputStream {
abstract OutputStream openNewOutputStream() throws IOException;
- final private void postSuccessfulWrite() {
- if (recoveryCoordinator != null) {
+
+ abstract boolean isRecoveryConfirmingOperation(OpType opType);
+
+ final private void postSuccessfulWrite(OpType opType) {
+ if (recoveryCoordinator != null && isRecoveryConfirmingOperation(opType)) {
recoveryCoordinator = null;
statusCount = 0;
addStatus(new InfoStatus("Recovered from IO failure on "
- + getDescription(), this));
+ + getDescription(), this));
}
}
void postIOFailure(IOException e) {
addStatusIfCountNotOverLimit(new ErrorStatus("IO failure while writing to "
- + getDescription(), this, e));
- presumedClean = false;
+ + getDescription(), this, e));
+ presumedUp = false;
if (recoveryCoordinator == null) {
recoveryCoordinator = new RecoveryCoordinator();
}
@@ -120,15 +126,15 @@ abstract public class ResilientOutputStreamBase extends OutputStream {
}
addStatusIfCountNotOverLimit(new InfoStatus(
- "Attempting to recover from IO failure on " + getDescription(), this));
+ "Attempting to recover from IO failure on " + getDescription(), this));
// subsequent writes must always be in append mode
try {
os = openNewOutputStream();
- presumedClean = true;
+ presumedUp = true;
} catch (IOException e) {
addStatusIfCountNotOverLimit(new ErrorStatus("Failed to open "
- + getDescription(), this, e));
+ + getDescription(), this, e));
}
}
@@ -141,7 +147,7 @@ abstract public class ResilientOutputStreamBase extends OutputStream {
if (statusCount == STATUS_COUNT_LIMIT) {
addStatus(s);
addStatus(new InfoStatus("Will supress future messages regarding "
- + getDescription(), this));
+ + getDescription(), this));
}
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientSyslogOutputStream.java b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientSyslogOutputStream.java
index d3c3822..4fe6d9a 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientSyslogOutputStream.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientSyslogOutputStream.java
@@ -31,7 +31,7 @@ public class ResilientSyslogOutputStream extends ResilientOutputStreamBase {
this.syslogHost = syslogHost;
this.port = port;
super.os = new SyslogOutputStream(syslogHost, port);
- this.presumedClean = true;
+ this.presumedUp = true;
}
@Override
@@ -43,7 +43,13 @@ public class ResilientSyslogOutputStream extends ResilientOutputStreamBase {
OutputStream openNewOutputStream() throws IOException {
return new SyslogOutputStream(syslogHost, port);
}
-
+
+ // A successful FLUSH operation confirms recovery
+ @Override
+ boolean isRecoveryConfirmingOperation(OpType opType) {
+ return opType == ResilientOutputStreamBase.OpType.FLUSH;
+ }
+
@Override
public String toString() {
return "c.q.l.c.recovery.ResilientSyslogOutputStream@"
diff --git a/logback-core/src/test/java/ch/qos/logback/core/recovery/RecoveryCoordinatorTest.java b/logback-core/src/test/java/ch/qos/logback/core/recovery/RecoveryCoordinatorTest.java
index 1d30e5c..82d20bb 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/recovery/RecoveryCoordinatorTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/recovery/RecoveryCoordinatorTest.java
@@ -31,8 +31,10 @@ public class RecoveryCoordinatorTest {
@Test
public void smoke() {
+ rc.injectTime(now);
+ rc.isTooSoon(); // this will update the "next" field
assertTrue(rc.isTooSoon());
- rc.setCurrentTime(now+RecoveryCoordinator.BACKOFF_COEFFICIENT_MIN+1);
+ rc.injectTime(now + 5*RecoveryCoordinator.BACKOFF_COEFFICIENT_MIN);
assertFalse(rc.isTooSoon());
}
@@ -41,7 +43,7 @@ public class RecoveryCoordinatorTest {
long offset = RecoveryCoordinator.BACKOFF_COEFFICIENT_MIN;
int tooSoonCount = 0;
for(int i = 0; i < 16; i++) {
- rc.setCurrentTime(now+offset);
+ rc.injectTime(now + offset);
if(rc.isTooSoon()) {
//System.out.println("is too soon at "+(offset));
diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/AppenderAttachableImplLockTest.java b/logback-core/src/test/java/ch/qos/logback/core/spi/AppenderAttachableImplLockTest.java
index e9e1130..a32f4dd 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/spi/AppenderAttachableImplLockTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/spi/AppenderAttachableImplLockTest.java
@@ -50,7 +50,7 @@ public class AppenderAttachableImplLockTest {
private AppenderAttachableImpl<Integer> aai = new AppenderAttachableImpl<Integer>();
@SuppressWarnings("unchecked")
- @Test(timeout = 1000)
+ @Test(timeout = 2000)
public void getAppenderBoom() {
Appender<Integer> mockAppender1 = EasyMock.createStrictMock(Appender.class);
diff --git a/logback-site/src/site/resources/logback-2011.ppt b/logback-site/src/site/resources/logback-2011.ppt
index aa3d289..f720bed 100644
Binary files a/logback-site/src/site/resources/logback-2011.ppt and b/logback-site/src/site/resources/logback-2011.ppt differ
-----------------------------------------------------------------------
Summary of changes:
.../logback/core/recovery/RecoveryCoordinator.java | 10 ++--
.../core/recovery/ResilientFileOutputStream.java | 8 +++-
.../core/recovery/ResilientOutputStreamBase.java | 40 +++++++++++--------
.../core/recovery/ResilientSyslogOutputStream.java | 10 ++++-
.../core/recovery/RecoveryCoordinatorTest.java | 6 ++-
.../core/spi/AppenderAttachableImplLockTest.java | 2 +-
logback-site/src/site/resources/logback-2011.ppt | Bin 281600 -> 285696 bytes
7 files changed, 48 insertions(+), 28 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list