perfsonar-dev - r1733 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType
Subject: perfsonar development work
List archive
r1733 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType
Chronological Thread
- From:
- To:
- Subject: r1733 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType
- Date: Wed, 1 Nov 2006 11:04:43 -0500
Author: zurawski
Date: 2006-11-01 11:04:42 -0500 (Wed, 01 Nov 2006)
New Revision: 1733
Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.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/LSLookupAction.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:
Modifications to allow for rest/xmlrp exist in conjunction with bdb.
-jason
Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.java
2006-10-31 14:39:10 UTC (rev 1732)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.java
2006-11-01 16:04:42 UTC (rev 1733)
@@ -10,6 +10,7 @@
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;
+import
org.perfsonar.service.commons.storage.xmldb.exist.rest.ExistDbHttpXmlStorageManager;
/**
@@ -140,7 +141,8 @@
//removes data from THESE schemas (LSStore,
LSStore-control, LSCache)
- if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager)
{
String query = "";
@@ -204,7 +206,8 @@
String query;
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
query =
"declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; " +
@@ -238,7 +241,8 @@
String query;
String[] resArray;
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
query =
"declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; " +
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-31 14:39:10 UTC (rev 1732)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSDeregisterAction.java
2006-11-01 16:04:42 UTC (rev 1733)
@@ -8,6 +8,7 @@
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;
+import
org.perfsonar.service.commons.storage.xmldb.exist.rest.ExistDbHttpXmlStorageManager;
/**
@@ -73,7 +74,8 @@
//Query - get Data identifiers for given Key (all occurencies of Data
//having metadataIdRef = Key)
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; "+
"data(/nmwg:store/nmwg:data[@metadataIdRef='"+keyValue+"']/@id)";
@@ -106,7 +108,8 @@
if (countDataRemoved>0) {
//generate XQuery that removes data
- if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
String remove = "";
remove = XQUERY_UPDATE_DECLARE +
@@ -125,7 +128,8 @@
//Query - get metadata identifiers for Key (all occurencies of
Metadata
//having id = Key : should be 0 or 1 !)
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; "+
"data(/nmwg:store/nmwg:metadata[@id='"+keyValue+"']/@id)";
@@ -158,7 +162,8 @@
//generate XQuery that removes data
//removes data from ALL schemas (LSStore, LSStore-control,
LSCache, LSGlobalPeers, LSLocalPeers)
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager
||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
String remove2 = "";
remove2 = XQUERY_UPDATE_DECLARE +
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-31 14:39:10 UTC (rev 1732)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGenericRegisterAction.java
2006-11-01 16:04:42 UTC (rev 1733)
@@ -9,8 +9,8 @@
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;
+import
org.perfsonar.service.commons.storage.xmldb.exist.rest.ExistDbHttpXmlStorageManager;
-
/**
* Class that has commons methods for registration, updates, and keepalives
*
@@ -81,7 +81,8 @@
logger.debug("LSGenericRegisterAction: remove parameter ["+
parameterName+"] for key ["+key+"]");
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
remove = XQUERY_UPDATE_DECLARE +
"for $p in
/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
@@ -99,7 +100,8 @@
//check if metadata empty
String query;
XmlDbResult res;
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
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)";
@@ -122,7 +124,8 @@
logger.debug("LSGenericRegisterAction: metadata block for key
["+key
+"] remained empty, delete it");
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager
||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
remove = XQUERY_UPDATE_DECLARE +
"for $md in
/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
@@ -166,7 +169,8 @@
XmlDbResult res;
//check if there is control metadata for such key
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
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)";
@@ -187,7 +191,8 @@
if (resnum==0) {
logger.debug("LSGenericRegisterAction: setParameter: no control
metadata, put metadata+parameters");
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager
||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
insert = insert + " <nmwg:metadata id=\"" + key +
"\">\n" +
@@ -208,7 +213,8 @@
else {
//if there is the metadata, check if it has a parameters block
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager
||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
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)";
@@ -229,7 +235,8 @@
if (resnum==0) {
// put parameters
- if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
String insert = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_INSERT;
insert = insert + " <nmwg:parameters
id=\"control-parameters\" xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\">\n"
+
@@ -248,7 +255,8 @@
}
//check if there is parameter inside metadata
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
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+"']";
@@ -272,7 +280,8 @@
"] not found, " +
"insert new parameter ["+key+"]");
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager
||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
insert = insert + "<nmwg:parameter name=\"" +
parameterName + "\">" +
@@ -297,7 +306,8 @@
+parameterName+"] found," +
"update existing one");
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager
||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
String update = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_VALUE;
update = update +
"/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
@@ -320,28 +330,25 @@
* Checks if there is any metadata for given key (in LSStore,LSCache
schemas)
*/
protected boolean checkIfKeyIsRegistered(String key, StorageManager
xmlStorageManager) throws SystemException, RequestException,
DataFormatException {
-
try {
String query;
- XmlDbResult res;
-
- if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager)
- {
+ XmlDbResult res;
+ if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
query =
"declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; " +
"data(/nmwg:store[@type='"+
LS_STORE_COLLECTION_TYPE + "' or @type='" +
LS_CACHE_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"+key+"']/@id)";
res = (XmlDbResult)xmlStorageManager.fetch(query);
}
- else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
- {
+ else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; " +
"data(collection(\""+LS_STORE_CONTAINER+"\")/nmwg:metadata[@id=\""+key+"\"]/@id)";
res = (XmlDbResult)xmlStorageManager.fetch(query);
}
- else
+ else {
throw new
SystemException("error.common.storage.xmldb.query", "No database exists");
-
+ }
int resnum = res.getCount();
if (resnum>0)
Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLookupAction.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLookupAction.java
2006-10-31 14:39:10 UTC (rev 1732)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLookupAction.java
2006-11-01 16:04:42 UTC (rev 1733)
@@ -9,6 +9,7 @@
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;
+import
org.perfsonar.service.commons.storage.xmldb.exist.rest.ExistDbHttpXmlStorageManager;
/**
* LOOKUP Action
@@ -145,7 +146,8 @@
/* XQuery */
XmlDbResult edbres;
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
edbres = (XmlDbResult)xmlStorageManager.fetch(query);
results = (String[])edbres.getResultAsStringArray();
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-31 14:39:10 UTC (rev 1732)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSRegisterAction.java
2006-11-01 16:04:42 UTC (rev 1733)
@@ -11,6 +11,7 @@
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;
+import
org.perfsonar.service.commons.storage.xmldb.exist.rest.ExistDbHttpXmlStorageManager;
/**
@@ -148,6 +149,8 @@
}
}
+
+logger.debug("LSRegisterAction: 1");
// check keyValue again, it may be accessPoint now
if(keyValue==null) {
@@ -157,6 +160,8 @@
throw new SystemException("error.ls.no_key", m);
}
+
+logger.debug("LSRegisterAction: 2");
//========check data========
@@ -165,6 +170,8 @@
//won't be thrown!)
Collection reqDataArr = request.getDataMap().values();
+logger.debug("LSRegisterAction: 3");
+
//if there is no data! -- to be discussed
//there should be at least ONE trigger -- to be discussed
if(reqDataArr.size() < 1) {
@@ -174,148 +181,147 @@
throw new SystemException("error.ls.no_data_trigger", m);
}
+logger.debug("LSRegisterAction: 4");
-
-
-//// update peer list (local vs global check) ...
-// if(summaryParam != null) {
-// logger.debug("LSRegisterAction: LS register - we need to update
the '" +
-// summaryParam.getParameterValue() + "' peers list
...");
-// org.ggf.ns.nmwg.base.v2_0.Parameter sumParam = null;
-// if(request.getParameters() != null) {
-// sumParam =
request.getParameters().getParameterByName("summary");
-// if(sumParam != null) {
-// if(sumParam.getParameterValue().equals("local")) {
-// lsTokenUtil.addToPeerList(xmlStorageManager,
requestMetadata, "local");
-// }
-// else if(sumParam.getParameterValue().equals("global")) {
-// lsTokenUtil.addToPeerList(xmlStorageManager,
requestMetadata, "global");
-//
-//
-// //we need to 'back up' the stuff from global guys
-//
-// //get the contents of LSLocalPeers
-// String query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE + "']";
-// String[] results = lsUtil.getDBContents(xmlStorageManager,
query);
-//
-// if(results[0].equals("")) {
-// String m = "LSLocalTokenAction: " +
-// "Peer List is empty; please populate it with at
least one peer.";
-// logger.error(m);
-// throw new SystemException("error.ls.peer_list_empty", m);
-// }
-//
-// Store result = (Store)XMLUtils.stringToElement(results[0],
lsUtil.getParserFile(), "store");
-//
-// Collection metadataCol = null;
-// metadataCol = result.getMetadataMap().values();
-// if(metadataCol.size() < 1) {
-// String m = "LSLocalTokenAction: " +
-// "Peer List is empty; please populate it with at
least one peer.";
-// logger.error(m);
-// throw new SystemException("error.ls.peer_list_empty", m);
-// }
-// String[][] sortedList = null;
-// sortedList = lsTokenUtil.formPeerArray(metadataCol);
-//
-// //create a 'special' global summary message (one that
won't be
-// // propagated by the other peers
-//
-// //setup the parameters for the message (indicating it is a
summary)
-// org.ggf.ns.nmwg.base.v2_0.Parameters reqParams = new
org.ggf.ns.nmwg.base.v2_0.Parameters();
-// reqParams = lsUtil.createSummaryParameters(reqParams,
"summary", "global-backup");
-//
-// //put them in a message, then insert
-// org.ggf.ns.nmwg.base.v2_0.Message registerMessage = new
Message();
-// registerMessage.setType("LSRegisterRequest");
-// registerMessage.addChild(requestMetadata);
-// Iterator reqDataArrIterator = reqDataArr.iterator();
-// while (reqDataArrIterator.hasNext()) {
-// registerMessage.addChild((Data)reqDataArrIterator.next());
-// }
-// registerMessage.addChild(reqParams);
-//
-//
-// //now try to send the message to people
-// int counter = 0;
-// for(int b = 0; b < metadataCol.size(); b++) {
-//
-// logger.debug("LSRegisterAction: Sending message to: " +
sortedList[b][0] + " - " + sortedList[b][1]);
-// try {
-// org.ggf.ns.nmwg.base.v2_0.Message response =
lsTokenUtil.sendRequest(sortedList[b][0], registerMessage);
-// if(response != null) {
-// //check to see if we succeeded:
-//
-// org.ggf.ns.nmwg.base.v2_0.Metadata
requestMetadata2[] = response.getMetadataArray();
-// if(requestMetadata2.length > 0){
-//
-// logger.debug("LSRegisterAction: response: " +
requestMetadata2[0].toString());
-//
if((requestMetadata2[0].getEventType().getEventType()).equals("result.success"))
{
-// if(Integer.parseInt(sortedList[b][1]) < 3) {
-// //update the peers list
-// String update = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_VALUE;
-//
-// update = update +
"/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE +
-//
"']//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
-//
"[@name='familiar']
with '" + (int)((Integer.parseInt(sortedList[b][1]))+1) + "'";
-//
-// xmlStorageManager.fetch(update);
-// sortedList[b][1] =
Integer.toString(Integer.parseInt(sortedList[b][1]) + 1);
-// counter++;
-// }
-// }
-// else {
-// logger.debug("LSRegisterAction: Success Code from
peer not found");
-// }
-// }
-// else {
-// logger.debug("LSRegisterAction: No metadata in peer
response");
-// }
-// }
-// else {
-// logger.debug("LSRegisterAction: Null response when
talking to peer");
-// if(Integer.parseInt(sortedList[b][1]) > 0) {
-// //update the peers list
-// String update = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_VALUE;
-//
-// update = update +
"/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE +
-//
"']//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
-//
"[@name='familiar']
with '" + (int)(Integer.parseInt(sortedList[b][1])-1) + "'";
-//
-// xmlStorageManager.fetch(update);
-// sortedList[b][1] =
Integer.toString(Integer.parseInt(sortedList[b][1])-1);
-// }
-// }
-// }
-// catch(Exception e) {
-// logger.debug("LSRegisterAction: Exception: " +
e.toString());
-// throw new SystemException("error.ls.client_error",
-// "Error sending to client LS " +
-// e.getMessage());
-// }
-// if(counter >= 2) {
-// b = metadataCol.size() + 1;
-// }
-// }
-//
-//
-//
-//
-//
-// }
-// else
if(sumParam.getParameterValue().equals("global-backup")) {
-// lsTokenUtil.addToPeerList(xmlStorageManager,
requestMetadata, "global");
-// }
-// }
-// }
-// }
+// update peer list (local vs global check) ...
+ if(summaryParam != null) {
+ logger.debug("LSRegisterAction: LS register - we need to update
the '" +
+ summaryParam.getParameterValue() + "' peers list
...");
+ org.ggf.ns.nmwg.base.v2_0.Parameter sumParam = null;
+ if(request.getParameters() != null) {
+ sumParam = request.getParameters().getParameterByName("summary");
+ if(sumParam != null) {
+ if(sumParam.getParameterValue().equals("local")) {
+ lsTokenUtil.addToPeerList(xmlStorageManager,
requestMetadata, "local");
+ }
+ else if(sumParam.getParameterValue().equals("global")) {
+ lsTokenUtil.addToPeerList(xmlStorageManager,
requestMetadata, "global");
+
+ //we need to 'back up' the stuff from global guys
+ //get the contents of LSLocalPeers
+ String query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE + "']";
+ String[] results = lsUtil.getDBContents(xmlStorageManager,
query);
+
+ if(results[0].equals("")) {
+ String m = "LSLocalTokenAction: " +
+ "Peer List is empty; please populate it with at
least one peer.";
+ logger.error(m);
+ throw new SystemException("error.ls.peer_list_empty", m);
+ }
+
+ Store result = (Store)XMLUtils.stringToElement(results[0],
lsUtil.getParserFile(), "store");
+
+ Collection metadataCol = null;
+ metadataCol = result.getMetadataMap().values();
+ if(metadataCol.size() < 1) {
+ String m = "LSLocalTokenAction: " +
+ "Peer List is empty; please populate it with at
least one peer.";
+ logger.error(m);
+ throw new SystemException("error.ls.peer_list_empty", m);
+ }
+ String[][] sortedList = null;
+ sortedList = lsTokenUtil.formPeerArray(metadataCol);
+
+ //create a 'special' global summary message (one that won't
be
+ // propagated by the other peers
+
+ //setup the parameters for the message (indicating it is a
summary)
+ org.ggf.ns.nmwg.base.v2_0.Parameters reqParams = new
org.ggf.ns.nmwg.base.v2_0.Parameters();
+ reqParams = lsUtil.createSummaryParameters(reqParams,
"summary", "global-backup");
+
+ //put them in a message, then insert
+ org.ggf.ns.nmwg.base.v2_0.Message registerMessage = new
Message();
+ registerMessage.setType("LSRegisterRequest");
+ registerMessage.addChild(requestMetadata);
+ Iterator reqDataArrIterator = reqDataArr.iterator();
+ while (reqDataArrIterator.hasNext()) {
+ registerMessage.addChild((Data)reqDataArrIterator.next());
+ }
+ registerMessage.addChild(reqParams);
+
+
+ //now try to send the message to people
+ int counter = 0;
+ for(int b = 0; b < metadataCol.size(); b++) {
+
+ logger.debug("LSRegisterAction: Sending message to: " +
sortedList[b][0] + " - " + sortedList[b][1]);
+ try {
+ org.ggf.ns.nmwg.base.v2_0.Message response =
lsTokenUtil.sendRequest(sortedList[b][0], registerMessage);
+ if(response != null) {
+ //check to see if we succeeded:
+
+ org.ggf.ns.nmwg.base.v2_0.Metadata requestMetadata2[]
= response.getMetadataArray();
+ if(requestMetadata2.length > 0){
+
+ logger.debug("LSRegisterAction: response: " +
requestMetadata2[0].toString());
+
if((requestMetadata2[0].getEventType().getEventType()).equals("result.success"))
{
+ if(Integer.parseInt(sortedList[b][1]) < 3) {
+ //update the peers list
+ String update = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_VALUE;
+
+ update = update +
"/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE +
+
"']//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
+
"[@name='familiar']
with '" + (int)((Integer.parseInt(sortedList[b][1]))+1) + "'";
+
+ xmlStorageManager.fetch(update);
+ sortedList[b][1] =
Integer.toString(Integer.parseInt(sortedList[b][1]) + 1);
+ counter++;
+ }
+ }
+ else {
+ logger.debug("LSRegisterAction: Success Code from
peer not found");
+ }
+ }
+ else {
+ logger.debug("LSRegisterAction: No metadata in peer
response");
+ }
+ }
+ else {
+ logger.debug("LSRegisterAction: Null response when
talking to peer");
+ if(Integer.parseInt(sortedList[b][1]) > 0) {
+ //update the peers list
+ String update = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_VALUE;
+
+ update = update +
"/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE +
+
"']//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
+
"[@name='familiar']
with '" + (int)(Integer.parseInt(sortedList[b][1])-1) + "'";
+
+ xmlStorageManager.fetch(update);
+ sortedList[b][1] =
Integer.toString(Integer.parseInt(sortedList[b][1])-1);
+ }
+ }
+ }
+ catch(Exception e) {
+ logger.debug("LSRegisterAction: Exception: " +
e.toString());
+ throw new SystemException("error.ls.client_error",
+ "Error sending to client LS " +
+ e.getMessage());
+ }
+ if(counter >= 2) {
+ b = metadataCol.size() + 1;
+ }
+ }
+
+
+
+
+
+ }
+ else if(sumParam.getParameterValue().equals("global-backup")) {
+ lsTokenUtil.addToPeerList(xmlStorageManager,
requestMetadata, "global");
+ }
+ }
+ }
+ }
+
+
+logger.debug("LSRegisterAction: 5");
-
//=========process with register/update===========
@@ -326,8 +332,11 @@
//if so, check if you're allowed to update data (to remove them)
//throw exception if you're not allowed
+logger.debug("LSRegisterAction: 6");
+
if(checkIfKeyIsRegistered(keyValue,xmlStorageManager)) {
+logger.debug("LSRegisterAction: 7");
logger.debug("LSRegisterAction: Key is already " +
"registered in DB (metadata), allow_update="+
@@ -337,7 +346,8 @@
logger.debug("LSRegisterAction: old data will be replaced by
new set of data");
- if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
String remove = XQUERY_UPDATE_DECLARE +
"for $md in
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE +
@@ -395,7 +405,8 @@
requestMetadata.setId(accessPoint);
//make sure we update the store vs the cache
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
@@ -447,7 +458,8 @@
//fill updateData structure
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager
||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
//make sure we update the store vs the cache
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-31 14:39:10 UTC (rev 1732)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
2006-11-01 16:04:42 UTC (rev 1733)
@@ -38,8 +38,10 @@
/**
* Service database type: "eXist or BDB"
*/
- private static final String SERVICE_DATABASE_TYPE = "BDB";
+// private static final String SERVICE_DATABASE_TYPE = "BDB";
+ private static final String SERVICE_DATABASE_TYPE = "eXist";
+
/**
* Service engine type
*/
- r1733 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType, svnlog, 11/01/2006
Archive powered by MHonArc 2.6.16.