Skip to Content.
Sympa Menu

idok-commit - [idok-commit] idok commit r331 - in branches/dmsd2/java/ch/idok/dmsd: impl/controller impl/queue pipeline

idok-commit AT lists.psi.ch

Subject: Commit emails of the iDok project

List archive

[idok-commit] idok commit r331 - in branches/dmsd2/java/ch/idok/dmsd: impl/controller impl/queue pipeline


Chronological Thread 
  • From: "AFS account Stadler Hans Christian" <stadler_h AT savannah.psi.ch>
  • To: idok-commit AT lists.psi.ch
  • Subject: [idok-commit] idok commit r331 - in branches/dmsd2/java/ch/idok/dmsd: impl/controller impl/queue pipeline
  • Date: Thu, 26 Feb 2009 16:37:58 +0100
  • List-archive: <https://lists.web.psi.ch/pipermail/idok-commit/>
  • List-id: Commit emails of the iDok project <idok-commit.lists.psi.ch>

Author: stadler_h
Date: Thu Feb 26 16:37:58 2009
New Revision: 331

Log:
Bugfixing the event based pipeline; logging improvements

Modified:
branches/dmsd2/java/ch/idok/dmsd/impl/controller/SimpleController.java
branches/dmsd2/java/ch/idok/dmsd/impl/queue/DataEvent.java
branches/dmsd2/java/ch/idok/dmsd/impl/queue/EventQueue.java
branches/dmsd2/java/ch/idok/dmsd/impl/queue/SignalEvent.java
branches/dmsd2/java/ch/idok/dmsd/pipeline/PipelineSignal.java

Modified:
branches/dmsd2/java/ch/idok/dmsd/impl/controller/SimpleController.java
==============================================================================
--- branches/dmsd2/java/ch/idok/dmsd/impl/controller/SimpleController.java
(original)
+++ branches/dmsd2/java/ch/idok/dmsd/impl/controller/SimpleController.java
Thu Feb 26 16:37:58 2009
@@ -64,11 +64,6 @@
private Config config;

/**
- * @brief The token that will be sent through the pipeline.
- */
- private PipelineData token;
-
- /**
* @brief Local logger with name "dmsd.controller"
*/
public Logger logger;
@@ -329,7 +324,7 @@
public void push(PipelineData data) {
logger.fine("Indexed " + data.repositoryChange.path.getName());
monitor.incCounter("operation.indexed.documents", 1);
- data.clear();
+ data.dispose();
}

