perfsonar-dev - r1449 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType
Subject: perfsonar development work
List archive
- From:
- To:
- Subject: r1449 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType
- Date: Tue, 18 Jul 2006 09:46:11 -0400
Author: mac
Date: 2006-07-18 09:46:10 -0400 (Tue, 18 Jul 2006)
New Revision: 1449
Modified:
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.java
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSDeregisterAction.java
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGenericRegisterAction.java
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLookupAction.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/LSCleanup.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.java
2006-07-18 13:41:46 UTC (rev 1448)
+++
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.java
2006-07-18 13:46:10 UTC (rev 1449)
@@ -7,6 +7,7 @@
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.XmlDbResult;
/**
@@ -104,7 +105,7 @@
XUPDATE_FOOTER;
//TODO: uncomment!!!!!!!!!!!!!!!!1
- //xmlStorageManager.store(query); //XUpdate
+ xmlStorageManager.store(query); //XUpdate
}
@@ -128,7 +129,8 @@
"declare namespace nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; " +
"data(/nmwg:store[@type='"+LS_STORE_COLLECTION_TYPE+"']/nmwg:metadata/@id)";
- String[] res = (String[])xmlStorageManager.fetch(query);
+ XmlDbResult edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ String[] res = (String[])edbres.getResultAsStringArray();
return res;
@@ -150,7 +152,8 @@
"']/nmwg:parameters/nmwg:parameter[@name='"+
parameterName+"']/text()";
- String[] resArray = (String[])xmlStorageManager.fetch(query);
+ XmlDbResult edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ String[] resArray = (String[])edbres.getResultAsStringArray();
try {
String result = resArray[0];
return result;
Modified:
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSDeregisterAction.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSDeregisterAction.java
2006-07-18 13:41:46 UTC (rev 1448)
+++
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSDeregisterAction.java
2006-07-18 13:46:10 UTC (rev 1449)
@@ -6,6 +6,7 @@
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.XmlDbResult;
/**
@@ -70,26 +71,25 @@
//Query - get Data identifiers for given Key (all occurencies of Data
//having metadataIdRef = Key)
-
- //query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; "+
- //
"/nmwg:store/nmwg:data[@metadataIdRef='"+keyValue+"']/@id";
-
-
query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; "+
-
"/nmwg:store/nmwg:data[@metadataIdRef='"+keyValue+"']";
+
"data(/nmwg:store/nmwg:data[@metadataIdRef='"+keyValue+"']/@id)";
- queryResults = (String[])xmlStorageManager.fetch(query);
+ XmlDbResult edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ queryResults = (String[])edbres.getResultAsStringArray();
+
if (queryResults!=null) {
- countDataRemoved = queryResults.length;
+ countDataRemoved = edbres.getCount();
+
for (int i=0; i<queryResults.length; i++) {
- logger.debug("XmlTypeLSServiceEngine: removing data id=["+
+ logger.debug("XmlTypeLSServiceEngine: removing
["+countDataRemoved+"] data elements id=["+
queryResults[i]+"]");
}
}
+
//If found at least one matching Data element, remove all
if (countDataRemoved>0) {
@@ -107,24 +107,23 @@
//Query - get metadata identifiers for Key (all occurencies of
Metadata
//having id = Key : should be 0 or 1 !)
- //query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; "+
- //
"/nmwg:store/nmwg:metadata[@id='"+keyValue+"']/@id";
-
-
query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; "+
-
"/nmwg:store/nmwg:metadata[@id='"+keyValue+"']";
-
- queryResults = (String[])xmlStorageManager.fetch(query); //XQuery
+
"data(/nmwg:store/nmwg:metadata[@id='"+keyValue+"']/@id)";
+
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query); //XQuery
+ queryResults = (String[])edbres.getResultAsStringArray();
+
if (queryResults!=null) {
- countMetadataRemoved = queryResults.length;
+ countMetadataRemoved = edbres.getCount();
+
for (int i=0; i<queryResults.length; i++) {
- logger.debug("XmlTypeLSServiceEngine: removing metadata
id=["+
+ logger.debug("XmlTypeLSServiceEngine: removing
["+countDataRemoved+"] metadata elements id=["+
queryResults[i]+"]");
}
}
-
+
//if found - remove (XUpdate)
if (countDataRemoved>0) {
@@ -146,6 +145,7 @@
//Prepare result code (put it into the response)
Message response = new Message();
+
// XXX: Should there be a different type for response?
response.setType("LSDeregisterResponse");
@@ -153,26 +153,6 @@
countMetadataRemoved+"] metadata and ["+
countDataRemoved+"] data blocks for key ["+keyValue+"]");
- // //replaced by SystemException
-// ResultCode rc = createResultCode("result.success", "Removed ["+
-// countMetadataRemoved+"] metadata and ["+
-// countDataRemoved+"] data blocks for key ["+keyValue+"]");
-//
-// Metadata[] responseMetadata = { rc.getMetadata() };
-// Data[] responseData = null;
-// if (rc.getData() !=null) {
-// responseData = new Data[1];
-// responseData[0] = rc.getData();
-// }
-//
-// response.addChild(responseData[0]);
-// for(int j=0; j < responseMetadata.length; j++){
-// response.addChild(responseMetadata[j]);
-// }
-//
-// //Return response
-// return response;
-
}
Modified:
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGenericRegisterAction.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGenericRegisterAction.java
2006-07-18 13:41:46 UTC (rev 1448)
+++
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGenericRegisterAction.java
2006-07-18 13:46:10 UTC (rev 1449)
@@ -6,6 +6,7 @@
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.XmlDbResult;
/**
@@ -93,9 +94,10 @@
String query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; " +
"data(/nmwg:store[@type='"+LS_STORE_CONTROL_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+key+"']/@id)";
+
+ XmlDbResult res = (XmlDbResult)xmlStorageManager.fetch(query);
+ int resnum = res.getCount();
- int resnum = ((String[])xmlStorageManager.fetch(query)).length;
-
//metadata empty -> remove it
if (resnum==0) {
@@ -145,8 +147,10 @@
query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; " +
"data(/nmwg:store[@type='"+LS_STORE_CONTROL_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+key+"']/@id)";
- resnum = ((String[])xmlStorageManager.fetch(query)).length;
+ XmlDbResult res = (XmlDbResult)xmlStorageManager.fetch(query);
+ resnum = res.getCount();
+
//if there is no control metadata, put it
if (resnum==0) {
@@ -171,7 +175,9 @@
query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; " +
"data(/nmwg:store[@type='"+LS_STORE_CONTROL_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+
key+"']/nmwg:parameters/@id)";
- resnum = ((String[])xmlStorageManager.fetch(query)).length;
+
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
+ resnum = res.getCount();
if (resnum==0) {
@@ -198,9 +204,10 @@
query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; " +
"/nmwg:store[@type='"+LS_STORE_CONTROL_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+key+
"']/nmwg:parameters/nmwg:parameter[@name='"+parameterName+"']";
- //logger.debug("check if there is parameter inside metadata:
"+query);
- resnum = ((String[])xmlStorageManager.fetch(query)).length;
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
+ resnum = res.getCount();
+
if (resnum==0) {
//if there is no such parameter, put new one
@@ -263,16 +270,14 @@
try {
-// String query =
-// "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; " +
-//
"/nmwg:store[@type='"+LS_STORE_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+key+"']/@id";
-
String query =
"declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; " +
-
"/nmwg:store[@type='"+LS_STORE_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+key+"']";
+
"data(/nmwg:store[@type='"+LS_STORE_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+key+"']/@id)";
-
- int resnum = ((String[])xmlStorageManager.fetch(query)).length;
+
+ XmlDbResult res = (XmlDbResult)xmlStorageManager.fetch(query);
+
+ int resnum = res.getCount();
if (resnum>0)
return true; //key is registered
@@ -282,6 +287,7 @@
} catch (NullPointerException ex) {
return false;
}
+
}
Modified:
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLookupAction.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLookupAction.java
2006-07-18 13:41:46 UTC (rev 1448)
+++
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLookupAction.java
2006-07-18 13:46:10 UTC (rev 1449)
@@ -3,9 +3,12 @@
import org.ggf.ns.nmwg.base.v2_0.*;
import org.perfsonar.commons.util.XMLUtils;
import org.perfsonar.service.commons.exceptions.DataFormatException;
+import org.perfsonar.service.commons.exceptions.PerfSONARException;
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.XmlDbResult;
+import
org.perfsonar.service.commons.storage.xmldb.exist.rest.ExistDbHTTPAccess;
/**
* LOOKUP Action
@@ -133,9 +136,20 @@
//Performing XQuery operation on the database
logger.debug("XmlTypeLSServiceEngine: perform query");
String[] results;
- results = (String[])xmlStorageManager.fetch(query); //XQuery
+
+
+ System.out.println(" LSq0,"+System.currentTimeMillis());
+ ///////////////////////////////////////////////////////////////
+ /* XQuery */
+ XmlDbResult edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+
+ ///////////////////////////////////////////////////////////////
+
+ System.out.println(" LSq1,"+System.currentTimeMillis());
+
logger.debug("XmlTypeLSServiceEngine: Got [["+
results.length+"]] results from DB");
- r1449 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType, svnlog, 07/18/2006
Archive powered by MHonArc 2.6.16.