Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r4168 - in trunk/ps-mdm-flowsa-ma: conf src/main/java/org/perfsonar/service/measurementArchive/flowsa

Subject: perfsonar development work

List archive

perfsonar: r4168 - in trunk/ps-mdm-flowsa-ma: conf src/main/java/org/perfsonar/service/measurementArchive/flowsa


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r4168 - in trunk/ps-mdm-flowsa-ma: conf src/main/java/org/perfsonar/service/measurementArchive/flowsa
  • Date: Sat, 12 Jul 2008 20:55:44 -0400

Author: michael.bischoff
Date: 2008-07-12 20:55:43 -0400 (Sat, 12 Jul 2008)
New Revision: 4168

Added:

trunk/ps-mdm-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/FlowsaConfiguration.java
Modified:
trunk/ps-mdm-flowsa-ma/conf/components.properties

trunk/ps-mdm-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/FlowsaMAServiceEngine.java

trunk/ps-mdm-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/LSRegistrationControll.java
Log:
separated configuration
Changed ls registration mechanism data is still a bit off.

Modified: trunk/ps-mdm-flowsa-ma/conf/components.properties
===================================================================
--- trunk/ps-mdm-flowsa-ma/conf/components.properties 2008-07-12 02:04:53
UTC (rev 4167)
+++ trunk/ps-mdm-flowsa-ma/conf/components.properties 2008-07-13 00:55:43
UTC (rev 4168)
@@ -14,11 +14,9 @@

context=org.perfsonar.base.auxiliary.components.context.inMemory.InMemoryContext

# workaround helper
-ls_Helper=org.perfsonar.service.measurementArchive.flowsa.LSHelper
+ls_Helper=org.perfsonar.service.measurementArchive.flowsa.LSRegistrationControll

-# - DO NOT USE - Registration in LS
-# - DO NOT USE - the service will load this component depending on
service.r.ls_url has a valid value in service.properties
-# - DO NOT USE -
registrator=org.perfsonar.service.base.registration.LSRegistrationComponent
+registrator=org.perfsonar.service.base.registration.LSRegistrationComponent


authn=org.perfsonar.commons.auxiliary.components.authn.wssec.WSSecAuthNComponent


Added:
trunk/ps-mdm-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/FlowsaConfiguration.java

Modified:
trunk/ps-mdm-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/FlowsaMAServiceEngine.java
===================================================================
---
trunk/ps-mdm-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/FlowsaMAServiceEngine.java
2008-07-12 02:04:53 UTC (rev 4167)
+++
trunk/ps-mdm-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/FlowsaMAServiceEngine.java
2008-07-13 00:55:43 UTC (rev 4168)
@@ -11,14 +11,12 @@
import java.util.Date;
import java.util.List;
import java.util.Set;
-import java.util.TreeSet;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

import org.ggf.ns.nmwg.base.v2_0.Message;
import org.perfsonar.base.auxiliary.AuxiliaryComponentManager;
import org.perfsonar.base.auxiliary.ComponentNames;
-import
org.perfsonar.base.auxiliary.components.configuration.ConfigurationComponent;
import org.perfsonar.base.auxiliary.components.logger.LoggerComponent;
import org.perfsonar.base.exceptions.PerfSONARException;
import org.perfsonar.service.base.engine.ActionType;
@@ -54,41 +52,10 @@

protected static final String SERVICE_TYPE =
"service.MeasurementArchive.flowType";

