perfsonar-dev - r1734 - in branches/ulisseskan: conf src/org/perfsonar/commons/messages src/org/perfsonar/service/commons/engine src/org/perfsonar/service/topologyService
Subject: perfsonar development work
List archive
r1734 - in branches/ulisseskan: conf src/org/perfsonar/commons/messages src/org/perfsonar/service/commons/engine src/org/perfsonar/service/topologyService
Chronological Thread
- From:
- To:
- Subject: r1734 - in branches/ulisseskan: conf src/org/perfsonar/commons/messages src/org/perfsonar/service/commons/engine src/org/perfsonar/service/topologyService
- Date: Thu, 2 Nov 2006 06:12:57 -0500
Author: rodriguez
Date: 2006-11-02 06:12:55 -0500 (Thu, 02 Nov 2006)
New Revision: 1734
Added:
branches/ulisseskan/conf/interfaces-description.xml
branches/ulisseskan/src/org/perfsonar/commons/messages/SetupDataDBRequest.java
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsDownloadAction.java
Removed:
branches/ulisseskan/src/org/perfsonar/commons/messages/TOPSDownloadDBRequest.java
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsDownloadDBAction.java
Modified:
branches/ulisseskan/conf/service.properties.tops
branches/ulisseskan/src/org/perfsonar/service/commons/engine/ActionType.java
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopServiceEngine.java
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsAction.java
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsJDBCComponent.java
Log:
Updated the Topology Service
Added: branches/ulisseskan/conf/interfaces-description.xml
Modified: branches/ulisseskan/conf/service.properties.tops
===================================================================
--- branches/ulisseskan/conf/service.properties.tops 2006-11-01 16:04:42
UTC (rev 1733)
+++ branches/ulisseskan/conf/service.properties.tops 2006-11-02 11:12:55
UTC (rev 1734)
@@ -72,8 +72,8 @@
service.ls.message_types=LSQueryRequest,LSRegisterRequest,LSDeregisterRequest
service.tops.class_name=org.perfsonar.service.topologyService.TopServiceEngine
-service.tops.message_types=TOPSDownloadDBRequest
+service.tops.message_types=SetupDataDBRequest
+service.tops.interfaces=/home/ulisses/rediris/jra1/perfsonar/conf/interfaces-description.xml
-
# ------- END
--------------------------------------------------------------------------
Added:
branches/ulisseskan/src/org/perfsonar/commons/messages/SetupDataDBRequest.java
Deleted:
branches/ulisseskan/src/org/perfsonar/commons/messages/TOPSDownloadDBRequest.java
Modified:
branches/ulisseskan/src/org/perfsonar/service/commons/engine/ActionType.java
===================================================================
---
branches/ulisseskan/src/org/perfsonar/service/commons/engine/ActionType.java
2006-11-01 16:04:42 UTC (rev 1733)
+++
branches/ulisseskan/src/org/perfsonar/service/commons/engine/ActionType.java
2006-11-02 11:12:55 UTC (rev 1734)
@@ -70,7 +70,7 @@
* Action type to request a full topology database download
*/
- public static final String TOPS_DOWNLOAD_DB = "TOPS_DOWNLOAD_DB";
+ public static final String SETUP_DATA_DB = "SETUP_DATA_DB";
Modified:
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopServiceEngine.java
===================================================================
---
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopServiceEngine.java
2006-11-01 16:04:42 UTC (rev 1733)
+++
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopServiceEngine.java
2006-11-02 11:12:55 UTC (rev 1734)
@@ -4,8 +4,11 @@
*/
package org.perfsonar.service.topologyService;
-import org.ggf.ns.nmwg.base.v2_0.*;
+import java.sql.Connection;
+import java.util.Arrays;
+import java.util.List;
+import org.ggf.ns.nmwg.base.v2_0.Message;
import org.perfsonar.commons.util.XMLUtils;
import org.perfsonar.commons.auxiliary.AuxiliaryComponentManager;
import org.perfsonar.commons.auxiliary.ComponentNames;
@@ -16,213 +19,216 @@
import org.perfsonar.service.commons.exceptions.RequestException;
import org.perfsonar.service.commons.exceptions.SystemException;
-import java.sql.*; // for jdbc
-
/**
- * ServiceEngine class for the Topology Service. (The heart of the Topology
Service)
- *
- * @see org.perfsonar.service.commons.ServiceEngine
- * @author Ulisses Alonso, used Maciej Glowiak's LookupService as an
skeleton
- *
+ * ServiceEngine class for the Topology Service. (The heart of the Topology
+ * Service)
+ *
+ * @see org.perfsonar.service.commons.ServiceEngine
+ * @author Ulisses Alonso, used Maciej Glowiak's LookupService as an
skeleton,
+ * and modified by Candido Rodriguez
+ *
*/
public class TopServiceEngine implements ServiceEngine {
-
- // -------------------------------------------------------------
Constants
-
- /**
- * Service engine type
- */
- private static final String SERVICE_ENGINE_TYPE = "service.TopService";
+ // -------------------------------------------------------------
Constants
- // These strings must match the componentName attribute of the component
going to be loaded
+ /**
+ * Service engine type
+ */
+ private static final String SERVICE_ENGINE_TYPE =
"service.TopService";
- private static final String TOPS_JDBC_COMPONENT = "tops-jdbc";
- private static final String TOPS_REGISTRATOR_COMPONENT =
"tops-registrator";
-
-
- // ---------------------------------------------------------- class
fields
+ // These strings must match the componentName attribute of the
component
+ // going to be loaded
+ private static final String TOPS_JDBC_COMPONENT = "tops-jdbc";
- /**
- * Type of service angine.
- */
- private String serviceEngineType = null;
+ private static final String TOPS_REGISTRATOR_COMPONENT =
"tops-registrator";
+ // ---------------------------------------------------------- class
fields
- /**
- * Array of action types which can be performed
- */
- private String[] acceptedTypes = null;
+ /**
+ * Type of service angine.
+ */
+ private String serviceEngineType = null;
+ /**
+ * Array of action types which can be performed
+ */
+ private List<String> acceptedTypes = null;
- private TopsJDBCComponent topsJDBC = null; // The
Component that holds the connection to the SQL database
- private LoggerComponent logger = null; // The
object to log control/debugging messages
- private TopsLSRegistrationComponent topsRegistration= null; // The
object for registering the service (done periodically with the scheduler)
-
- private Connection jdbc = null; // The
object to connect to the SQL database
-
- /**
- * Construction for the service engine
- */
- public TopServiceEngine() throws SystemException {
+ private TopsJDBCComponent topsJDBC = null; // The Component that
holds the
- // set the accepted action types
- acceptedTypes = new String[] {
- ActionType.TOPS_DOWNLOAD_DB, // Download currently valid version
of the topology
- // In the future it might be useful
to download the topology valid in an specified date
- };
-
- this.serviceEngineType = SERVICE_ENGINE_TYPE;
+ // connection to the SQL
+ // database
- // We have to:
- //
- // - initialize JDBC
- // - initialize Logger
- //
- // - register to the Lookup Service
- //
+ private LoggerComponent logger = null; // The object to log
- // get logger
+ // control/debugging messages
- logger = (LoggerComponent)AuxiliaryComponentManager.
- getInstance().getComponent(ComponentNames.LOGGER);
+ private TopsLSRegistrationComponent topsRegistration = null; // The
- if (logger == null) {
- String m= "TopologyServiceEngine: can't obtain Logger object";
- throw new SystemException("error.tops.dependency", m);
- }
+ // object
+ // for
+ // registering
+ // the
+ // service
+ // (done
+ // periodically
+ // with the
+ // scheduler)
- logger.debug("TopServiceEngine: starting... ");
+ private Connection jdbc = null; // The object to connect to the SQL
database
- // obtain jdbc connection
+ /**
+ * Construction for the service engine
+ */
+ public TopServiceEngine() throws SystemException {
- logger.debug("TopServiceEngine: Getting JDBC object");
+ // set the accepted action types
+ this.acceptedTypes = Arrays
+ .asList(new String[] {
ActionType.SETUP_DATA_DB });
+ this.serviceEngineType = SERVICE_ENGINE_TYPE;
- topsJDBC =
(TopsJDBCComponent)AuxiliaryComponentManager.getInstance().getComponent(TOPS_JDBC_COMPONENT);
-
- if (topsJDBC == null) {
- String m = "TopServiceEngine: can't obtain [" +
TOPS_JDBC_COMPONENT + "] object";
- logger.error(m);
- throw new SystemException("error.tops.dependency", m);
- }
+ // We have to:
+ //
+ // - initialize JDBC
+ // - initialize Logger
+ //
+ // - register to the Lookup Service
+ //
- logger.debug("TopServiceEngine: forcing jdbc initialization");
- topsJDBC.initComponent();
+ // get logger
- jdbc= topsJDBC.getConnection();
+ logger = (LoggerComponent)
AuxiliaryComponentManager.getInstance()
+ .getComponent(ComponentNames.LOGGER);
- if (jdbc == null) {
+ if (logger == null) {
+ String m = "TopologyServiceEngine: can't obtain
Logger object";
+ throw new SystemException("error.tops.dependency", m);
+ }
- String m = "TopServiceEngine: can't obtain jdbc connection from
the component";
- logger.error(m);
- throw new SystemException("error.tops.dependency", m);
- }
+ logger.debug("TopServiceEngine: starting... ");
- String mm = "TopServiceEngine: trying to get registrator component";
- logger.debug(mm);
-
- topsRegistration=
(TopsLSRegistrationComponent)AuxiliaryComponentManager.
- getInstance().getComponent(TOPS_REGISTRATOR_COMPONENT);
+ // obtain jdbc connection
- if (topsRegistration == null) {
- String m = "TopServiceEngine: can't obtain [" +
TOPS_REGISTRATOR_COMPONENT + "] component";
- logger.error(m);
- throw new SystemException("error.tops.dependency", m);
- }
+ logger.debug("TopServiceEngine: Getting JDBC object");
- logger.debug("TopServiceEngine: started ");
-
- } //constructor
+ topsJDBC = (TopsJDBCComponent)
AuxiliaryComponentManager.getInstance()
+ .getComponent(TOPS_JDBC_COMPONENT);
+ if (topsJDBC == null) {
+ String m = "TopServiceEngine: can't obtain [" +
TOPS_JDBC_COMPONENT
+ + "] object";
+ logger.error(m);
+ throw new SystemException("error.tops.dependency", m);
+ }
+ logger.debug("TopServiceEngine: forcing jdbc initialization");
+ topsJDBC.initComponent();
- // --------------------------------------------------------- public
methods
+ jdbc = topsJDBC.getConnection();
+ if (jdbc == null) {
+ String m = "TopServiceEngine: can't obtain jdbc
connection from the component";
+ logger.error(m);
+ throw new SystemException("error.tops.dependency", m);
+ }
- /**
- * Method which provides access the type of ServiceEngine.
- * It implements the method definition in ServiceEngine Interface
- *
- * @return String containing ServiceEngine Type
- *
- * @see org.perfsonar.service.commons.engine.ServiceEngine#getType()
- */
- public String getType() {
+ String mm = "TopServiceEngine: trying to get registrator
component";
+ logger.debug(mm);
- return this.serviceEngineType;
+ topsRegistration = (TopsLSRegistrationComponent)
AuxiliaryComponentManager
+
.getInstance().getComponent(TOPS_REGISTRATOR_COMPONENT);
- }
+ if (topsRegistration == null) {
+ String m = "TopServiceEngine: can't obtain ["
+ + TOPS_REGISTRATOR_COMPONENT + "]
component";
+ logger.error(m);
+ throw new SystemException("error.tops.dependency", m);
+ }
+ logger.debug("TopServiceEngine: started ");
- /**
- * Method to accept requests for action. It implements
- * the method definition in ServiceEngine Interface
- *
- * @return Message object containing the response
- *
- * @throws SystemException
- * @throws RequestException
- * @throws DataFormatException
- *
- * @see org.perfsonar.service.commons.engine.ServiceEngine
- */
- public Message takeAction(String actionType,
- Message request)
- throws SystemException, RequestException, DataFormatException{
-
-
- logger.debug("TopServiceEngine: takeAction for action [" +
- actionType+"]");
-
- // check if the action type can be satisfied
- boolean actionTypeCanBeSatisfied = false;
+ } // constructor
- for (int itr=0; itr<acceptedTypes.length; itr++) {
- if (acceptedTypes[itr].equals(actionType)) {
- actionTypeCanBeSatisfied = true;
- break;
- }
- }
+ // --------------------------------------------------------- public
methods
- if (!actionTypeCanBeSatisfied) {
+ /**
+ * Method which provides access the type of ServiceEngine. It
implements the
+ * method definition in ServiceEngine Interface
+ *
+ * @return String containing ServiceEngine Type
+ *
+ * @see org.perfsonar.service.commons.engine.ServiceEngine#getType()
+ */
+ public String getType() {
- String m= "TopServiceEngine: ActionType specified: " + actionType
+ " is not supported";
- logger.info(m);
- throw new SystemException("error.common.action_not_supported",
m);
- }
-
- logger.debug("TopServiceEngine: action valid for this ServiceEngine:
" + actionType);
-
- //Create response
- Message response = null;
+ return this.serviceEngineType;
- // ------------ serving actions
---------------------------------------
-
- //Take an action
- if (actionType.equals(ActionType.TOPS_DOWNLOAD_DB)) {
+ }
- TopsAction action = new TopsDownloadDBAction(jdbc);
- response = action.performAction(request);
-
- } else {
- String m= "TopServiceEngine: Action [" +actionType +"] not
supported";
- logger.info(m);
- throw new SystemException("error.common.action_not_supported",
m);
- }
-
- // ------end of serving actions
---------------------------------------
-
- String m;
- m= "finally response in Topology Service:\n" +
XMLUtils.serializeXML(response);
+ /**
+ * Method to accept requests for action. It implements the method
definition
+ * in ServiceEngine Interface
+ *
+ * @return Message object containing the response
+ *
+ * @throws SystemException
+ * @throws RequestException
+ * @throws DataFormatException
+ *
+ * @see org.perfsonar.service.commons.engine.ServiceEngine
+ */
+ public Message takeAction(String actionType, Message request)
+ throws SystemException, RequestException,
DataFormatException {
- logger.debug(m);
+ logger.debug("TopServiceEngine: takeAction for action [" +
actionType
+ + "]");
- return response;
-
- } //takeAction
+ // check if the action type can be satisfied
+ boolean actionTypeCanBeSatisfied =
acceptedTypes.contains(actionType);
-
-} //TopServiceEngine
+ if (!actionTypeCanBeSatisfied) {
+ String m = "TopServiceEngine: ActionType specified: "
+ actionType
+ + " is not supported";
+ logger.info(m);
+ throw new
SystemException("error.common.action_not_supported", m);
+ }
+ logger.debug("TopServiceEngine: action valid for this
ServiceEngine: "
+ + actionType);
+
+ // ------------ serving actions
---------------------------------------
+
+ // Create response
+ Message response = null;
+
+ TopsAction action = null;
+ // Take an action
+ if (actionType.equals(ActionType.SETUP_DATA_DB)) {
+ action = new TopsDownloadAction(jdbc);
+ }
+
+ if (action == null) {
+ String m = "TopServiceEngine: Action [" + actionType
+ + "] not supported";
+ logger.info(m);
+ throw new
SystemException("error.common.action_not_supported", m);
+ }
+
+ response = action.performAction(request);
+
+ // ------end of serving actions
---------------------------------------
+
+ String m;
+ m = "finally response in Topology Service:\n"
+ + XMLUtils.serializeXML(response);
+
+ logger.debug(m);
+
+ return response;
+
+ } // takeAction
+
+} // TopServiceEngine
Modified:
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsAction.java
===================================================================
---
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsAction.java
2006-11-01 16:04:42 UTC (rev 1733)
+++
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsAction.java
2006-11-02 11:12:55 UTC (rev 1734)
@@ -1,7 +1,6 @@
package org.perfsonar.service.topologyService;
-import java.sql.*;
-
+import java.sql.Connection;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
@@ -21,216 +20,174 @@
import org.perfsonar.service.commons.exceptions.RequestException;
import org.perfsonar.service.commons.exceptions.SystemException;
-
/**
* Generic class for all Tops actions performed by TopServiceEngine
*
- * @author Maciej Glowiak, modified by Ulisses Alonso
- *
+ * @author Maciej Glowiak, modified by Ulisses Alonso & Candido Rodriguez
+ *
*/
public abstract class TopsAction {
- // --------------------------------------------------------------
Constants
-
- // ----------------------------------------------------- Instance
variables
-
-
- /**
- * JDBC connection
- */
- protected Connection jdbc = null;
-
-
- /**
- * The object to log control/debugging messages
- */
- protected LoggerComponent logger = null;
+ // --------------------------------------------------------------
Constants
-
- /**
- * Reference to configuration
- */
- protected ConfigurationComponent configuration;
-
-
- // ------------------------------------------------------------
Constructor
-
-
- public TopsAction(Connection jdbc) throws SystemException {
-
- this.jdbc = jdbc;
-
- logger = (LoggerComponent)AuxiliaryComponentManager.
- getInstance().getComponent(ComponentNames.LOGGER);
+ // ----------------------------------------------------- Instance
variables
- configuration = (ConfigurationComponent)AuxiliaryComponentManager.
- getInstance().getComponent(ComponentNames.CONFIG);
-
- }
-
+ /**
+ * JDBC connection
+ */
+ protected Connection jdbc = null;
- // ------------------------------------------------------ Protected
methods
-
-
- /**
- * Extracts first Metadata from Request
- * @param request
- * @return Metadata
- */
- protected Metadata getMetadataFromRequest(
- Message request) {
+ /**
+ * The object to log control/debugging messages
+ */
+ protected LoggerComponent logger = null;
- //Get Metadata
-
- Metadata requestMetadata[] = request.getMetadataArray();
- if(requestMetadata.length > 0){
- return requestMetadata[0];
- }
- else{
- return null;
- }
- }
-
-
- /**
- * Extracts Key of specific Id from Metadata
- * @param requestMetadata
- * @param keyId Key identifier
- * @return Key value
- */
- protected String getKeyFromMetadata(
- Metadata requestMetadata, String keyId) {
+ /**
+ * Reference to configuration
+ */
+ protected ConfigurationComponent configuration;
- //get Key
-
- Key key = requestMetadata.getKey();
-
- String keyValue = null;
-
- //check if there is a Key
- if (key!=null) try {
-
- //iterate parameters
- if (key.getParameters()!=null) {
-
- Map params = key.getParameters().getParameterMap();
- Collection collect = params.values();
-
- for(Iterator i = collect.iterator(); i.hasNext(); ){
-
- try {
-
- Parameter parameter = (Parameter)i.next();
-
- String parameterName = parameter.getParameterName();
- String parameterValue =
parameter.getParameterValue();
-
- //parse parameters
- if (parameterName.equals(keyId)) {
- keyValue = parameterValue;
- } //else if (parameterName.equals(...)) {...}
-
- //print all parameters read
- //logger.debug("XmlTypeLSServiceEngine:
key-parameter: ["+
- // parameterName + "] =
["+parameterValue+"]");
-
- //don't finish parsing, there may still be other
- //parameters
-
- }catch (RuntimeException ex) {
- logger.warn("XmlTypeLSServiceEngine: error while " +
- "parsing parameters from Key");
- }
- }
- }
-
- } catch (RuntimeException npex) {
- logger.warn("XmlTypeLSServiceEngine: error while getting " +
- "parameters from Key");
- }
-
- return keyValue;
-
- }
-
-
- /**
- * @author: Maciej Glowiak
- *
- * @param resultCode textual result code (result.success OR
result.error),
- * put into Metadata
- * @param details textual description (will be put in Data block);
- * if null value, Data won't be created
- * @return ResultCode (Metadata+Data)
- */
- protected ResultCode createResultCode(String resultCode, String details)
{
-
- ResultCode res = new ResultCode();
- Metadata metadata = new Metadata();
- metadata.setId("resultCodeMetadata");
-
- EventType eventType = new EventType();
- eventType.setEventType(resultCode);
- metadata.setEventType(eventType);
-
- res.setMetadata(metadata);
-
- if (details!=null) {
-
- Data data = new Data();
-
- Datum datum = new Datum();
-
- data.setId("resultCodeData");
- data.setMetadataIdRef("resultCodeMetadata");
- datum.setValue(details);
- data.setDatum(datum);
-
- res.setData(data);
-
+ // ------------------------------------------------------------
Constructor
+
+ public TopsAction(Connection jdbc) throws SystemException {
+ this.jdbc = jdbc;
+ logger = (LoggerComponent)
AuxiliaryComponentManager.getInstance()
+ .getComponent(ComponentNames.LOGGER);
+ configuration = (ConfigurationComponent)
AuxiliaryComponentManager
+
.getInstance().getComponent(ComponentNames.CONFIG);
}
- return res;
- }
-
-
- // ----------------------------------------------- Abstract methods
-
-
- public abstract Message performAction(
- Message request)
- throws SystemException, RequestException, DataFormatException;
-
-
- // ---------------------------------------------------------- Inner
classes
-
-
- /**
- * Result code, contains Metadata and Data blocks
- * @author Maciej Glowiak
- *
- */
- protected class ResultCode {
-
- private Metadata metadata;
- private Data data;
-
- public Data getData() {
- return data;
- }
- public void setData(Data data) {
- this.data = data;
- }
-
- public Metadata getMetadata() {
- return metadata;
- }
-
- public void setMetadata(Metadata metadata) {
- this.metadata = metadata;
- }
-
- } //ResultCode
-
-
-} //LSAction
+ // ------------------------------------------------------ Protected
methods
+
+ /**
+ * Extracts first Metadata from Request
+ *
+ * @param request
+ * @return Metadata
+ */
+ protected Metadata getMetadataFromRequest(Message request) {
+ // Get Metadata
+ Metadata requestMetadata[] = request.getMetadataArray();
+ if (requestMetadata.length > 0) {
+ return requestMetadata[0];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Extracts Key of specific Id from Metadata
+ *
+ * @param requestMetadata
+ * @param keyId
+ * Key identifier
+ * @return Key value
+ */
+ protected String getKeyFromMetadata(Metadata requestMetadata, String
keyId) {
+ // get Key
+ Key key = requestMetadata.getKey();
+ String keyValue = null;
+
+ // check if there is a Key
+ if (key != null) {
+ try {
+ // iterate parameters
+ if (key.getParameters() != null) {
+ Map params =
key.getParameters().getParameterMap();
+ Collection collect = params.values();
+ for (Iterator i = collect.iterator();
i.hasNext();) {
+ try {
+ Parameter parameter =
(Parameter) i.next();
+ String parameterName
= parameter.getParameterName();
+ String parameterValue
= parameter
+
.getParameterValue();
+ // parse parameters
+ if
(parameterName.equals(keyId)) {
+ keyValue =
parameterValue;
+ }
+ } catch (RuntimeException ex)
{
+
logger.warn("TopsAction: error while "
+ +
"parsing parameters from Key");
+ }
+ }
+ }
+ } catch (RuntimeException npex) {
+ logger.warn("TopsAction: error while getting "
+ + "parameters from Key");
+ }
+ }
+ return keyValue;
+ }
+
+ /**
+ * @author: Maciej Glowiak
+ *
+ * @param resultCode
+ * textual result code (result.success OR result.error),
put into
+ * Metadata
+ * @param details
+ * textual description (will be put in Data block); if null
+ * value, Data won't be created
+ * @return ResultCode (Metadata+Data)
+ */
+ protected ResultCode createResultCode(String resultCode, String
details) {
+ ResultCode res = new ResultCode();
+ Metadata metadata = new Metadata();
+ metadata.setId("resultCodeMetadata");
+
+ EventType eventType = new EventType();
+ eventType.setEventType(resultCode);
+ metadata.setEventType(eventType);
+
+ res.setMetadata(metadata);
+
+ if (details != null) {
+ Data data = new Data();
+ Datum datum = new Datum();
+ data.setId("resultCodeData");
+ data.setMetadataIdRef("resultCodeMetadata");
+ datum.setValue(details);
+ data.setDatum(datum);
+ res.setData(data);
+ }
+ return res;
+ }
+
+ // ----------------------------------------------- Abstract methods
+
+ public abstract Message performAction(Message request)
+ throws SystemException, RequestException,
DataFormatException;
+
+ // ---------------------------------------------------------- Inner
classes
+
+ /**
+ * Result code, contains Metadata and Data blocks
+ *
+ * @author Maciej Glowiak
+ *
+ */
+ protected class ResultCode {
+
+ private Metadata metadata;
+
+ private Data data;
+
+ public Data getData() {
+ return data;
+ }
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+ public Metadata getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Metadata metadata) {
+ this.metadata = metadata;
+ }
+
+ } // ResultCode
+
+} // TopsAction
\ No newline at end of file
Added:
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsDownloadAction.java
Deleted:
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsDownloadDBAction.java
Modified:
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsJDBCComponent.java
===================================================================
---
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsJDBCComponent.java
2006-11-01 16:04:42 UTC (rev 1733)
+++
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsJDBCComponent.java
2006-11-02 11:12:55 UTC (rev 1734)
@@ -1,132 +1,115 @@
package org.perfsonar.service.topologyService;
-import org.ggf.ns.nmwg.base.v2_0.Message;
+import java.sql.Connection;
+import java.sql.DriverManager;
+
import org.perfsonar.commons.auxiliary.AuxiliaryComponent;
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.commons.auxiliary.components.simplescheduler.Scheduler;
-import
org.perfsonar.commons.auxiliary.components.simplescheduler.SchedulerAction;
-import org.perfsonar.service.commons.exceptions.PerfSONARException;
import org.perfsonar.service.commons.exceptions.SystemException;
-import
org.perfsonar.service.commons.registration.GenericServiceLSRegistrator;
-import
org.perfsonar.service.commons.registration.InformationXMLFileServiceContent;
-import
org.perfsonar.service.commons.registration.PropertiesServiceDescription;
-import org.perfsonar.service.commons.registration.ServiceLSRegistrator;
-import java.sql.*; // for jdbc
-
/**
* Action for simple Scheduler that registers with the LS
*
- * @author Maciej Glowiak, modified by Ulisses Alonso for incorporating it
- * in the Topology Service
+ * @author Maciej Glowiak, modified by Ulisses Alonso for incorporating it in
+ * the Topology Service
*/
public class TopsJDBCComponent implements AuxiliaryComponent {
-
- // ----------------------------------------------------- constants
-
-
- // -------------------------------------------- Instance variables
-
-
- private String componentName = "tops-jdbc";
-
- private LoggerComponent logger;
-
- private ConfigurationComponent config;
- private Connection jdbc = null; // JDBC
acess to the topology information
-
- // ------------------------------------------------------- Methods
-
-
- public Connection getConnection() {
-
- return jdbc;
- }
+ // ----------------------------------------------------- constants
+ // -------------------------------------------- Instance variables
- // ---------------------- component that loads action to scheduler
-
-
- public void initComponent() throws SystemException {
+ private String componentName = "tops-jdbc";
-
- try {
-
- logger = (LoggerComponent)AuxiliaryComponentManager.
- getInstance().getComponent(ComponentNames.LOGGER);
-
- } catch (SystemException e) {
- String m = "TopsJDBCComponent: Can't obtain Logger component ";
- throw new SystemException(m);
- }
-
- logger.debug("TopsJDBCComponent: initializing component");
+ private LoggerComponent logger;
- try {
- config = (ConfigurationComponent)
- AuxiliaryComponentManager.getInstance().
- getComponent(ComponentNames.CONFIG);
- } catch (SystemException e) {
+ private ConfigurationComponent config;
- String m = "TopsJDBCComponent: Can't obtain Config component ";
- logger.error(m);
- throw new SystemException("error.tops.dependency", m);
- }
+ private Connection jdbc = null; // JDBC acess to the topology
information
+ // ------------------------------------------------------- Methods
- try {
- Class.forName("org.postgresql.Driver");
- } catch(Exception e) {
- String m = "TopsJDBCComponent: Can't obtain postgresql driver for
JDBC access";
- logger.error(m);
- throw new SystemException("error.tops.dependency", m);
- }
-
- String jdbcURI =
config.getProperty("component."+componentName+".jdbc_uri");
- String jdbcUSER =
config.getProperty("component."+componentName+".jdbc_user");
- String jdbcPASS =
config.getProperty("component."+componentName+".jdbc_pass");
+ public Connection getConnection() {
- try {
+ return jdbc;
+ }
- jdbc = DriverManager.getConnection(jdbcURI, jdbcUSER, jdbcPASS);
+ // ---------------------- component that loads action to scheduler
- } catch(Exception e) {
- String m = "TopsJDBCComponent: Can't obtain jdbc connection:
uri: " +jdbcURI +", user: " +jdbcUSER +", pass: " +jdbcPASS;
- logger.error(m);
- throw new SystemException("error.tops.dependency", m);
- }
+ public void initComponent() throws SystemException {
-
- logger.debug("TopsJDBCComponent: component initialized");
- }
+ try {
+ logger = (LoggerComponent)
AuxiliaryComponentManager.getInstance()
+ .getComponent(ComponentNames.LOGGER);
- public String getComponentName() {
+ } catch (SystemException e) {
+ String m = "TopsJDBCComponent: Can't obtain Logger
component ";
+ throw new SystemException(m);
+ }
- return componentName;
-
- }
+ logger.debug("TopsJDBCComponent: initializing component");
+ try {
+ config = (ConfigurationComponent)
AuxiliaryComponentManager
+
.getInstance().getComponent(ComponentNames.CONFIG);
+ } catch (SystemException e) {
- public void setComponentName(String name) {
-
- componentName = name;
-
- }
+ String m = "TopsJDBCComponent: Can't obtain Config
component ";
+ logger.error(m);
+ throw new SystemException("error.tops.dependency", m);
+ }
-
- // ---------------------------------------------------------- test
-
-
- public static void main(String[] args) throws Exception {
+ try {
+ Class.forName("org.postgresql.Driver");
+ } catch (Exception e) {
+ String m = "TopsJDBCComponent: Can't obtain
postgresql driver for JDBC access";
+ logger.error(m);
+ throw new SystemException("error.tops.dependency", m);
+ }
- AuxiliaryComponentManager.getInstance();
-
- }
-
-
-} // TopServiceLSRegistrationComponent
+ String jdbcURI = config.getProperty("component." +
componentName
+ + ".jdbc_uri");
+ String jdbcUSER = config.getProperty("component." +
componentName
+ + ".jdbc_user");
+ String jdbcPASS = config.getProperty("component." +
componentName
+ + ".jdbc_pass");
+
+ try {
+
+ jdbc = DriverManager.getConnection(jdbcURI, jdbcUSER,
jdbcPASS);
+
+ } catch (Exception e) {
+ String m = "TopsJDBCComponent: Can't obtain jdbc
connection: uri: "
+ + jdbcURI + ", user: " + jdbcUSER +
", pass: " + jdbcPASS;
+ logger.error(m);
+ throw new SystemException("error.tops.dependency", m);
+ }
+
+ logger.debug("TopsJDBCComponent: component initialized");
+ }
+
+ public String getComponentName() {
+
+ return componentName;
+
+ }
+
+ public void setComponentName(String name) {
+
+ componentName = name;
+
+ }
+
+ // ---------------------------------------------------------- test
+
+ public static void main(String[] args) throws Exception {
+
+ AuxiliaryComponentManager.getInstance();
+
+ }
+
+} // TopServiceLSRegistrationComponent
\ No newline at end of file
- r1734 - in branches/ulisseskan: conf src/org/perfsonar/commons/messages src/org/perfsonar/service/commons/engine src/org/perfsonar/service/topologyService, svnlog, 11/02/2006
Archive powered by MHonArc 2.6.16.