perfsonar-dev - perfsonar: r5388 - in branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice: . registerService storage/exist
Subject: perfsonar development work
List archive
perfsonar: r5388 - in branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice: . registerService storage/exist
Chronological Thread
- From:
- To:
- Subject: perfsonar: r5388 - in branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice: . registerService storage/exist
- Date: Wed, 9 Dec 2009 04:36:04 -0500
Author: trzaszcz
Date: 2009-12-09 04:36:04 -0500 (Wed, 09 Dec 2009)
New Revision: 5388
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/registerService/LSRegisterServiceHelper.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/CommonExistDAOImpl.java
Log:
refactoring
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-09 08:53:12 UTC (rev 5387)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSRegisterServiceEngine.java
2009-12-09 09:36:04 UTC (rev 5388)
@@ -38,38 +38,39 @@
// extract message
Message request = serviceRequest.getMessageElement();
- // lsTTL param processing
- List<Element> parametersNodes = (List<Element>) serviceRequest
- .getElement().getChildren("parameters");
- if (parametersNodes != null && parametersNodes.size() == 1) {
- try {
- long clientTTL =
getLSTTLFromParametrs(parametersNodes.get(0));
- setClientTTL(clientTTL);
- if (clientTTL != 0) {
- if (getTtlBound() != null) {
- logger.debug("TTL parameters
are set");
- logger.debug("suggested TTL
param by client :"
- + clientTTL);
- if
(isBetweenTTLBound(clientTTL)) {
-
setTtlParameterStatus(LsTTLParameterStatus.ACCEPTED);
-
setClientTTL(clientTTL);
- logger.info("client
TTL accepted");
- } else {
-
setTtlParameterStatus(LsTTLParameterStatus.OUT_OF_BOUND);
- logger.info("client
TTL rejected - out of bound");
- setClientTTL(0);
- }
- } else {
- logger
- .warn("client
sent ttl parameter - no ranges params defined in config file !!");
+
+ if (getTtlBound() != null) {
+ // if TTL bounds are defined check if the user send
lsTTL parameter
+
+ List<Element> parametersNodes = (List<Element>)
serviceRequest
+ .getElement().getChildren("parameters");
+ if (parametersNodes != null && parametersNodes.size()
== 1) {
+ try {
+ long clientTTL =
getLSTTLFromParametrs(parametersNodes.get(0));
+ setClientTTL(clientTTL);
+ if (clientTTL != 0) {
+ logger.debug("TTL
parameters are set");
+
logger.debug("suggested TTL param by client :"
+ +
clientTTL);
+ if
(isBetweenTTLBound(clientTTL)) {
+
setTtlParameterStatus(LsTTLParameterStatus.ACCEPTED);
+
setClientTTL(clientTTL);
+
logger.info("client TTL accepted");
+ } else {
+
setTtlParameterStatus(LsTTLParameterStatus.OUT_OF_BOUND);
+
logger.info("client TTL rejected - out of bound");
+
setClientTTL(0);
+ }
}
+ } catch (PerfSONARException ex) {
+
setTtlParameterStatus(LsTTLParameterStatus.NOT_A_NUMBER);
}
- } catch (PerfSONARException ex) {
-
setTtlParameterStatus(LsTTLParameterStatus.NOT_A_NUMBER);
+
}
-
+ }else{
+ logger.warn("client sent ttl parameter - no ranges
params defined in config file !!");
}
-
+
// Get Metadata from request
Metadata requestMetadata =
getFirstMetadataFromRequest(request);
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registerService/LSRegisterServiceHelper.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registerService/LSRegisterServiceHelper.java
2009-12-09 08:53:12 UTC (rev 5387)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registerService/LSRegisterServiceHelper.java
2009-12-09 09:36:04 UTC (rev 5388)
@@ -3,6 +3,7 @@
import java.util.Collection;
import org.apache.log4j.Logger;
+import org.perfsonar.base2.service.configuration.Option;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
import org.perfsonar.base2.service.util.ResultCodesUtil;
import org.perfsonar.base2.xml.Element;
@@ -106,7 +107,7 @@
}
}
}
- String m = "No serviceName in request - ";
+ String m = "No serviceName in request ";
logger.error(m);
throw new PerfSONARException("error/ls/no_service_name", m);
}
@@ -130,38 +131,44 @@
private int[] getTTLParameters(
org.perfsonar.base2.service.configuration.Message msg)
throws PerfSONARException {
- String strMinTTL = msg.getOption("minTTL").getValue();
- String strMaxTTL = msg.getOption("maxTTL").getValue();
- int[] result = new int[2];
+ Option minTTLOption = msg.getOption("minTTL");
+ Option maxTTLOption = msg.getOption("maxTTL");
- if (strMinTTL != null && strMaxTTL != null) {
- try {
- result[0] = Integer.parseInt(strMinTTL);
- } catch (NumberFormatException ex) {
- throw new PerfSONARException(
- "incorrect value of minTTL
parameter", ex);
- }
+ if (minTTLOption != null && maxTTLOption != null) {
- try {
- result[1] = Integer.parseInt(strMaxTTL);
- } catch (NumberFormatException ex) {
- throw new PerfSONARException(
- "incorrect value of maxTTL
parameter ", ex);
- }
+ String strMinTTL = minTTLOption.getValue();
+ String strMaxTTL = maxTTLOption.getValue();
+
- if (result[0] >= result[1]) {
- throw new PerfSONARException(
- " minTTL must be less then
maxTTL ");
+ if (strMinTTL != null && strMaxTTL != null) {
+ int[] result = new int[2];
+
+ try {
+ result[0] =
Integer.parseInt(strMinTTL);
+ } catch (NumberFormatException ex) {
+ throw new PerfSONARException(
+ "incorrect value of
minTTL parameter", ex);
+ }
+
+ try {
+ result[1] =
Integer.parseInt(strMaxTTL);
+ } catch (NumberFormatException ex) {
+ throw new PerfSONARException(
+ "incorrect value of
maxTTL parameter ", ex);
+ }
+
+ if (result[0] >= result[1]) {
+ throw new PerfSONARException(
+ " minTTL must be less
then maxTTL ");
+ }
+
+ return result;
+ }else{
+ throw new PerfSONARException("incorrect
values of TTL bound");
}
-
- return result;
- } else if (strMinTTL != strMaxTTL) {
- throw new PerfSONARException(
- "both or any TTL parameters
(minTTL,maxTTL) should be set !");
- } else {
- return null;
}
+ return null;
}
/**
@@ -204,23 +211,24 @@
* @throws PerfSONARException
*/
protected Data[] getDataElements(Message request) throws
PerfSONARException {
- // Get all Data elements, suppose they all belong to
metadata
- // (data map is created in the constructor of
Message, so
- // NullPointerException won't be thrown!)
- Collection<Data> reqDataArr =
request.getDataMap().values();
+ // Get all Data elements, suppose they all belong to metadata
+ // (data map is created in the constructor of Message, so
+ // NullPointerException won't be thrown!)
+ Collection<Data> reqDataArr = request.getDataMap().values();
- // if there is no data! -- to be discussed
- // there should be at least ONE trigger -- to be
discussed
- if (reqDataArr.size() < 1) {
- String m = "Request must have at least one
data element - trigger";
- logger.error(m);
- throw new
PerfSONARException("error/ls/no_data_trigger", m);
- }
+ // if there is no data! -- to be discussed
+ // there should be at least ONE trigger -- to be discussed
+ if (reqDataArr.size() < 1) {
+ String m = "Request must have at least one data
element - trigger";
+ logger.error(m);
+ throw new
PerfSONARException("error/ls/no_data_trigger", m);
+ }
- // convert dataArr to Data[]
- Data[] dataElements = (Data[]) reqDataArr.toArray(new
Data[reqDataArr.size()]);
+ // convert dataArr to Data[]
+ Data[] dataElements = (Data[]) reqDataArr.toArray(new
Data[reqDataArr
+ .size()]);
- return dataElements;
+ return dataElements;
}
/**
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/CommonExistDAOImpl.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/CommonExistDAOImpl.java
2009-12-09 08:53:12 UTC (rev 5387)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/CommonExistDAOImpl.java
2009-12-09 09:36:04 UTC (rev 5388)
@@ -8,7 +8,6 @@
import org.perfsonar.base2.service.storage.xml.XMLDBComponent;
import org.perfsonar.base2.service.storage.xml.XMLDataStorage;
import org.perfsonar.base2.service.storage.xml.exist.ExistHTTPDataStorage;
-import org.perfsonar.service.lookupservice.LSRegisterServiceEngine;
/**
* Abstract implementation of LookupServiceDAO Implements all generic
functions
@@ -22,8 +21,7 @@
*/
public abstract class CommonExistDAOImpl extends Component {
- protected static final Logger logger = Logger
- .getLogger(LSRegisterServiceEngine.class.getName());
+ protected static final Logger logger =
Logger.getLogger(CommonExistDAOImpl.class);
private XMLDataStorage dataStorage;
private String dataCollection;
- perfsonar: r5388 - in branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice: . registerService storage/exist, svnlog, 12/09/2009
Archive powered by MHonArc 2.6.16.