perfsonar-dev - perfsonar: r3911 - in trunk/perfsonar_base/src/main/java/org/perfsonar/service/base: engine registration
Subject: perfsonar development work
List archive
perfsonar: r3911 - in trunk/perfsonar_base/src/main/java/org/perfsonar/service/base: engine registration
Chronological Thread
- From:
- To:
- Subject: perfsonar: r3911 - in trunk/perfsonar_base/src/main/java/org/perfsonar/service/base: engine registration
- Date: Thu, 29 May 2008 08:27:44 -0400
Author: mac
Date: 2008-05-29 08:27:44 -0400 (Thu, 29 May 2008)
New Revision: 3911
Added:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/registration/LSSummaryServiceContent.java
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/engine/ActionType.java
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/registration/LSRegistrationComponent.java
Log:
Changes for hLS (registration to gLS).
Just template code, not the real implementation yet
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/engine/ActionType.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/engine/ActionType.java
2008-05-29 12:25:30 UTC (rev 3910)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/engine/ActionType.java
2008-05-29 12:27:44 UTC (rev 3911)
@@ -78,6 +78,11 @@
*/
public static final String LS_CLEANUP = "LS_CLEANUP";
+
+ /**
+ * Action type for LS Control
+ */
+ public static final String LS_CONTROL = "LS_CONTROL";
// ----------------------------------------- Echo Action
@@ -131,4 +136,6 @@
+
+
} //ActionType
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/registration/LSRegistrationComponent.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/registration/LSRegistrationComponent.java
2008-05-29 12:25:30 UTC (rev 3910)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/registration/LSRegistrationComponent.java
2008-05-29 12:27:44 UTC (rev 3911)
@@ -4,6 +4,8 @@
*/
package org.perfsonar.service.base.registration;
+import java.util.ArrayList;
+
import org.ggf.ns.nmwg.base.v2_0.Message;
import org.perfsonar.base.auxiliary.AuxiliaryComponent;
import org.perfsonar.base.auxiliary.AuxiliaryComponentManager;
@@ -19,210 +21,302 @@
*
* @author Maciej Glowiak (main author)
* @author romradz (contributor)
- *
+ *
*/
-public class LSRegistrationComponent implements SchedulerAction,
AuxiliaryComponent {
+public class LSRegistrationComponent implements SchedulerAction,
+ AuxiliaryComponent {
// ----------------------------------------------------- constants
private static final int DEFAULT_RUN_INTERVAL = 1800000;
+
private static final int MINIMAL_RUN_INTERVAL = 300000;
- /** Posible values: <empty> "xmldb" "context" or "file"
+
+ /**
+ * Posible values: <empty> "xmldb" "context" or "file"
* Where <empty> defaults to file and if the value of
* service.ls.registration_file is empty or whitespace
* don't use a
{@link
ServiceContent} this is for backward
* compatibility
*/
private static final String SERVICE_CONTENT_TYPE =
"service.ls.service_content_type";
+
private enum ContentType {
- EMPTY(null),
- FILE("file"),
- XMLDB("xmldb"),
- CONTEXT("context");
-
- private String name;
-
- ContentType(String name) {
- this.name = name;
- }
-
- static ContentType getByName(String name) {
- if(name==null) {
- return EMPTY;
- }
-
- for(ContentType type : values() ) {
- if(name.equals(type.name)) {
- return type;
- }
- }
- return null;
- }
+ EMPTY(null),
+ FILE("file"),
+ XMLDB("xmldb"),
+ LSSUMMARY("lssummary"),
+ CONTEXT("context");
+
+ private String name;
+
+
+ ContentType(String name) {
+
+ this.name = name;
+ }
+
+
+ static ContentType getByName(String name) {
+
+ if (name == null) {
+ return EMPTY;
+ }
+
+ for (ContentType type : values()) {
+ if (name.equals(type.name)) {
+ return type;
+ }
+ }
+ return null;
+ }
}
+
private static final String REGISTRATION_FILE =
"service.ls.registration_file";
// -------------------------------------------- class fields
private Message responseMessage = null;
+
private String componentName = "ls-registrator";
+
private LoggerComponent logger = null;
+
private ConfigurationComponent configuration = null;
+
private Scheduler scheduler = null;
-
+
+ private ArrayList<Message> responseMessages = new ArrayList<Message>();
+
// ---------------------------------- constructors
public LSRegistrationComponent() throws PerfSONARException {
+
try {
- this.logger = (LoggerComponent)
AuxiliaryComponentManager.getInstance().getComponent(ComponentNames.LOGGER);
+ this.logger = (LoggerComponent) AuxiliaryComponentManager
+ .getInstance().getComponent(ComponentNames.LOGGER);
} catch (PerfSONARException e) {
- throw new PerfSONARException(
- "error.common.no_logger",
- "LSRegistrationComponent.initComponent: Cannot get logger
component"
- );
+ throw new PerfSONARException("error.common.no_logger",
+ "LSRegistrationComponent.initComponent: Cannot get
logger component");
}
try {
- this.configuration = (ConfigurationComponent)
AuxiliaryComponentManager.getInstance().getComponent(ComponentNames.CONFIG);
+ this.configuration = (ConfigurationComponent)
AuxiliaryComponentManager
+ .getInstance().getComponent(ComponentNames.CONFIG);
} catch (PerfSONARException e) {
- throw new PerfSONARException(
- "error.common.no_configuration",
- "LSRegistrationComponent.initComponent: Cannot get config
component"
- );
+ throw new PerfSONARException("error.common.no_configuration",
+ "LSRegistrationComponent.initComponent: Cannot get
config component");
}
+
}
+
// ---------------------------------- public methods
/**
- * Scheduler action
+ * Scheduler action
*/
public void runAction() {
+
try {
- ContentType type =
ContentType.getByName(getServiceContentPropery());
- ServiceContent content = null;
-
- switch(type) {
- case EMPTY: case FILE: {
- content = getXMLFileContent();
- } break;
-
- case XMLDB: {
- content = getXMLDBContent();
- } break;
-
- case CONTEXT: {
- content = getContextContent();
- } break;
- }
- logger.debug("LSRegistrationComponent.runAction: register
ServiceContent = "+content);
+ ContentType type = ContentType
+ .getByName(getServiceContentPropery());
+ ServiceContent content = null;
- ServiceLSRegistrator registrator = new
GenericServiceLSRegistrator(
- new PropertiesServiceDescription(),
- content
- );
- registrator.initRegistrator();
- String lsURL =
configuration.getProperty("service.r.ls_url");
- logger.debug("LSRegistrationComponent.runAction: register to LS
[" + lsURL + "] ");
- responseMessage = registrator.register(lsURL);
- /* TODO: do something with message... ? */
-
- } catch (PerfSONARException e) {
- logger.error("LSRegistrationComponent.runAction:
Error while registration: " + e.getMessage());
- }
- }
+ switch (type) {
+ case EMPTY:
+ case FILE: {
+ content = getXMLFileContent();
+ }
+ break;
+
+ case XMLDB: {
+ content = getXMLDBContent();
+ }
+ break;
+
+ case CONTEXT: {
+ content = getContextContent();
+ }
+ break;
+
+ case LSSUMMARY: {
+ content = getLSSummaryContent();
+ }
+ break;
+ }
+ logger.debug("LSRegistrationComponent.runAction: register
ServiceContent = "
+ + content);
- protected ServiceContent getXMLFileContent() throws
PerfSONARException {
- String registrationFile =
configuration.getProperty(LSRegistrationComponent.REGISTRATION_FILE);
-
- if (registrationFile != null && registrationFile.length() > 0){
- return new InformationXMLFileServiceContent(registrationFile);
- }
- return null;
- }
+ ServiceLSRegistrator registrator = new
GenericServiceLSRegistrator(
+ new PropertiesServiceDescription(), content);
+
+ //initialize Registration
+ registrator.initRegistrator();
- protected ServiceContent getXMLDBContent() throws PerfSONARException {
- return new InformationExistDbXmlrpcServiceContent();
- }
-
- protected ServiceContent getContextContent() throws
PerfSONARException {
- return new InformationContextServiceContent();
- }
+ String lsURLs = configuration.getProperty("service.r.ls_url");
+ if (lsURLs == null)
+ throw new
PerfSONARException("error.lsregistration.no_ls_url");
- private String getServiceContentPropery() {
- String contentType = null;
- try {
- contentType =
configuration.getProperty(LSRegistrationComponent.SERVICE_CONTENT_TYPE);
- } catch (PerfSONARException e) {
- logger.debug("service.ls.service_content_type could
not be read.");
- }
- if(contentType == null || contentType.trim().equals("")) {
- return null;
- }
- return contentType;
- }
+ logger.debug("LSRegistrationComponent.runAction: "
+ + "register to LS [" + lsURLs + "]");
- public Message getResponseMessage() {
- return responseMessage;
- }
+ // process all URLs - splitted by comma sign
+ //
+ responseMessages.clear(); //clear content of array list.
+
+ String[] urls = lsURLs.split(",");
+ int i = 1;
+ for (String url : urls) {
+
+ try {
+
+ logger.debug("LSRegistrationComponent send to [" + i +
"/"
+ + urls.length + "] url: [" + url + "]: ");
+
+ // send registration request
+ Message rspMsg = registrator.register(url);
+ // store result
+ responseMessages.add(rspMsg);
+ i++;
+
+ } catch (Exception ex) {
+ logger.error("LSRegistrationComponent error sending to ["
+ + url + "]: ");
+ }
+ }
+
+ } catch (PerfSONARException e) {
+ logger.error("LSRegistrationComponent.runAction: Error while
registration: "
+ + e.getMessage());
+ }
+ }
+
+
+ private ServiceContent getLSSummaryContent() {
+
+ return new LSSummaryServiceContent();
+
+ }
+
+
+ protected ServiceContent getXMLFileContent() throws PerfSONARException {
+
+ String registrationFile = configuration
+ .getProperty(LSRegistrationComponent.REGISTRATION_FILE);
+
+ if (registrationFile != null && registrationFile.length() > 0) {
+ return new InformationXMLFileServiceContent(registrationFile);
+ }
+ return null;
+ }
+
+
+ protected ServiceContent getXMLDBContent() throws PerfSONARException {
+
+ return new InformationExistDbXmlrpcServiceContent();
+ }
+
+
+ protected ServiceContent getContextContent() throws PerfSONARException {
+
+ return new InformationContextServiceContent();
+ }
+
+
+ private String getServiceContentPropery() {
+
+ String contentType = null;
+ try {
+ contentType = configuration
+
.getProperty(LSRegistrationComponent.SERVICE_CONTENT_TYPE);
+ } catch (PerfSONARException e) {
+ logger.debug("service.ls.service_content_type could not be
read.");
+ }
+ if (contentType == null || contentType.trim().equals("")) {
+ return null;
+ }
+ return contentType;
+ }
+
+
+ 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 {
- //if too small take default?
+ // 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
+ }
+
+ // 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"
+ // get scheduler - parameter "component.CName.scheduler_component"
try {
- String schedulerVal = configuration.getProperty("component." +
componentName + ".scheduler_component");
- logger.debug("LSRegistrationComponent.initComponent:
LSCleanupLoader: parameter SCHEDULER = " + schedulerVal);
- scheduler = (Scheduler)
AuxiliaryComponentManager.getInstance().getComponent(schedulerVal);
+ String schedulerVal = configuration.getProperty("component."
+ + componentName + ".scheduler_component");
+ logger.debug("LSRegistrationComponent.initComponent:
LSCleanupLoader: parameter SCHEDULER = "
+ + schedulerVal);
+ scheduler = (Scheduler) AuxiliaryComponentManager.getInstance()
+ .getComponent(schedulerVal);
} catch (PerfSONARException e) {
- throw new PerfSONARException(
- "error.rrdma.no_scheduler",
-
"LSRegistrationComponent.initComponent: "
- + "LSCleanupLoader:
no [component." + componentName
- +
".scheduler_component] parameter. "+ e.getMessage()
- );
- }
+ throw new PerfSONARException("error.rrdma.no_scheduler",
+ "LSRegistrationComponent.initComponent: "
+ + "LSCleanupLoader: no [component." +
componentName
+ + ".scheduler_component] parameter. "
+ + e.getMessage());
+ }
- if (scheduler == null) {
- throw new PerfSONARException(
- "error.rrdma.no_scheduler",
-
"LSRegistrationComponent.initComponent: No scheduler component in
AuxiliaryComponentManager"
- );
- }
- // add cleanup action to scheduler
- scheduler.addSchedulerTask(interval, this);
- }
+ if (scheduler == null) {
+ throw new PerfSONARException(
+ "error.rrdma.no_scheduler",
+ "LSRegistrationComponent.initComponent: No scheduler
component in AuxiliaryComponentManager");
+ }
+ // add cleanup action to scheduler
+ scheduler.addSchedulerTask(interval, this);
+ }
- public String getComponentName() {
- return componentName;
- }
- public void setComponentName(String name) {
- componentName = name;
- }
+ public String getComponentName() {
- // ---------------------------------------------------------- test
main() method
- // TODO remove?
- public static void main(String[] args) throws Exception {
- AuxiliaryComponentManager.getInstance();
- }
+ return componentName;
+ }
-} // LSRegistrationComponent
\ No newline at end of file
+
+ public void setComponentName(String name) {
+
+ componentName = name;
+ }
+
+
+ // ---------------------------------------------------------- test main()
+ // method
+ // TODO remove?
+ public static void main(String[] args) throws Exception {
+
+ AuxiliaryComponentManager.getInstance();
+ }
+
+} // LSRegistrationComponent
Added:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/registration/LSSummaryServiceContent.java
Property changes on:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/registration/LSSummaryServiceContent.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
- perfsonar: r3911 - in trunk/perfsonar_base/src/main/java/org/perfsonar/service/base: engine registration, svnlog, 05/29/2008
Archive powered by MHonArc 2.6.16.