- protected static final int DEFAULT_MAX_RESULTS = 1000;
- protected static final int DEFAULT_TIMEOUT = 10;
- protected static final int DEFAULT_NFCAPDINTERVAL = 5;
- 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;
-
- protected static final String TIMEOUT_PROPERTY_KEY =
"service.ma.flowsa.query.timeout";
- protected static final String NFDUMPLOCATION_PROPERTY_KEY =
"service.ma.flowsa.nfdump.location";
- 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 NFCAPDINTERVAL_PROPERTY_KEY =
"service.ma.flowsa.nfcapd.interval";
- protected static final String EXPORTER_PROPERTY_PART =
"service.common.flow.exporter.";
- protected static final String EXPORTERHOST_PROPERTY_PART = ".address";
- protected static final String EXPORTERPORT_PROPERTY_PART = ".port";
- protected static final String EXPORTERDESCRIPTION_PROPERTY_PART =
".description";
- protected static final String EXPORTEROS_PROPERTY_PART =
".operating-system";
- protected static final String EXPORTERFLOWVERSION_PROPERTY_PART =
".flow-version";
- protected static final String EXPORTERFLOWRATE_PROPERTY_PART =
".sample-rate";
- protected static final String
EXPORTERLOCATIONINSTITUTION_PROPERTY_PART = ".location.institution";
- protected static final String EXPORTERLOCATIONCITY_PROPERTY_PART =
".location.city";
- protected static final String EXPORTERLOCATIONCOUNTRY_PROPERTY_PART =
".location.country";
- protected static final String EXPORTERLOCATIONLATITUDE_PROPERTY_PART
= ".location.latitude";
- protected static final String
EXPORTERLOCATIONLONGTITUDE_PROPERTY_PART = ".location.longitude";
-
protected final LoggerComponent logger;
- protected final ConfigurationComponent configuration;
+ protected final FlowsaConfiguration configuration;
protected final NfdumpControll nfdump;
protected final NfcapdControll nfcapd;
- protected final LSRegistrationControll ls;

