perfsonar-dev - perfsonar: r4088 - trunk/geant2-java-rrd-ma/src/main/java/org/perfsonar/service/measurementArchive/rrdType
Subject: perfsonar development work
List archive
perfsonar: r4088 - trunk/geant2-java-rrd-ma/src/main/java/org/perfsonar/service/measurementArchive/rrdType
Chronological Thread
- From:
- To:
- Subject: perfsonar: r4088 - trunk/geant2-java-rrd-ma/src/main/java/org/perfsonar/service/measurementArchive/rrdType
- Date: Wed, 2 Jul 2008 06:45:12 -0400
Author: roman
Date: 2008-07-02 06:45:11 -0400 (Wed, 02 Jul 2008)
New Revision: 4088
Modified:
trunk/geant2-java-rrd-ma/src/main/java/org/perfsonar/service/measurementArchive/rrdType/RRDStorageManager.java
trunk/geant2-java-rrd-ma/src/main/java/org/perfsonar/service/measurementArchive/rrdType/RRDTypeMAServiceEngine.java
Log:
Modified:
trunk/geant2-java-rrd-ma/src/main/java/org/perfsonar/service/measurementArchive/rrdType/RRDStorageManager.java
===================================================================
---
trunk/geant2-java-rrd-ma/src/main/java/org/perfsonar/service/measurementArchive/rrdType/RRDStorageManager.java
2008-07-02 09:56:58 UTC (rev 4087)
+++
trunk/geant2-java-rrd-ma/src/main/java/org/perfsonar/service/measurementArchive/rrdType/RRDStorageManager.java
2008-07-02 10:45:11 UTC (rev 4088)
@@ -274,17 +274,25 @@
this.updateRRDFile(dataSet);
-
return dataSet;
}
+ public Message remove(Message dataSet) throws PerfSONARException {
+ return null;
+ }
- // ---------------------------------- protected methods
+ public void removeAll() throws PerfSONARException {
+ }
+ public Message update(Message dataSet) throws PerfSONARException {
+ return null;
+ }
+
+
/**
*
* Returns measurement data fetched from rrd file.
@@ -297,7 +305,7 @@
* @throws PerfSONARException
* @throws RequestException
* @throws DataFormatException
- *
+ *
* @author romradz
*/
protected Message rrdFetch(Message query)
@@ -465,31 +473,31 @@
try {
- _dataSourceStep = dataSourceStep.getParameterValue();
+ _dataSourceStep = dataSourceStep.getParameterValue();
} catch (Exception ex) {
;
}
try {
- _dataSourceType = dataSourceType.getParameterValue();
+ _dataSourceType = dataSourceType.getParameterValue();
} catch (Exception ex) {
;
}
try {
- _dataSourceHeartbeat =
dataSourceHeartbeat.getParameterValue();
+ _dataSourceHeartbeat =
dataSourceHeartbeat.getParameterValue();
} catch (Exception ex) {
;
}
try {
- _dataSourceMinValue = dataSourceMinValue.getParameterValue();
+ _dataSourceMinValue = dataSourceMinValue.getParameterValue();
} catch (Exception ex) {
;
}
try {
- _dataSourceMaxValue = dataSourceMaxValue.getParameterValue();
+ _dataSourceMaxValue = dataSourceMaxValue.getParameterValue();
} catch (Exception ex) {
;
}
@@ -515,7 +523,7 @@
parameters.addParameter("dataSourceStep",
_dataSourceStep);
if (_dataSourceType != null)
- if (!_dataSourceType.trim().equals(""))
+ if (!_dataSourceType.trim().equals(""))
parameters.addParameter("dataSourceType",
_dataSourceType);
if (_dataSourceHeartbeat != null)
@@ -527,7 +535,7 @@
parameters.addParameter("dataSourceMinValue",
_dataSourceMinValue);
if (_dataSourceMaxValue != null)
- if (!_dataSourceMaxValue.trim().equals(""))
+ if (!_dataSourceMaxValue.trim().equals(""))
parameters.addParameter("dataSourceMaxValue",
_dataSourceMaxValue);
data.setChild(parameters);
@@ -566,14 +574,9 @@
}
-
- // -------------------------------------- private methods
-
-
-
/**
* Runs FETCH command from rrdjtool library
- *
+ *
* @author romradz
* @author mac
*/
@@ -659,15 +662,15 @@
if (ds > -1) {
- ResponseGenerator responseGenerator = null;
- Data data = null;
+ ResponseGenerator responseGenerator = null;
+ Data data = null;
- if (eventType == null) {
- responseGenerator = new GenericResponseGenerator();
- } else {
+ if (eventType == null) {
+ responseGenerator = new GenericResponseGenerator();
+ } else {
responseGenerator =
ResponseGeneratorFactory.getResponseGenerator(eventType);
- }
- data = responseGenerator.getResponse(fetchData, ds, rows,
valueUnits);
+ }
+ data = responseGenerator.getResponse(fetchData, ds, rows,
valueUnits);
return data;
Modified:
trunk/geant2-java-rrd-ma/src/main/java/org/perfsonar/service/measurementArchive/rrdType/RRDTypeMAServiceEngine.java
===================================================================
---
trunk/geant2-java-rrd-ma/src/main/java/org/perfsonar/service/measurementArchive/rrdType/RRDTypeMAServiceEngine.java
2008-07-02 09:56:58 UTC (rev 4087)
+++
trunk/geant2-java-rrd-ma/src/main/java/org/perfsonar/service/measurementArchive/rrdType/RRDTypeMAServiceEngine.java
2008-07-02 10:45:11 UTC (rev 4088)
@@ -48,11 +48,9 @@
public class RRDTypeMAServiceEngine implements ServiceEngine {
-
// ---------------------------------- class fields
-
/**
* Type of service angine.
*/
@@ -78,77 +76,40 @@
protected NMWGStorageManager metadataConfig = null;
- public static final String SELECT_NAMESPACE =
"http://ggf.org/ns/nmwg/ops/select/2.0";
+ protected String dbStatus = null;
+ protected String dbStore = null;
+ /**
+ * This variable is used to detect if there is more than one
+ * data triggers in the request.
+ */
+ protected boolean firstRunDone = false;
- // ---------------------------------- constructors
+ public static final String SELECT_NAMESPACE =
"http://ggf.org/ns/nmwg/ops/select/2.0";
+ // ---------------------------------- constructors
+
+
/**
* Construction for the service engine
* @throws PerfSONARException
*/
public RRDTypeMAServiceEngine() throws PerfSONARException {
-
this.serviceEngineType = "service.MeasurementArchive.RRDType";
-
- try {
-
- this.logger = (LoggerComponent)
- AuxiliaryComponentManager.
- getInstance().
- getComponent(ComponentNames.LOGGER);
-
- } catch (PerfSONARException e) {
-
- throw new PerfSONARException(
- "error.common.no_logger",
- "RRDTypeMAServiceEngine.constructor: "
- + "Cannot get logger component");
-
- }
-
- try {
-
- this.configuration = (ConfigurationComponent)
- AuxiliaryComponentManager.
- getInstance().
- getComponent(ComponentNames.CONFIG);
-
- } catch (PerfSONARException e) {
-
- throw new PerfSONARException(
- "error.common.no_configuration",
- "RRDTypeMAServiceEngine.constructor: "
- + "Cannot get config component");
-
- }
-
-
- // checking if using xml db is allowed
- String dbStatus =
- configuration.getProperty("component.ma.xmldb.db_status");
-
- if (dbStatus.trim().equalsIgnoreCase("on")) {
- // xmldb is present
- metadataConfig = new MetadataConfigurationStorageManager();
- } else {
- // xmldb is not present
- metadataConfig = new SimpleMetadataConfigurationStorageManager();
- }
- metadataConfig.initStorage(null);
-
+ this.logger = getLogger();
+ this.configuration = getConfiguration();
+ setProperties();
+ getMetadataConfigurationStorageManager();
}
+ // ---------------------------------- methods
- // ---------------------------------- public methods
-
-
/**
* Method which provides access the type of ServiceEngine.
* It implements the method definition in ServiceEngine Interface
@@ -156,15 +117,18 @@
* It does not return null
* @return String containing ServiceEngine Type
*
- * @see org.perfsonar.service.commons.engine.ServiceEngine#getType()
+ * @see org.perfsonar.service.base.engine.ServiceEngine#getType()
*/
public String getType() {
-
return this.serviceEngineType;
+ }
+
+ protected boolean isFirstRunDone() {
+ return firstRunDone;
}
-
+
/**
* Method to accept requests for action. It implements
* the method definition in ServiceEngine Interface.
@@ -176,10 +140,8 @@
* @return Message object containing the response
*
* @throws PerfSONARException
- * @throws RequestException
- * @throws DataFormatException
*
- * @see org.perfsonar.service.commons.engine.ServiceEngine
+ * @see org.perfsonar.service.base.engine.ServiceEngine
*/
public Message takeAction(String actionType, Message request)
throws PerfSONARException {
@@ -190,32 +152,26 @@
Message response = null;
-
if (actionType.equals(ActionType.GET_KEY)) {
// handle GET_KEY
-
+ // message type: MetadataKeyRequest
response = getKey(request);
} else if (actionType.equals(ActionType.GET_DATA)) {
// handle GET_DATA
-
+ // message type: SetupDataRequest
response = getData(request);
} else if (actionType.equals(ActionType.STORE_DATA)) {
// handle STORE_DATA
+ // message type: MeasurementArchiveStoreRequest
- String storeStatus =
- configuration.getProperty("service.ma.xmldb.db_store");
- String dbStatus =
- configuration.getProperty("component.ma.xmldb.db_status");
+ if (!dbStore.trim().equalsIgnoreCase("on")) {
- if (!storeStatus.trim().equalsIgnoreCase("on")) {
-
response = storeData(request, false);
-
logger.debug(
"RRDTypeMAServiceEngine.takeAction: "
+ "writing data into MA is switched off "
@@ -224,7 +180,6 @@
} else if (!dbStatus.trim().equalsIgnoreCase("on")) {
response = storeData(request, false);
-
logger.debug(
"RRDTypeMAServiceEngine.takeAction: "
+ "xmldb is not setup in the configuration "
@@ -239,15 +194,9 @@
// handle STORE_KEY
- String storeStatus =
- configuration.getProperty("service.ma.xmldb.db_store");
- String dbStatus =
- configuration.getProperty("component.ma.xmldb.db_status");
+ if (!dbStore.trim().equalsIgnoreCase("on")) {
- if (!storeStatus.trim().equalsIgnoreCase("on")) {
-
response = storeData(request, false);
-
logger.debug(
"RRDTypeMAServiceEngine.takeAction: "
+ "writing data into MA is switched off "
@@ -256,7 +205,6 @@
} else if (!dbStatus.trim().equalsIgnoreCase("on")) {
response = storeData(request, false);
-
logger.debug(
"RRDTypeMAServiceEngine.takeAction: "
+ "xmldb is not setup in the configuration "
@@ -267,6 +215,15 @@
response = storeKey(request);
}
+ } else if
(actionType.equals(ActionType.STORE_METADATA_CONFIGURATION)) {
+ // TEMPORARY CHANGE !!!!!!!!!!
+ //} else if (actionType.equals("STORE_METADATA_CONFIGURATION")) {
+
+ // handle STORE_METADATA_CONFIGURATION
+ // replace complete metadata configuration file
+ // message type: CompleteMetadataStoreRequest
+ response = replaceMetadataConfiguration(request);
+
} else if (actionType.equals(ActionType.ECHO)) {
response = getEcho(request);
@@ -288,17 +245,12 @@
}
-
+ firstRunDone = true;
return response;
}
-
- // ---------------------------------- public static methods
-
-
-
private static long seq = 0;
public static String getSeq() {
@@ -317,11 +269,58 @@
}
+ protected LoggerComponent getLogger() throws PerfSONARException {
- // ---------------------------------- protected methods
+ try {
+ return (LoggerComponent)AuxiliaryComponentManager.getInstance().
+ getComponent(ComponentNames.LOGGER);
+ } catch (PerfSONARException e) {
+ throw new PerfSONARException(
+ "error.common.no_logger",
+ "RRDTypeMAServiceEngine.getLogger: "
+ + "Cannot get logger component");
+ }
+ }
+ protected ConfigurationComponent getConfiguration() throws
PerfSONARException {
+ try {
+ return configuration =
(ConfigurationComponent)AuxiliaryComponentManager.getInstance().
+ getComponent(ComponentNames.CONFIG);
+ } catch (PerfSONARException e) {
+ throw new PerfSONARException(
+ "error.common.no_configuration",
+ "RRDTypeMAServiceEngine.getConfiguration: "
+ + "Cannot get config component");
+ }
+ }
+
+
+ protected void setProperties() throws PerfSONARException {
+
+ // checking if using xml db is allowed
+ dbStatus = configuration.getProperty("component.ma.xmldb.db_status");
+ dbStore = configuration.getProperty("service.ma.xmldb.db_store");
+
+ }
+
+
+ protected NMWGStorageManager getMetadataConfigurationStorageManager()
+ throws PerfSONARException {
+
+ if (dbStatus.trim().equalsIgnoreCase("on"))
+ // xmldb is present
+ metadataConfig = new MetadataConfigurationStorageManager();
+ else
+ // xmldb is not present
+ metadataConfig = new SimpleMetadataConfigurationStorageManager();
+
+ metadataConfig.initStorage(null);
+ return metadataConfig;
+ }
+
+
/**
* Returns a key for a request message.
*
@@ -329,11 +328,8 @@
* @return Message object containing the response with a key
*
* @throws PerfSONARException
- * @throws RequestException
- * @throws DataFormatException
*/
- protected Message getKey(Message request)
- throws PerfSONARException {
+ protected Message getKey(Message request) throws PerfSONARException {
//process the base chaining
request = messageProcess(request);
@@ -398,7 +394,7 @@
String mergerNames = null;
try {
- mergerNames =
+ mergerNames =
configuration.getProperty("service.ma.base_chaining_mergers");
} catch (Exception ex) {;}
@@ -430,8 +426,6 @@
* Method used in getKey method. Helps to find a key for a request
message.
*
* @throws PerfSONARException
- * @throws RequestException
- * @throws DataFormatException
*/
protected void _getKey(Metadata metadata,
Data data,
@@ -467,17 +461,17 @@
} else {
- String eventType = null;
- try {
- eventType = metadata.getEventType().getEventType().trim();
- } catch (Exception ex) {
- throw new PerfSONARException(
+ String eventType = null;
+ try {
+ eventType =
metadata.getEventType().getEventType().trim();
+ } catch (Exception ex) {
+ throw new PerfSONARException(
"error.ma.query",
"RRDTypeMAServiceEngine._getKey: "
+ "something wrong with eventType in metadata
id=" + metadata.getId());
- }
+ }
- if
(metadata.getEventType().getEventType().trim().equals(SELECT_NAMESPACE)) {
+ if
(metadata.getEventType().getEventType().trim().equals(SELECT_NAMESPACE)) {
Parameters params = metadata.getParameters();
String metadataIdRef =
metadata.getSubject().getMetadataIdRef();
Metadata m = (Metadata) metadataMap.get(metadataIdRef);
@@ -486,7 +480,7 @@
for (Object d : message.getDataMap().values()) {
- Key key = null;
+ Key key = null;
if ((key = ((Data)d).getKey()) != null) {
key = ((Data)d).getKey();
key.setParameters(params);
@@ -494,21 +488,21 @@
}
- } else {
+ } else {
- throw new PerfSONARException(
+ throw new PerfSONARException(
"error.ma.query",
"RRDTypeMAServiceEngine._getKey: "
+ "eventType " + eventType + " in metadata id="
+ metadata.getId()
+ " is not supported");
- }
+ }
}
} else {
- Key key = null;
+ Key key = null;
if ((key = metadata.getKey()) != null) {
@@ -578,8 +572,6 @@
* @return Message object containing the response with measurement data
*
* @throws PerfSONARException
- * @throws RequestException
- * @throws DataFormatException
*/
protected Message getData(Message request)
throws PerfSONARException {
@@ -637,8 +629,6 @@
* @return Message object containing the response
*
* @throws PerfSONARException
- * @throws RequestException
- * @throws DataFormatException
*/
protected Message storeData(Message request, boolean status)
throws PerfSONARException {
@@ -714,8 +704,6 @@
* Returns a key for the request with data to be stored in MA.
*
* @throws PerfSONARException
- * @throws RequestException
- * @throws DataFormatException
*/
protected Key getStoreKey(Metadata metadata)
throws PerfSONARException {
@@ -896,25 +884,23 @@
}
return key;
-
}
- protected Message getEcho(Message request) {
+ protected Message replaceMetadataConfiguration(Message request)
+ throws PerfSONARException {
- Message response = new Message();
+ String desc = "This functionality isn't implemented in RRD-MA yet.";
+ return generateResultCodeResponse("error.request", desc);
+ }
- PerfSONARException pex =
- new PerfSONARException(
- "error.request",
- "This eventType in echo request is not supported");
+ protected Message getEcho(Message request) throws PerfSONARException {
+
// this method will be used for advanced types of echo request
- ResultCodesUtil.createResultCodeMetadata(response, pex);
-
- return response;
-
+ String desc = "This eventType in echo request is not supported";
+ return generateResultCodeResponse("error.request", desc);
}
@@ -924,20 +910,27 @@
* @throws PerfSONARException
*/
protected Message storeKey(Message request)
- throws PerfSONARException{
-
- Message response = new Message();
+ throws PerfSONARException {
- PerfSONARException pex =
- new PerfSONARException(
- "error.request",
- "This functionality isn't implemented in RRD-MA yet.");
+ String desc = "This functionality isn't implemented in RRD-MA yet.";
+ return generateResultCodeResponse("error.request", desc);
+ }
+
+ protected Message generateResultCodeResponse(String resultCodeId, String
resultCodeDescription)
+ throws PerfSONARException {
+
+ Message response = new Message();
+
+ PerfSONARException pex =
+ new PerfSONARException(resultCodeId, resultCodeDescription);
ResultCodesUtil.createResultCodeMetadata(response, pex);
return response;
+
}
+
//---------------------------------- private methods
- perfsonar: r4088 - trunk/geant2-java-rrd-ma/src/main/java/org/perfsonar/service/measurementArchive/rrdType, svnlog, 07/02/2008
Archive powered by MHonArc 2.6.16.