Skip to content

Commit a6416a7

Browse files
author
Gerd Behrmann
committed
Fix log filtering initialization
dCache support per cell log levels through a custom turbo filter. This turbo filter is initialized during cell initialization, however the current initialization point is at the end of the cell creation. The consequence is that messages logged before this point are not under the control of the filter. This patch moves the initialization point inside CellNucleus instead. Target: trunk Require-notes: no Require-book: no Acked-by: Paul Millar <paul.millar@desy.de> Patch: http://rb.dcache.org/r/5245/
1 parent 9942273 commit a6416a7

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

modules/cells/src/main/java/dmg/cells/nucleus/CellAdapter.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,7 @@ public CellAdapter(String cellName,
164164
setCommandExceptionEnabled(false);
165165
}
166166

167-
/* Instantiate management component for log filtering.
168-
*/
169-
CellNucleus parentNucleus =
170-
CellNucleus.getLogTargetForCell(MDC.get(CDC.MDC_CELL));
171-
FilterThresholds parentThresholds =
172-
(parentNucleus.isSystemNucleus() || parentNucleus == _nucleus)
173-
? RootFilterThresholds.getInstance()
174-
: parentNucleus.getLoggingThresholds();
175-
176-
FilterThresholds thresholds = new FilterThresholds(parentThresholds);
177-
_nucleus.setLoggingThresholds(thresholds);
178-
addCommandListener(new FilterShell(thresholds));
167+
addCommandListener(new FilterShell(_nucleus.getLoggingThresholds()));
179168

180169
if (startNow) {
181170
start();

modules/cells/src/main/java/dmg/cells/nucleus/CellNucleus.java

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
5+
import org.slf4j.MDC;
56

67
import java.io.FileNotFoundException;
78
import java.io.Reader;
@@ -28,6 +29,7 @@
2829
import dmg.util.Slf4jErrorWriter;
2930
import dmg.util.Slf4jInfoWriter;
3031
import dmg.util.logback.FilterThresholds;
32+
import dmg.util.logback.RootFilterThresholds;
3133

3234
/**
3335
*
@@ -130,6 +132,16 @@ public CellNucleus(Cell cell, String name, String type)
130132
_cell = cell;
131133
_cellClass = _cell.getClass().getName();
132134

135+
/* Instantiate management component for log filtering.
136+
*/
137+
CellNucleus parentNucleus =
138+
CellNucleus.getLogTargetForCell(MDC.get(CDC.MDC_CELL));
139+
FilterThresholds parentThresholds =
140+
(parentNucleus.isSystemNucleus() || parentNucleus == this)
141+
? RootFilterThresholds.getInstance()
142+
: parentNucleus.getLoggingThresholds();
143+
setLoggingThresholds(new FilterThresholds(parentThresholds));
144+
133145
//
134146
// for the use in restricted sandboxes
135147
//
@@ -153,7 +165,7 @@ public CellNucleus(Cell cell, String name, String type)
153165
_printoutLevel = __cellGlue.getDefaultPrintoutLevel();
154166
__cellGlue.addCell(_cellName, this);
155167

156-
_logNucleus.info("Created : "+name);
168+
_logNucleus.info("Created : " + name);
157169
}
158170

159171
/**
@@ -649,7 +661,8 @@ private void killThreads(Collection<Thread> threads)
649661
{
650662
for (Thread thread: threads) {
651663
if (thread.isAlive()) {
652-
_logNucleus.info("killerThread : interrupting " + thread.getName());
664+
_logNucleus.info("killerThread : interrupting " + thread
665+
.getName());
653666
thread.interrupt();
654667
}
655668
}
@@ -745,7 +758,7 @@ void addToEventQueue(MessageEvent ce) {
745758
//
746759
final CellMessage msg = ce.getMessage();
747760
if (msg != null) {
748-
_logNucleus.info("addToEventQueue : message arrived : "+msg);
761+
_logNucleus.info("addToEventQueue : message arrived : " + msg);
749762
CellLock lock;
750763

751764
synchronized (_waitHash) {
@@ -756,16 +769,16 @@ void addToEventQueue(MessageEvent ce) {
756769
//
757770
// we were waiting for you (sync or async)
758771
//
759-
_logNucleus.info("addToEventQueue : lock found for : "+msg);
772+
_logNucleus.info("addToEventQueue : lock found for : " + msg);
760773
if (lock.isSync()) {
761-
_logNucleus.info("addToEventQueue : is synchronous : "+msg);
774+
_logNucleus.info("addToEventQueue : is synchronous : " + msg);
762775
synchronized (lock) {
763776
lock.setObject(msg);
764777
lock.notifyAll();
765778
}
766-
_logNucleus.info("addToEventQueue : dest. was triggered : "+msg);
779+
_logNucleus.info("addToEventQueue : dest. was triggered : " + msg);
767780
} else {
768-
_logNucleus.info("addToEventQueue : is asynchronous : "+msg);
781+
_logNucleus.info("addToEventQueue : is asynchronous : " + msg);
769782
try {
770783
_callbackExecutor.execute(new CallbackTask(lock, msg));
771784
} catch (RejectedExecutionException e) {
@@ -794,7 +807,7 @@ void sendKillEvent(KillEvent ce)
794807
Thread thread = new Thread(__cellGlue.getKillerThreadGroup(), wrapLoggingContext(new KillerTask(ce)), "killer-" + _cellName);
795808
thread.start();
796809
_logNucleus.info("sendKillEvent : {} started on group {}",
797-
thread.getName(), thread.getThreadGroup().getName());
810+
thread.getName(), thread.getThreadGroup().getName());
798811
}
799812

800813
//
@@ -962,7 +975,7 @@ public void run()
962975
shutdownPrivateExecutors();
963976

964977
_logNucleus.info("killerThread : waiting for all threads in {} to finish",
965-
_threads);
978+
_threads);
966979

967980
try {
968981
Collection<Thread> threads = getNonDaemonThreads(_threads);
@@ -1089,15 +1102,18 @@ public void innerRun()
10891102
//
10901103
if (_logMessages.isDebugEnabled()) {
10911104
String messageObject = msg.getMessageObject() == null? "NULL" : msg.getMessageObject().getClass().getName();
1092-
_logMessages.debug("nucleusMessageArrived src=" + msg.getSourcePath() +
1093-
" dest=" + msg.getDestinationPath() + " [" + messageObject + "] UOID=" + msg.getUOID().toString());
1105+
_logMessages.debug("nucleusMessageArrived src=" + msg
1106+
.getSourcePath() +
1107+
" dest=" + msg
1108+
.getDestinationPath() + " [" + messageObject + "] UOID=" + msg
1109+
.getUOID().toString());
10941110
}
10951111
//
10961112
// and deliver it
10971113
//
1098-
_logNucleus.info("messageThread : delivering message : "+msg);
1114+
_logNucleus.info("messageThread : delivering message : " + msg);
10991115
_cell.messageArrived(new MessageEvent(msg));
1100-
_logNucleus.info("messageThread : delivering message done : "+msg);
1116+
_logNucleus.info("messageThread : delivering message done : " + msg);
11011117
} catch (RuntimeException e) {
11021118
if (!msg.isReply()) {
11031119
try {

0 commit comments

Comments
 (0)