/**
* Default constructor for the Service engine
@@ -97,19 +64,11 @@
public FlowsaMAServiceEngine() throws PerfSONARException {
this.logger = getLoggerComponent();
logger.debug("FlowsaMAServiceEngine.<Constructor> Creating...
FlowsaMAServiceEngine.");
- this.configuration = getConfigurationComponent();
+ this.configuration = new FlowsaConfiguration();
this.nfcapd = createNfcapdControll();
logger.debug("FlowsaMAServiceEngine.<Constructor> Successfully
created NfcapdControll.");
this.nfdump = createNfdumpControll();
logger.debug("FlowsaMAServiceEngine.<Constructor> Successfully
created NfdumpControll.");
-
- this.ls = new LSRegistrationControll();
- logger.debug("FlowsaMAServiceEngine.<Constructor> Successfully
created LSRegistrationControll.");
-
- if(ls.isConfigured(configuration) && !ls.hasStarted()) {
- ls.start(nfcapd.getExporters());
- logger.debug("FlowsaMAServiceEngine.<Constructor> Started
LSRegistrationControll.");
- }
}

/* (non-Javadoc)
@@ -301,7 +260,7 @@
* @throws PerfSONARException
*/
protected NfdumpControll createNfdumpControll() throws
PerfSONARException {
- File nfdumpExecutable =
getNfdumpExecutableFrom(configuration);
+ File nfdumpExecutable = configuration.getNfdumpExecutable();

if (!nfdumpExecutable.exists()) {
logger.error("Nfdump executable not found!
("+nfdumpExecutable+")");
throw new PerfSONARException(
@@ -310,9 +269,9 @@
);
}

- int maxResults = getMaxResultsFrom(configuration);
- int timeoutValue = getTimeoutValueFrom(configuration);
- String readerFactoryClassName =
getReaderFactoryClassNameFrom(configuration);
+ int maxResults = configuration.getMaxResults();
+ int timeoutValue = configuration.getTimeoutValue();
+ String readerFactoryClassName =
configuration.getReaderFactoryClassName();
try {
return new
NfdumpControll(nfdumpExecutable,readerFactoryClassName,maxResults,timeoutValue);
} catch (Exception e) {
@@ -329,7 +288,7 @@
* @throws PerfSONARException on failure
*/
protected NfcapdControll createNfcapdControll() throws
PerfSONARException {
- File sourceDirectory = getSourceDirectory(configuration);
+ File sourceDirectory = configuration.getSourceDirectory();
if(!sourceDirectory.exists()) {
logger.warn("FlowsaMAServiceEngine.checkSource Source
directory doesn't exist trying to create.");
try {
@@ -347,7 +306,7 @@
}
}

- boolean startNfcapdProcesses =
getShouldStartNfcapdProcesses(configuration);
+ boolean startNfcapdProcesses =
configuration.getShouldStartNfcapdProcesses();

if(startNfcapdProcesses && !sourceDirectory.canWrite()) {
throw new PerfSONARException(
@@ -356,9 +315,9 @@
);
}

- Set<Exporter> exporters = getExporters(sourceDirectory,
configuration);
+ Set<Exporter> exporters =
configuration.getExporters(sourceDirectory);

- File nfcapdExecutable =
getNfcapdExecutableFrom(configuration);
+ File nfcapdExecutable = configuration.getNfcapdExecutable();

if (!nfcapdExecutable.exists()) {
logger.error("nfcapd executable not found!
("+nfcapdExecutable+")");
throw new PerfSONARException(
@@ -367,7 +326,7 @@
);
}

- int interval = getNfcapdInterval(configuration);
+ int interval = configuration.getNfcapdInterval();

return new NfcapdControll(nfcapdExecutable, exporters,
interval, startNfcapdProcesses);
}
@@ -394,217 +353,13 @@
}
return fileData;
}
- /**
- * looks up the property from the specified source. returns the
default value
- * if the source didn't supply one.
- * @param source
- * @return boolean if nfcapdControll should start it's own processes
- */
- private boolean getShouldStartNfcapdProcesses(ConfigurationComponent
source) {
- boolean shouldStart = DEFAULT_SHOULDSTARTNFCAPDPROCESSES;
- try {
- shouldStart =
Boolean.parseBoolean(source.getProperty(SHOULDSTARTNFCAPDPROCESSES_PROPERTY_KEY));
- } catch (PerfSONARException e) {
- logger.debug("No configuration found: using standard value for
should start nfcapd processes");
- return DEFAULT_SHOULDSTARTNFCAPDPROCESSES;
- }
- return shouldStart;
- }
- /**
- * Get's the exporters from the configuration source. Checks access
to the specified source dir.
- * @param sourceDir
- * @param source
- * @return a set of exporters or null if exporters couldn't be located
- * @throws PerfSONARException
- */
- private Set<Exporter> getExporters(File sourceDir,
ConfigurationComponent source) throws PerfSONARException {
- Set<Exporter> exporters = new TreeSet<Exporter>();
- for(int i = 1; ;i++) {
- try {
- String value =
configuration.getProperty(EXPORTER_PROPERTY_PART+i+".enabled");
- if(!value.equalsIgnoreCase("true")) continue;
- } catch (PerfSONARException e) {
- break;
- }
- logger.debug("FlowsaMAServiceEngine.getExporters:
found an enabled exporter with number "+i);
-
- Exporter exporter = getExporter(i, sourceDir, source);
- if(exporter!=null) {
- exporters.add(exporter);
- }
- }
- if(exporters.isEmpty()) throw new PerfSONARException("No router
configuration found!");
- return exporters;
- }
- private Exporter getExporter(int i, File sourceDir,
ConfigurationComponent source) {
- // get required
- Exporter exporter;
- try {
- String host =
source.getProperty(EXPORTER_PROPERTY_PART + i + EXPORTERHOST_PROPERTY_PART);
- int port =
Integer.parseInt(source.getProperty(EXPORTER_PROPERTY_PART + i +
EXPORTERPORT_PROPERTY_PART));
- String flowVersion =
source.getProperty(EXPORTER_PROPERTY_PART + i +
EXPORTERFLOWVERSION_PROPERTY_PART);
- int flowRate =
Integer.parseInt(source.getProperty(EXPORTER_PROPERTY_PART + i +
EXPORTERFLOWRATE_PROPERTY_PART));
- exporter = new Exporter(sourceDir, host, port,
flowVersion, flowRate);
- } catch (Exception e) {
- logger.warn("FlowsaMAServiceEngine.getExporter:
Couldn't create exporter (" + e.getLocalizedMessage() + ")");
- return null;
- }
- exporter.setDescription(getExporterProperty(source, i,
EXPORTERDESCRIPTION_PROPERTY_PART));
- exporter.setOperatingSystem(getExporterProperty(source, i,
EXPORTEROS_PROPERTY_PART));
- exporter.setInstitution(getExporterProperty(source, i,
EXPORTERLOCATIONINSTITUTION_PROPERTY_PART));
- exporter.setCity(getExporterProperty(source, i,
EXPORTERLOCATIONCITY_PROPERTY_PART));
- exporter.setCountry(getExporterProperty(source, i,
EXPORTERLOCATIONCOUNTRY_PROPERTY_PART));
- exporter.setLatitude(getExporterProperty(source, i,
EXPORTERLOCATIONLATITUDE_PROPERTY_PART));
- exporter.setLongtitude(getExporterProperty(source, i,
EXPORTERLOCATIONLONGTITUDE_PROPERTY_PART));

- return exporter;
- }
-
- private String getExporterProperty(ConfigurationComponent source,int
i, String property) {
- try {
- return source.getProperty(EXPORTER_PROPERTY_PART + i
+ property);
- } catch (PerfSONARException e) {
- logger.warn(EXPORTER_PROPERTY_PART + i + property + "
could not be read");
- }
- return null;
- }
/**
- * 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 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_NFDUMP_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 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) {
- try {
- return
Integer.parseInt(source.getProperty(TIMEOUT_PROPERTY_KEY));
- } catch (PerfSONARException e) {
- logger.debug("No configuration found: using standard MaxResult
for nfDump");
- return DEFAULT_TIMEOUT;
- } catch (NumberFormatException e) {
- logger.debug("Couldn't parse from configuration: using standard
MaxResult for nfDump");
- return DEFAULT_TIMEOUT;
- }
- }
- /**
- * looks up the property from the specified source. returns the
default value
- * if the source didn't supply one.
- * @param source
- * @return property for MaxResults
- */
- private int getMaxResultsFrom(ConfigurationComponent source) {
- try {
- return
Integer.parseInt(source.getProperty(MAXRESULTS_PROPERTY_KEY));
- } catch (PerfSONARException e) {
- logger.debug("No configuration found: using standard MaxResult
for nfDump");
- return DEFAULT_MAX_RESULTS;
- } catch (NumberFormatException e) {
- logger.debug("Couldn't parse from configuration: using standard
MaxResult for nfDump");
- return DEFAULT_MAX_RESULTS;
- }
- }
- /**
- * looks up the property from the specified source. returns the
default value
- * if the source didn't supply one.
- * @param source
- * @return property for ReaderFactoryClassName
- */
- private String getReaderFactoryClassNameFrom(ConfigurationComponent
source) {
- String name;
- try {
- name =
source.getProperty(READERFACTORYCLASSNAME_PROPERTY_KEY);
- } catch (PerfSONARException e) {
- logger.debug("No configuration found: using standard
ReaderFactory class-name for nfDump");
- return DEFAULT_READERFACTORYCLASSNAME;
- }
- return name;
- }
- /**
- * looks up the property from the specified source. returns the
default value
- * if the source didn't supply one.
- * @param source
- * @return property for SourceDirectory
- */
- private File getSourceDirectory(ConfigurationComponent source) {
- String name;
- try {
- name = source.getProperty(SOURCEDIRECTORY_PROPERTY_KEY);
- } catch (PerfSONARException e) {
- logger.debug("No configuration found: using standard
ReaderFactory class-name for nfDump");
- return DEFAULT_SOURCEDIRECTORY;
- }
- return new File(name);
- }
- /**
- * looks up the property from the specified source. returns the
default value
- * if the source didn't supply one.
- * @param source
- * @return property for SourceDirectory
- */
- private int getNfcapdInterval(ConfigurationComponent source) {
- try {
- return
Integer.parseInt(source.getProperty(NFCAPDINTERVAL_PROPERTY_KEY));
- } catch (PerfSONARException e) {
- logger.debug("No configuration found: using standard interval
for nfcapd");
- return DEFAULT_NFCAPDINTERVAL;
- } catch (NumberFormatException e) {
- logger.debug("Couldn't parse from configuration: using standard
interval for nfcapd");
- return DEFAULT_NFCAPDINTERVAL;
- }
- }
- /**
- * gets the configuration component
- * @return a non-null ConfigurationComponent
- * @throws PerfSONARException
- */
- protected ConfigurationComponent getConfigurationComponent() throws
PerfSONARException {
- try {
- return (ConfigurationComponent)
AuxiliaryComponentManager.getInstance().getComponent(ComponentNames.CONFIG);
- } catch (PerfSONARException underlayingException) {
- throw new PerfSONARException(
- "error.common.no_configuration",
- "FlowTypeMAServiceEngine.constructor: Cannot get config
component",
- underlayingException
- );
- }
- }
- /**
* get's the logger component
* @return a non-null LoggerComponent
* @throws PerfSONARException
*/
- protected LoggerComponent getLoggerComponent() throws
PerfSONARException {
+ private LoggerComponent getLoggerComponent() throws
PerfSONARException {
try {
return (LoggerComponent)
AuxiliaryComponentManager.getInstance().getComponent(ComponentNames.LOGGER);
} catch (PerfSONARException underlayingException) {

Modified:
trunk/ps-mdm-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/LSRegistrationControll.java
===================================================================
---
trunk/ps-mdm-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/LSRegistrationControll.java
2008-07-12 02:04:53 UTC (rev 4167)
+++
trunk/ps-mdm-flowsa-ma/src/main/java/org/perfsonar/service/measurementArchive/flowsa/LSRegistrationControll.java
2008-07-13 00:55:43 UTC (rev 4168)
@@ -2,35 +2,40 @@

import static
org.perfsonar.service.base.registration.InformationContextServiceContent.REGISTRATION_DATA;

+import java.io.File;
import java.util.Set;

import org.perfsonar.base.auxiliary.AuxiliaryComponent;
import org.perfsonar.base.auxiliary.AuxiliaryComponentManager;
import org.perfsonar.base.auxiliary.ComponentNames;
-import
org.perfsonar.base.auxiliary.components.configuration.ConfigurationComponent;
import
org.perfsonar.base.auxiliary.components.context.PerfsonarContextComponent;
import org.perfsonar.base.exceptions.PerfSONARException;
import org.perfsonar.service.measurementArchive.flowsa.nfcapd.Exporter;

/**
* Workaround until we find a better way
+ * Adapted the workaround to be better but now it's a real workaround.
*
* @author michael.bischoff
- *
*/
-public class LSRegistrationControll {
+public class LSRegistrationControll implements AuxiliaryComponent {

- /**
- * starts registration
- * @param exporters
- * @throws PerfSONARException
- */
- public void start(Set<Exporter> exporters) throws PerfSONARException {
- update(exporters);
- AuxiliaryComponent registrator =
AuxiliaryComponentManager.getInstance().loadComponent("registrator",
"org.perfsonar.service.base.registration.LSRegistrationComponent");
- registrator.initComponent();
+ private String componentName;
+
+ public String getComponentName() {
+ return componentName;
}

+ public void setComponentName(String componentName) {
+ this.componentName = componentName;
+ }
+
+ public void initComponent() throws PerfSONARException {
+ FlowsaConfiguration configuration = new FlowsaConfiguration();
+ File sourceDirectory = configuration.getSourceDirectory();
+ update(configuration.getExporters(sourceDirectory));
+ }
+
/**
* updates with new data
* @param exporters
@@ -58,28 +63,5 @@
);
context.put(REGISTRATION_DATA, new String[] {
builder.toString() });
}
-
- /**
- * tests if the ls registration is configured
- * @param configuration
- * @return true if the ls registration is configured
- */
- public boolean isConfigured(ConfigurationComponent configuration) {
- try {
- String lsUrl =
configuration.getProperty("service.r.ls_url");
- return !lsUrl.trim().equals("");
- } catch (PerfSONARException e) {
- return false;
- }
- }
-
- /**
- * Checks if registration has started
- * @return true if it has started
- * @throws PerfSONARException
- */
- public boolean hasStarted() throws PerfSONARException {
- return
AuxiliaryComponentManager.getInstance().getComponent("")!=null;
- }
-
+
}



  • perfsonar: r4168 - in trunk/ps-mdm-flowsa-ma: conf src/main/java/org/perfsonar/service/measurementArchive/flowsa, svnlog, 07/12/2008

Archive powered by MHonArc 2.6.16.

Top of Page