perfsonar-dev - perfsonar: r3037 - in branches/new-structure/trunk/surfnet_java-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa: . nfcapd
Subject: perfsonar development work
List archive
perfsonar: r3037 - in branches/new-structure/trunk/surfnet_java-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa: . nfcapd
Chronological Thread
- From:
- To:
- Subject: perfsonar: r3037 - in branches/new-structure/trunk/surfnet_java-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa: . nfcapd
- Date: Tue, 13 Nov 2007 11:15:54 -0500
Author: gijs
Date: 2007-11-13 11:15:54 -0500 (Tue, 13 Nov 2007)
New Revision: 3037
Modified:
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/FlowsaMAServiceEngine.java
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/nfcapd/NfcapdControll.java
Log:
nfcapd
Modified:
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/FlowsaMAServiceEngine.java
===================================================================
---
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/FlowsaMAServiceEngine.java
2007-11-13 08:19:38 UTC (rev 3036)
+++
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/FlowsaMAServiceEngine.java
2007-11-13 16:15:54 UTC (rev 3037)
@@ -45,7 +45,8 @@
protected static final int DEFAULT_MAX_RESULTS = 1000;
protected static final int DEFAULT_TIMEOUT = 10;
- protected static final File DEFAULT_EXECUTABLE_FILE = new
File("/usr/local/bin/nfdump");
+ protected static final File DEFAULT_NFDUMP_EXECUTABLE = new
File("/usr/local/bin/nfdump");
+ protected static final File DEFAULT_NFCAPD_EXECUTABLE = new
File("/usr/local/bin/nfcapd");
protected static final String DEFAULT_READERFACTORYCLASSNAME =
"org.perfsonar.service.measurementArchive.flowsa.FlowsaMAServiceEngine";
protected static final File DEFAULT_SOURCEDIRECTORY = new
File("/var/nfdump/flows/");
protected static final boolean DEFAULT_SHOULDSTARTNFCAPDPROCESSES =
false;
@@ -55,6 +56,7 @@
protected static final String MAXRESULTS_PROPERTY_KEY =
"service.ma.flowsa.query.max-results";
protected static final String READERFACTORYCLASSNAME_PROPERTY_KEY =
"service.ma.flowsa.nfdump.ouputreader";
protected static final String SOURCEDIRECTORY_PROPERTY_KEY =
"service.ma.flowsa.nfdump.source";
+ protected static final String NFCAPDLOCATION_PROPERTY_KEY =
"service.ma.flowsa.nfcapd.location";
protected static final String SHOULDSTARTNFCAPDPROCESSES_PROPERTY_KEY
= "service.ma.flowsa.nfcapd.start-processes";
protected static final String EXPORTERS_PROPERTY_KEY =
"service.ma.flowsa.exporters";
@@ -277,7 +279,7 @@
* @throws PerfSONARException
*/
protected NfdumpControll createNfdumpControll() throws
PerfSONARException {
- File nfdumpExecutable = getExecutableFrom(configuration);
+ File nfdumpExecutable =
getNfdumpExecutableFrom(configuration);
if (!nfdumpExecutable.exists()) {
logger.error("Nfdump executable not found!
("+nfdumpExecutable+")");
throw new PerfSONARException(
@@ -331,7 +333,16 @@
Set<Exporter> exporters = getExporters(sourceDirectory,
configuration);
- return new NfcapdControll(exporters, startNfcapdProcesses);
+ File nfcapdExecutable =
getNfcapdExecutableFrom(configuration);
+ if (!nfcapdExecutable.exists()) {
+ logger.error("Nfdump executable not found!
("+nfcapdExecutable+")");
+ throw new PerfSONARException(
+ "", //TODO errorcode
+ "Nfdump executable not found. "
+ );
+ }
+
+ return new NfcapdControll(nfcapdExecutable, exporters,
startNfcapdProcesses);
}
/**
* looks up the property from the specified source. returns the
default value
@@ -397,13 +408,13 @@
* @param source
* @return Executable
*/
- private File getExecutableFrom(ConfigurationComponent source) {
+ private File getNfdumpExecutableFrom(ConfigurationComponent source) {
String fileLocation = null;
try {
fileLocation = source.getProperty(NFDUMPLOCATION_PROPERTY_KEY);
} catch (PerfSONARException e) {
logger.debug("No configuration found: using standard location
for nfDump");
- return DEFAULT_EXECUTABLE_FILE;
+ return DEFAULT_NFDUMP_EXECUTABLE;
}
return new File(fileLocation);
}
@@ -411,6 +422,22 @@
* looks up the property from the specified source. returns the
default value
* if the source didn't supply one.
* @param source
+ * @return Executable
+ */
+ private File getNfcapdExecutableFrom(ConfigurationComponent source) {
+ String fileLocation = null;
+ try {
+ fileLocation = source.getProperty(NFCAPDLOCATION_PROPERTY_KEY);
+ } catch (PerfSONARException e) {
+ logger.debug("No configuration found: using standard location
for nfDump");
+ return DEFAULT_NFCAPD_EXECUTABLE;
+ }
+ return new File(fileLocation);
+ }
+ /**
+ * looks up the property from the specified source. returns the
default value
+ * if the source didn't supply one.
+ * @param source
* @return property for Timeout value
*/
private int getTimeoutValueFrom(ConfigurationComponent source) {
Modified:
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/nfcapd/NfcapdControll.java
===================================================================
---
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/nfcapd/NfcapdControll.java
2007-11-13 08:19:38 UTC (rev 3036)
+++
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/nfcapd/NfcapdControll.java
2007-11-13 16:15:54 UTC (rev 3037)
@@ -1,6 +1,8 @@
package org.perfsonar.service.measurementArchive.flowsa.nfcapd;
+import java.io.File;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.util.Collection;
import java.util.Date;
import java.util.Set;
@@ -54,19 +56,24 @@
}
+ private final File nfcapdExecutable;
private final Set<Exporter> exporters;
private final boolean startingNfcapdProcesses;
- public NfcapdControll(Set<Exporter> exporters, boolean
startNfcapdProcesses) {
+ public NfcapdControll(File nfcapdExecutable, Set<Exporter> exporters,
boolean startNfcapdProcesses) {
+ if(startNfcapdProcesses && !nfcapdExecutable.exists()) {
+ throw new IllegalArgumentException("Nfcapd doesn't
exist.");
+ }
+ this.nfcapdExecutable = nfcapdExecutable;
this.exporters = exporters;
this.startingNfcapdProcesses = startNfcapdProcesses;
if(startNfcapdProcesses) {
- startNfcapdProcesses();
+ startNfcapdProcesses();
}
}
protected void startNfcapdProcesses() {
- //TODO start nfcapd processes
+ new NfcapdProcessesControllThread().start();
}
public Exporter getExporterByHostName(String hostname) {
@@ -116,11 +123,28 @@
return new FileData(startFile,endFile,directories);
}
- protected class NfcapdProcessesControllThread implements Runnable {
+ /**
+ * Minimal support for starting of nfcapd processes, handling of
stopping the deamons in not arranged for.
+ * @author michael.bischoff
+ */
+ protected class NfcapdProcessesControllThread extends Thread {
- public void run() {
-
+ private Set<Process> processes = new TreeSet<Process>();
+
+ public void run() {
+ for(Exporter exporter : exporters) {
+ startNfcapdProcess(exporter.getDirectory(),
exporter.getPort());
+ }
}
+
+ private void startNfcapdProcess(String directory, int port) {
+ try {
+ String[] commands = new String[] {
nfcapdExecutable.getAbsolutePath(), "-w", "-D", "-l", directory, "-p",
String.valueOf(port) };
+ processes.add(new
ProcessBuilder(commands).start());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
}
- perfsonar: r3037 - in branches/new-structure/trunk/surfnet_java-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa: . nfcapd, svnlog, 11/13/2007
Archive powered by MHonArc 2.6.16.