perfsonar-dev - perfsonar: r3912 - trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription
Subject: perfsonar development work
List archive
perfsonar: r3912 - trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription
Chronological Thread
- From:
- To:
- Subject: perfsonar: r3912 - trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription
- Date: Thu, 29 May 2008 08:39:23 -0400
Author: michael.bischoff
Date: 2008-05-29 08:39:22 -0400 (Thu, 29 May 2008)
New Revision: 3912
Modified:
trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription/NfReplayControll.java
Log:
improved logging
Modified:
trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription/NfReplayControll.java
===================================================================
---
trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription/NfReplayControll.java
2008-05-29 12:27:44 UTC (rev 3911)
+++
trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription/NfReplayControll.java
2008-05-29 12:39:22 UTC (rev 3912)
@@ -5,14 +5,17 @@
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
+import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -120,7 +123,7 @@
}
protected void processNewFile(File target) throws
InterruptedException {
- CompletionService<Boolean> task = new
ExecutorCompletionService<Boolean>(relayer);
+ CompletionService<Integer> task = new
ExecutorCompletionService<Integer>(relayer);
int submitted = 0;
for(Subscription subscriber : interestedSubscribers) {
task.submit(
@@ -129,14 +132,23 @@
subscriber.getFilter(),
subscriber.getAnomisingKey(),
subscriber.getTunnel().getPort()
- ),
- Boolean.TRUE
+ )
);
submitted++;
}
+ List<Integer> resultValues = new ArrayList<Integer>();
for(int i=0;i<submitted;i++) {
- task.take();
+ try {
+ resultValues.add(task.take().get());
+ } catch (ExecutionException e) {
+ if(e.getCause()!= null) {
+ logger.error("nfreplaytask
failed" + e.getCause().getLocalizedMessage());
+ } else {
+ logger.error("nfreplaytask
failed " + e.getLocalizedMessage() );
+ }
+ }
}
+ logger.debug("processNewFile() Finished processing
file, nfreplaytask's exit values are:
"+Arrays.toString(resultValues.toArray()));
if(!target.delete()) logger.error("processNewFile()
Couldn't delete file("+target+") after processing it");
else logger.debug("processNewFile() deleted "+
target) ;
}
@@ -175,7 +187,7 @@
}
- private class NfreplayTask implements Runnable {
+ private class NfreplayTask implements Callable<Integer> {
private final ProcessBuilder builder = new ProcessBuilder();
@@ -204,7 +216,7 @@
}
}
- public void run() {
+ public Integer call() throws Exception {
Process proces = null;
try {
try {
@@ -214,14 +226,16 @@
while(input.read() != -1) {
/* ignore */
}
+ return
Integer.valueOf(proces.exitValue());
} catch (IOException e) {
logger.warn("Error relaying output");
- }
+ }
} finally {
if(proces != null) {
proces.destroy();
}
}
+ return null;
}
}
- perfsonar: r3912 - trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription, svnlog, 05/29/2008
Archive powered by MHonArc 2.6.16.