Skip to Content.
Sympa Menu

perfsonar-dev - r1691 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType

Subject: perfsonar development work

List archive

r1691 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType


Chronological Thread 
  • From:
  • To:
  • Subject: r1691 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType
  • Date: Wed, 18 Oct 2006 15:36:06 -0400

Author: yi
Date: 2006-10-18 15:36:06 -0400 (Wed, 18 Oct 2006)
New Revision: 1691

Modified:

branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSAction.java

branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSDeregisterAction.java

branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGenericRegisterAction.java

branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSRegisterAction.java

branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
Log:
Berkely DB XML support

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSAction.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSAction.java
2006-10-18 19:35:34 UTC (rev 1690)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSAction.java
2006-10-18 19:36:06 UTC (rev 1691)
@@ -20,6 +20,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.bdbxml.BerkeleyDbXmlStorageManager;

/**
* Generic class for all LS actions performed by XmlTypeLSServiceEngine
@@ -31,6 +32,11 @@

// --------------------------------------------------------------
Constants

+ /**
+ * BDB store container
+ */
+ protected static final String LS_STORE_CONTAINER =
BerkeleyDbXmlStorageManager.BDBXML_DEFAULT_CONTAINER;
+
/**
* The name of the store collection (containing LS data/metadata
*/

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSDeregisterAction.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSDeregisterAction.java
2006-10-18 19:35:34 UTC (rev 1690)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSDeregisterAction.java
2006-10-18 19:36:06 UTC (rev 1691)
@@ -7,6 +7,8 @@
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.bdbxml.BerkeleyDbXmlStorageManager;
+import
org.perfsonar.service.commons.storage.xmldb.exist.xmlrpc.ExistDbXmlrpcXmlStorageManager;


/**
@@ -71,8 +73,19 @@
//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/\";; "+
-
"data(/nmwg:store/nmwg:data[@metadataIdRef='"+keyValue+"']/@id)";
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; "+
+
"data(/nmwg:store/nmwg:data[@metadataIdRef='"+keyValue+"']/@id)";
+ }
+ else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
+ {
+ query =
+ "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"data(collection(\""+LS_STORE_CONTAINER+"\")/nmwg:store/nmwg:data[@metadataIdRef=\""+keyValue+"\"]/@id)";

+ }
+ else
+ query = "";


XmlDbResult edbres = (XmlDbResult)xmlStorageManager.fetch(query);
@@ -94,20 +107,37 @@
if (countDataRemoved>0) {

//generate XQuery that removes data
-
- String remove = "";
- remove = XQUERY_UPDATE_DECLARE +
- "for $d in
/nmwg:store/nmwg:data[@metadataIdRef='"
- + keyValue +"'] return " + XQUERY_UPDATE_DELETE + "$d";
- logger.debug("XmlTypeLSServiceEngine: Remove xupdate=" +
remove);
- xmlStorageManager.fetch(remove); //XQuery
+ if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager)
+ {
+ String remove = "";
+ remove = XQUERY_UPDATE_DECLARE +
+ "for $d in
/nmwg:store/nmwg:data[@metadataIdRef='"
+ + keyValue +"'] return " + XQUERY_UPDATE_DELETE +
"$d";
+ logger.debug("XmlTypeLSServiceEngine: Remove xupdate=" +
remove);
+ xmlStorageManager.fetch(remove); //XQuery
+ }
+ else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
+ {
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteElement(XQUERY_UPDATE_DECLARE,

"/nmwg:store/nmwg:data[@metadataIdRef=\""
+ keyValue +"\"]");
+ }
}

//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/\";; "+
-
"data(/nmwg:store/nmwg:metadata[@id='"+keyValue+"']/@id)";
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; "+
+
"data(/nmwg:store/nmwg:metadata[@id='"+keyValue+"']/@id)";
+ }
+ else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
+ {
+ query =
+ "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"data(collection(\""+LS_STORE_CONTAINER+"\")/nmwg:store/nmwg:metadata[@id=\""+keyValue+"\"]/@id)";

+ }
+ else
+ query = "";

edbres = (XmlDbResult)xmlStorageManager.fetch(query); //XQuery
queryResults = (String[])edbres.getResultAsStringArray();
@@ -128,12 +158,18 @@

//generate XQuery that removes data
//removes data from ALL schemas (LSStore, LSStore-control)
-
- String remove2 = "";
- remove2 = XQUERY_UPDATE_DECLARE +
- "for $md in
/nmwg:store/nmwg:metadata[@id='"
+
- keyValue+"'] return " + XQUERY_UPDATE_DELETE + "$md";

- xmlStorageManager.fetch(remove2); //XQuery
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ String remove2 = "";
+ remove2 = XQUERY_UPDATE_DECLARE +
+ "for $md in
/nmwg:store/nmwg:metadata[@id='"
+
+ keyValue+"'] return " + XQUERY_UPDATE_DELETE +
"$md";
+ xmlStorageManager.fetch(remove2); //XQuery
+ }
+ else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
+ {
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteElement(XQUERY_UPDATE_DECLARE,

"/nmwg:store/nmwg:metadata[@id=\""
+ keyValue +"\"]");
+ }
}

//status of operation

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGenericRegisterAction.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGenericRegisterAction.java
2006-10-18 19:35:34 UTC (rev 1690)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGenericRegisterAction.java
2006-10-18 19:36:06 UTC (rev 1691)
@@ -7,6 +7,8 @@
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.bdbxml.BerkeleyDbXmlStorageManager;
+import
org.perfsonar.service.commons.storage.xmldb.exist.xmlrpc.ExistDbXmlrpcXmlStorageManager;


/**
@@ -231,12 +233,23 @@
protected boolean checkIfKeyIsRegistered(String key, StorageManager
xmlStorageManager) throws SystemException, RequestException,
DataFormatException {

try {
+ String query;
+
+ if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager)
+ {
+ query =
+ "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"data(/nmwg:store[@type='"+LS_STORE_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+key+"']/@id)";

+ }
+ else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
+ {
+ query =
+ "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"data(doc(\""+LS_STORE_CONTAINER+"/"+LS_STORE_COLLECTION_TYPE+"\")/nmwg:store/nmwg:metadata[@id=\""+key+"\"]/@id)";

+ }
+ else
+ query = "";

- String query =
- "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
-
"data(/nmwg:store[@type='"+LS_STORE_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+key+"']/@id)";

-
-
XmlDbResult res = (XmlDbResult)xmlStorageManager.fetch(query);

int resnum = res.getCount();

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSRegisterAction.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSRegisterAction.java
2006-10-18 19:35:34 UTC (rev 1690)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSRegisterAction.java
2006-10-18 19:36:06 UTC (rev 1691)
@@ -9,6 +9,8 @@
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.bdbxml.BerkeleyDbXmlStorageManager;
+import
org.perfsonar.service.commons.storage.xmldb.exist.xmlrpc.ExistDbXmlrpcXmlStorageManager;


/**
@@ -203,12 +205,18 @@
//change metadata id
requestMetadata.setId(accessPoint);

- String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
- insert = insert + XMLUtils.serializeXML(requestMetadata) + " into
/nmwg:store[@type='"
+
- LS_STORE_COLLECTION_TYPE + "']";
- xmlStorageManager.fetch(insert);
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
+ insert = insert + XMLUtils.serializeXML(requestMetadata) + "
into
/nmwg:store[@type='"
+
+ LS_STORE_COLLECTION_TYPE + "']";
+ xmlStorageManager.fetch(insert);
+ }
+ else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
+ {
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insertElement(XQUERY_UPDATE_DECLARE,
LS_STORE_COLLECTION_TYPE, "/nmwg:store",
XMLUtils.serializeXML(requestMetadata));
+ }

-
//Prepare XQuery data

String updateData[] = new String[reqDataArr.size()];
@@ -239,10 +247,17 @@
//Prepare XQuery for Data
//fill updateData structure

- String insert2 = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
- insert2 = insert2 + XMLUtils.serializeXML(requestData) + " into
/nmwg:store[@type='"
+
- LS_STORE_COLLECTION_TYPE + "']";
- xmlStorageManager.fetch(insert2);
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ String insert2 = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
+ insert2 = insert2 + XMLUtils.serializeXML(requestData) +
" into
/nmwg:store[@type='"
+
+ LS_STORE_COLLECTION_TYPE + "']";
+ xmlStorageManager.fetch(insert2);
+ }
+ else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
+ {
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insertElement(XQUERY_UPDATE_DECLARE,
LS_STORE_COLLECTION_TYPE, "/nmwg:store", XMLUtils.serializeXML(requestData));
+ }

datanum++;
}

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
2006-10-18 19:35:34 UTC (rev 1690)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
2006-10-18 19:36:06 UTC (rev 1691)
@@ -16,6 +16,7 @@
import org.perfsonar.service.commons.exceptions.SystemException;
import org.perfsonar.service.commons.storage.xmldb.XmlDbDataRepository;
import org.perfsonar.service.commons.storage.xmldb.XmlDbStorageManager;
+import
org.perfsonar.service.commons.storage.xmldb.bdbxml.BerkeleyDbXmlStorageManager;
import org.perfsonar.service.commons.storage.xmldb.exist.ExistDbFactory;
import org.perfsonar.service.commons.storage.xmldb.XmlDbConstants;

@@ -35,6 +36,8 @@

// -------------------------------------------------------------
Constants

+ private static final String SERVICE_DATABASE_TYPE = "BDB";
+
/**
* Service engine type
*/
@@ -103,7 +106,7 @@