/**
@@ -376,6 +371,24 @@
}

/**
+ * @brief Handle events in the queue until there are no more
+ */
+ void eventLoop() {
+ Event event = EventQueue.dequeue();
+ while (event != null) {
+ try {
+ event.handle();
+ event.dispose();
+ event = EventQueue.dequeue();
+ } catch (Throwable th) {
+ StringBuffer msg = new StringBuffer("Exception in event
loop:\n");
+ logger.warning(Util.getStackTrace(msg, th).toString());
+ }
+ Thread.yield();
+ }
+ }
+
+ /**
* @brief Start daemon operation.
*
* This method starts the inner daemon loop. One iteration corresponds to
@@ -401,7 +414,6 @@
MonitoringHandler monitoringHandler =
config.getMonitoringManager();
isStopped = false;
stopnow = false;
- token = PipelineData.getInstance();
loop: do {
monitoringHandler.startCycle();
monitor.resumeTimer("operation.time");
@@ -411,26 +423,19 @@
logger.finest("Signalling START");
getOut().signal(new PipelineSignal(Signal.START, this));
while (!(finished || stopnow)) {
+ eventLoop();
logger.finest("Releasing token");
+ PipelineData token = PipelineData.getInstance();
token.stage = this;
getOut().push(this, token);
- Event event = EventQueue.dequeue();
- while (event != null) {
- try {
- event.handle();
- event = EventQueue.dequeue();
- } catch (Throwable th) {
- StringBuffer msg = new StringBuffer("Exception
in event loop:\n");
- logger.warning(Util.getStackTrace(msg,
th).toString());
- }
- }
- token.clear();
}
logger.finest("Signalling STOP");
getOut().signal(new PipelineSignal(Signal.STOP, this));
+ eventLoop();
monitor.suspendTimer("operation.time");
logger.finest("Signalling GET_COUNTERS");
getOut().signal(new PipelineSignal(Signal.GET_COUNTERS,
this));
+ eventLoop();
// Handle our own monitoring data here to avoid multiple
// invocations
monitoringHandler.handleMonitoringData(monitor);
@@ -456,7 +461,6 @@
logger.warning(Util.getStackTrace(ex).toString());
} finally {
isStopped = true;
- token.dispose();
monitor.suspendTimer("operation.time");
SimpleControllerManager.cyclicCleanupThread.interrupt();
config.destroy();
@@ -552,9 +556,9 @@
* @brief Called at the end of an indexing cycle.
*/
public void endCycle() {
- if (monitorValues == null)
- monitorValues = new StringBuilder();
- monitorValues.append("--- ACCUMULATED VALUES ---\n");
+ if (monitorValues != null)
+ logger.fine(monitorValues.toString());
+ monitorValues = new StringBuilder("\n--- ACCUMULATED MONITOR VALUES
---\n");
for (String key : accum.keySet()) {
monitorValues.append(key);
monitorValues.append(" = ");
@@ -562,7 +566,7 @@
monitorValues.append("\n");
}
accum.clear();
- monitorValues.append("--------------------------");
+ monitorValues.append("----------------------------------");
logger.info(monitorValues.toString());
monitorValues = null;
}

Modified: branches/dmsd2/java/ch/idok/dmsd/impl/queue/DataEvent.java
==============================================================================
--- branches/dmsd2/java/ch/idok/dmsd/impl/queue/DataEvent.java (original)
+++ branches/dmsd2/java/ch/idok/dmsd/impl/queue/DataEvent.java Thu Feb 26
16:37:58 2009
@@ -68,10 +68,9 @@
*/
@Override
public void handle() throws DmsException {
- if (data != null)
- if (data.stage != null)
- data.stage.push(data);
- DmsException.throwIt(ErrorType.INTERNAL, this, "Bug detected", "Data
event handler called without valid data object!");
+ if ((data == null) || (data.stage == null))
+ DmsException.throwIt(ErrorType.INTERNAL, this, "Bug detected",
"Data event handler called without valid data object!");
+ data.stage.push(data);
}

/**
@@ -79,6 +78,6 @@
*/
@Override
public String toString() {
- return this.getClass().toString()+": "+data.toString();
+ return
this.getClass().toString()+"(->"+data==null?"null":data.stage.toString()+")";
}
}

Modified: branches/dmsd2/java/ch/idok/dmsd/impl/queue/EventQueue.java
==============================================================================
--- branches/dmsd2/java/ch/idok/dmsd/impl/queue/EventQueue.java (original)
+++ branches/dmsd2/java/ch/idok/dmsd/impl/queue/EventQueue.java Thu Feb 26
16:37:58 2009
@@ -57,7 +57,7 @@
*/
public static void enqueue(Event event) {
instance().eventQueue.add(event);
- logger.finest("Enqueued event: "+event);
+ logger.finest("Enqueueing event: "+event);
}

/**

Modified: branches/dmsd2/java/ch/idok/dmsd/impl/queue/SignalEvent.java
==============================================================================
--- branches/dmsd2/java/ch/idok/dmsd/impl/queue/SignalEvent.java
(original)
+++ branches/dmsd2/java/ch/idok/dmsd/impl/queue/SignalEvent.java Thu
Feb 26 16:37:58 2009
@@ -30,6 +30,11 @@
*/
public final class SignalEvent extends Event {
/**
+ * @brief Exception identified for this class
+ */
+ private final static String id = "SignalEvent";
+
+ /**
* @brief Signal destination
*/
public PipelineStage destination;
@@ -51,7 +56,14 @@
/**
* @brief Create a signaling event object
*/
- public static SignalEvent getInstance(PipelineStage dest, PipelineSignal
sig) {
+ public static SignalEvent getInstance(PipelineStage dest, PipelineSignal
sig)
+ throws DmsException {
+ if (dest == null)
+ DmsException.throwIt(ErrorType.INTERNAL, id,
+ "Bug detected", "SignalEvent.getInstance called with
invalid pipeline stage argument!");
+ if (sig == null)
+ DmsException.throwIt(ErrorType.INTERNAL, id,
+ "Bug detected", "SignalEvent.getInstance called with
invalid signal argument!");
return new SignalEvent(dest, sig);
}

@@ -77,10 +89,9 @@
*/
@Override
public void handle() throws DmsException {
- if (signal != null)
- if (destination != null)
- destination.signal(signal);
- DmsException.throwIt(ErrorType.INTERNAL, this, "Bug detected",
"Signal handler was called without a valid signal object!");
+ if ((signal == null) || (destination == null))
+ DmsException.throwIt(ErrorType.INTERNAL, this, "Bug detected",
"Signal handler was called without a valid signal object!");
+ destination.signal(signal);
}

/**
@@ -88,6 +99,6 @@
*/
@Override
public String toString() {
- return this.getClass().toString()+"("+signal+"): "+destination;
+ return this.getClass().toString()+"("+signal+"->"+destination+")";
}
}

Modified: branches/dmsd2/java/ch/idok/dmsd/pipeline/PipelineSignal.java
==============================================================================
--- branches/dmsd2/java/ch/idok/dmsd/pipeline/PipelineSignal.java
(original)
+++ branches/dmsd2/java/ch/idok/dmsd/pipeline/PipelineSignal.java Thu
Feb 26 16:37:58 2009
@@ -56,5 +56,13 @@
type = sig;
originator = orig;
}
-
+
+ /**
+ * @brief Return a description of this object
+ * @return String describing this object
+ */
+ @Override
+ public String toString() {
+ return this.getClass().toString()+"("+type+", "+originator+")";
+ }
}



  • [idok-commit] idok commit r331 - in branches/dmsd2/java/ch/idok/dmsd: impl/controller impl/queue pipeline, AFS account Stadler Hans Christian, 02/26/2009

Archive powered by MHonArc 2.6.19.

Top of Page