Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r5382 - in branches/new-structure-with-base2/ps-mdm-ls/src/main: java/org/perfsonar/service/lookupservice java/org/perfsonar/service/lookupservice/schedulerActions resources/perfsonar/conf

Subject: perfsonar development work

List archive

perfsonar: r5382 - in branches/new-structure-with-base2/ps-mdm-ls/src/main: java/org/perfsonar/service/lookupservice java/org/perfsonar/service/lookupservice/schedulerActions resources/perfsonar/conf


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r5382 - in branches/new-structure-with-base2/ps-mdm-ls/src/main: java/org/perfsonar/service/lookupservice java/org/perfsonar/service/lookupservice/schedulerActions resources/perfsonar/conf
  • Date: Tue, 8 Dec 2009 04:35:33 -0500

Author: trzaszcz
Date: 2009-12-08 04:35:33 -0500 (Tue, 08 Dec 2009)
New Revision: 5382

Added:

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/CleanupSchedulerAction.java

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/SummarySynchronizationAction.java
Removed:

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSCleanupSchedulerAction.java

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/LSSummarySynchronizationAction.java
Modified:

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/GenericLSServiceEngine.java

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/GenericLSServiceROEngine.java

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSRegisterServiceEngine.java

branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
Log:
refactoring, added javadocs, code enhancement

Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/GenericLSServiceEngine.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/GenericLSServiceEngine.java
2009-12-08 08:58:26 UTC (rev 5381)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/GenericLSServiceEngine.java
2009-12-08 09:35:33 UTC (rev 5382)
@@ -11,143 +11,129 @@
import org.perfsonar.service.lookupservice.storage.LookupServiceDAO;
import org.perfsonar.service.lookupservice.storage.LookupServiceDAOFactory;

