perfsonar-dev - perfsonar: r4938 - in trunk/perfsonar_base: . ant src/main/java/org/perfsonar/service/measurementArchive/register
Subject: perfsonar development work
List archive
perfsonar: r4938 - in trunk/perfsonar_base: . ant src/main/java/org/perfsonar/service/measurementArchive/register
Chronological Thread
- From:
- To:
- Subject: perfsonar: r4938 - in trunk/perfsonar_base: . ant src/main/java/org/perfsonar/service/measurementArchive/register
- Date: Tue, 3 Feb 2009 08:45:28 -0500
Author: roman
Date: 2009-02-03 08:45:28 -0500 (Tue, 03 Feb 2009)
New Revision: 4938
Modified:
trunk/perfsonar_base/ant/const.properties
trunk/perfsonar_base/pom.xml
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/register/LSRegistrationComponent.java
Log:
LS registration for MA service improved
- more then one LS supported
- seconds instead of milliseconds
Modified: trunk/perfsonar_base/ant/const.properties
===================================================================
--- trunk/perfsonar_base/ant/const.properties 2009-02-03 11:04:53 UTC (rev
4937)
+++ trunk/perfsonar_base/ant/const.properties 2009-02-03 13:45:28 UTC (rev
4938)
@@ -13,4 +13,4 @@
# name of jar file to be created
jarfilename=perfsonar-base
# version of the product (will be included in the final name of jar file)
-version=1.0.20090202
+version=1.0.20090203
Modified: trunk/perfsonar_base/pom.xml
===================================================================
--- trunk/perfsonar_base/pom.xml 2009-02-03 11:04:53 UTC (rev 4937)
+++ trunk/perfsonar_base/pom.xml 2009-02-03 13:45:28 UTC (rev 4938)
@@ -7,7 +7,7 @@
<artifactId>perfsonar-base</artifactId>
<packaging>jar</packaging>
<name>Perfsonar Base package</name>
- <version>1.0.20090202</version>
+ <version>1.0.20090203</version>
<description>
The perfSONAR base provides a number of common, shared
classes which can be used by
MA, MP and Clients.
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/register/LSRegistrationComponent.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/register/LSRegistrationComponent.java
2009-02-03 11:04:53 UTC (rev 4937)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/register/LSRegistrationComponent.java
2009-02-03 13:45:28 UTC (rev 4938)
@@ -19,6 +19,8 @@
import org.perfsonar.service.base.registration.PropertiesServiceDescription;
import org.perfsonar.service.base.registration.ServiceLSRegistrator;
+import java.util.regex.PatternSyntaxException;
+
/**
* Action for simple Scheduler that registers with the LS
*
@@ -30,8 +32,8 @@
// ----------------------------------------------------- constants
- private static final int DEFAULT_RUN_INTERVAL = 10000;
- private static final int MINIMAL_RUN_INTERVAL = 100;
+ private static final int DEFAULT_RUN_INTERVAL = 60; // sec
+ private static final int MINIMAL_RUN_INTERVAL = 5; // sec
private static final String MA_CONFIG_FILE = "service.ma.conf_file";
private static final String MA_CONFIG_STORE =
"service.ma.conf_file.store_type"; // "xmldb" or "file"
@@ -43,8 +45,10 @@
private ConfigurationComponent configuration = null;
private Scheduler scheduler = null;
- private static boolean firstRun = true;
+ String lsURL = null;
+ String[] lsURLArray = null;
+
// ---------------------------------- constructors
public LSRegistrationComponent() throws PerfSONARException {
@@ -79,7 +83,7 @@
public void runAction() {
try {
- String lsURL = configuration.getProperty("service.r.ls_url");
+ //String lsURL = configuration.getProperty("service.r.ls_url");
logger.debug("LSRegistrationComponent.runAction: register to LS:
" + lsURL);
String metadataConfigStore = "";
@@ -111,38 +115,27 @@
} else {
// xmldb
+ registrator = new GenericServiceLSRegistrator(
+ new PropertiesServiceDescription(),
+ new InformationExistDbXmlrpcServiceContent()
+ );
- if (firstRun) {
+ logger.debug("LSRegistrationComponent.runAction: "
+ + "metadata configuration taken from xml database");
- String maConfigFile =
-
configuration.getProperty(LSRegistrationComponent.MA_CONFIG_FILE);
+ }
- logger.debug("LSRegistrationComponent.runAction: "
- + "First run; metadata config file to register to
LS: "
- + maConfigFile);
+ registrator.initRegistrator();
- registrator = new GenericServiceLSRegistrator(
- new PropertiesServiceDescription(),
- new InformationXMLFileServiceContent(maConfigFile)
- );
-
- firstRun = false;
-
- } else {
-
- registrator = new GenericServiceLSRegistrator(
- new PropertiesServiceDescription(),
- new InformationExistDbXmlrpcServiceContent()
- );
-
- logger.debug("LSRegistrationComponent.runAction: "
- + "metadata configuration taken from xml database");
+ if (lsURLArray != null) {
+ for (int i = 0; i < lsURLArray.length; i++) {
+ if (!lsURLArray[i].trim().equals("")) {
+ registrator.register(lsURLArray[i]);
+ }
}
-
}
- registrator.initRegistrator();
- responseMessage = registrator.register(lsURL);
+ //responseMessage = registrator.register(lsURL);
/* TODO: do something with message... ? */
@@ -153,73 +146,91 @@
}
}
-
+ /*
public Message getResponseMessage() {
return responseMessage;
}
+ */
// ---------------------- component that loads action to scheduler
- public void initComponent() throws PerfSONARException {
- // Get configuration
- // get interval - parameter "component.CName.interval"
- int interval = LSRegistrationComponent.DEFAULT_RUN_INTERVAL;
-
- try {
- String intervalVal =
configuration.getProperty("component." + componentName + ".interval");
- interval = Integer.parseInt(intervalVal);
- } catch (RuntimeException e) {
- // possibly not an integer - keep default interval
- } catch (PerfSONARException e) {
- // no property - keep default interval
- }
+ public void initComponent() throws PerfSONARException {
+ // Get configuration
+
+ try {
+ lsURL = configuration.getProperty("service.r.ls_url");
+ if (lsURL != null)
+ if (!lsURL.trim().equals(""))
+ lsURLArray = lsURL.split(",");
+ } catch (PatternSyntaxException ex) {
+ throw new PerfSONARException(
+ "error.ma.register",
+ "LSRegistrationComponent: Cannot read ls addreses from the
configuration"
+ );
+ }
+
+ // get interval - parameter "component.CName.interval"
+ int interval = LSRegistrationComponent.DEFAULT_RUN_INTERVAL;
+
+ try {
+ String intervalVal = configuration.getProperty("component." +
componentName + ".interval");
+ interval = Integer.parseInt(intervalVal);
+ } catch (RuntimeException e) {
+ // possibly not an integer - keep default interval
+ } catch (PerfSONARException e) {
+ // no property - keep default interval
+ }
+
//if too small take default?
if (interval < LSRegistrationComponent.MINIMAL_RUN_INTERVAL) {
interval = LSRegistrationComponent.DEFAULT_RUN_INTERVAL;
}
- logger.debug("LSRegistrationComponent.initComponent:
LSCleanupLoader: parameter RUN_INTERVAL = " + interval);
+ logger.debug("LSRegistrationComponent.initComponent:
LSCleanupLoader: parameter RUN_INTERVAL = " + interval);
//get scheduler - parameter "component.CName.scheduler_component"
try {
String schedulerVal = configuration.getProperty("component." +
componentName + ".scheduler_component");
- logger.debug("LSRegistrationComponent.initComponent:
LSCleanupLoader: parameter SCHEDULER = " + schedulerVal);
+ logger.debug("LSRegistrationComponent.initComponent:
LSCleanupLoader: parameter SCHEDULER = " + schedulerVal);
- scheduler = (Scheduler)
AuxiliaryComponentManager.getInstance().getComponent(schedulerVal);
+ scheduler = (Scheduler)
AuxiliaryComponentManager.getInstance().getComponent(schedulerVal);
- if (scheduler == null) {
- throw new PerfSONARException(
- "error.rrdma.no_scheduler",
-
"LSRegistrationComponent.initComponent: No scheduler component in
AuxiliaryComponentManager"
- );
- }
- } catch (PerfSONARException e) {
- throw new PerfSONARException(
- "error.ma.no_scheduler",
-
"LSRegistrationComponent.initComponent:"
- + "LSCleanupLoader:
no [component." + componentName
- +
".scheduler_component] parameter. "+ e.getMessage()
- );
- }
+ if (scheduler == null) {
+ throw new PerfSONARException(
+ "error.ma.no_scheduler",
+ "LSRegistrationComponent.initComponent: No scheduler
component in AuxiliaryComponentManager"
+ );
+ }
+ } catch (PerfSONARException e) {
+ throw new PerfSONARException(
+ "error.ma.no_scheduler",
+ "LSRegistrationComponent.initComponent:"
+ + "LSCleanupLoader: no [component." +
componentName
+ + ".scheduler_component] parameter. "+
e.getMessage()
+ );
+ }
- // add cleanup action to scheduler
- scheduler.addSchedulerTask(interval, this);
- }
+ // add cleanup action to scheduler
+ scheduler.addSchedulerTask(interval*1000, this); // seconds
converted into milliseconds
+ }
- public String getComponentName() {
- return componentName;
- }
+ public String getComponentName() {
+ return componentName;
+ }
- public void setComponentName(String name) {
- componentName = name;
- }
+ public void setComponentName(String name) {
+ componentName = name;
+ }
- // ---------------------------------------------------------- test
main() method
- // TODO remove?
- public static void main(String[] args) throws Exception {
- AuxiliaryComponentManager.getInstance();
- }
+ // ---------------------------------------------------------- test
main() method
+ // TODO remove?
+ public static void main(String[] args) throws Exception {
+ AuxiliaryComponentManager.getInstance();
+ }
+
+
+
} // LSRegistrationComponent
\ No newline at end of file
- perfsonar: r4938 - in trunk/perfsonar_base: . ant src/main/java/org/perfsonar/service/measurementArchive/register, svnlog, 02/03/2009
Archive powered by MHonArc 2.6.16.