Skip to Content.
Sympa Menu

perfsonar-dev - r1450 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType

Subject: perfsonar development work

List archive

r1450 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType


Chronological Thread 
  • From:
  • To:
  • Subject: r1450 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType
  • Date: Tue, 18 Jul 2006 09:46:45 -0400

Author: mac
Date: 2006-07-18 09:46:45 -0400 (Tue, 18 Jul 2006)
New Revision: 1450

Modified:

trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
Log:
all LS actions support both storage managers for Exist DB now (XML RPC and
HTTP)

Modified:
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
2006-07-18 13:46:10 UTC (rev 1449)
+++
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
2006-07-18 13:46:45 UTC (rev 1450)
@@ -4,17 +4,20 @@
*/
package org.perfsonar.service.lookupService.xmlType;

-import org.ggf.ns.nmwg.base.v2_0.*;
-
+import org.ggf.ns.nmwg.base.v2_0.Message;
import org.perfsonar.commons.auxiliary.AuxiliaryComponentManager;
import org.perfsonar.commons.auxiliary.ComponentNames;
+import
org.perfsonar.commons.auxiliary.components.configuration.ConfigurationComponent;
import org.perfsonar.commons.auxiliary.components.logger.LoggerComponent;
import org.perfsonar.service.commons.engine.ActionType;
import org.perfsonar.service.commons.engine.ServiceEngine;
import org.perfsonar.service.commons.exceptions.DataFormatException;
import org.perfsonar.service.commons.exceptions.RequestException;
import org.perfsonar.service.commons.exceptions.SystemException;
-import org.perfsonar.service.commons.storage.StorageManager;
+import org.perfsonar.service.commons.storage.xmldb.XmlDbDataRepository;
+import org.perfsonar.service.commons.storage.xmldb.XmlDbStorageManager;
+import org.perfsonar.service.commons.storage.xmldb.exist.ExistDbFactory;
+import org.perfsonar.service.commons.storage.xmldb.XmlDbConstants;

/**
* ServiceEngine class for LookupService. (The heart of the LookupService)
@@ -37,10 +40,7 @@
*/
private static final String SERVICE_ENGINE_TYPE =
"service.LookupService";

-
- private static final String LS_STORAGE_COMPONENT = "ls_storage";
-
-
+
// ---------------------------------------------------------- class
fields


@@ -57,18 +57,21 @@


/**
- * Local XML DB Access
- */
- private StorageManager xmlDbStorageManager = null;
-
-
- /**
* The object to log control/debugging messages
*/
private LoggerComponent logger = null;

+ /**
+ * The object to configuration
+ */
+ private ConfigurationComponent config;

/**
+ * Storage Manager Type
+ */
+ private String smType;
+
+ /**
* Construction for the service engine
*/
public XmlTypeLSServiceEngine() throws SystemException {
@@ -76,9 +79,14 @@
//get logger
logger = (LoggerComponent)AuxiliaryComponentManager.
getInstance().getComponent(ComponentNames.LOGGER);
+
+ logger.debug("XmlTypeLSServiceEngine: started... ");

- logger.debug("XmlTypeLSServiceEngine: started... ");
+ //get logger
+ config = (ConfigurationComponent)AuxiliaryComponentManager.
+ getInstance().getComponent(ComponentNames.CONFIG);

+
this.serviceEngineType = SERVICE_ENGINE_TYPE;

// set the accepted action types
@@ -89,19 +97,8 @@
ActionType.LS_KEEPALIVE
};

- //obtain storage manager for LS
- logger.debug("XmlTypeLSServiceEngine: Getting Storage Manager");
- xmlDbStorageManager = (StorageManager)AuxiliaryComponentManager.
- getInstance().getComponent(LS_STORAGE_COMPONENT);
+ smType = config.getProperty("service.ls.db_type");

- //check if Storage Manager is not null, otherwise error
- if (xmlDbStorageManager==null) {
- String m = "XmlTypeLSServiceEngine: can't obtain StorageManager
for" +
- " LS storage. No component ["+LS_STORAGE_COMPONENT+"]";
- logger.error(m);
- throw new SystemException("error.ls.no_storage",m);
- }
-
} //constructor


@@ -141,7 +138,7 @@
Message request)
throws SystemException, RequestException, DataFormatException{

-
+ System.out.println(" LS0,"+System.currentTimeMillis());
logger.debug("XmlTypeLSServiceEngine: takeAction for action [" +
actionType+"]");

@@ -177,36 +174,72 @@
//Take an action
if (actionType.equals(ActionType.LS_REGISTER)) {

+ XmlDbStorageManager xmlDbStorageManager =
+ getStorageManager(smType);
+
LSAction action = new LSRegisterAction(xmlDbStorageManager);
response = action.performAction(request);

} else if (actionType.equals(ActionType.LS_LOOKUP)) {

+ XmlDbStorageManager xmlDbStorageManager =
+ getStorageManager(smType);
LSAction action = new LSLookupAction(xmlDbStorageManager);
response = action.performAction(request);

} else if (actionType.equals(ActionType.LS_DEREGISTER)) {

+ XmlDbStorageManager xmlDbStorageManager =
+ getStorageManager(smType);
LSAction action = new LSDeregisterAction(xmlDbStorageManager);
response = action.performAction(request);

} else if (actionType.equals(ActionType.LS_KEEPALIVE)) {

+ XmlDbStorageManager xmlDbStorageManager =
+ getStorageManager(smType);
LSAction action = new LSKeepaliveAction(xmlDbStorageManager);
response = action.performAction(request);

} else {
+
throw new SystemException("error.ls.action_not_suported",
"XmlTypeLSServiceEngine: Action ["
+actionType+"] not supported");
+
}

+
// ------end of serving actions
---------------------------------------

//Return Response Message
+ System.out.println(" LSaux,"+System.currentTimeMillis());
return response;

} //takeAction


+
+ protected XmlDbStorageManager getStorageManager(String type)
+ throws SystemException {
+
+ XmlDbDataRepository dataRepository =
+ ExistDbFactory.getDataRepositoryByProperties(
+ smType,
+ "service.ls.db_uri",
+ "service.ls.db_username",
+ "service.ls.db_password");
+
+ XmlDbStorageManager storageManager =
+ ExistDbFactory.getXMLStorageManager(
+ type, dataRepository);
+ storageManager.setResultType(
+ XmlDbStorageManager.XML_DB_RESULT_TYPE);
+
+
+ return storageManager;
+
+ }
+
+
} //XmlTypeLSServiceEngine



  • r1450 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType, svnlog, 07/18/2006

Archive powered by MHonArc 2.6.16.

Top of Page