perfsonar-dev - perfsonar: r3922 - in trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription: . wizard
Subject: perfsonar development work
List archive
perfsonar: r3922 - in trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription: . wizard
Chronological Thread
- From:
- To:
- Subject: perfsonar: r3922 - in trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription: . wizard
- Date: Fri, 30 May 2008 10:09:41 -0400
Author: michael.bischoff
Date: 2008-05-30 10:09:40 -0400 (Fri, 30 May 2008)
New Revision: 3922
Added:
trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription/Pipe.java
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/SubscriptionService.java
trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription/wizard/WizardHandler.java
Log:
Unix Pipe ('|') implemented in java
fixed some code warnings.
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-30 12:22:32 UTC (rev 3921)
+++
trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription/NfReplayControll.java
2008-05-30 14:09:40 UTC (rev 3922)
@@ -4,7 +4,6 @@
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -192,21 +191,23 @@
private class NfreplayTask implements Callable<Integer> {
- private final ProcessBuilder builder = new ProcessBuilder();
-
+ private final ProcessBuilder builder1 = new ProcessBuilder();
+ private final ProcessBuilder builder2;
+
NfreplayTask(File target, String filter, String
anonomisingKey, int port) {
- builder.redirectErrorStream(true);
- List<String> commands = builder.command();
- if(anonomisingKey!=null) {
- commands.add(nfdumpExecutable);
- commands.add("-r");
- commands.add(target.getAbsolutePath());
- commands.add("-K");
- commands.add(anonomisingKey);
- commands.add("-w");
- commands.add("-");
- commands.add("|");
- }
+ builder1.redirectErrorStream(true);
+
+ List<String> commands;
+ if(anonomisingKey==null) {
+ builder2 = null;
+ commands = builder1.command();
+ } else {
+ builder1.command(buildNfdumpCommand(target,
anonomisingKey));
+
+ builder2 = new ProcessBuilder();
+ commands = builder2.command();
+ }
+
commands.add(nfreplayExecutable);
commands.add("-p");
commands.add(String.valueOf(port));
@@ -218,17 +219,32 @@
commands.add(filter);
}
}
+
+ private List<String> buildNfdumpCommand(File target, String
anonomisingKey) {
+ List<String> commands = builder1.command();
+ commands.add(nfdumpExecutable);
+ commands.add("-r");
+ commands.add(target.getAbsolutePath());
+ commands.add("-K");
+ commands.add(anonomisingKey);
+ commands.add("-w");
+ commands.add("-");
+ return commands;
+ }
public Integer call() throws Exception {
Process proces = null;
+ Process pipeTarget = null;
try {
try {
- logger.debug("Executing replay: " +
Arrays.toString(builder.command().toArray()) );
- proces = builder.start();
- InputStream input =
proces.getInputStream();
- while(input.read() != -1) {
- /* ignore */
+ String commands =
Arrays.toString(builder1.command().toArray());
+ proces = builder1.start();
+ if(builder2!=null) {
+ pipeTarget = builder2.start();
+ commands += " piped into " +
Arrays.toString(builder2.command().toArray());
+ new
Pipe(proces,pipeTarget).call();
}
+ logger.debug("Executing replay: " +
commands);
return
Integer.valueOf(proces.waitFor());
} catch (IOException e) {
logger.warn("Error relaying output");
@@ -237,6 +253,9 @@
if(proces != null) {
proces.destroy();
}
+ if(pipeTarget != null) {
+ pipeTarget.destroy();
+ }
}
return null;
}
Added:
trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription/Pipe.java
Modified:
trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription/SubscriptionService.java
===================================================================
---
trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription/SubscriptionService.java
2008-05-30 12:22:32 UTC (rev 3921)
+++
trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription/SubscriptionService.java
2008-05-30 14:09:40 UTC (rev 3922)
@@ -42,7 +42,7 @@
for(Subscription subscription :
deathSubscriptions) {
end(subscription);
}
- logger.debug("Ran timeoutChecker,
cleaned up "+deathSubscriptions.size()+" death subscriptions. (est. alive:
"+subscriptions.size()+")");
+ logger.debug("TimeoutChecker#run()
Ran timeoutChecker, cleaned up "+deathSubscriptions.size()+" death
subscriptions. (est. alive: "+subscriptions.size()+")");
deathSubscriptions.clear();
Thread.sleep(timeoutCheckInterval);
}
Modified:
trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription/wizard/WizardHandler.java
===================================================================
---
trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription/wizard/WizardHandler.java
2008-05-30 12:22:32 UTC (rev 3921)
+++
trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription/wizard/WizardHandler.java
2008-05-30 14:09:40 UTC (rev 3922)
@@ -89,7 +89,7 @@
return configured;
}
- public void setHTMLOutput(HTMLOutput output) {}
+ public void setHTMLOutput(HTMLOutput output) { /* QUESTION not used?
*/ }
public void setProperties(WizardProperties loadedProperties) {
properties = loadedProperties;
@@ -109,15 +109,12 @@
*
* @param request
* The HttpServletRequest containing input from the user
- * @return True if other groups are configured successfully
* @throws Exception
*/
public void handleOther(HttpServletRequest request) throws Exception {
- // Getting all groups
- Iterator groupIt = groupedProperties.keySet().iterator();
+
// Iterating through the groups
- while (groupIt.hasNext()) {
- String group = (String) groupIt.next();
+ for(String group : groupedProperties.keySet()) {
// Every other group should be handled except for
eXist and LS
if (!(group.equals("eXist") || group.equals("LS"))) {
- perfsonar: r3922 - in trunk/surfnet_java-flowsubscription-mp/src/main/java/org/perfsonar/service/measurementPoint/flowsubscription: . wizard, svnlog, 05/30/2008
Archive powered by MHonArc 2.6.16.