- // --------------------------------------------------------- public
methods
+ //
---------------------------------------------acceptedTypes------------ public
methods



@@ -226,25 +229,34 @@



- protected static XmlDbStorageManager getStorageManager(String type)
- throws SystemException {
-
- XmlDbDataRepository dataRepository =
- ExistDbFactory.getDataRepositoryByProperties(
- type,
- "service.ls.db_uri",
- "service.ls.db_username",
- "service.ls.db_password");
-
- XmlDbStorageManager storageManager =
- ExistDbFactory.getXMLStorageManager(
- type, dataRepository);
- storageManager.setResultType(
- XmlDbStorageManager.XML_DB_RESULT_TYPE);
-
-
- return storageManager;
-
+ protected static XmlDbStorageManager getStorageManager(String type)
throws SystemException
+ {
+ if (SERVICE_DATABASE_TYPE == "eXist")
+ {
+ XmlDbDataRepository dataRepository =
+ ExistDbFactory.getDataRepositoryByProperties(
+ type,
+ "service.ls.db_uri",
+ "service.ls.db_username",
+ "service.ls.db_password");
+
+ XmlDbStorageManager storageManager =
+ ExistDbFactory.getXMLStorageManager(
+ type, dataRepository);
+ storageManager.setResultType(
+ XmlDbStorageManager.XML_DB_RESULT_TYPE);
+
+ return storageManager;
+ }
+ else if (SERVICE_DATABASE_TYPE == "BDB")
+ {
+ XmlDbStorageManager storageManager = new
BerkeleyDbXmlStorageManager();
+
storageManager.setResultType(XmlDbStorageManager.XML_DB_RESULT_TYPE);
+
+ return storageManager;
+ }
+
+ return null;
}





  • r1691 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType, svnlog, 10/18/2006

Archive powered by MHonArc 2.6.16.

Top of Page