+/**
+ * provides support for operation on messages
+ *
+ * @author Maciej Glowiak, Slawomir Trzaszczka
+ *
+ */
public abstract class GenericLSServiceEngine implements ServiceEngine {
-
- private static final Logger logger =
Logger.getLogger(GenericLSServiceEngine.class.getName());
-
- protected LookupServiceDAO dao;
-
- protected Configuration configuration;
- protected ConfigurationManager configurationManager;
- private boolean gls;
-
- protected static final String LS_KEY = "lsKey";

+ private final Logger logger =
Logger.getLogger(GenericLSServiceEngine.class);

- protected GenericLSServiceEngine() throws PerfSONARException {
- //get LS DAO
- dao = LookupServiceDAOFactory.getDAO();
-
- //get configuration
- configurationManager = ConfigurationManager.getInstance();
- configuration = configurationManager.getConfiguration();
+ protected final LookupServiceDAO dao;
+ protected final Configuration configuration;
+ protected final ConfigurationManager configurationManager;
+ private boolean gls;

- }
-
-
- protected String extractEventType(Message request) {
+ protected static final String LS_KEY = "lsKey";

- //find eventType in the metadatas
- String eventType = null;
- for (Metadata m : request.getMetadataCollection()) {
- try {
- eventType = m.getFirstEventType().getEventType();
- } catch (RuntimeException ex) {
- ex.printStackTrace();
- }
- if (eventType!=null) break;
- }
- return eventType;
- }
-
- /**
- * Extracts first Metadata from Request
- * @param request
- * @return Metadata
- */
- protected Metadata getFirstMetadataFromRequest(
- Message request) throws PerfSONARException {
+ public GenericLSServiceEngine() throws PerfSONARException {
+ dao = getDao();

- //Get Metadata
-
- for (Metadata m : request.getMetadataCollection()) {
- return m;
- }
- return null;
- }
-
- /**
- * Extracts Key of specific Id from Metadata
- * @param requestMetadata
- * @param keyId Key identifier
- * @return Key value
- *
+ configurationManager = ConfigurationManager.getInstance();
+ configuration = configurationManager.getConfiguration();
+ }

- <!-- lsKey to be updated -->
- <nmwg:key>
- <nmwg:parameters id="param1">
- <nmwg:parameter
name="lsKey">http://shower.fr:8080/axis/services/MeasurementArchiveService</nmwg:parameter>
- </nmwg:parameters>
- </nmwg:key>
-
- */
- public String getParameterFromKey(
- Metadata requestMetadata, String parameterName) {
- if(requestMetadata.getChildren("key")==null){
- return null;
- }
- for (Element key : requestMetadata.getChildren("key")) {
- if(key.getChildren("parameters")==null){
- return null;
- }
- for (Element params : key.getChildren("parameters")) {
- if(params.getChildren("parameter")==null){
- return null;
- }
- for (Element p : params.getChildren("parameter")) {
- String parameterValue = extractParameterValue(p);
- if (parameterName.equals(p.getAttribute("name"))) {
- logger.debug("Found Parameter ["+parameterName+"] in
metadata ["+requestMetadata.getId()+"]");
- return parameterValue; //if key has keyId and
- }
- }
- }
- }
- return null;
- }
-
-
-
-
- /**
- * Tests if paramstr is = "yes", "true" or "test" or "ok"
- */
- protected boolean testIfTrue(String paramstr) {
-
- return ("yes".equalsIgnoreCase(paramstr)||
- "true".equalsIgnoreCase(paramstr)||
- "ok".equalsIgnoreCase(paramstr)||
- "test".equalsIgnoreCase(paramstr));
-
- }
-
- public boolean isGLS() {
-
- return gls;
- }
-
- public void setGLS(boolean g) {
-
- gls = g;
- }
+ protected LookupServiceDAO getDao() throws PerfSONARException {
+ return LookupServiceDAOFactory.getDAO();
+ }

-
- /**
- * Extract parameter value if value attribute not null or text content
- * @param p
- * @return
- */
- protected String extractParameterValue(Element p) {
- String val = p.getAttribute("value");
- if (val != null) return val;
- try {
- String txt = p.getText().trim();
- return txt;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
-
-} //GenericLSServiceEngine
\ No newline at end of file
+ /**
+ * extracts eventType from message
+ *
+ * @param request
+ * @return
+ */
+ protected String extractEventType(Message request) {
+
+ // find eventType in the metadatas
+ String eventType = null;
+ for (Metadata m : request.getMetadataCollection()) {
+ eventType = m.getFirstEventType().getEventType();
+ if (eventType != null)
+ return eventType;
+ }
+ return null;
+ }
+
+ /**
+ * Extracts first Metadata from Request
+ *
+ * @param request
+ * @return Metadata
+ */
+ protected Metadata getFirstMetadataFromRequest(Message request)
+ throws PerfSONARException {
+
+ for (Metadata m : request.getMetadataCollection()) {
+ return m;
+ }
+ return null;
+ }
+
+ /**
+ * Extracts Key of specific Id from Metadata
+ *
+ * @param requestMetadata
+ * @param keyId
+ * Key identifier
+ * @return Key value
+ *
+ *
+ * <!-- lsKey to be updated --> <nmwg:key> <nmwg:parameters
+ * id="param1"> <nmwg:parameter
+ * name="lsKey">http://shower.fr:8080/axis
+ * /services/MeasurementArchiveService</nmwg:parameter>
+ * </nmwg:parameters> </nmwg:key>
+ */
+ public String getParameterFromKey(Metadata requestMetadata,
+ String parameterName) {
+ if (requestMetadata.getChildren("key") == null) {
+ return null;
+ }
+ for (Element key : requestMetadata.getChildren("key")) {
+ if (key.getChildren("parameters") == null) {
+ return null;
+ }
+ for (Element params : key.getChildren("parameters")) {
+ if (params.getChildren("parameter") == null) {
+ return null;
+ }
+ for (Element p :
params.getChildren("parameter")) {
+ String parameterValue =
extractParameterValue(p);
+ if
(parameterName.equals(p.getAttribute("name"))) {
+ logger.debug("Found Parameter
[" + parameterName
+ + "] in
metadata [" + requestMetadata.getId()
+ + "]");
+ return parameterValue; // if
key has keyId and
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean isGLS() {
+ return gls;
+ }
+
+ public void setGLS(boolean g) {
+ gls = g;
+ }
+
+ /**
+ * Extract parameter value if value attribute not null or text content
+ *
+ * @param p
+ * @return
+ */
+ protected String extractParameterValue(Element p) {
+ String val = p.getAttribute("value");
+ if (val != null)
+ return val;
+ String txt = p.getText().trim();
+ return txt;
+ }
+
+}
\ No newline at end of file

Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/GenericLSServiceROEngine.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/GenericLSServiceROEngine.java
2009-12-08 08:58:26 UTC (rev 5381)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/GenericLSServiceROEngine.java
2009-12-08 09:35:33 UTC (rev 5382)
@@ -1,18 +1,24 @@
package org.perfsonar.service.lookupservice;

-import org.perfsonar.base2.service.configuration.ConfigurationManager;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
+import org.perfsonar.service.lookupservice.storage.LookupServiceDAO;
import org.perfsonar.service.lookupservice.storage.LookupServiceDAOFactory;
-
+/**
+ *
+ * Service provides read only operation on Exist DB
+ *
+ *
+ * @author Slawomir Trzaszczka
+ */
public abstract class GenericLSServiceROEngine extends
GenericLSServiceEngine {

- protected GenericLSServiceROEngine() throws PerfSONARException {
- // get LS DAO
- dao = LookupServiceDAOFactory.getRODAO();
- // get configuration
- configurationManager = ConfigurationManager.getInstance();
- configuration = configurationManager.getConfiguration();
+ public GenericLSServiceROEngine() throws PerfSONARException {
+ super();
+ }

+ @Override
+ protected LookupServiceDAO getDao() throws PerfSONARException {
+ return LookupServiceDAOFactory.getRODAO();
}

}
\ No newline at end of file

Deleted:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSCleanupSchedulerAction.java

Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSRegisterServiceEngine.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSRegisterServiceEngine.java
2009-12-08 08:58:26 UTC (rev 5381)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSRegisterServiceEngine.java
2009-12-08 09:35:33 UTC (rev 5382)
@@ -87,9 +87,6 @@
}
}

- logger.debug("[LS Registration] Action started, service is "
- + (isGLS() ? "GlobalLS" : "HomeLS"));
-
// Get Metadata from request

Metadata requestMetadata =
getFirstMetadataFromRequest(request);

Added:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/CleanupSchedulerAction.java


Property changes on:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/CleanupSchedulerAction.java
___________________________________________________________________
Name: svn:executable
+ *

Deleted:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/LSSummarySynchronizationAction.java

Added:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/SummarySynchronizationAction.java


Property changes on:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/SummarySynchronizationAction.java
___________________________________________________________________
Name: svn:executable
+ *

Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
2009-12-08 08:58:26 UTC (rev 5381)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
2009-12-08 09:35:33 UTC (rev 5382)
@@ -125,7 +125,7 @@
<option name="interval" value="60"/> <!-- sec -->
<actions>

- <action name="LSCleanup_1"
className="org.perfsonar.service.lookupservice.LSCleanupSchedulerAction">
+ <action name="LSCleanup_1"
className="org.perfsonar.service.lookupservice.schedulerActions.CleanupSchedulerAction">
<option name="status" value="on" />
<option name="interval" value="300" />
<option name="lsTTL" value="86400"/>
@@ -136,7 +136,7 @@
nrOfModifications - nr of changes in db after which
summarization process is executed immediately
nrOfIterations - after this nr of iteration if there are
some changes in db - summarization process is executed
-->
- <action name="LSSummarySynchronization"
className="org.perfsonar.service.lookupservice.schedulerActions.LSSummarySynchronizationAction">
+ <action name="LSSummarySynchronization"
className="org.perfsonar.service.lookupservice.schedulerActions.SummarySynchronizationAction">
<option name="status" value="on" />
<option name="interval" value="60" />
<option name="nrOfModifications" value="10"/>



  • perfsonar: r5382 - in branches/new-structure-with-base2/ps-mdm-ls/src/main: java/org/perfsonar/service/lookupservice java/org/perfsonar/service/lookupservice/schedulerActions resources/perfsonar/conf, svnlog, 12/08/2009

Archive powered by MHonArc 2.6.16.

Top of Page