Skip to Content.
Sympa Menu

perfsonar-dev - r1751 - in branches/yi-udel/perfsonar/src/org/perfsonar: commons/auxiliary/components/simplescheduler commons/util service/commons/storage/xmldb/bdbxml service/lookupService/xmlType

Subject: perfsonar development work

List archive

r1751 - in branches/yi-udel/perfsonar/src/org/perfsonar: commons/auxiliary/components/simplescheduler commons/util service/commons/storage/xmldb/bdbxml service/lookupService/xmlType


Chronological Thread 
  • From:
  • To:
  • Subject: r1751 - in branches/yi-udel/perfsonar/src/org/perfsonar: commons/auxiliary/components/simplescheduler commons/util service/commons/storage/xmldb/bdbxml service/lookupService/xmlType
  • Date: Mon, 13 Nov 2006 02:58:30 -0500

Author: zurawski
Date: 2006-11-13 02:58:28 -0500 (Mon, 13 Nov 2006)
New Revision: 1751

Modified:

branches/yi-udel/perfsonar/src/org/perfsonar/commons/auxiliary/components/simplescheduler/Scheduler.java
branches/yi-udel/perfsonar/src/org/perfsonar/commons/util/XMLUtils.java

branches/yi-udel/perfsonar/src/org/perfsonar/service/commons/storage/xmldb/bdbxml/BerkeleyDbXmlStorageManager.java

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

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

branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanupLoader.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/LSGlobalTokenAction.java

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

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

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

branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLocalTokenLoader.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/LSSummary.java

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

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

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

branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
Log:
Berkeley DB api updates, various code cleanup and doc steps.

-jason



Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/commons/auxiliary/components/simplescheduler/Scheduler.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/commons/auxiliary/components/simplescheduler/Scheduler.java
2006-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/commons/auxiliary/components/simplescheduler/Scheduler.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -21,6 +21,7 @@
* This class provides the capability to run an action each N seconds
*
* @author Maciej Glowiak
+ * @author Jason Zurawski
*
*/
public class Scheduler extends Thread implements AuxiliaryComponent {

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/commons/util/XMLUtils.java
===================================================================
--- branches/yi-udel/perfsonar/src/org/perfsonar/commons/util/XMLUtils.java
2006-11-09 12:48:39 UTC (rev 1750)
+++ branches/yi-udel/perfsonar/src/org/perfsonar/commons/util/XMLUtils.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -47,6 +47,7 @@
*
* @author Maciej Glowiak
* @author romradz (contributor)
+ * @author Jason Zurawski (contributor)
*
*/
public class XMLUtils {
@@ -293,9 +294,16 @@
}


+
+ /**
+ * Given a string of XML, convert to the proper XML element
+ * object. We return this as a generic 'element' which we
+ * can cast later.
+ */
+
public static Element stringToElement(String elementString,
- String parserFile,
- String element) {
+ String parserFile,
+ String element) {

String DEFAULT_PARSER_NAME = "org.apache.xerces.parsers.SAXParser";
String NAMESPACES_FEATURE_ID =
"http://xml.org/sax/features/namespaces";;

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/commons/storage/xmldb/bdbxml/BerkeleyDbXmlStorageManager.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/commons/storage/xmldb/bdbxml/BerkeleyDbXmlStorageManager.java
2006-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/commons/storage/xmldb/bdbxml/BerkeleyDbXmlStorageManager.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -64,7 +64,8 @@
final static boolean DEBUG = false;

// default Berkeley database environment path
- final static String XML_DB_HOME = "/home/gabyfox/xmldb";
+// final static String XML_DB_HOME = "/home/gabyfox/xmldb";
+ final static String XML_DB_HOME = "/home/jason/xmldb";

//------------------------------------------------------------------------

private Environment myEnv;

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-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSAction.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -1,6 +1,5 @@
package org.perfsonar.service.lookupService.xmlType;

-
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
@@ -12,10 +11,12 @@
import org.ggf.ns.nmwg.base.v2_0.Message;
import org.ggf.ns.nmwg.base.v2_0.Metadata;
import org.ggf.ns.nmwg.base.v2_0.Parameter;
+
import org.perfsonar.commons.auxiliary.AuxiliaryComponentManager;
import org.perfsonar.commons.auxiliary.ComponentNames;
import
org.perfsonar.commons.auxiliary.components.configuration.ConfigurationComponent;
import org.perfsonar.commons.auxiliary.components.logger.LoggerComponent;
+
import org.perfsonar.service.commons.exceptions.DataFormatException;
import org.perfsonar.service.commons.exceptions.RequestException;
import org.perfsonar.service.commons.exceptions.SystemException;
@@ -25,14 +26,17 @@
* Generic class for all LS actions performed by XmlTypeLSServiceEngine
*
* @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/
public abstract class LSAction {

+
// --------------------------------------------------------------
Constants

/**
- * The name of the store collection (containing LS data/metadata
+ * The name of the store collection (containing LS data/metadata)
*/
protected static final String LS_STORE_COLLECTION_TYPE = "LSStore";

@@ -41,43 +45,68 @@
* The name of the cache collection (containing summarized LS
data/metadata)
*/
protected static final String LS_CACHE_COLLECTION_TYPE = "LSCache";
-
-
+
+
/**
* The name of the control collection of LS
*/
protected static final String LS_STORE_CONTROL_COLLECTION_TYPE =
"LSStore-control";

+
/**
- * BDB container
+ * The name of the local list of peers
*/
+ protected static final String LS_LOCAL_PEER_COLLECTION_TYPE =
"LSLocalPeers";
+
+
+ /**
+ * The name of the global list of peers
+ */
+ protected static final String LS_GLOBAL_PEER_COLLECTION_TYPE =
"LSGlobalPeers";
+
+
+ /**
+ * BDB container (the same as LSStore)
+ */
public final static String LS_STORE_CONTAINER = LS_STORE_COLLECTION_TYPE
+ ".dbxml";
+
+
+ /**
+ * BDB container (the same as LSCache)
+ */
+ public final static String LS_CACHE_CONTAINER = LS_CACHE_COLLECTION_TYPE
+ ".dbxml";
+
+
+ /**
+ * BDB container (the same as LSStore-control)
+ */
public final static String LS_STORE_CONTROL_CONTAINER =
LS_STORE_CONTROL_COLLECTION_TYPE + ".dbxml";

+
/**
- * The name of the cache collection (containing summarized LS
data/metadata)
+ * BDB container (the same as LSLocalPeers)
*/
- protected static final String LS_LOCAL_PEER_COLLECTION_TYPE =
"LSLocalPeers";
-
-
+ public final static String LS_LOCAL_PEER_CONTAINER =
LS_LOCAL_PEER_COLLECTION_TYPE + ".dbxml";
+
+
/**
- * The name of the cache collection (containing summarized LS
data/metadata)
+ * BDB container (the same as LSGlobalPeers)
*/
- protected static final String LS_GLOBAL_PEER_COLLECTION_TYPE =
"LSGlobalPeers";
+ public final static String LS_GLOBAL_PEER_CONTAINER =
LS_GLOBAL_PEER_COLLECTION_TYPE + ".dbxml";

-
+
/**
* LS Key name
*/
protected static final String LS_KEY = "lsKey";

+
/**
* Header for all XUpdates used in LS modifications
- */
-
-/*
-do we still need this with no XUpdate?
-*/
+ *
+ * XXX - jason do we still need this with no XUpdate?
+ *
+ */
protected static final String XUPDATE_HEADER =
"<xu:modifications version=\'1.0\'" +
" xmlns:xu=\'http://www.xmldb.org/xupdate\'" +
@@ -88,14 +117,16 @@
"
xmlns:netutil='http://ggf.org/ns/nmwg/characteristic/utilization/2.0/'" +
">\n";

+
/**
* Footer for all XUpdates used in LS register
- */
-/*
-do we still need this with no XUpdate?
-*/
+ *
+ * XXX - jason do we still need this with no XUpdate?
+ *
+ */
protected static final String XUPDATE_FOOTER = "</xu:modifications>";

+
/**
* Header for all XQuery used in LS modifications
*/
@@ -107,6 +138,8 @@
protected static final String XQUERY_UPDATE_DELETE = "update delete ";
protected static final String XQUERY_UPDATE_RENAME = "update rename ";


+
+
// ----------------------------------------------------- Instance
variables

/**
@@ -127,9 +160,9 @@
protected ConfigurationComponent configuration;


+
// ------------------------------------------------------------
Constructor

-
public LSAction(StorageManager xmlStorageManager) throws SystemException
{

this.xmlStorageManager = xmlStorageManager;
@@ -138,29 +171,24 @@
getInstance().getComponent(ComponentNames.LOGGER);

configuration = (ConfigurationComponent)AuxiliaryComponentManager.
- getInstance().getComponent(ComponentNames.CONFIG);
-
+ getInstance().getComponent(ComponentNames.CONFIG);
}


+
// ------------------------------------------------------ Protected
methods
-
-
+
/**
* Extracts first Metadata from Request
* @param request
* @return Metadata
*/
- protected Metadata getMetadataFromRequest(
- Message request) {
-
- //Get Metadata
-
+ protected Metadata getMetadataFromRequest(Message request) {
Metadata requestMetadata[] = request.getMetadataArray();
- if(requestMetadata.length > 0){
+ if(requestMetadata.length > 0) {
return requestMetadata[0];
}
- else{
+ else {
return null;
}
}
@@ -172,59 +200,55 @@
* @param keyId Key identifier
* @return Key value
*/
- protected String getKeyFromMetadata(
- Metadata requestMetadata, String keyId) {
-
- //get Key
-
- Key key = requestMetadata.getKey();
-
+ protected String getKeyFromMetadata(Metadata requestMetadata,
+ String keyId) {
+ Key key = requestMetadata.getKey();
String keyValue = null;

//check if there is a Key
- if (key!=null) try {
-
- //iterate parameters
- if (key.getParameters()!=null) {
+ if(key != null) {
+ try {
+ //iterate parameters
+ if(key.getParameters() != null) {

- Map params = key.getParameters().getParameterMap();
- Collection collect = params.values();
+ Map params = key.getParameters().getParameterMap();
+ Collection collect = params.values();

- for(Iterator i = collect.iterator(); i.hasNext(); ){
+ for(Iterator i = collect.iterator(); i.hasNext();) {

- try {
-
- Parameter parameter = (Parameter)i.next();
+ try {
+ Parameter parameter = (Parameter)i.next();

- String parameterName = parameter.getParameterName();
- String parameterValue =
parameter.getParameterValue();
+ String parameterName =
parameter.getParameterName();
+ String parameterValue =
parameter.getParameterValue();

- //parse parameters
- if (parameterName.equals(keyId)) {
- keyValue = parameterValue;
- } //else if (parameterName.equals(...)) {...}
+ //parse parameters
+ if(parameterName.equals(keyId)) {
+ keyValue = parameterValue;
+ }
+ //else if (parameterName.equals(...)) {...}

- //print all parameters read
- //logger.debug("XmlTypeLSServiceEngine:
key-parameter: ["+
- // parameterName + "] =
["+parameterValue+"]");
+ //print all parameters read
+ //logger.debug("XmlTypeLSServiceEngine:
key-parameter: ["+
+ // parameterName + "] =
["+parameterValue+"]");

- //don't finish parsing, there may still be other
- //parameters
+ //don't finish parsing, there may still be other
+ //parameters

- }catch (RuntimeException ex) {
- logger.warn("XmlTypeLSServiceEngine: error while " +
- "parsing parameters from Key");
+ }
+ catch(RuntimeException ex) {
+ logger.warn("XmlTypeLSServiceEngine: error while
" +
+ "parsing parameters from Key");
+ }
}
- }
+ }
+ }
+ catch(RuntimeException npex) {
+ logger.warn("XmlTypeLSServiceEngine: error while getting " +
+ "parameters from Key");
}
-
- } catch (RuntimeException npex) {
- logger.warn("XmlTypeLSServiceEngine: error while getting " +
- "parameters from Key");
- }
-
- return keyValue;
-
+ }
+ return keyValue;
}


@@ -236,8 +260,8 @@
* if null value, Data won't be created
* @return ResultCode (Metadata+Data)
*/
- protected ResultCode createResultCode(String resultCode, String details)
{
-
+ protected ResultCode createResultCode(String resultCode,
+ String details) {
ResultCode res = new ResultCode();
Metadata metadata = new Metadata();
metadata.setId("resultCodeMetadata");
@@ -248,41 +272,36 @@

res.setMetadata(metadata);

- if (details!=null) {
-
- Data data = new Data();
-
+ if(details != null) {
+ Data data = new Data();
Datum datum = new Datum();

data.setId("resultCodeData");
data.setMetadataIdRef("resultCodeMetadata");
datum.setValue(details);
- data.setDatum(datum);
-
- res.setData(data);
-
+ data.setDatum(datum);
+ res.setData(data);
}
return res;
}
+
+

// ----------------------------------------------- Abstract methods
+
+ public abstract Message performAction(Message request)
+ throws SystemException, RequestException, DataFormatException;


- public abstract Message performAction(
- Message request)
- throws SystemException, RequestException, DataFormatException;

-
// ---------------------------------------------------------- Inner
classes

-
/**
* Result code, contains Metadata and Data blocks
* @author Maciej Glowiak
*
*/
- protected class ResultCode {
-
+ protected class ResultCode {
private Metadata metadata;
private Data data;

@@ -300,9 +319,12 @@

public void setMetadata(Metadata metadata) {
this.metadata = metadata;
- }
+ }
+
+

} //ResultCode


+
} //LSAction

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-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -1,21 +1,25 @@
package org.perfsonar.service.lookupService.xmlType;

import org.ggf.ns.nmwg.base.v2_0.Message;
+
import
org.perfsonar.commons.auxiliary.components.simplescheduler.SchedulerAction;
+
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.bdbxml.BerkeleyDbXmlStorageManager;
import
org.perfsonar.service.commons.storage.xmldb.exist.xmlrpc.ExistDbXmlrpcXmlStorageManager;
import
org.perfsonar.service.commons.storage.xmldb.exist.rest.ExistDbHttpXmlStorageManager;

-
/**
* Action that removes all obsolete lookup information
* @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/
public class LSCleanup extends LSAction implements SchedulerAction {
@@ -28,76 +32,81 @@
*/
public static final long DEFAULT_LS_TTL = 60; //seconds

+
/**
* name of property in config file
*/
private static final String LS_TTL_PROPERTY = "service.ls.ttl";
-
+
+
+
// -------------------------------------------- Instance variables

/**
* Value of LS TTL in seconds
*/
long lsTTL = DEFAULT_LS_TTL; //in seconds
+

/**
* number of iteration (for debugging)
*/
long iterations = 0;
+


// --------------------------------------------------- Constructor
-
-
+
/**
* LSCleanup constructor
*/
- public LSCleanup(StorageManager xmlStorageManager)
- throws SystemException {
-
+ public LSCleanup(StorageManager xmlStorageManager) throws
SystemException {
super(xmlStorageManager);

//read service.ls.lookup_info_timeout
String prop = null;
try {
prop = configuration.getProperty(LS_TTL_PROPERTY);
- } catch (SystemException sex) {
- prop=null;
+ }
+ catch(SystemException sex) {
+ prop = null;
}

- if (prop!=null) {
+ if(prop != null) {
try {
lsTTL = Long.parseLong(prop);
- } catch (Exception ex) {
+ }
+ catch(Exception ex) {
logger.debug("LSRegisterAction: LS TTL=default");
lsTTL = DEFAULT_LS_TTL;
}
- } else {
+ }
+ else {
logger.debug("LSRegisterAction: LS TTL=default");
lsTTL = DEFAULT_LS_TTL;
}
- logger.debug("LSRegisterAction: LS TTL="+lsTTL+" seconds");
-
+ logger.debug("LSRegisterAction: LS TTL= "+ lsTTL + " seconds");

}

+
/**
* Scheduler Action for LS Cleanup
*/
public Message performAction(Message request)
throws SystemException, RequestException, DataFormatException {

- //input parameter request - unimportant
-
-
+ //input parameter request - unimportant
long now = System.currentTimeMillis(); // current timestamp

//process all keys from Database
String[] keys = getMetadataKeys(xmlStorageManager);

//for each of them check timestamp parameter
- for (int i=0; i<keys.length; i++) {
- if ("".equals(keys[i])) break;
-
+ for(int i=0; i<keys.length; i++) {
+ if("".equals(keys[i])) {
+ break;
+ }
+
logger.debug("LSCleanup: checking key ["+keys[i]+"]");

String timestampStr = getControlParameter(
@@ -108,29 +117,30 @@
long uptime = 0;

//convert timestamp into long "uptime"
- if (timestampStr != null) {
+ if(timestampStr != null) {
try {
uptime = Long.parseLong(timestampStr);
- } catch (NumberFormatException ex) {
+ }
+ catch(NumberFormatException ex) {
logger.debug("LSCleanup: timestamp parameter for key
["+keys[i]+"] value=["+
timestampStr+"] is not a number, omitting!");
}
}

- if (uptime==0) {
+ if(uptime == 0) {
logger.debug("LSCleanup: omitting key ["+keys[i]+"],
timestamp=0 or no timestamp parameter");

//TODO: what to do?
- //do nothing...
-
- } else {
+ //do nothing...
+ }
+ else {
long ttlsec = (uptime - now + getLsTTLInMillis())/1000;
logger.debug("LSCleanup: Checking if time is exceeded for
key ["+keys[i]+"]: TTL=["+
((ttlsec<0)
?"exceeded from "+(-1*ttlsec)
:"valid for "+ttlsec)+" seconds]");

- if ( (uptime + getLsTTLInMillis() - now ) < 0) {
+ if((uptime + getLsTTLInMillis() - now ) < 0) {

logger.info("LSCleanup: Time exceeded - " +
"REMOVING metadata for key ["+
@@ -140,38 +150,34 @@
//generate XQuery that removes data
//removes data from THESE schemas (LSStore,
LSStore-control, LSCache)

-
- if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
- xmlStorageManager instanceof
ExistDbHttpXmlStorageManager)
- {
-
- String query = "";
- query = XQUERY_UPDATE_DECLARE +
- "for $md in
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE + "' or @type='" +
- LS_CACHE_COLLECTION_TYPE + "' or @type='" +
LS_STORE_CONTROL_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ keys[i] + "'] return " +
- XQUERY_UPDATE_DELETE + "$md";
-
- xmlStorageManager.fetch(query); //XQuery

+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ String query = "";
+ query = XQUERY_UPDATE_DECLARE +
+ "for $md in
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE + "' or @type='" +
+ LS_CACHE_COLLECTION_TYPE + "' or @type='" +
LS_STORE_CONTROL_COLLECTION_TYPE +
+
"']/nmwg:metadata[@id='"
+ keys[i] + "'] return " +
+ XQUERY_UPDATE_DELETE + "$md";

+ xmlStorageManager.fetch(query); //XQuery


- query = "";
- query = XQUERY_UPDATE_DECLARE +
- "for $d in
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE + "' or @type='" +
- LS_CACHE_COLLECTION_TYPE + "' or @type='" +
LS_STORE_CONTROL_COLLECTION_TYPE +
-
"']/nmwg:data[@metadataIdRef='"
+ keys[i] + "'] return " +
- XQUERY_UPDATE_DELETE + "$d";
- xmlStorageManager.fetch(query); //XQuery
-
- }
- else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
- {
- String xPath =
"/nmwg:metadata[@id=\""
+ keys[i] +"\"]";
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_STORE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
- xPath =
"/nmwg:data[@metadataIdRef=\""
+ keys[i] +"\"]";
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_STORE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
- }
+ query = "";
+ query = XQUERY_UPDATE_DECLARE +
+ "for $d in
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE + "' or @type='" +
+ LS_CACHE_COLLECTION_TYPE + "' or @type='" +
LS_STORE_CONTROL_COLLECTION_TYPE +
+
"']/nmwg:data[@metadataIdRef='"
+ keys[i] + "'] return " +
+ XQUERY_UPDATE_DELETE + "$d";
+ xmlStorageManager.fetch(query); //XQuery
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath =
"/nmwg:metadata[@id=\""
+ keys[i] +"\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_STORE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_CACHE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+ xPath =
"/nmwg:data[@metadataIdRef=\""
+ keys[i] +"\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_STORE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_CACHE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+ }

} //if

@@ -180,7 +186,6 @@
} //for

return null; //result unimportant
-
}


@@ -191,9 +196,7 @@
* get LS TTL in milliseconds
*/
private long getLsTTLInMillis() {
-
return lsTTL * 1000; //because lsTTP is in seconds
-
}


@@ -203,91 +206,91 @@
protected String[] getMetadataKeys(StorageManager xmlStorageManager)
throws SystemException, RequestException, DataFormatException {

-
String query;
+ 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)";
+ XmlDbResult edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ String[] res = (String[])edbres.getResultAsStringArray();
+ return res;
+ }
+ 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)";
+ XmlDbResult edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ String[] res1 = (String[])edbres.getResultAsStringArray();
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+ "data(collection(\"" + LS_CACHE_CONTAINER +
"\")/nmwg:metadata/@id)";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ String[] res2 = (String[])edbres.getResultAsStringArray();

- 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)";
- XmlDbResult edbres =
(XmlDbResult)xmlStorageManager.fetch(query);
- String[] res = (String[])edbres.getResultAsStringArray();
- return res;
+ String[] res = new String[res1.length + res2.length];
+ System.arraycopy(res1, 0, res, 0, res1.length);
+ System.arraycopy(res2, 0, res, res1.length, res2.length);
+
+ return res;
}
- 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)";
- XmlDbResult edbres =
(XmlDbResult)xmlStorageManager.fetch(query);
- String[] res = (String[])edbres.getResultAsStringArray();
- return res;
- }
- else
- throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
+ else {
+ throw new SystemException("error.common.storage.xmldb.query", "No
database exists");
+ }
}


/**
* Get control parameter for given key
*/
- protected String getControlParameter(
- String key,
- String parameterName, StorageManager xmlStorageManager)
- throws SystemException, RequestException,
DataFormatException {
+ protected String getControlParameter(String key, String parameterName,
+ StorageManager xmlStorageManager) throws SystemException,
+ RequestException, DataFormatException {

String query;
String[] resArray;
-
- 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+"']/text()";
- XmlDbResult edbres =
(XmlDbResult)xmlStorageManager.fetch(query);
+
+ 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+"']/text()";
+ XmlDbResult edbres = (XmlDbResult)xmlStorageManager.fetch(query);
resArray = (String[])edbres.getResultAsStringArray();
}
- else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
- {
- query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
-
"collection(\""+LS_STORE_CONTROL_CONTAINER+"\")" +
-
"/nmwg:metadata[@id=\""+key+"\"]"
+
-
"/nmwg:parameters/nmwg:parameter[@name=\""+parameterName+"\"]/text()";
- XmlDbResult edbres =
(XmlDbResult)xmlStorageManager.fetch(query);
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+ "collection(\"" + LS_STORE_CONTROL_CONTAINER + "\")" +
+
"/nmwg:metadata[@id=\""
+ key + "\"]" +
"/nmwg:parameters/nmwg:parameter[@name=\""
+
+ parameterName + "\"]/text()";
+ XmlDbResult edbres = (XmlDbResult)xmlStorageManager.fetch(query);
resArray = (String[])edbres.getResultAsStringArray();
}
- else
- throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
-
+ else {
+ throw new SystemException("error.common.storage.xmldb.query", "No
database exists");
+ }

try {
String result = resArray[0];
return result.trim();
- } catch (Exception ex) {
+ }
+ catch(Exception ex) {
return null;
- }
-
+ }
}

-
- public void runAction() {
-
+ /**
+ * run action
+ */
+ public void runAction() {
iterations++;

logger.info("LSCleanup: Run as scheduled action for the ["+
iterations+"] time");
-
try {
performAction(null); //input unimportant
- } catch (PerfSONARException e) {
- }
-
+ }
+ catch(PerfSONARException e) {
+ }
}



Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanupLoader.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanupLoader.java
2006-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanupLoader.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -6,28 +6,30 @@
import
org.perfsonar.commons.auxiliary.components.configuration.ConfigurationComponent;
import org.perfsonar.commons.auxiliary.components.logger.LoggerComponent;
import org.perfsonar.commons.auxiliary.components.simplescheduler.Scheduler;
+
import org.perfsonar.service.commons.exceptions.SystemException;
import org.perfsonar.service.commons.storage.StorageManager;

-
/**
* Initializes component action in simple scheduler
* @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/
public class LSCleanupLoader implements AuxiliaryComponent {

+
// ----------------------------------------------------- constants
-
-
+
private static final int DEFAULT_RUN_INTERVAL = 30; //seconds

private static final int MINIMAL_RUN_INTERVAL = 10; //seconds

+

//---------------------------------------------- private variables
-
-
+
private String componentName = "ls_cleanup_loader";

private LoggerComponent logger;
@@ -39,17 +41,16 @@
private StorageManager storage;


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

-
- public void initComponent() throws SystemException {
-
- try {
-
+ public void initComponent() throws SystemException {
+ try {
logger = (LoggerComponent)AuxiliaryComponentManager.
getInstance().getComponent(ComponentNames.LOGGER);

- } catch (SystemException e) {
+ }
+ catch(SystemException e) {
String m = "Cannot get logger component ";
throw new SystemException("error.common.no_logger",m);

}
@@ -58,7 +59,8 @@
config = (ConfigurationComponent)
AuxiliaryComponentManager.getInstance().
getComponent(ComponentNames.CONFIG);
- } catch (SystemException e) {
+ }
+ catch(SystemException e) {
String m = "Cannot get config component ";
throw new SystemException("error.common.no_configuration", m);

}
@@ -71,9 +73,11 @@
String intervalVal = config.getProperty(
"component."+componentName+".interval");
interval = Integer.parseInt(intervalVal);
- } catch (RuntimeException e) {
+ }
+ catch(RuntimeException e) {
//possibly not an integer - keep default interval
- } catch (SystemException e) {
+ }
+ catch(SystemException e) {
//no property - keep default interval
}

@@ -95,12 +99,13 @@
AuxiliaryComponentManager.getInstance().
getComponent(schedulerVal);

- if (scheduler==null)
+ if(scheduler == null) {
throw new SystemException(
"error.ls.no_scheduler",
"No such component in AuxiliaryComponentManager:
"+schedulerVal);
-
- } catch (SystemException e) {
+ }
+ }
+ catch(SystemException e) {
throw new SystemException(
"error.ls.no_scheduler",
"LSCleanupLoader: no [component."+
@@ -122,38 +127,32 @@
// AuxiliaryComponentManager.getInstance().
// getComponent(storageVal);

- if (storage==null)
+ if(storage == null) {
throw new SystemException("error.ls.no_storage",
"No such component in AuxiliaryComponentManager");
-
- } catch (SystemException e) {
+ }
+ }
+ catch(SystemException e) {
throw new SystemException("error.ls.no_storage",
"LSCleanupLoader: no [component."+
componentName+".storage_component] parameter. "
+e.getMessage());
}

-
//add cleanup action to scheduler (note time*1000 because it's
// in seconds and scheduler needs time in millis
- scheduler.addSchedulerTask(interval * 1000, new LSCleanup(storage));
-
- //done.
+ scheduler.addSchedulerTask(interval * 1000, new LSCleanup(storage));

}


- public String getComponentName() {
-
- return componentName;
-
+ public String getComponentName() {
+ return componentName;
}


- public void setComponentName(String name) {
-
- componentName = name;
-
+ public void setComponentName(String name) {
+ componentName = name;
}


-} //component name
+}

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-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSDeregisterAction.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -1,31 +1,34 @@
package org.perfsonar.service.lookupService.xmlType;

import org.ggf.ns.nmwg.base.v2_0.*;
+
import org.perfsonar.service.commons.exceptions.DataFormatException;
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.bdbxml.BerkeleyDbXmlStorageManager;
import
org.perfsonar.service.commons.storage.xmldb.exist.xmlrpc.ExistDbXmlrpcXmlStorageManager;
import
org.perfsonar.service.commons.storage.xmldb.exist.rest.ExistDbHttpXmlStorageManager;

-
/**
* DEREGISTER Action
*
* @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/
public class LSDeregisterAction extends LSAction {

+
// --------------------------------------------------------------
Constants

// ----------------------------------------------------- instance
variables

// -----------------------------------------------------------
Constructor

-
public LSDeregisterAction(StorageManager xmlStorageManager)
throws SystemException {

@@ -33,32 +36,29 @@

}

+

// --------------------------------------------------------- Public
methods
-
-
- public Message performAction(Message request)
- throws SystemException, RequestException, DataFormatException {

+ public Message performAction(Message request) throws SystemException,
+ RequestException, DataFormatException {
+
logger.debug(
"XmlTypeLSServiceEngine: LS deregister - action DEREGISTER
started");

- //Get Metadata from Request
-
- Metadata requestMetadata =
- getMetadataFromRequest(request);
- if (requestMetadata==null) {
+ //Get Metadata from Request
+ Metadata requestMetadata = getMetadataFromRequest(request);
+ if(requestMetadata == null) {
String m="XmlTypeLSServiceEngine: No metadata in request";
logger.error(m);
throw new SystemException("error.ls.no_metadata",m);
}

//Get Key from Metadata
-
String keyValue = getKeyFromMetadata(requestMetadata, LS_KEY);
logger.debug("XmlTypeLSServiceEngine: LS key=["+keyValue+"]");

- if (keyValue==null) {
+ if(keyValue == null) {
String m="XmlTypeLSServiceEngine: No key";
logger.error(m);
throw new SystemException("error.ls.no_key", m);
@@ -69,133 +69,116 @@
String[] queryResults;
XmlDbResult edbres;
int countMetadataRemoved = 0;
- int countDataRemoved =0;
+ int countDataRemoved = 0;

//Query - get Data identifiers for given Key (all occurencies of Data
//having metadataIdRef = Key)

- 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)";
- edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ 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 +
+
"']/nmwg:data[@metadataIdRef='"
+ keyValue + "']/@id)";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
queryResults = (String[])edbres.getResultAsStringArray();
}
- else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
- {
- query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
-
"data(collection(\""+LS_STORE_CONTAINER+"\")/nmwg:data[@metadataIdRef=\""+keyValue+"\"]/@id)";
- edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+ "data(collection(\"" + LS_STORE_CONTAINER +
"\")/nmwg:data[@metadataIdRef=\""
+
+ keyValue + "\"]/@id)";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
queryResults = (String[])edbres.getResultAsStringArray();
}
- else
- throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
-
- if (queryResults!=null) {
-
- countDataRemoved = edbres.getCount();
-
- for (int i=0; i<queryResults.length; i++) {
+ else {
+ throw new SystemException("error.common.storage.xmldb.query", "No
database exists");
+ }
+
+ if(queryResults != null) {
+ countDataRemoved = edbres.getCount();
+ for(int i=0; i < queryResults.length; i++) {
logger.debug("XmlTypeLSServiceEngine: removing
["+countDataRemoved+"] data elements id=["+
queryResults[i]+"]");
}
-
}

-
//If found at least one matching Data element, remove all
- if (countDataRemoved>0) {
+ if(countDataRemoved > 0) {

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

+
//Query - get metadata identifiers for Key (all occurencies of
Metadata
//having id = Key : should be 0 or 1 !)
-
- 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)";
- edbres = (XmlDbResult)xmlStorageManager.fetch(query); //XQuery
+ 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 +
+
"']/nmwg:metadata[@id='"
+ keyValue + "']/@id)";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query); //XQuery
queryResults = (String[])edbres.getResultAsStringArray();
}
- 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=\""+keyValue+"\"]/@id)";

- edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ 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=\""
+
+ keyValue + "\"]/@id)";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
queryResults = (String[])edbres.getResultAsStringArray();
}
- else
- throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
-
- if (queryResults!=null) {
-
- countMetadataRemoved = edbres.getCount();
-
- for (int i=0; i<queryResults.length; i++) {
- logger.debug("XmlTypeLSServiceEngine: removing
["+countDataRemoved+"] metadata elements id=["+
- queryResults[i]+"]");
- }
-
+ else {
+ throw new SystemException("error.common.storage.xmldb.query", "No
database exists");
}
+
+ if(queryResults != null) {
+ countMetadataRemoved = edbres.getCount();
+ for(int i=0; i < queryResults.length; i++) {
+ logger.debug("XmlTypeLSServiceEngine: removing [" +
countDataRemoved +
+ "] metadata elements id=[" + queryResults[i] + "]");
+ }
+ }

//if found - remove (XUpdate)
- if (countDataRemoved>0) {
+ if(countDataRemoved > 0) {

//generate XQuery that removes data
- //removes data from ALL schemas (LSStore, LSStore-control,
LSCache, LSGlobalPeers, LSLocalPeers)
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager
||
- xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
- {
+
+ //removes data from ALL schemas (LSStore, LSStore-control,
LSCache)
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
String remove2 = "";
- remove2 = XQUERY_UPDATE_DECLARE +
- "for $md in
/nmwg:store/nmwg:metadata[@id='"
+
- keyValue+"'] return " + XQUERY_UPDATE_DELETE +
"$md";
+ remove2 = XQUERY_UPDATE_DECLARE + "for $md in
/nmwg:store[@type='"
+
+ LS_STORE_COLLECTION_TYPE + "' or @type='" +
LS_STORE_CONTROL_COLLECTION_TYPE +
+ "' or @type='" + LS_CACHE_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"
+
+ keyValue+"'] return " + XQUERY_UPDATE_DELETE +
"$md";
xmlStorageManager.fetch(remove2); //XQuery
- }
- else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
- {
- String xPath =
"/nmwg:metadata[@id=\""
+ keyValue +"\"]";
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_STORE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
- }
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath =
"/nmwg:metadata[@id=\""
+ keyValue +"\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_STORE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_CACHE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+ }
}

//status of operation

logger.debug("XmlTypeLSServiceEngine: Removed
data="+countDataRemoved+
", metadata="+countMetadataRemoved);
-
-

-
- /*
- throw new SystemException("result.success", "Removed ["+
- countMetadataRemoved+"] metadata and ["+
- countDataRemoved+"] data blocks for key ["+keyValue+"]");
- */
-
-
-
-
Message response = new Message();
response.setType("LSDeregisterResponse");

@@ -207,19 +190,16 @@
Metadata[] responseMetadata = { rc.getMetadata() };

Data[] responseData = null;
- if(rc.getData() !=null) {
- responseData = new Data[1];
- responseData[0] = rc.getData();
+ 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]);
+ for(int j=0; j < responseMetadata.length; j++){
+ response.addChild(responseMetadata[j]);
}
return response;
-
-
-
}


@@ -229,8 +209,7 @@
* @param keyValue
* @return Key element
*/
- private org.ggf.ns.nmwg.base.v2_0.Key createLSKey(String keyValue) {
-
+ private org.ggf.ns.nmwg.base.v2_0.Key createLSKey(String keyValue) {

org.ggf.ns.nmwg.base.v2_0.Key key =
new org.ggf.ns.nmwg.base.v2_0.Key();

@@ -247,7 +226,6 @@
key.setParameters(parameters);

return key;
-
}



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-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGenericRegisterAction.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -1,10 +1,9 @@
-
package org.perfsonar.service.lookupService.xmlType;

-
import org.perfsonar.service.commons.exceptions.DataFormatException;
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.bdbxml.BerkeleyDbXmlStorageManager;
@@ -15,13 +14,14 @@
* Class that has commons methods for registration, updates, and keepalives
*
* @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/
public abstract class LSGenericRegisterAction extends LSAction {


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

// ------------------------------------------------------------
Constructor

@@ -30,13 +30,13 @@

//run super constructor (LSAction)
super(xmlStorageManager);
-
}

+

// ------------------------------------------------------ Protected
methods

-
+
/**
* Updates timestamp parameter in LSStorage-control schema
* Sets it to current timestamp (System.currentTimeMillis())
@@ -60,8 +60,7 @@

}

-
-
+
/**
* Remove parameter from LSStorage-control. If metadata remains empty,
* remove it as well
@@ -69,82 +68,72 @@
* @throws RequestException
* @throws SystemException
*/
- protected void removeControlParameter(
- String key,
- String parameterName,
- StorageManager xmlStorageManager) throws SystemException,
RequestException, DataFormatException {
+ protected void removeControlParameter(String key, String parameterName,
+ StorageManager xmlStorageManager) throws SystemException,
RequestException, DataFormatException {

- String remove = null;
-
+ String remove = null;
//remove single parameter
-
- logger.debug("LSGenericRegisterAction: remove parameter ["+
- parameterName+"] for key ["+key+"]");
+ logger.debug("LSGenericRegisterAction: remove parameter [" +
parameterName +
+ "] for key [" + key + "]");

- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
- xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
- {
- remove = XQUERY_UPDATE_DECLARE +
- "for $p in
/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ key +
"']/nmwg:parameters/nmwg:parameter[@name='"
+
- parameterName + "'] return " +
XQUERY_UPDATE_DELETE + "$p";
- xmlStorageManager.fetch(remove); //XQuery
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+ remove = XQUERY_UPDATE_DECLARE +
+ "for $p in
/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
+
"']/nmwg:metadata[@id='"
+ key +
"']/nmwg:parameters/nmwg:parameter[@name='"
+
+ parameterName + "'] return " + XQUERY_UPDATE_DELETE +
"$p";
+ xmlStorageManager.fetch(remove); //XQuery
}
- else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
- {
- String xPath =
"/nmwg:metadata[@id=\""
+ key +"\"]" +
-
"/nmwg:parameters/nmwg:parameter[@name=\""
+ parameterName + "\"]";
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {
+ String xPath =
"/nmwg:metadata[@id=\""
+ key +"\"]" +
+
"/nmwg:parameters/nmwg:parameter[@name=\""
+ parameterName + "\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
}

+
//check if metadata empty
String query;
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_CONTROL_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+key+"']/@id)";
- res = (XmlDbResult)xmlStorageManager.fetch(query);
+ 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)";
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
}
- else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
- {
- query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
-
"data(collection(\""+LS_STORE_CONTROL_CONTAINER+"\")/nmwg:metadata[@id=\""+key+"\"]/@id)";
- res = (XmlDbResult)xmlStorageManager.fetch(query);
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+ "data(collection(\"" + LS_STORE_CONTROL_CONTAINER +
"\")/nmwg:metadata[@id=\""
+
+ key + "\"]/@id)";
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
}
- else
- throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
-
- int resnum = res.getCount();
-
+ else {
+ throw new SystemException("error.common.storage.xmldb.query", "No
database exists");
+ }
+
+
+ int resnum = res.getCount();
//metadata empty -> remove it
- if (resnum==0) {
-
- logger.debug("LSGenericRegisterAction: metadata block for key
["+key
- +"] remained empty, delete it");
+ if(resnum == 0) {
+ logger.debug("LSGenericRegisterAction: metadata block for key ["
+ key +
+ "] remained empty, delete it");

- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager
||
- xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
- {
- remove = XQUERY_UPDATE_DECLARE +
- "for $md in
/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ key + "'] return " +
- XQUERY_UPDATE_DELETE + "$md";

+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+ remove = XQUERY_UPDATE_DECLARE + "for $md in
/nmwg:store[@type='"
+
+ LS_STORE_CONTROL_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"
+
+ key + "'] return " + XQUERY_UPDATE_DELETE + "$md";

xmlStorageManager.fetch(remove); //XQuery
}
- else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
- {
- String xPath =
"/nmwg:metadata[@id=\""
+ key +"\"]";
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath =
"/nmwg:metadata[@id=\""
+ key +"\"]";

((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
}
}
-
+
} //remove parameter

-
-
-
+
/**
* Puts parameterValue into LSStore-control schema:
*
nmwg:store[@type='LSStore-control']
/
@@ -152,175 +141,163 @@
* nmwg:parameters /
nmwg:parameter[@name='parameterName']

*
*/
- protected void setControlParameter(
- String key,
- String parameterName,
- String parameterValue,
- StorageManager xmlStorageManager)
- throws SystemException, RequestException,
DataFormatException {
+ protected void setControlParameter(String key, String parameterName,
+ String parameterValue, StorageManager xmlStorageManager) throws
SystemException,
+ RequestException, DataFormatException {

logger.debug("LSGenericRegisterAction: Set parameter ["+
parameterName+"] = ["+parameterValue+"]");

- //initialize
-
+ //initialize
String query = null;
int resnum = 0;
XmlDbResult res;

//check if there is control metadata for such key
- 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)";
- res = (XmlDbResult)xmlStorageManager.fetch(query);
+ 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)";
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
}
- else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
- {
- query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
-
"data(collection(\""+LS_STORE_CONTROL_CONTAINER+"\")/nmwg:metadata[@id=\""+key+"\"]/@id)";

- res = (XmlDbResult)xmlStorageManager.fetch(query);
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+ "data(collection(\"" + LS_STORE_CONTROL_CONTAINER +
"\")/nmwg:metadata[@id=\""
+
+ key + "\"]/@id)";
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
}
- else
- throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
-
+ else {
+ throw new SystemException("error.common.storage.xmldb.query", "No
database exists");
+ }
+
resnum = res.getCount();
-
//if there is no control metadata, put it
- if (resnum==0) {
+ if(resnum == 0) {
logger.debug("LSGenericRegisterAction: setParameter: no control
metadata, put metadata+parameters");

- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager
||
- xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
- {
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
- insert = insert + " <nmwg:metadata id=\"" + key +
"\">\n" +
- " <nmwg:parameters
id=\"control-parameters\">\n" +
- " </nmwg:parameters>\n" +
- " </nmwg:metadata>\n into
/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE + "']";
+ insert = insert + " <nmwg:metadata id=\"" + key + "\">\n" +
+ " <nmwg:parameters id=\"control-parameters\">\n" +
+ " </nmwg:parameters>\n" +
+ " </nmwg:metadata>\n into
/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE + "']";
xmlStorageManager.fetch(insert);
- }
- else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
- {
- String insertData = "<nmwg:metadata id=\"" + key +
"\" xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";>\n" +
- " <nmwg:parameters
id=\"control-parameters\">\n" +
- "
</nmwg:parameters>\n" +
- "</nmwg:metadata>\n";
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).insertDocument(LS_STORE_CONTROL_CONTAINER,
insertData);
- }
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String insertData = "<nmwg:metadata id=\"" + key + "\"
xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";>\n" +
+ " <nmwg:parameters
id=\"control-parameters\">\n" +
+ " </nmwg:parameters>\n" +
+ "</nmwg:metadata>\n";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insertDocument(LS_STORE_CONTROL_CONTAINER,
insertData);
+ }
}
else {
//if there is the metadata, check if it has a parameters block

- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager
||
- xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
- {
+ 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)";
+
"data(/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
+
"']/nmwg:metadata[@id='"
+ key + "']/nmwg:parameters/@id)";
res = (XmlDbResult)xmlStorageManager.fetch(query);
- }
- else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
- {
- query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
-
"data(collection(\""+LS_STORE_CONTROL_CONTAINER+"\")/nmwg:metadata[@id=\""+key+"\"]/nmwg:parameters/@id)";
- res = (XmlDbResult)xmlStorageManager.fetch(query);
- }
- else
- throw new
SystemException("error.common.storage.xmldb.query", "No database exists");
-
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+ "data(collection(\"" + LS_STORE_CONTROL_CONTAINER +
"\")/nmwg:metadata[@id=\""
+
+ key + "\"]/nmwg:parameters/@id)";
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
+ }
+ else {
+ throw new
SystemException("error.common.storage.xmldb.query", "No database exists");
+ }


- resnum = res.getCount();
-
- if (resnum==0) {
+ resnum = res.getCount();
+ if(resnum == 0) {
// put parameters
- if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
- xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
- {
+ 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"
+
- " </nmwg:parameters>\n
into
/nmwg:store[@type='"
+
- LS_STORE_CONTROL_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"
+ key + "']";
+ insert = insert + " <nmwg:parameters
id=\"control-parameters\" xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";>\n"
+
+ " </nmwg:parameters>\n into
/nmwg:store[@type='"
+
+ LS_STORE_CONTROL_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"
+ key + "']";
xmlStorageManager.fetch(insert);
}
- else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
- {
- String xPath =
"/nmwg:metadata[@id='"
+ key + "']";
- String insertData = "<nmwg:parameters
id=\"control-parameters\" xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";>\n"
+
-
"</nmwg:parameters>\n";
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).insert(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath, insertData);
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath =
"/nmwg:metadata[@id='"
+ key + "']";
+ String insertData = "<nmwg:parameters
id=\"control-parameters\" xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";>\n"
+
+ "</nmwg:parameters>\n";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insert(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath, insertData);
}
}
}

//check if there is parameter inside metadata
- 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+"']";
- res = (XmlDbResult)xmlStorageManager.fetch(query);
+ 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 + "']";
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
}
- else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
- {
- query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
-
"collection(\""+LS_STORE_CONTROL_CONTAINER+"\")/nmwg:metadata[@id=\""+key+"\"]/nmwg:parameters/nmwg:parameter[@name=\""+parameterName+"\"]";
- res = (XmlDbResult)xmlStorageManager.fetch(query);
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+ "collection(\"" + LS_STORE_CONTROL_CONTAINER +
"\")/nmwg:metadata[@id=\""
+
+ key +
"\"]/nmwg:parameters/nmwg:parameter[@name=\""
+ parameterName + "\"]";
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
}
- else
+ else {
throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
+ }

resnum = res.getCount();
+ if(resnum == 0) {

- if (resnum==0) {
-
//if there is no such parameter, put new one
- logger.debug("LSGenericRegisterAction: Set parameter
["+parameterName+
- "] not found, " +
- "insert new parameter ["+key+"]");
+ logger.debug("LSGenericRegisterAction: Set parameter [" +
parameterName + "] not found, " +
+ "insert new parameter ["+key+"]");

- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager
||
- xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
- {
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+
String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
- insert = insert + "<nmwg:parameter name=\"" +
parameterName + "\">" +
- parameterValue + "</nmwg:parameter>
into
/nmwg:store[@type='"
+
- LS_STORE_CONTROL_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"
+
- key + "']/nmwg:parameters";
+ insert = insert + "<nmwg:parameter name=\"" + parameterName +
"\">" +
+ parameterValue + "</nmwg:parameter> into
/nmwg:store[@type='"
+
+ LS_STORE_CONTROL_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"
+
+ key + "']/nmwg:parameters";
xmlStorageManager.fetch(insert);
- }
- else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
- {
- String xPath =
"/nmwg:metadata[@id=\""
+ key + "\"]/nmwg:parameters";
- String insertData = "<nmwg:parameter name=\"" +
parameterName + "\" xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";>"
- + parameterValue
- + "</nmwg:parameter>";
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).insert(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath, insertData);
- }
- } else {
-
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath =
"/nmwg:metadata[@id=\""
+ key + "\"]/nmwg:parameters";
+ String insertData = "<nmwg:parameter name=\"" + parameterName
+ "\" xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";>"
+ + parameterValue + "</nmwg:parameter>";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insert(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath, insertData);
+ }
+ }
+ else {
//otherwise update it

logger.debug("LSGenericRegisterAction: Set parameter ["
+parameterName+"] found," +
"update existing one");
-
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager
||
- xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
- {
+
+ 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 +
-
"']/nmwg:metadata[@id='"
+ key +
-
"']/nmwg:parameters/nmwg:parameter[@name='"
+ parameterName +
- "'] with " + parameterValue;
+ update = update +
"/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
+
"']/nmwg:metadata[@id='"
+ key +
+
"']/nmwg:parameters/nmwg:parameter[@name='"
+ parameterName +
+ "'] with " + parameterValue;
xmlStorageManager.fetch(update);
- }
- else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
- {
- String xPath =
"/nmwg:metadata[@id=\""
+ key +
"\"]/nmwg:parameters/nmwg:parameter[@name=\""
+ parameterName + "\"]";
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath, parameterValue);
- }
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath =
"/nmwg:metadata[@id=\""
+ key +
"\"]/nmwg:parameters/nmwg:parameter[@name=\""
+ parameterName + "\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath, parameterValue);
+ }
}

} //set parameter
@@ -329,38 +306,42 @@
/**
* Checks if there is any metadata for given key (in LSStore,LSCache
schemas)
*/
- protected boolean checkIfKeyIsRegistered(String key, StorageManager
xmlStorageManager) throws SystemException, RequestException,
DataFormatException {
+
+ protected boolean checkIfKeyIsRegistered(String key, StorageManager
xmlStorageManager)
+ throws SystemException, RequestException, DataFormatException {
+
try {
- String query;
- 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) {
- 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 {
- throw new
SystemException("error.common.storage.xmldb.query", "No database exists");
- }
+ String query;
+ 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) {
+ 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 {
+ throw new
SystemException("error.common.storage.xmldb.query", "No database exists");
+ }
+
int resnum = res.getCount();
-
- if (resnum>0)
+ if(resnum > 0) {
return true; //key is registered
- else
+ }
+ else {
return false; //key not registered
-
- } catch (NullPointerException ex) {
+ }
+ }
+ catch (NullPointerException ex) {
return false;
}

}
-

} //LSGenericRegisterAction

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGlobalTokenAction.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGlobalTokenAction.java
2006-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGlobalTokenAction.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -6,18 +6,23 @@
import java.util.Map;

import org.ggf.ns.nmwg.base.v2_0.*;
+import org.ggf.ns.nmwg.base.v2_0.Message;
+import org.ggf.ns.nmwg.base.v2_0.Store;
+
import org.perfsonar.commons.util.XMLUtils;
import org.perfsonar.commons.util.MathUtil;
+
import org.perfsonar.service.commons.exceptions.DataFormatException;
import org.perfsonar.service.commons.exceptions.RequestException;
import org.perfsonar.service.commons.exceptions.SystemException;
import org.perfsonar.service.commons.storage.StorageManager;
+import
org.perfsonar.commons.auxiliary.components.simplescheduler.SchedulerAction;

-import org.ggf.ns.nmwg.base.v2_0.Message;
-import org.ggf.ns.nmwg.base.v2_0.Store;
-import
org.perfsonar.commons.auxiliary.components.simplescheduler.SchedulerAction;
import org.perfsonar.service.commons.exceptions.PerfSONARException;
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;

import org.perfsonar.commons.auxiliary.AuxiliaryComponent;
import org.perfsonar.commons.auxiliary.AuxiliaryComponentManager;
@@ -28,76 +33,86 @@

/**
* TOKEN Action
- *
- * @author Jason Zurawski
+ * @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/
public class LSGlobalTokenAction extends LSGenericRegisterAction implements
SchedulerAction {

- private Scheduler scheduler;
-
+
// --------------------------------------------------------------
Constants
-
+
+ /**
+ * allow replacement of items in the xmldb
+ */
private final static boolean DEFAULT_ALLOW_REPLACE = true;
-
+
+
/**
* name of property in config file
*/
private static final String LS_TOKEN_INTERVAL =
"component.ls_global_token_loader.interval";

+

// ----------------------------------------------------- Instance
variables
+
+ /**
+ * scheduler
+ */
+ private Scheduler scheduler;
+

/**
* allow the replacement of already registered data
*/
private boolean allowReplaceIfAlreadyRegistered = DEFAULT_ALLOW_REPLACE;
+

/**
* lsUtil
*/
private LSUtilities lsUtil;

+
/**
* lsTokenUtil
*/
private LSTokenUtilities lsTokenUtil;
+

/**
* number of iteration (for debugging)
*/
long iterations = 0;
+


// -----------------------------------------------------------
Constructor

- public LSGlobalTokenAction(StorageManager xmlStorageManager)
- throws SystemException {
+ public LSGlobalTokenAction(StorageManager xmlStorageManager) throws
SystemException {
super(xmlStorageManager);

String temp = null;
try {
- temp =
configuration.getProperty("component.ls_global_token_loader.scheduler_component");
-
+ temp =
configuration.getProperty("component.ls_global_token_loader.scheduler_component");

logger.debug("\tLSGlobalTokenAction: parameter SCHEDULER=" + temp);
-
- scheduler = (Scheduler)AuxiliaryComponentManager.
- getInstance().getComponent(temp);

+ scheduler =
(Scheduler)AuxiliaryComponentManager.getInstance().getComponent(temp);

}
- catch (SystemException e) {
+ catch(SystemException e) {
temp = null;
}

lsUtil = new LSUtilities();
-
lsTokenUtil = new LSTokenUtilities(logger, configuration, lsUtil,
LS_TOKEN_INTERVAL);
}


// --------------------------------------------------------- Public
methods

- public Message performAction(Message request)
- throws SystemException, RequestException, DataFormatException {
+ public Message performAction(Message request) throws SystemException,
+ RequestException, DataFormatException {
String query = null;
String[] results = null;
XmlDbResult edbres = null;
@@ -110,342 +125,447 @@

//If we get a null request, the scheduler clicked off before we saw
a token
if(request == null) {
-
- if(iterations <= 3) {
- logger.debug("LSGlobalTokenAction: Testing to make sure THIS LS
is in the peer list");
+
+ //make sure that THIS ls is loaded into the peer list
+ if(iterations <= 3) {
+ logger.debug("LSGlobalTokenAction: Testing to make sure THIS
LS is in the peer list");

- //do a query to be sure we are in there...
- query = XQUERY_UPDATE_DECLARE;
- query = query +
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ lsUtil.getLsAccessPoint() + "']";

- logger.debug("LSGlobalTokenAction: Query: " + query);
- results = lsUtil.getDBContents(xmlStorageManager, query);
-
- if(results[0].equals("")) {
- logger.debug("LSGlobalTokenAction: We are not In there!");
+ //get the contents of the peer list
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
+ query = XQUERY_UPDATE_DECLARE +
"/nmwg:store[@type='"
+
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"
+
+ lsUtil.getLsAccessPoint() + "']";

+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();

+
+ logger.debug("LSGlobalTokenAction: Query: " + query);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_GLOBAL_PEER_CONTAINER +
+
"\")/nmwg:metadata[@id='"
+ lsUtil.getLsAccessPoint() + "'])";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+
+ logger.debug("LSGlobalTokenAction: Query: " + query);
+ }
+ else {
+ throw new
SystemException("error.common.storage.xmldb.query", "No database exists");
+ }
+
+ //see what was returned
+ if(results[0].equals("")) {
+ //if we got nothing, we need to be inserted into the peer
list
+
+ logger.debug("LSGlobalTokenAction: We are not In
there!");

- //if we are not, make us
- Metadata peerMetadata = new Metadata();
- peerMetadata.setId(lsUtil.getLsAccessPoint());
- peerMetadata.addChild(lsTokenUtil.getLSPeerKey());
+ //if we are not, make us
+ Metadata peerMetadata = new Metadata();
+ peerMetadata.setId(lsUtil.getLsAccessPoint());
+ peerMetadata.addChild(lsTokenUtil.getLSPeerKey());

- //insert us
- logger.debug("LSGlobalTokenAction: MD Ready, inserting...");
+ //insert us
+ logger.debug("LSGlobalTokenAction: MD Ready,
inserting...");

- String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT +
- XMLUtils.serializeXML(peerMetadata) + " into
/nmwg:store[@type='"
+
- LS_GLOBAL_PEER_COLLECTION_TYPE + "']";
- xmlStorageManager.fetch(insert);
-
- logger.debug("LSGlobalTokenAction: Done Adding Us");
- }
- else {
- logger.debug("LSGlobalTokenAction: We are already in the LS, do
nothing...");
- }
- }
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ String insert = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_INSERT + XMLUtils.serializeXML(peerMetadata) +
+ " into
/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE + "']";
+ xmlStorageManager.fetch(insert);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath = "/";
+ String insertData =
XMLUtils.serializeXML(peerMetadata);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insert(LS_GLOBAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath, insertData);
+ }
+
+ logger.debug("LSGlobalTokenAction: Done Adding Us");
+ }
+ else {
+ logger.debug("LSGlobalTokenAction: We are already in the
LS, do nothing...");
+ }
+ }


- logger.debug("LSGlobalTokenAction: Scheduled Case Starting");
+ logger.debug("LSGlobalTokenAction: Scheduled Case Starting");

- //we need to look at everyone's familiarity, there are three cases:
- //
- // 1) Iterations <= 3; this is the first time we are running so we
should
- // send out 'hello' summaries to people on our list.
- //
- // 2) Iterations > 3, but everyone's familiarity is '0'; It is like
we are
- // joining for the first time, so we should send out a 'hello'
summary to
- // anyone that will listen.
- //
- // 3) Iterations > 3, but the familiarity of at least one person is
'1';
- // we can still try to send out a 'real' token at this point,
don't
- // resort to re-introducing yourself
- //
+ //we need to look at everyone's familiarity, there are three
cases:
+ //
+ // 1) Iterations <= 3; this is the first time we are running so
we should
+ // send out 'hello' summaries to people on our list.
+ //
+ // 2) Iterations > 3, but everyone's familiarity is '0'; It is
like we are
+ // joining for the first time, so we should send out a 'hello'
summary to
+ // anyone that will listen.
+ //
+ // 3) Iterations > 3, but the familiarity of at least one person
is '1';
+ // we can still try to send out a 'real' token at this point,
don't
+ // resort to re-introducing yourself
+ //

- //get the contents of LSGlobalPeers
- query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE + "']";
- results = lsUtil.getDBContents(xmlStorageManager, query);
-
- if(results[0].equals("")) {
- String m = "LSGlobalTokenAction: " +
- "Peer List is empty; please populate it with at
least one peer.";
- logger.error(m);
- throw new SystemException("error.ls.peer_list_empty", m);
- }
+
+ //get the contents of LSGlobalPeers
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE + "']";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
{
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_GLOBAL_PEER_CONTAINER + "\"))";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else {
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
+ }
+
+ if(results[0].equals("")) {
+ String m = "LSGlobalTokenAction: " +
+ "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");
+ Store result = (Store)XMLUtils.stringToElement(results[0],
lsUtil.getParserFile(), "store");

- metadataCol = result.getMetadataMap().values();
- if(metadataCol.size() < 1) {
- String m = "LSGlobalTokenAction: " +
- "Peer List is empty; please populate it with at
least one peer.";
- logger.error(m);
- throw new SystemException("error.ls.peer_list_empty", m);
- }
- sortedList = lsTokenUtil.formPeerArray(metadataCol);
-
-
- query = XQUERY_UPDATE_DECLARE + "for $p in
/nmwg:store[@type='"
+
- LS_GLOBAL_PEER_COLLECTION_TYPE +
"']//nmwg:parameter[@name='familiar']
return $p/text()";
+ metadataCol = result.getMetadataMap().values();
+ if(metadataCol.size() < 1) {
+ String m = "LSGlobalTokenAction: " +
+ "Peer List is empty; please populate it with at
least one peer.";
+ logger.error(m);
+ throw new SystemException("error.ls.peer_list_empty", m);
+ }
+ sortedList = lsTokenUtil.formPeerArray(metadataCol);
+
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE + "for $p in
/nmwg:store[@type='"
+
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
"']//nmwg:parameter[@name='familiar']
return $p/text()";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+
+ logger.debug("LSGlobalTokenAction: Staring Query: " + query);
+ }
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
{
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_GLOBAL_PEER_CONTAINER +
+
"\")//nmwg:parameter[@name='familiar']
return $p/text())";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+
+ logger.debug("LSGlobalTokenAction: Staring Query: " + query);
+ }
+ else {
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
+ }

- logger.debug("LSGlobalTokenAction: Staring Query: " + query);
- results = lsUtil.getDBContents(xmlStorageManager, query);
-
- boolean emptyFlag = true;
- for(int i = 0; i < results[0].length()-1; i++) {
- if(!(results[0].charAt(i) == '0')) {
- emptyFlag = false;
- break;
- }
- }
+ boolean emptyFlag = true;
+ for(int i = 0; i < results[0].length()-1; i++) {
+ if(!(results[0].charAt(i) == '0')) {
+ emptyFlag = false;
+ break;
+ }
+ }

- if((iterations <= 3) || (emptyFlag == true)) {
+ if((iterations <= 3) || (emptyFlag == true)) {

- logger.debug("LSGlobalTokenAction: Starting Case 1/2");
+ logger.debug("LSGlobalTokenAction: Starting Case 1/2");

- //If this is the first time we are running (of we just can't
seem to
- // reach anyone), update the peer lists to indicate that we don't
know
- // anyone
- String update = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_VALUE;
- update = update +
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
-
"']//nmwg:parameter[@name='familiar']
with '0'";
- xmlStorageManager.fetch(update);
+ //If this is the first time we are running (of we just can't
seem to
+ // reach anyone), update the peer lists to indicate that we
don't know
+ // anyone
+
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
+ String update = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_VALUE;
+ update = update +
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
+
"']//nmwg:parameter[@name='familiar']
with '0'";
+ xmlStorageManager.fetch(update);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath =
"//nmwg:parameter[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_GLOBAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath, "0");
+ }

- for(c = 0; c < metadataCol.size(); c++) {
- sortedList[c][1] = "0";
- }
+ for(c = 0; c < metadataCol.size(); c++) {
+ sortedList[c][1] = "0";
+ }

- //send the summary message to your peers
- lsTokenUtil.sendExternalSummaryMessage(xmlStorageManager);
+ //send the summary message to your peers
+ lsTokenUtil.sendExternalSummaryMessage(xmlStorageManager);

- logger.debug("LSGlobalTokenAction: Done sending out messages");
-
- //NB: how long of a backoff do we need here?
- }
- else {
- //case 3
+ logger.debug("LSGlobalTokenAction: Done sending out
messages");
+ //NB: how long of a backoff do we need here?
+ }
+ else {
+ //case 3

- logger.debug("LSGlobalTokenAction: Starting Case 3.");
+ logger.debug("LSGlobalTokenAction: Starting Case 3.");

- //now we make a metadata that describes who we are...
- Metadata reqMetadata = new Metadata();
- reqMetadata = lsUtil.createLSMetadata(reqMetadata,
MathUtil.calculateId(lsUtil.getLsAccessPoint(), lsUtil.getLsServiceRank()));
+ //now we make a metadata that describes who we are...
+ Metadata reqMetadata = new Metadata();
+ reqMetadata = lsUtil.createLSMetadata(reqMetadata,
MathUtil.calculateId(lsUtil.getLsAccessPoint(), lsUtil.getLsServiceRank()));

- Data reqData = new Data();
- reqData.setId("tokenData");
-
reqData.setMetadataIdRef(MathUtil.calculateId(lsUtil.getLsAccessPoint(),
lsUtil.getLsServiceRank()));
+ Data reqData = new Data();
+ reqData.setId("tokenData");
+
reqData.setMetadataIdRef(MathUtil.calculateId(lsUtil.getLsAccessPoint(),
lsUtil.getLsServiceRank()));

- metadataCol = result.getMetadataMap().values();
- Iterator metadataColIterator = metadataCol.iterator();
- while (metadataColIterator.hasNext()) {
- Metadata tempMetadata = (Metadata)metadataColIterator.next();

- reqData.addChild(tempMetadata);
- }
+ metadataCol = result.getMetadataMap().values();
+ Iterator metadataColIterator = metadataCol.iterator();
+ while (metadataColIterator.hasNext()) {
+ Metadata tempMetadata =
(Metadata)metadataColIterator.next();
+ reqData.addChild(tempMetadata);
+ }

- //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, "token",
"global");
+ //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,
"token", "global");

- //make token message
- // put them in a message, then insert
- Message registerMessage = new Message();
- registerMessage.setType("LSTokenRequest");
- registerMessage.addChild(reqMetadata);
- registerMessage.addChild(reqData);
- registerMessage.addChild(reqParams);
+ //make token message
+ // put them in a message, then insert
+ Message registerMessage = new Message();
+ registerMessage.setType("LSTokenRequest");
+ registerMessage.addChild(reqMetadata);
+ registerMessage.addChild(reqData);
+ registerMessage.addChild(reqParams);

- logger.debug("LSGlobalTokenAction: CASE 3: MSG: " +
registerMessage);
+ logger.debug("LSGlobalTokenAction: CASE 3: MSG: " +
registerMessage);

- boolean successFlag = false;
- for(int b = 0; b < metadataCol.size(); b++) {
-
- //don't insert into ourself...
- //if(!(sortedList[b][0].equals(lsUtil.getLsAccessPoint()))) {
-
- logger.debug("LSGlobalTokenAction: CASE3 Sending token
message to: " + sortedList[b][0] + " - " + sortedList[b][1]);
- try {
- Message response =
lsTokenUtil.sendRequest(sortedList[b][0], registerMessage);

- if(response != null) {
- //check to see if we succeeded:
- Metadata resp = getMetadataFromRequest(response);
- if (resp == null) {
- logger.debug("LSGlobalTokenAction: CASE3 No metadata in
peer response");
- }
- else {
- logger.debug("LSGlobalTokenAction: CASE3 response: " +
resp.toString());
-
if((resp.getEventType().getEventType()).equals("result.success")) {
- if(Integer.parseInt(sortedList[b][1]) < 3) {
+ boolean successFlag = false;
+ for(int b = 0; b < metadataCol.size(); b++) {
+ //don't insert into ourself...
+
//if(!(sortedList[b][0].equals(lsUtil.getLsAccessPoint()))) {
+ logger.debug("LSGlobalTokenAction: CASE3 Sending
token message to: " + sortedList[b][0] + " - " + sortedList[b][1]);
+ try {
+ Message response =
lsTokenUtil.sendRequest(sortedList[b][0], registerMessage);

+ if(response != null) {
+ //check to see if we succeeded:
+ Metadata resp =
getMetadataFromRequest(response);
+ if(resp == null) {
+ logger.debug("LSGlobalTokenAction: CASE3
No metadata in peer response");
+ }
+ else {
+ logger.debug("LSGlobalTokenAction: CASE3
response: " + resp.toString());
+
if((resp.getEventType().getEventType()).equals("result.success")) {
+ if(Integer.parseInt(sortedList[b][1])
< 3) {
+

+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ String update =
XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_VALUE;
+ update = update +
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
+
"']//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
+
"[@name='familiar']
with '" + (int)((Integer.parseInt(sortedList[b][1]))+1) + "'";
+
xmlStorageManager.fetch(update);
+ }
+ else if(xmlStorageManager
instanceof BerkeleyDbXmlStorageManager) {
+ String xPath =
"//nmwg:parameters[@id='"
+ sortedList[b][0] +
+
"']/nmwg:parameter[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_GLOBAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE,
xPath, Integer.toString((Integer.parseInt(sortedList[b][1]))+1));
+ }

+
+ sortedList[b][1] =
Integer.toString(Integer.parseInt(sortedList[b][1]) + 1);
+ }
+ b = metadataCol.size() + 1;

- //update the peers list
- String update = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_VALUE;
- update = update +
"/nmwg:store[@type='"
+ LS_GLOBAL_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);
- }
- b = metadataCol.size() + 1;
+ //advance the scheduler (wait for the
real token)
+ //scheduler.advanceScheduler(1000 *
Integer.parseInt(getLsTokenFrequency()) * metadataCol.size());
+ successFlag = true;
+ }
+ else {
+ logger.debug("LSGlobalTokenAction:
CASE3 Success Code from peer not found");
+ }
+ }
+ }
+ else {
+ logger.debug("LSGlobalTokenAction: CASE3 Null
response when talking to peer");
+
+ if(Integer.parseInt(sortedList[b][1]) > 0) {
+ //update the peers list

- //advance the scheduler (wait for the real token)
- //scheduler.advanceScheduler(1000 *
Integer.parseInt(getLsTokenFrequency()) * metadataCol.size());
- successFlag = true;
- }
- else {
- logger.debug("LSGlobalTokenAction: CASE3 Success Code
from peer not found");
- }
- }
- }
- else {
- logger.debug("LSGlobalTokenAction: CASE3 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_GLOBAL_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);
- }
- }
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ String update = XQUERY_UPDATE_DECLARE
+ XQUERY_UPDATE_VALUE +
+
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
+
"']//nmwg:parameters[@id='"
+ sortedList[b][0] +
+
"']/nmwg:parameter[@name='familiar']
with '" +
+
(int)((Integer.parseInt(sortedList[b][1]))-1) + "'";
+ xmlStorageManager.fetch(update);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath =
"//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
+
"[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_GLOBAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath,
Integer.toString((Integer.parseInt(sortedList[b][1]))-1));
+ }
+
+ sortedList[b][1] =
Integer.toString(Integer.parseInt(sortedList[b][1])-1);
+ }
+ }
+ }
+ catch(Exception e) {
+ logger.debug("LSGlobalTokenAction: CASE3
Exception: " + e.toString());
+ throw new
SystemException("error.ls.client_error",
+ "Error sending to
client LS " +
+ e.getMessage());
+ }
+ //}
}
- catch(Exception e) {
- logger.debug("LSGlobalTokenAction: CASE3 Exception: " +
e.toString());
- throw new SystemException("error.ls.client_error",
- "Error sending to client LS " +
- e.getMessage());
- }
- //}
- }

- if(successFlag == false) {
- //advance the scheduler (wait for the real token)
- //scheduler.advanceScheduler(1000 *
Integer.parseInt(getLsTokenFrequency()) * metadataCol.size());

+ if(successFlag == false) {
+ //advance the scheduler (wait for the real token)
+ //scheduler.advanceScheduler(1000 *
Integer.parseInt(getLsTokenFrequency()) * metadataCol.size());
+ }
+ //NB: how long of a backoff do we need here?
}
- //NB: how long of a backoff do we need here?
- }
- logger.debug("LSGlobalTokenAction: Scheduled Case Stopping");
- return null;
- }
- else {
- //This is the case when we get a token messgage
+ logger.debug("LSGlobalTokenAction: Scheduled Case Stopping");
+ return null;
+ }
+ else {
+ //This is the case when we get a token messgage

- logger.debug("LSGlobalTokenAction: Message Arriving Start: " +
request.toString());
+ logger.debug("LSGlobalTokenAction: Message Arriving Start: " +
request.toString());

// pause the scheduler while we do our work?

- //Get Metadata from request
- Metadata requestMetadata = getMetadataFromRequest(request);
- if (requestMetadata==null) {
- String m="LSRegisterAction: No metadata in request";
- logger.error(m);
- throw new SystemException("error.ls.no_metadata", m);
- }
+ //Get Metadata from request
+ Metadata requestMetadata = getMetadataFromRequest(request);
+ if(requestMetadata == null) {
+ String m="LSRegisterAction: No metadata in request";
+ logger.error(m);
+ throw new SystemException("error.ls.no_metadata", m);
+ }

+ //add information to the peers list
+ lsTokenUtil.addToPeerList(xmlStorageManager, requestMetadata,
"global");
+
+ //now deal with the data that this person sent
+ logger.debug("LSGlobalTokenAction: MESSAGE Dealing with the
data block");
+ Collection reqDataArr = request.getDataMap().values();
+ if(reqDataArr.size() < 1) {
+ String m = "LSRegisterAction: " +
+ "Request must have at least one data element -
trigger) ";
+ logger.error(m);
+ throw new SystemException("error.ls.no_data_trigger", m);
+ }

- //add information to the peers list
- lsTokenUtil.addToPeerList(xmlStorageManager, requestMetadata,
"global");
-
-
- //now deal with the data that this person sent
- logger.debug("LSGlobalTokenAction: MESSAGE Dealing with the data
block");
- Collection reqDataArr = request.getDataMap().values();
- if(reqDataArr.size() < 1) {
- String m = "LSRegisterAction: " +
- "Request must have at least one data element -
trigger) ";
- logger.error(m);
- throw new SystemException("error.ls.no_data_trigger", m);
- }
-
- //there really should be only one
- Iterator reqDataArrIterator = reqDataArr.iterator();
- while (reqDataArrIterator.hasNext()) {
- Data requestData = (Data)reqDataArrIterator.next();
+ //there really should be only one
+ Iterator reqDataArrIterator = reqDataArr.iterator();
+ while (reqDataArrIterator.hasNext()) {
+ Data requestData = (Data)reqDataArrIterator.next();

- //each data is a collection of MDs...
- logger.debug("LSGlobalTokenAction: MESSAGE Found Data: " +
requestData.toString());
+ //each data is a collection of MDs...
+ logger.debug("LSGlobalTokenAction: MESSAGE Found Data: " +
requestData.toString());

- Collection reqDataMDArr = requestData.getMetadataMap().values();
- Iterator reqDataArrMDIterator = reqDataMDArr.iterator();
- while (reqDataArrMDIterator.hasNext()) {
- Metadata tokenMD = (Metadata)reqDataArrMDIterator.next();
+ Collection reqDataMDArr =
requestData.getMetadataMap().values();
+ Iterator reqDataArrMDIterator = reqDataMDArr.iterator();

+ while (reqDataArrMDIterator.hasNext()) {
+ Metadata tokenMD = (Metadata)reqDataArrMDIterator.next();

- logger.debug("LSGlobalTokenAction: MESSAGE That data has this
metadata: " + tokenMD);
+ logger.debug("LSGlobalTokenAction: MESSAGE That data has
this metadata: " + tokenMD);

- //now we need to update/add this to the XMLDB
- query = XQUERY_UPDATE_DECLARE;
- query = query +
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ tokenMD.getId() + "']";
+ //now we need to update/add this to the XMLDB
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE +
"/nmwg:store[@type='"
+
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"
+
+ tokenMD.getId() + "']";
+ edbres =
(XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+
+ logger.debug("LSGlobalTokenAction: Staring Query: " +
query);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\""
+ LS_GLOBAL_PEER_CONTAINER +
+
"\")/nmwg:metadata[@id='"
+ tokenMD.getId() + "'])";
+ edbres =
(XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+
+ logger.debug("LSGlobalTokenAction: Staring Query: " +
query);
+ }
+ else {
+ throw new
SystemException("error.common.storage.xmldb.query", "No database exists");
+ }

- logger.debug("LSGlobalTokenAction: MESSAGE Query: " + query);
- results = lsUtil.getDBContents(xmlStorageManager, query);
-
- if(results[0].equals("")) {

- //not in there, add it
- logger.debug("LSGlobalTokenAction: MESSAGE MD Ready,
inserting...");
+ if(results[0].equals("")) {

+ //not in there, add it
+ logger.debug("LSGlobalTokenAction: MESSAGE MD
Ready, inserting...");

- String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT
+
- XMLUtils.serializeXML(tokenMD) + " into
/nmwg:store[@type='"
+
- LS_GLOBAL_PEER_COLLECTION_TYPE + "']";
- xmlStorageManager.fetch(insert);
-
- logger.debug("LSGlobalTokenAction: MESSAGE Done Adding");

- }
- else {
- //in there, so do nothing...
- }
- }
- }
- lsTokenUtil.sendExternalSummaryMessage(xmlStorageManager);
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ String insert = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_INSERT +
+ XMLUtils.serializeXML(tokenMD) +
" into
/nmwg:store[@type='"
+
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
"']";
+ xmlStorageManager.fetch(insert);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath = "/";
+ String insertData =
XMLUtils.serializeXML(tokenMD);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insert(LS_GLOBAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath, insertData);
+ }
+
+ logger.debug("LSGlobalTokenAction: MESSAGE Done
Adding");
+ }
+ else {
+ //in there, so do nothing...
+ }
+ }
+ }
+ lsTokenUtil.sendExternalSummaryMessage(xmlStorageManager);

//now we sleep and send out 'new' token (this needs some work)

- //set the scheduler to sometime in the future...
- scheduler.advanceScheduler(1000 *
Integer.parseInt(lsTokenUtil.getLsTokenFrequency()) * metadataCol.size());
+ //set the scheduler to sometime in the future...
+ scheduler.advanceScheduler(1000 *
Integer.parseInt(lsTokenUtil.getLsTokenFrequency()) * metadataCol.size());

//now return (thank) our token friend

- //Prepare result code (put it into the response)
- Message response = new Message();
- response.setType("LSGlobalTokenResponse");
+ //Prepare result code (put it into the response)
+ Message response = new Message();
+ response.setType("LSGlobalTokenResponse");

- ResultCode rc = createResultCode("result.success", "GlobalToken -
We Got the message...");
+ ResultCode rc = createResultCode("result.success", "GlobalToken
- We Got the message...");

- Metadata[] responseMetadata = { rc.getMetadata() };
- Data[] responseData = null;
- if(rc.getData() !=null) {
- responseData = new Data[1];
- responseData[0] = rc.getData();
- }
+ 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]);
- }
+ response.addChild(responseData[0]);
+ for(int j=0; j < responseMetadata.length; j++){
+ response.addChild(responseMetadata[j]);
+ }

- logger.debug("LSGlobalTokenAction: Message Arriving Stop");
- return response;
- }
+ logger.debug("LSGlobalTokenAction: Message Arriving Stop");
+ return response;
+ }
}

-
+
+ /**
+ * run action
+ */
public void runAction() {
iterations++;
if(iterations <= 2) {
- logger.info("LSGlobalTokenAction: Don't run the first 2 times (let
the data register)");
+ logger.info("LSGlobalTokenAction: Don't run the first 2 times
(let the data register)");
}
else {
- logger.info("LSGlobalTokenAction: Run as scheduled action for the
[" +
- iterations + "] time");
- try {
- performAction(null); //input unimportant
- }
- catch (PerfSONARException e) {
- //Catch nothing for now?
- }
+ logger.info("LSGlobalTokenAction: Run as scheduled action for
the [" + iterations + "] time");
+ try {
+ performAction(null); //input unimportant
+ }
+ catch (PerfSONARException e) {
+ //Catch nothing for now?
+ }
}
}
+

} //LSGlobalTokenAction

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGlobalTokenLoader.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGlobalTokenLoader.java
2006-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGlobalTokenLoader.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -6,22 +6,26 @@
import
org.perfsonar.commons.auxiliary.components.configuration.ConfigurationComponent;
import org.perfsonar.commons.auxiliary.components.logger.LoggerComponent;
import org.perfsonar.commons.auxiliary.components.simplescheduler.Scheduler;
+
import org.perfsonar.service.commons.exceptions.SystemException;
import org.perfsonar.service.commons.storage.StorageManager;

/**
* Initializes token mechanism into the simple scheduler
- * @author Jason Zurawski
* @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/

public class LSGlobalTokenLoader implements AuxiliaryComponent {

+
// ----------------------------------------------------- constants

private static final int DEFAULT_RUN_INTERVAL = 30; //seconds

+
private static final int MINIMAL_RUN_INTERVAL = 10; //seconds


@@ -29,12 +33,16 @@
//---------------------------------------------- private variables

private String componentName = "ls_global_token_loader";
+

private LoggerComponent logger;
+

private ConfigurationComponent config;
+

private Scheduler scheduler;
+

private StorageManager storage;

@@ -42,114 +50,105 @@

// ------------------------------------------------ public methods

- public void initComponent() throws SystemException {
+ public void initComponent() throws SystemException {
+ //get Logger
+ try {
+ logger = (LoggerComponent)AuxiliaryComponentManager.
+ getInstance().getComponent(ComponentNames.LOGGER);

+ }
+ catch(SystemException e) {
+ String m = "Cannot get logger component ";
+ throw new SystemException("error.common.no_logger",m);
+ }

-
- //get Logger
- try {
- logger = (LoggerComponent)AuxiliaryComponentManager.
- getInstance().getComponent(ComponentNames.LOGGER);
- }
- catch (SystemException e) {
- String m = "Cannot get logger component ";
- throw new SystemException("error.common.no_logger",m);
- }
-

- //get config (base)
- try {
- config = (ConfigurationComponent)AuxiliaryComponentManager.
- getInstance().getComponent(ComponentNames.CONFIG);
- }
- catch (SystemException e) {
- String m = "Cannot get config component ";
- throw new SystemException("error.common.no_configuration", m);

- }
+ //get config (base)
+ try {
+ config = (ConfigurationComponent)AuxiliaryComponentManager.
+ getInstance().getComponent(ComponentNames.CONFIG);
+ }
+ catch(SystemException e) {
+ String m = "Cannot get config component ";
+ throw new SystemException("error.common.no_configuration", m);

+ }

- //SPECIFIC TO TOKEN
-
+
+ //get interval - parameter "component.ls_global_token_loader.interval"
+ int interval = DEFAULT_RUN_INTERVAL;
+ try {
+ String intervalVal = config.getProperty("component." +
componentName + ".interval");
+ interval = Integer.parseInt(intervalVal);
+ }
+ catch(RuntimeException e) {
+ //possibly not an integer - keep default interval
+ interval = DEFAULT_RUN_INTERVAL;
+ }
+ catch(SystemException e) {
+ //no property - keep default interval
+ interval = DEFAULT_RUN_INTERVAL;
+ }

- //get interval - parameter "component.ls_global_token_loader.interval"
- int interval = DEFAULT_RUN_INTERVAL;
- try {
- String intervalVal = config.getProperty("component." +
- componentName +
- ".interval");
- interval = Integer.parseInt(intervalVal);
- }
- catch (RuntimeException e) {
- //possibly not an integer - keep default interval
- interval = DEFAULT_RUN_INTERVAL;
- }
- catch (SystemException e) {
- //no property - keep default interval
- interval = DEFAULT_RUN_INTERVAL;
- }
+ //if too small take default?
+ if(interval < MINIMAL_RUN_INTERVAL) {
+ interval = DEFAULT_RUN_INTERVAL;
+ }

- //if too small take default?
- if (interval < MINIMAL_RUN_INTERVAL) {
- interval = DEFAULT_RUN_INTERVAL;
- }
-
- logger.debug("LSGlobalTokenLoader: parameter RUN_INTERVAL = [" +
- interval + "] seconds");
-
-
- //get scheduler - parameter
"component.ls_global_token_loader.scheduler_component"
- try {
- String schedulerVal = config.getProperty("component." +
- componentName +
- ".scheduler_component");
- logger.debug("LSGlobalTokenLoader: parameter SCHEDULER=" +
schedulerVal);
- scheduler = (Scheduler)AuxiliaryComponentManager.
- getInstance().getComponent(schedulerVal);
+ logger.debug("LSGlobalTokenLoader: parameter RUN_INTERVAL = [" +
+ interval + "] seconds");
+
+ //get scheduler - parameter
"component.ls_global_token_loader.scheduler_component"
+ try {
+ String schedulerVal = config.getProperty("component." +
componentName + ".scheduler_component");
+ logger.debug("LSGlobalTokenLoader: parameter SCHEDULER=" +
schedulerVal);
+ scheduler = (Scheduler)AuxiliaryComponentManager.
+ getInstance().getComponent(schedulerVal);

- if (scheduler == null) {
- throw new SystemException("error.ls.no_scheduler",
- "No such component in Auxiliary" +
- "ComponentManager: " + schedulerVal);
+ if(scheduler == null) {
+ throw new SystemException("error.ls.no_scheduler",
+ "No such component in Auxiliary" +
+ "ComponentManager: " + schedulerVal);
+ }
+ }
+ catch(SystemException e) {
+ throw new SystemException("error.ls.no_scheduler",
+ "LSGlobalTokenLoader: no [component." +
+ componentName + ".scheduler_component] "
+
+ "parameter. " + e.getMessage());
}
- }
- catch (SystemException e) {
- throw new SystemException("error.ls.no_scheduler",
- "LSGlobalTokenLoader: no [component." +
- componentName + ".scheduler_component] " +
- "parameter. " + e.getMessage());
- }

-
- //get storage
- try {
-
- String smType = config.getProperty("service.ls.db_type");
- storage = XmlTypeLSServiceEngine.getStorageManager(smType);
- logger.debug("LSGlobalTokenLoader: parameter STORAGE=" + smType);

- if (storage == null) {
- throw new SystemException("error.ls.no_storage",
- "No such component in AuxiliaryComponent"
+
- "Manager");
+ //get storage
+ try {
+ String smType = config.getProperty("service.ls.db_type");
+ storage = XmlTypeLSServiceEngine.getStorageManager(smType);
+ logger.debug("LSGlobalTokenLoader: parameter STORAGE=" + smType);

+ if(storage == null) {
+ throw new SystemException("error.ls.no_storage",
+ "No such component in
AuxiliaryComponent" +
+ "Manager");
+ }
+ }
+ catch(SystemException e) {
+ throw new SystemException("error.ls.no_storage",
+ "LSGlobalTokenLoader: no [component." +
+ componentName +
+ ".storage_component] parameter. " +
+ e.getMessage());
}
- }
- catch (SystemException e) {
- throw new SystemException("error.ls.no_storage",
- "LSGlobalTokenLoader: no [component." +
- componentName +
- ".storage_component] parameter. " +
- e.getMessage());
- }
-
- //add token action to scheduler (note time*1000 because it's
- // in seconds and scheduler needs time in ms
+ //add token action to scheduler (note time*1000 because it's
+ // in seconds and scheduler needs time in ms

- scheduler.addSchedulerTask(interval * 1000, new
LSGlobalTokenAction(storage));
+ scheduler.addSchedulerTask(interval * 1000, new
LSGlobalTokenAction(storage));
}
+

public String getComponentName() {
- return componentName;
+ return componentName;
}

+
public void setComponentName(String name) {
- componentName = name;
+ componentName = name;
}

+
}

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSKeepaliveAction.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSKeepaliveAction.java
2006-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSKeepaliveAction.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -3,6 +3,7 @@
import org.ggf.ns.nmwg.base.v2_0.Data;
import org.ggf.ns.nmwg.base.v2_0.Message;
import org.ggf.ns.nmwg.base.v2_0.Metadata;
+
import org.perfsonar.service.commons.exceptions.DataFormatException;
import org.perfsonar.service.commons.exceptions.RequestException;
import org.perfsonar.service.commons.exceptions.SystemException;
@@ -12,6 +13,8 @@
* KEEPALIVE - register/keepalive Action
*
* @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/
public class LSKeepaliveAction extends LSGenericRegisterAction {
@@ -19,25 +22,17 @@

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

-
-
// ------------------------------------------------------------
Constructor

-
public LSKeepaliveAction(StorageManager xmlStorageManager)
throws SystemException {
-
super(xmlStorageManager);
-
}

+

// --------------------------------------------------------- Public
methods

-
-
-
-
public Message performAction(Message request)
throws SystemException, RequestException, DataFormatException {

@@ -64,7 +59,6 @@
}

if (checkIfKeyIsRegistered(keyValue, xmlStorageManager)) {
-
logger.debug("LSKeepaliveAction: KEEPALIVE - update time");

//key is registered, update time
@@ -97,9 +91,7 @@
response.addChild(responseMetadata[j]);
}

- //Return response
- return response;
-
+ return response;
}



Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLocalTokenAction.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLocalTokenAction.java
2006-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLocalTokenAction.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -6,18 +6,23 @@
import java.util.Map;

import org.ggf.ns.nmwg.base.v2_0.*;
+import org.ggf.ns.nmwg.base.v2_0.Message;
+import org.ggf.ns.nmwg.base.v2_0.Store;
+
import org.perfsonar.commons.util.XMLUtils;
import org.perfsonar.commons.util.MathUtil;
+
import org.perfsonar.service.commons.exceptions.DataFormatException;
import org.perfsonar.service.commons.exceptions.RequestException;
import org.perfsonar.service.commons.exceptions.SystemException;
import org.perfsonar.service.commons.storage.StorageManager;
+import
org.perfsonar.commons.auxiliary.components.simplescheduler.SchedulerAction;

-import org.ggf.ns.nmwg.base.v2_0.Message;
-import org.ggf.ns.nmwg.base.v2_0.Store;
-import
org.perfsonar.commons.auxiliary.components.simplescheduler.SchedulerAction;
import org.perfsonar.service.commons.exceptions.PerfSONARException;
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;

import org.perfsonar.commons.auxiliary.AuxiliaryComponent;
import org.perfsonar.commons.auxiliary.AuxiliaryComponentManager;
@@ -28,76 +33,86 @@

/**
* TOKEN Action
- *
- * @author Jason Zurawski
+ * @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/
public class LSLocalTokenAction extends LSGenericRegisterAction implements
SchedulerAction {

- private Scheduler scheduler;
-
+
// --------------------------------------------------------------
Constants
-
+
+ /**
+ * allow replacement of items in the xmldb
+ */
private final static boolean DEFAULT_ALLOW_REPLACE = true;
-
+
+
/**
* name of property in config file
*/
private static final String LS_TOKEN_INTERVAL =
"component.ls_local_token_loader.interval";

+

// ----------------------------------------------------- Instance
variables
+
+ /**
+ * scheduler
+ */
+ private Scheduler scheduler;
+

/**
* allow the replacement of already registered data
*/
private boolean allowReplaceIfAlreadyRegistered = DEFAULT_ALLOW_REPLACE;
+

/**
* lsUtil
*/
private LSUtilities lsUtil;

+
/**
* lsTokenUtil
*/
private LSTokenUtilities lsTokenUtil;
+

/**
* number of iteration (for debugging)
*/
long iterations = 0;
+


// -----------------------------------------------------------
Constructor

- public LSLocalTokenAction(StorageManager xmlStorageManager)
- throws SystemException {
+ public LSLocalTokenAction(StorageManager xmlStorageManager) throws
SystemException {
super(xmlStorageManager);

String temp = null;
try {
- temp =
configuration.getProperty("component.ls_local_token_loader.scheduler_component");
-
+ temp =
configuration.getProperty("component.ls_local_token_loader.scheduler_component");

logger.debug("\tLSLocalTokenAction: parameter SCHEDULER=" + temp);
-
- scheduler = (Scheduler)AuxiliaryComponentManager.
- getInstance().getComponent(temp);

+ scheduler =
(Scheduler)AuxiliaryComponentManager.getInstance().getComponent(temp);

}
- catch (SystemException e) {
+ catch(SystemException e) {
temp = null;
}

lsUtil = new LSUtilities();
-
lsTokenUtil = new LSTokenUtilities(logger, configuration, lsUtil,
LS_TOKEN_INTERVAL);
}


// --------------------------------------------------------- Public
methods

- public Message performAction(Message request)
- throws SystemException, RequestException, DataFormatException {
+ public Message performAction(Message request) throws SystemException,
+ RequestException, DataFormatException {
String query = null;
String[] results = null;
XmlDbResult edbres = null;
@@ -110,341 +125,447 @@

//If we get a null request, the scheduler clicked off before we saw
a token
if(request == null) {
-
- if(iterations <= 3) {
- logger.debug("LSLocalTokenAction: Testing to make sure THIS LS
is in the peer list");
+
+ //make sure that THIS ls is loaded into the peer list
+ if(iterations <= 3) {
+ logger.debug("LSLocalTokenAction: Testing to make sure THIS
LS is in the peer list");

- //do a query to be sure we are in there...
- query = XQUERY_UPDATE_DECLARE;
- query = query +
"/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ lsUtil.getLsAccessPoint() + "']";

- logger.debug("LSLocalTokenAction: Query: " + query);
- results = lsUtil.getDBContents(xmlStorageManager, query);
-
- if(results[0].equals("")) {
- logger.debug("LSLocalTokenAction: We are not In there!");
+ //get the contents of the peer list
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
+ query = XQUERY_UPDATE_DECLARE +
"/nmwg:store[@type='"
+
+ LS_LOCAL_PEER_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"
+
+ lsUtil.getLsAccessPoint() + "']";

+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();

+
+ logger.debug("LSLocalTokenAction: Query: " + query);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_LOCAL_PEER_CONTAINER +
+
"\")/nmwg:metadata[@id='"
+ lsUtil.getLsAccessPoint() + "'])";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+
+ logger.debug("LSLocalTokenAction: Query: " + query);
+ }
+ else {
+ throw new
SystemException("error.common.storage.xmldb.query", "No database exists");
+ }
+
+ //see what was returned
+ if(results[0].equals("")) {
+ //if we got nothing, we need to be inserted into the peer
list
+
+ logger.debug("LSLocalTokenAction: We are not In there!");

- //if we are not, make us
- Metadata peerMetadata = new Metadata();
- peerMetadata.setId(lsUtil.getLsAccessPoint());
- peerMetadata.addChild(lsTokenUtil.getLSPeerKey());
+ //if we are not, make us
+ Metadata peerMetadata = new Metadata();
+ peerMetadata.setId(lsUtil.getLsAccessPoint());
+ peerMetadata.addChild(lsTokenUtil.getLSPeerKey());

- //insert us
- logger.debug("LSLocalTokenAction: MD Ready, inserting...");
+ //insert us
+ logger.debug("LSLocalTokenAction: MD Ready,
inserting...");

- String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT +
- XMLUtils.serializeXML(peerMetadata) + " into
/nmwg:store[@type='"
+
- LS_LOCAL_PEER_COLLECTION_TYPE + "']";
- xmlStorageManager.fetch(insert);
-
- logger.debug("LSLocalTokenAction: Done Adding Us");
- }
- else {
- logger.debug("LSLocalTokenAction: We are already in the LS, do
nothing...");
- }
- }
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ String insert = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_INSERT + XMLUtils.serializeXML(peerMetadata) +
+ " into
/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE + "']";
+ xmlStorageManager.fetch(insert);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath = "/";
+ String insertData =
XMLUtils.serializeXML(peerMetadata);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insert(LS_LOCAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath, insertData);
+ }
+
+ logger.debug("LSLocalTokenAction: Done Adding Us");
+ }
+ else {
+ logger.debug("LSLocalTokenAction: We are already in the
LS, do nothing...");
+ }
+ }


- logger.debug("LSLocalTokenAction: Scheduled Case Starting");
+ logger.debug("LSLocalTokenAction: Scheduled Case Starting");

- //we need to look at everyone's familiarity, there are three cases:
- //
- // 1) Iterations <= 3; this is the first time we are running so we
should
- // send out 'hello' summaries to people on our list.
- //
- // 2) Iterations > 3, but everyone's familiarity is '0'; It is like
we are
- // joining for the first time, so we should send out a 'hello'
summary to
- // anyone that will listen.
- //
- // 3) Iterations > 3, but the familiarity of at least one person is
'1';
- // we can still try to send out a 'real' token at this point,
don't
- // resort to re-introducing yourself
- //
+ //we need to look at everyone's familiarity, there are three
cases:
+ //
+ // 1) Iterations <= 3; this is the first time we are running so
we should
+ // send out 'hello' summaries to people on our list.
+ //
+ // 2) Iterations > 3, but everyone's familiarity is '0'; It is
like we are
+ // joining for the first time, so we should send out a 'hello'
summary to
+ // anyone that will listen.
+ //
+ // 3) Iterations > 3, but the familiarity of at least one person
is '1';
+ // we can still try to send out a 'real' token at this point,
don't
+ // resort to re-introducing yourself
+ //

- //get the contents of LSLocalPeers
- query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE + "']";
- 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);
- }
+
+ //get the contents of LSLocalPeers
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE + "']";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
{
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_LOCAL_PEER_CONTAINER + "\"))";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else {
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
+ }
+
+ 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");
+ Store result = (Store)XMLUtils.stringToElement(results[0],
lsUtil.getParserFile(), "store");

- 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);
- }
- sortedList = lsTokenUtil.formPeerArray(metadataCol);
+ 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);
+ }
+ sortedList = lsTokenUtil.formPeerArray(metadataCol);
+
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE + "for $p in
/nmwg:store[@type='"
+
+ LS_LOCAL_PEER_COLLECTION_TYPE +
"']//nmwg:parameter[@name='familiar']
return $p/text()";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+
+ logger.debug("LSLocalTokenAction: Staring Query: " + query);
+ }
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
{
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_LOCAL_PEER_CONTAINER +
+
"\")//nmwg:parameter[@name='familiar']
return $p/text())";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+
+ logger.debug("LSLocalTokenAction: Staring Query: " + query);
+ }
+ else {
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
+ }

- query = XQUERY_UPDATE_DECLARE + "for $p in
/nmwg:store[@type='"
+
- LS_LOCAL_PEER_COLLECTION_TYPE +
"']//nmwg:parameter[@name='familiar']
return $p/text()";
-
- logger.debug("LSLocalTokenAction: Staring Query: " + query);
- results = lsUtil.getDBContents(xmlStorageManager, query);
-
- boolean emptyFlag = true;
- for(int i = 0; i < results[0].length()-1; i++) {
- if(!(results[0].charAt(i) == '0')) {
- emptyFlag = false;
- break;
- }
- }
+ boolean emptyFlag = true;
+ for(int i = 0; i < results[0].length()-1; i++) {
+ if(!(results[0].charAt(i) == '0')) {
+ emptyFlag = false;
+ break;
+ }
+ }

- if((iterations <= 3) || (emptyFlag == true)) {
+ if((iterations <= 3) || (emptyFlag == true)) {

- logger.debug("LSLocalTokenAction: Starting Case 1/2");
+ logger.debug("LSLocalTokenAction: Starting Case 1/2");

- //If this is the first time we are running (of we just can't
seem to
- // reach anyone), update the peer lists to indicate that we don't
know
- // anyone
- String update = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_VALUE;
- update = update +
"/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE +
-
"']//nmwg:parameter[@name='familiar']
with '0'";
- xmlStorageManager.fetch(update);
+ //If this is the first time we are running (of we just can't
seem to
+ // reach anyone), update the peer lists to indicate that we
don't know
+ // anyone
+
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
+ String update = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_VALUE;
+ update = update +
"/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE +
+
"']//nmwg:parameter[@name='familiar']
with '0'";
+ xmlStorageManager.fetch(update);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath =
"//nmwg:parameter[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_LOCAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath, "0");
+ }

- for(c = 0; c < metadataCol.size(); c++) {
- sortedList[c][1] = "0";
- }
+ for(c = 0; c < metadataCol.size(); c++) {
+ sortedList[c][1] = "0";
+ }

- //send the summary message to your peers
- lsTokenUtil.sendSummaryMessage(xmlStorageManager, "local");
+ //send the summary message to your peers
+ lsTokenUtil.sendExternalSummaryMessage(xmlStorageManager);

- logger.debug("LSLocalTokenAction: Done sending out messages");
-
- //NB: how long of a backoff do we need here?
- }
- else {
- //case 3
+ logger.debug("LSLocalTokenAction: Done sending out
messages");
+ //NB: how long of a backoff do we need here?
+ }
+ else {
+ //case 3

- logger.debug("LSLocalTokenAction: Starting Case 3.");
+ logger.debug("LSLocalTokenAction: Starting Case 3.");

- //now we make a metadata that describes who we are...
- Metadata reqMetadata = new Metadata();
- reqMetadata = lsUtil.createLSMetadata(reqMetadata,
MathUtil.calculateId(lsUtil.getLsAccessPoint(), lsUtil.getLsServiceRank()));
+ //now we make a metadata that describes who we are...
+ Metadata reqMetadata = new Metadata();
+ reqMetadata = lsUtil.createLSMetadata(reqMetadata,
MathUtil.calculateId(lsUtil.getLsAccessPoint(), lsUtil.getLsServiceRank()));

- Data reqData = new Data();
- reqData.setId("tokenData");
-
reqData.setMetadataIdRef(MathUtil.calculateId(lsUtil.getLsAccessPoint(),
lsUtil.getLsServiceRank()));
+ Data reqData = new Data();
+ reqData.setId("tokenData");
+
reqData.setMetadataIdRef(MathUtil.calculateId(lsUtil.getLsAccessPoint(),
lsUtil.getLsServiceRank()));

- metadataCol = result.getMetadataMap().values();
- Iterator metadataColIterator = metadataCol.iterator();
- while (metadataColIterator.hasNext()) {
- Metadata tempMetadata = (Metadata)metadataColIterator.next();

- reqData.addChild(tempMetadata);
- }
+ metadataCol = result.getMetadataMap().values();
+ Iterator metadataColIterator = metadataCol.iterator();
+ while (metadataColIterator.hasNext()) {
+ Metadata tempMetadata =
(Metadata)metadataColIterator.next();
+ reqData.addChild(tempMetadata);
+ }

- //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, "token",
"local");
+ //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,
"token", "local");

- //make token message
- // put them in a message, then insert
- Message registerMessage = new Message();
- registerMessage.setType("LSTokenRequest");
- registerMessage.addChild(reqMetadata);
- registerMessage.addChild(reqData);
- registerMessage.addChild(reqParams);
+ //make token message
+ // put them in a message, then insert
+ Message registerMessage = new Message();
+ registerMessage.setType("LSTokenRequest");
+ registerMessage.addChild(reqMetadata);
+ registerMessage.addChild(reqData);
+ registerMessage.addChild(reqParams);

- logger.debug("LSLocalTokenAction: CASE 3: MSG: " +
registerMessage);
+ logger.debug("LSLocalTokenAction: CASE 3: MSG: " +
registerMessage);

- boolean successFlag = false;
- for(int b = 0; b < metadataCol.size(); b++) {
-
- //don't insert into ourself...
- //if(!(sortedList[b][0].equals(lsUtil.getLsAccessPoint()))) {
-
- logger.debug("LSLocalTokenAction: CASE3 Sending token message
to: " + sortedList[b][0] + " - " + sortedList[b][1]);
- try {
- Message response =
lsTokenUtil.sendRequest(sortedList[b][0], registerMessage);

- if(response != null) {
- //check to see if we succeeded:
- Metadata resp = getMetadataFromRequest(response);
- if (resp == null) {
- logger.debug("LSLocalTokenAction: CASE3 No metadata in
peer response");
- }
- else {
- logger.debug("LSLocalTokenAction: CASE3 response: " +
resp.toString());
-
if((resp.getEventType().getEventType()).equals("result.success")) {
- if(Integer.parseInt(sortedList[b][1]) < 3) {
+ boolean successFlag = false;
+ for(int b = 0; b < metadataCol.size(); b++) {
+ //don't insert into ourself...
+
//if(!(sortedList[b][0].equals(lsUtil.getLsAccessPoint()))) {
+ logger.debug("LSLocalTokenAction: CASE3 Sending token
message to: " + sortedList[b][0] + " - " + sortedList[b][1]);
+ try {
+ Message response =
lsTokenUtil.sendRequest(sortedList[b][0], registerMessage);

+ if(response != null) {
+ //check to see if we succeeded:
+ Metadata resp =
getMetadataFromRequest(response);
+ if(resp == null) {
+ logger.debug("LSLocalTokenAction: CASE3
No metadata in peer response");
+ }
+ else {
+ logger.debug("LSLocalTokenAction: CASE3
response: " + resp.toString());
+
if((resp.getEventType().getEventType()).equals("result.success")) {
+ if(Integer.parseInt(sortedList[b][1])
< 3) {
+

+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ 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);
+ }
+ else if(xmlStorageManager
instanceof BerkeleyDbXmlStorageManager) {
+ String xPath =
"//nmwg:parameters[@id='"
+ sortedList[b][0] +
+
"']/nmwg:parameter[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_LOCAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE,
xPath, Integer.toString((Integer.parseInt(sortedList[b][1]))+1));
+ }

+
+ sortedList[b][1] =
Integer.toString(Integer.parseInt(sortedList[b][1]) + 1);
+ }
+ b = metadataCol.size() + 1;

- //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);
- }
- b = metadataCol.size() + 1;
+ //advance the scheduler (wait for the
real token)
+ //scheduler.advanceScheduler(1000 *
Integer.parseInt(getLsTokenFrequency()) * metadataCol.size());
+ successFlag = true;
+ }
+ else {
+ logger.debug("LSLocalTokenAction:
CASE3 Success Code from peer not found");
+ }
+ }
+ }
+ else {
+ logger.debug("LSLocalTokenAction: CASE3 Null
response when talking to peer");
+
+ if(Integer.parseInt(sortedList[b][1]) > 0) {
+ //update the peers list

- //advance the scheduler (wait for the real token)
- //scheduler.advanceScheduler(1000 *
Integer.parseInt(getLsTokenFrequency()) * metadataCol.size());
- successFlag = true;
- }
- else {
- logger.debug("LSLocalTokenAction: CASE3 Success Code
from peer not found");
- }
- }
- }
- else {
- logger.debug("LSLocalTokenAction: CASE3 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);
- }
- }
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ String update = XQUERY_UPDATE_DECLARE
+ XQUERY_UPDATE_VALUE +
+
"/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);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath =
"//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
+
"[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_LOCAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath,
Integer.toString((Integer.parseInt(sortedList[b][1]))-1));
+ }
+
+ sortedList[b][1] =
Integer.toString(Integer.parseInt(sortedList[b][1])-1);
+ }
+ }
+ }
+ catch(Exception e) {
+ logger.debug("LSLocalTokenAction: CASE3
Exception: " + e.toString());
+ throw new
SystemException("error.ls.client_error",
+ "Error sending to
client LS " +
+ e.getMessage());
+ }
+ //}
}
- catch(Exception e) {
- logger.debug("LSLocalTokenAction: CASE3 Exception: " +
e.toString());
- throw new SystemException("error.ls.client_error",
- "Error sending to client LS " +
- e.getMessage());
- }
- //}
- }

- if(successFlag == false) {
- //advance the scheduler (wait for the real token)
- //scheduler.advanceScheduler(1000 *
Integer.parseInt(getLsTokenFrequency()) * metadataCol.size());

+ if(successFlag == false) {
+ //advance the scheduler (wait for the real token)
+ //scheduler.advanceScheduler(1000 *
Integer.parseInt(getLsTokenFrequency()) * metadataCol.size());
+ }
+ //NB: how long of a backoff do we need here?
}
- //NB: how long of a backoff do we need here?
- }
- logger.debug("LSLocalTokenAction: Scheduled Case Stopping");
- return null;
- }
- else {
- //This is the case when we get a token messgage
+ logger.debug("LSLocalTokenAction: Scheduled Case Stopping");
+ return null;
+ }
+ else {
+ //This is the case when we get a token messgage

- logger.debug("LSLocalTokenAction: Message Arriving Start: " +
request.toString());
+ logger.debug("LSLocalTokenAction: Message Arriving Start: " +
request.toString());

// pause the scheduler while we do our work?

- //Get Metadata from request
- Metadata requestMetadata = getMetadataFromRequest(request);
- if (requestMetadata==null) {
- String m="LSRegisterAction: No metadata in request";
- logger.error(m);
- throw new SystemException("error.ls.no_metadata", m);
- }
+ //Get Metadata from request
+ Metadata requestMetadata = getMetadataFromRequest(request);
+ if(requestMetadata == null) {
+ String m="LSRegisterAction: No metadata in request";
+ logger.error(m);
+ throw new SystemException("error.ls.no_metadata", m);
+ }

+ //add information to the peers list
+ lsTokenUtil.addToPeerList(xmlStorageManager, requestMetadata,
"local");
+
+ //now deal with the data that this person sent
+ logger.debug("LSLocalTokenAction: MESSAGE Dealing with the data
block");
+ Collection reqDataArr = request.getDataMap().values();
+ if(reqDataArr.size() < 1) {
+ String m = "LSRegisterAction: " +
+ "Request must have at least one data element -
trigger) ";
+ logger.error(m);
+ throw new SystemException("error.ls.no_data_trigger", m);
+ }

- //add information to the peers list
- lsTokenUtil.addToPeerList(xmlStorageManager, requestMetadata,
"local");
-
-
- //now deal with the data that this person sent
- logger.debug("LSLocalTokenAction: MESSAGE Dealing with the data
block");
- Collection reqDataArr = request.getDataMap().values();
- if(reqDataArr.size() < 1) {
- String m = "LSRegisterAction: " +
- "Request must have at least one data element -
trigger) ";
- logger.error(m);
- throw new SystemException("error.ls.no_data_trigger", m);
- }
-
- //there really should be only one
- Iterator reqDataArrIterator = reqDataArr.iterator();
- while (reqDataArrIterator.hasNext()) {
- Data requestData = (Data)reqDataArrIterator.next();
+ //there really should be only one
+ Iterator reqDataArrIterator = reqDataArr.iterator();
+ while (reqDataArrIterator.hasNext()) {
+ Data requestData = (Data)reqDataArrIterator.next();

- //each data is a collection of MDs...
- logger.debug("LSLocalTokenAction: MESSAGE Found Data: " +
requestData.toString());
+ //each data is a collection of MDs...
+ logger.debug("LSLocalTokenAction: MESSAGE Found Data: " +
requestData.toString());

- Collection reqDataMDArr = requestData.getMetadataMap().values();
- Iterator reqDataArrMDIterator = reqDataMDArr.iterator();
- while (reqDataArrMDIterator.hasNext()) {
- Metadata tokenMD = (Metadata)reqDataArrMDIterator.next();
+ Collection reqDataMDArr =
requestData.getMetadataMap().values();
+ Iterator reqDataArrMDIterator = reqDataMDArr.iterator();

+ while (reqDataArrMDIterator.hasNext()) {
+ Metadata tokenMD = (Metadata)reqDataArrMDIterator.next();

- logger.debug("LSLocalTokenAction: MESSAGE That data has this
metadata: " + tokenMD);
+ logger.debug("LSLocalTokenAction: MESSAGE That data has
this metadata: " + tokenMD);

- //now we need to update/add this to the XMLDB
- query = XQUERY_UPDATE_DECLARE;
- query = query +
"/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ tokenMD.getId() + "']";
+ //now we need to update/add this to the XMLDB
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE +
"/nmwg:store[@type='"
+
+ LS_LOCAL_PEER_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"
+
+ tokenMD.getId() + "']";
+ edbres =
(XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+
+ logger.debug("LSLocalTokenAction: Staring Query: " +
query);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\""
+ LS_LOCAL_PEER_CONTAINER +
+
"\")/nmwg:metadata[@id='"
+ tokenMD.getId() + "'])";
+ edbres =
(XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+
+ logger.debug("LSLocalTokenAction: Staring Query: " +
query);
+ }
+ else {
+ throw new
SystemException("error.common.storage.xmldb.query", "No database exists");
+ }

- logger.debug("LSLocalTokenAction: MESSAGE Query: " + query);
- results = lsUtil.getDBContents(xmlStorageManager, query);
-
- if(results[0].equals("")) {

- //not in there, add it
- logger.debug("LSLocalTokenAction: MESSAGE MD Ready,
inserting...");
+ if(results[0].equals("")) {

+ //not in there, add it
+ logger.debug("LSLocalTokenAction: MESSAGE MD Ready,
inserting...");

- String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT
+
- XMLUtils.serializeXML(tokenMD) + " into
/nmwg:store[@type='"
+
- LS_LOCAL_PEER_COLLECTION_TYPE + "']";
- xmlStorageManager.fetch(insert);
-
- logger.debug("LSLocalTokenAction: MESSAGE Done Adding");

- }
- else {
- //in there, so do nothing...
- }
- }
- }
- lsTokenUtil.sendSummaryMessage(xmlStorageManager, "local");
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ String insert = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_INSERT +
+ XMLUtils.serializeXML(tokenMD) +
" into
/nmwg:store[@type='"
+
+ LS_LOCAL_PEER_COLLECTION_TYPE +
"']";
+ xmlStorageManager.fetch(insert);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath = "/";
+ String insertData =
XMLUtils.serializeXML(tokenMD);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insert(LS_LOCAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath, insertData);
+ }
+
+ logger.debug("LSLocalTokenAction: MESSAGE Done
Adding");
+ }
+ else {
+ //in there, so do nothing...
+ }
+ }
+ }
+ lsTokenUtil.sendExternalSummaryMessage(xmlStorageManager);

//now we sleep and send out 'new' token (this needs some work)

- //set the scheduler to sometime in the future...
- scheduler.advanceScheduler(1000 *
Integer.parseInt(lsTokenUtil.getLsTokenFrequency()) * metadataCol.size());
+ //set the scheduler to sometime in the future...
+ scheduler.advanceScheduler(1000 *
Integer.parseInt(lsTokenUtil.getLsTokenFrequency()) * metadataCol.size());

//now return (thank) our token friend

- //Prepare result code (put it into the response)
- Message response = new Message();
- response.setType("LSLocalTokenResponse");
+ //Prepare result code (put it into the response)
+ Message response = new Message();
+ response.setType("LSLocalTokenResponse");

- ResultCode rc = createResultCode("result.success", "LocalToken -
We Got the message...");
+ ResultCode rc = createResultCode("result.success", "LocalToken -
We Got the message...");

- Metadata[] responseMetadata = { rc.getMetadata() };
- Data[] responseData = null;
- if(rc.getData() !=null) {
- responseData = new Data[1];
- responseData[0] = rc.getData();
- }
+ 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]);
- }
+ response.addChild(responseData[0]);
+ for(int j=0; j < responseMetadata.length; j++){
+ response.addChild(responseMetadata[j]);
+ }

- logger.debug("LSLocalTokenAction: Message Arriving Stop");
- return response;
- }
+ logger.debug("LSLocalTokenAction: Message Arriving Stop");
+ return response;
+ }
}

-
+
+ /**
+ * run action
+ */
public void runAction() {
iterations++;
if(iterations <= 2) {
- logger.info("LSLocalTokenAction: Don't run the first 2 times (let
the data register)");
+ logger.info("LSLocalTokenAction: Don't run the first 2 times
(let the data register)");
}
else {
- logger.info("LSLocalTokenAction: Run as scheduled action for the
[" +
- iterations + "] time");
- try {
- performAction(null); //input unimportant
- }
- catch (PerfSONARException e) {
- //Catch nothing for now?
- }
+ logger.info("LSLocalTokenAction: Run as scheduled action for the
[" + iterations + "] time");
+ try {
+ performAction(null); //input unimportant
+ }
+ catch (PerfSONARException e) {
+ //Catch nothing for now?
+ }
}
}
+

} //LSLocalTokenAction

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLocalTokenLoader.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLocalTokenLoader.java
2006-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLocalTokenLoader.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -6,22 +6,26 @@
import
org.perfsonar.commons.auxiliary.components.configuration.ConfigurationComponent;
import org.perfsonar.commons.auxiliary.components.logger.LoggerComponent;
import org.perfsonar.commons.auxiliary.components.simplescheduler.Scheduler;
+
import org.perfsonar.service.commons.exceptions.SystemException;
import org.perfsonar.service.commons.storage.StorageManager;

/**
* Initializes token mechanism into the simple scheduler
- * @author Jason Zurawski
* @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/

public class LSLocalTokenLoader implements AuxiliaryComponent {

+
// ----------------------------------------------------- constants

private static final int DEFAULT_RUN_INTERVAL = 30; //seconds

+
private static final int MINIMAL_RUN_INTERVAL = 10; //seconds


@@ -29,12 +33,16 @@
//---------------------------------------------- private variables

private String componentName = "ls_local_token_loader";
+

private LoggerComponent logger;
+

private ConfigurationComponent config;
+

private Scheduler scheduler;
+

private StorageManager storage;

@@ -42,114 +50,105 @@

// ------------------------------------------------ public methods

- public void initComponent() throws SystemException {
+ public void initComponent() throws SystemException {
+ //get Logger
+ try {
+ logger = (LoggerComponent)AuxiliaryComponentManager.
+ getInstance().getComponent(ComponentNames.LOGGER);

+ }
+ catch(SystemException e) {
+ String m = "Cannot get logger component ";
+ throw new SystemException("error.common.no_logger",m);
+ }

-
- //get Logger
- try {
- logger = (LoggerComponent)AuxiliaryComponentManager.
- getInstance().getComponent(ComponentNames.LOGGER);
- }
- catch (SystemException e) {
- String m = "Cannot get logger component ";
- throw new SystemException("error.common.no_logger",m);
- }
-

- //get config (base)
- try {
- config = (ConfigurationComponent)AuxiliaryComponentManager.
- getInstance().getComponent(ComponentNames.CONFIG);
- }
- catch (SystemException e) {
- String m = "Cannot get config component ";
- throw new SystemException("error.common.no_configuration", m);

- }
+ //get config (base)
+ try {
+ config = (ConfigurationComponent)AuxiliaryComponentManager.
+ getInstance().getComponent(ComponentNames.CONFIG);
+ }
+ catch(SystemException e) {
+ String m = "Cannot get config component ";
+ throw new SystemException("error.common.no_configuration", m);

+ }

- //SPECIFIC TO TOKEN
-
+
+ //get interval - parameter "component.ls_local_token_loader.interval"
+ int interval = DEFAULT_RUN_INTERVAL;
+ try {
+ String intervalVal = config.getProperty("component." +
componentName + ".interval");
+ interval = Integer.parseInt(intervalVal);
+ }
+ catch(RuntimeException e) {
+ //possibly not an integer - keep default interval
+ interval = DEFAULT_RUN_INTERVAL;
+ }
+ catch(SystemException e) {
+ //no property - keep default interval
+ interval = DEFAULT_RUN_INTERVAL;
+ }

- //get interval - parameter "component.ls_local_token_loader.interval"
- int interval = DEFAULT_RUN_INTERVAL;
- try {
- String intervalVal = config.getProperty("component." +
- componentName +
- ".interval");
- interval = Integer.parseInt(intervalVal);
- }
- catch (RuntimeException e) {
- //possibly not an integer - keep default interval
- interval = DEFAULT_RUN_INTERVAL;
- }
- catch (SystemException e) {
- //no property - keep default interval
- interval = DEFAULT_RUN_INTERVAL;
- }
+ //if too small take default?
+ if(interval < MINIMAL_RUN_INTERVAL) {
+ interval = DEFAULT_RUN_INTERVAL;
+ }

- //if too small take default?
- if (interval < MINIMAL_RUN_INTERVAL) {
- interval = DEFAULT_RUN_INTERVAL;
- }
-
- logger.debug("LSLocalTokenLoader: parameter RUN_INTERVAL = [" +
- interval + "] seconds");
-
-
- //get scheduler - parameter
"component.ls_local_token_loader.scheduler_component"
- try {
- String schedulerVal = config.getProperty("component." +
- componentName +
- ".scheduler_component");
- logger.debug("LSLocalTokenLoader: parameter SCHEDULER=" +
schedulerVal);
- scheduler = (Scheduler)AuxiliaryComponentManager.
- getInstance().getComponent(schedulerVal);
+ logger.debug("LSLocalTokenLoader: parameter RUN_INTERVAL = [" +
+ interval + "] seconds");
+
+ //get scheduler - parameter
"component.ls_local_token_loader.scheduler_component"
+ try {
+ String schedulerVal = config.getProperty("component." +
componentName + ".scheduler_component");
+ logger.debug("LSLocalTokenLoader: parameter SCHEDULER=" +
schedulerVal);
+ scheduler = (Scheduler)AuxiliaryComponentManager.
+ getInstance().getComponent(schedulerVal);

- if (scheduler == null) {
- throw new SystemException("error.ls.no_scheduler",
- "No such component in Auxiliary" +
- "ComponentManager: " + schedulerVal);
+ if(scheduler == null) {
+ throw new SystemException("error.ls.no_scheduler",
+ "No such component in Auxiliary" +
+ "ComponentManager: " + schedulerVal);
+ }
+ }
+ catch(SystemException e) {
+ throw new SystemException("error.ls.no_scheduler",
+ "LSLocalTokenLoader: no [component." +
+ componentName + ".scheduler_component] "
+
+ "parameter. " + e.getMessage());
}
- }
- catch (SystemException e) {
- throw new SystemException("error.ls.no_scheduler",
- "LSLocalTokenLoader: no [component." +
- componentName + ".scheduler_component] " +
- "parameter. " + e.getMessage());
- }

-
- //get storage
- try {
-
- String smType = config.getProperty("service.ls.db_type");
- storage = XmlTypeLSServiceEngine.getStorageManager(smType);
- logger.debug("LSLocalTokenLoader: parameter STORAGE=" + smType);

- if (storage == null) {
- throw new SystemException("error.ls.no_storage",
- "No such component in AuxiliaryComponent"
+
- "Manager");
+ //get storage
+ try {
+ String smType = config.getProperty("service.ls.db_type");
+ storage = XmlTypeLSServiceEngine.getStorageManager(smType);
+ logger.debug("LSLocalTokenLoader: parameter STORAGE=" + smType);

+ if(storage == null) {
+ throw new SystemException("error.ls.no_storage",
+ "No such component in
AuxiliaryComponent" +
+ "Manager");
+ }
+ }
+ catch(SystemException e) {
+ throw new SystemException("error.ls.no_storage",
+ "LSLocalTokenLoader: no [component." +
+ componentName +
+ ".storage_component] parameter. " +
+ e.getMessage());
}
- }
- catch (SystemException e) {
- throw new SystemException("error.ls.no_storage",
- "LSLocalTokenLoader: no [component." +
- componentName +
- ".storage_component] parameter. " +
- e.getMessage());
- }
-
- //add token action to scheduler (note time*1000 because it's
- // in seconds and scheduler needs time in ms
+ //add token action to scheduler (note time*1000 because it's
+ // in seconds and scheduler needs time in ms

- scheduler.addSchedulerTask(interval * 1000, new
LSLocalTokenAction(storage));
+ scheduler.addSchedulerTask(interval * 1000, new
LSLocalTokenAction(storage));
}
+

public String getComponentName() {
- return componentName;
+ return componentName;
}

+
public void setComponentName(String name) {
- componentName = name;
+ componentName = name;
}

+
}

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-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLookupAction.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -1,10 +1,13 @@
package org.perfsonar.service.lookupService.xmlType;

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.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.bdbxml.BerkeleyDbXmlStorageManager;
@@ -15,21 +18,24 @@
* LOOKUP Action
*
* @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/
public class LSLookupAction extends LSAction {

+
// --------------------------------------------------------------
Constants
-
-
+
private final static String XPATH_QUERY_TYPE = "service.lookup.xpath";

+
private final static String XQUERY_QUERY_TYPE = "service.lookup.xquery";


+
// ----------------------------------------------------- instance
variables

-
/**
* Supported query types, eventType (e.g. "xquery")
*/
@@ -39,23 +45,23 @@
};


+
// -----------------------------------------------------------
Constructor

-
public LSLookupAction(StorageManager xmlStorageManager)
throws SystemException {
-
- super(xmlStorageManager);
-
+ super(xmlStorageManager);
}

+

// --------------------------------------------------------- Public
methods
-
-
- public Message performAction(Message request)
- throws SystemException, RequestException, DataFormatException {

+ public Message performAction(Message request)
+ throws SystemException, RequestException, DataFormatException {
+ String[] results;
+ XmlDbResult edbres;
+
logger.debug(
"XmlTypeLSServiceEngine: LS lookup - action LOOKUP started");

@@ -75,12 +81,10 @@
//get eventType and query type
String queryType;
try {
-
- EventType eventType =
- requestMetadata.getEventType();
+ EventType eventType = requestMetadata.getEventType();
queryType = eventType.getEventType();
-
- } catch (NullPointerException e) {
+ }
+ catch(NullPointerException e) {
String m =
"XmlTypeLSServiceEngine: no eventType in metadata (type of
query)";
logger.fatal(m);
@@ -92,27 +96,24 @@

// check if the query type can be satisfied
boolean queryTypeCanBeSatisfied = false;
-
- for (int itr=0; itr<acceptedQueryTypes.length; itr++) {
- if (acceptedQueryTypes[itr].equals(queryType)) {
+ for(int itr=0; itr < acceptedQueryTypes.length; itr++) {
+ if(acceptedQueryTypes[itr].equals(queryType)) {
queryTypeCanBeSatisfied = true;
break;
}
}
- if (!queryTypeCanBeSatisfied) {
+ if(!queryTypeCanBeSatisfied) {
String m = "XmlTypeLSServiceEngine: Query Type specified: ["
+ queryType + "] is not supported";
logger.fatal(m);
throw new SystemException("error.ls.querytype_not_suported", m);
}
- logger.debug("LSLookupAction: Query type [" + queryType
- + "] is supported");
+ logger.debug("LSLookupAction: Query type [" + queryType + "] is
supported");

//If query type is supported
//Get xquery:subject from metadata
String query;
try {
-
org.ggf.ns.nmwg.tools.org.perfsonar.
service.lookup.xquery.v1_0.Subject requestSubject =
(org.ggf.ns.nmwg.tools.org.perfsonar.
@@ -122,7 +123,7 @@
logger.info(requestSubject.toString());

query = requestSubject.getSubject();
- logger.debug("LSLookupAction: query="+query);
+ logger.debug("LSLookupAction: query=" + query);

} catch (NullPointerException e) {
String m =
@@ -137,36 +138,27 @@

//Performing XQuery operation on the database
logger.debug("LSLookupAction: perform query");
- String[] results;
-
-
+
+
System.out.println(" LSq0,"+System.currentTimeMillis());
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);

- ///////////////////////////////////////////////////////////////
-
- /* XQuery */
- XmlDbResult edbres;
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
- xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
- {
- edbres = (XmlDbResult)xmlStorageManager.fetch(query);
results = (String[])edbres.getResultAsStringArray();
}
- else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
- {
- edbres = (XmlDbResult)xmlStorageManager.fetch(query);
- results = (String[])edbres.getResultAsStringArray();
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
}
- else
- throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
+ else {
+ throw new SystemException("error.common.storage.xmldb.query", "No
database exists");
+ }
+
+ System.out.println(" LSq1," + System.currentTimeMillis());

- ///////////////////////////////////////////////////////////////
+ logger.debug("LSLookupAction: Got [[" + results.length + "]] results
from DB");

- System.out.println(" LSq1,"+System.currentTimeMillis());
-
- logger.debug("LSLookupAction: Got [["+
- results.length+"]] results from DB");
-
//TODO: if results.length==0 --> return error code or not?

//create ServiceEngineResponse and put there the results
@@ -194,17 +186,14 @@
for (int i=0; i<results.length; i++) {
org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.Datum datum =
new org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.Datum();
-
datum.setValue(results[i]);
- responseData.setDatum(datum);
-
+ responseData.setDatum(datum);
}

//Encapsulate Data in Response Message
response.addChild(responseData);

- return response;
-
+ return response;
}



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-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSRegisterAction.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -4,20 +4,24 @@
import java.util.Iterator;

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.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.bdbxml.BerkeleyDbXmlStorageManager;
import
org.perfsonar.service.commons.storage.xmldb.exist.xmlrpc.ExistDbXmlrpcXmlStorageManager;
import
org.perfsonar.service.commons.storage.xmldb.exist.rest.ExistDbHttpXmlStorageManager;

-
/**
* REGISTER Action
- *
* @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/
public class LSRegisterAction extends LSGenericRegisterAction {
@@ -27,28 +31,30 @@

private final static boolean DEFAULT_ALLOW_REPLACE = true;

+
+
// ----------------------------------------------------- Instance
variables

-
private boolean allowReplaceIfAlreadyRegistered = DEFAULT_ALLOW_REPLACE;

+
/**
* lsUtil
*/
private LSUtilities lsUtil;

+
/**
* lsTokenUtil
*/
private LSTokenUtilities lsTokenUtil;
+


// -----------------------------------------------------------
Constructor
-
-
+
public LSRegisterAction(StorageManager xmlStorageManager)
- throws SystemException {
-
+ throws SystemException {
super(xmlStorageManager);

//read service.ls.lookup_info_timeout
@@ -56,18 +62,23 @@
String prop = null;
try {
prop = configuration.getProperty("service.ls.allow_replace");
- } catch (SystemException ex) {
- prop=null;
+ }
+ catch(SystemException ex) {
+ prop = null;
}

- if (prop!=null) {
- if ("yes".equalsIgnoreCase(prop)||"true".equalsIgnoreCase(prop))
+ if(prop != null) {
+ if("yes".equalsIgnoreCase(prop)||"true".equalsIgnoreCase(prop)) {
allowReplaceIfAlreadyRegistered = true;
- else
+ }
+ else {
allowReplaceIfAlreadyRegistered = false;
- } else
+ }
+ }
+ else {
allowReplaceIfAlreadyRegistered = DEFAULT_ALLOW_REPLACE;
-
+ }
+
logger.debug("LSRegisterAction: service.ls.lookup_info_timeout="+
allowReplaceIfAlreadyRegistered);

@@ -82,41 +93,43 @@

public Message performAction(Message request)
throws SystemException, RequestException, DataFormatException {
+ String query = null;
+ String[] results = null;
+ XmlDbResult edbres = null;

- logger.debug(
- "LSRegisterAction: LS register - action REGISTER started");
+ logger.debug("LSRegisterAction: LS register - action REGISTER
started");

-
//is this a summary message?
org.ggf.ns.nmwg.base.v2_0.Parameter summaryParam = null;
if(request.getParameters() != null) {
- summaryParam =
request.getParameters().getParameterByName("summary");
- }
+ summaryParam =
request.getParameters().getParameterByName("summary");
+ }
+
if(summaryParam == null) {
- logger.debug("LSRegisterAction: LS register - this is not a
summary registration ...");
+ logger.debug("LSRegisterAction: LS register - this is not a
summary registration ...");
}
else {
- logger.debug("LSRegisterAction: LS register - summary registration
...");
+ logger.debug("LSRegisterAction: LS register - summary
registration ...");
}

-
//Get Metadata from request
Metadata requestMetadata = getMetadataFromRequest(request);
- if(requestMetadata==null) {
- String m="LSRegisterAction: No metadata in request in summary";
- logger.error(m);
- throw new SystemException("error.ls.no_metadata", m);
+ if(requestMetadata == null) {
+ String m="LSRegisterAction: No metadata in request in summary";
+ logger.error(m);
+ throw new SystemException("error.ls.no_metadata", m);
}

//get accessPoint from Metadata - obligatory element

String accessPoint = null;
try {
- accessPoint = ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
- requestMetadata.getSubject()).getService().
+ accessPoint = ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+ requestMetadata.getSubject()).getService().
getAccessPoint().getAccessPoint();
- } catch (RuntimeException e) {
- logger.debug("LSRegisterAction: no accessPoint in summary");
+ }
+ catch(RuntimeException e) {
+ logger.debug("LSRegisterAction: no accessPoint in summary");
}

//Try to get Key from Metadata
@@ -128,40 +141,37 @@

//check keyValue

- if(keyValue == null) { //REGISTER
+ if(keyValue == null) {
+ //REGISTER

- //let the key value be accesspoint
- logger.debug("LSRegisterAction: key = accessPoint");
- keyValue = accessPoint;
-
- } else { //UPDATE
- //always enable register especially if data is registered!
- allowReplaceIfAlreadyRegistered = true;
+ //let the key value be accesspoint
+ logger.debug("LSRegisterAction: key = accessPoint");
+ keyValue = accessPoint;
+ }
+ else {
+ //UPDATE
+ //always enable register especially if data is registered!
+ allowReplaceIfAlreadyRegistered = true;

- //but check the key if it's already been in the DB
- if(checkIfKeyIsRegistered(keyValue, xmlStorageManager)) {
+ //but check the key if it's already been in the DB
+ if(checkIfKeyIsRegistered(keyValue, xmlStorageManager)) {

- String m = "LSRegisterAction: key from request [" + keyValue +
- "] not found in the storage. " +
- "Can't UPDATE such data, because can't determine what data
should be updated";
- logger.debug(m);
- throw new DataFormatException("error.ls.update.key_not_found",
m);
-
- }
+ String m = "LSRegisterAction: key from request [" + keyValue
+
+ "] not found in the storage. " +
+ "Can't UPDATE such data, because can't determine
what data should be updated";
+ logger.debug(m);
+ throw new
DataFormatException("error.ls.update.key_not_found", m);
+ }
}
-
-logger.debug("LSRegisterAction: 1");

// check keyValue again, it may be accessPoint now
- if(keyValue==null) {
- String m = "LSRegisterAction: Cannot register " +
- "Lookup Info without Metadata/accessPoint or Key";
- logger.error(m);
- throw new SystemException("error.ls.no_key", m);
+ if(keyValue == null) {
+ String m = "LSRegisterAction: Cannot register " +
+ "Lookup Info without Metadata/accessPoint or Key";
+ logger.error(m);
+ throw new SystemException("error.ls.no_key", m);
}

-
-logger.debug("LSRegisterAction: 2");

//========check data========

@@ -170,160 +180,175 @@
//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) {
- String m = "LSRegisterAction: " +
- "Request must have at least one data element - trigger)
";
- logger.error(m);
- throw new SystemException("error.ls.no_data_trigger", m);
+ String m = "LSRegisterAction: " +
+ "Request must have at least one data element -
trigger) ";
+ logger.error(m);
+ 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");
+ 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

- //we need to 'back up' the stuff from global guys
+ //get the contents of LSLocalPeers
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE + "']";
+ edbres =
(XmlDbResult)xmlStorageManager.fetch(query);
+ results =
(String[])edbres.getResultAsStringArray();
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE +
"data(collection(\"" + LS_LOCAL_PEER_CONTAINER + "\"))";
+ edbres =
(XmlDbResult)xmlStorageManager.fetch(query);
+ results =
(String[])edbres.getResultAsStringArray();
+ }
+ else {
+ throw new
SystemException("error.common.storage.xmldb.query", "No database exists");
+ }
+
+ if(results[0].equals("")) {
+ String m = "LSRegisterAction: Peer List is
empty; please populate it with at least one peer.";
+ logger.error(m);
+ throw new
SystemException("error.ls.peer_list_empty", m);
+ }

- //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");
+ 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);
+ Collection metadataCol = null;
+ metadataCol = result.getMetadataMap().values();

+ if(metadataCol.size() < 1) {
+ String m = "LSRegisterAction: 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
+ //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");
+ //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);
+ //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++) {

- //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:
+ 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){
+ 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;
- }
- }
+ 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

+ if(xmlStorageManager
instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager
instanceof ExistDbHttpXmlStorageManager) {
+ 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);
+ }
+ else if(xmlStorageManager
instanceof BerkeleyDbXmlStorageManager) {
+ String xPath =
"//nmwg:parameters[@id='"
+ sortedList[b][0] +
+
"']/nmwg:parameter[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_LOCAL_PEER_CONTAINER,

+
XQUERY_UPDATE_DECLARE, xPath,
Integer.toString((Integer.parseInt(sortedList[b][1]))+1));
+ }

+
+ 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
+
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ 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);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath =
"//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
+
"[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_GLOBAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath,
Integer.toString(Integer.parseInt(sortedList[b][1])-1));
+ }
+
+ 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");
- }
- }
- }
+ }
+ else
if(sumParam.getParameterValue().equals("global-backup")) {
+ lsTokenUtil.addToPeerList(xmlStorageManager,
requestMetadata, "global");
+ }
+ }
+ }
}


-
-logger.debug("LSRegisterAction: 5");
-
-

-
//=========process with register/update===========

String removeUpdate = null;
@@ -332,101 +357,103 @@
//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="+
- allowReplaceIfAlreadyRegistered);
- if(summaryParam == null) {
- if (allowReplaceIfAlreadyRegistered) {
+ logger.debug("LSRegisterAction: Key is already " +
+ "registered in DB (metadata), allow_update="+
+ allowReplaceIfAlreadyRegistered);
+ if(summaryParam == null) {
+ if (allowReplaceIfAlreadyRegistered) {

- logger.debug("LSRegisterAction: old data will be replaced by
new set of data");
+ logger.debug("LSRegisterAction: old data will be
replaced by new set of data");

- if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
- xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
- {
- String remove = XQUERY_UPDATE_DECLARE +
- "for $md in
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ keyValue + "'] return " +
- XQUERY_UPDATE_DELETE
+ "$md";
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ String remove = XQUERY_UPDATE_DECLARE +
+ "for $md in
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE +
+
"']/nmwg:metadata[@id='"
+ keyValue + "'] return " +
+ XQUERY_UPDATE_DELETE + "$md";
xmlStorageManager.fetch(remove); //XQuery

remove = "";
remove = XQUERY_UPDATE_DECLARE +
- "for $d in
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE +
-
"']/nmwg:data[@metadataIdRef='"
+ keyValue + "'] return " +
- XQUERY_UPDATE_DELETE + "$d";
+ "for $d in
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE +
+
"']/nmwg:data[@metadataIdRef='"
+ keyValue + "'] return " +
+ XQUERY_UPDATE_DELETE + "$d";
xmlStorageManager.fetch(remove); //XQuery
- }
- else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
- {
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
String xPath =
"/nmwg:metadata[@id=\""
+ keyValue +"\"]";

((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_STORE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
xPath =
"/nmwg:data[@metadataIdRef=\""
+ keyValue +"\"]";

((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_STORE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
- }
+ }
+ }
+ else {
+ String m = "LSRegisterAction: Can't replace data";
+ logger.error(m);
+ //TODO: what to do? Remove everything?
+ throw new SystemException("error.ls.cant_replace_data",
m);
+ }
+ }
+ else {

-
-
- } else {
- String m = "LSRegisterAction: Can't replace data";
- logger.error(m);
- //TODO: what to do? Remove everything?
- throw new SystemException("error.ls.cant_replace_data", m);

- }
- }
- else {
-
//summary data always gets updated (don't look at the conf file info)

- logger.debug("LSRegisterAction: old data summary data is always
replaced");
-
- String remove = XQUERY_UPDATE_DECLARE +
- "for $md in
/nmwg:store[@type='"
+ LS_CACHE_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ keyValue + "'] return " +
- XQUERY_UPDATE_DELETE + "$md";
- xmlStorageManager.fetch(remove); //XQuery
+ logger.debug("LSRegisterAction: old data summary data is
always replaced");
+
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
{
+ String remove = XQUERY_UPDATE_DECLARE +
+ "for $md in
/nmwg:store[@type='"
+ LS_CACHE_COLLECTION_TYPE +
+
"']/nmwg:metadata[@id='"
+ keyValue + "'] return " +
+ XQUERY_UPDATE_DELETE + "$md";
+ xmlStorageManager.fetch(remove); //XQuery

- remove = "";
- remove = XQUERY_UPDATE_DECLARE +
- "for $d in
/nmwg:store[@type='"
+ LS_CACHE_COLLECTION_TYPE +
-
"']/nmwg:data[@metadataIdRef='"
+ keyValue + "'] return " +
- XQUERY_UPDATE_DELETE + "$d";
- xmlStorageManager.fetch(remove); //XQuery
- }
-
+ remove = "";
+ remove = XQUERY_UPDATE_DECLARE +
+ "for $d in
/nmwg:store[@type='"
+ LS_CACHE_COLLECTION_TYPE +
+
"']/nmwg:data[@metadataIdRef='"
+ keyValue + "'] return " +
+ XQUERY_UPDATE_DELETE + "$d";
+ xmlStorageManager.fetch(remove); //XQuery
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath =
"/nmwg:metadata[@id=\""
+ keyValue +"\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_CACHE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+ xPath =
"/nmwg:data[@metadataIdRef=\""
+ keyValue +"\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_CACHE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+ }
+ }
}

//change metadata id
requestMetadata.setId(accessPoint);

//make sure we update the store vs the cache
- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
- xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
- {
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {

-
- String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
- insert = insert + XMLUtils.serializeXML(requestMetadata) + " into
/nmwg:store[@type='";
- if(summaryParam == null) {
- insert = insert + LS_STORE_COLLECTION_TYPE + "']";
- }
- else {
- insert = insert + LS_CACHE_COLLECTION_TYPE + "']";
- }
- xmlStorageManager.fetch(insert);
-
-
- }
- else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
- {
- String insertData = XMLUtils.serializeXML(requestMetadata);
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).insertDocument(LS_STORE_CONTAINER,
insertData);
- }
+ String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
+ insert = insert + XMLUtils.serializeXML(requestMetadata) + " into
/nmwg:store[@type='";
+ if(summaryParam == null) {
+ insert = insert + LS_STORE_COLLECTION_TYPE + "']";
+ }
+ else {
+ insert = insert + LS_CACHE_COLLECTION_TYPE + "']";
+ }
+ xmlStorageManager.fetch(insert);
+ }
+ else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {
+ String insertData = null;
+ if(summaryParam == null) {
+ insertData = XMLUtils.serializeXML(requestMetadata);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insertDocument(LS_STORE_CONTAINER,
insertData);
+ }
+ else {
+ insertData = XMLUtils.serializeXML(requestMetadata);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insertDocument(LS_CACHE_CONTAINER,
insertData);
+ }
+ }

//Prepare XQuery data

@@ -439,55 +466,58 @@
Iterator reqDataArrIterator = reqDataArr.iterator();

while (reqDataArrIterator.hasNext()) {
- Data requestData = (Data)reqDataArrIterator.next();
+ Data requestData = (Data)reqDataArrIterator.next();

-// //TODO: what to check?
-// if (requestData==null) {
-// String m = "XmlTypeLSServiceEngine: Cannot register " +
-// "Lookup Info without Data";
-// logger.error(m);
-// throw new SystemException(m);
-// }
+// //TODO: what to check?
+// if (requestData==null) {
+// String m = "XmlTypeLSServiceEngine: Cannot register " +
+// "Lookup Info without Data";
+// logger.error(m);
+// throw new SystemException(m);
+// }

- //change data references
-
- requestData.setId(accessPoint+"/"+currTime+"/"+datanum);
- requestData.setMetadataIdRef(accessPoint);
+ //change data references
+ requestData.setId(accessPoint+"/"+currTime+"/"+datanum);
+ requestData.setMetadataIdRef(accessPoint);

- //Prepare XQuery for Data
- //fill updateData structure
+ //Prepare XQuery for Data
+ //fill updateData structure


- if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager
||
- xmlStorageManager instanceof ExistDbHttpXmlStorageManager)
- {
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager ) {

//make sure we update the store vs the cache
- String insert2 = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
- insert2 = insert2 + XMLUtils.serializeXML(requestData) + " into
/nmwg:store[@type='";
- if(summaryParam == null) {
- insert2 = insert2 + LS_STORE_COLLECTION_TYPE + "']";
- }
- else {
- insert2 = insert2 + LS_CACHE_COLLECTION_TYPE + "']";
- }
- xmlStorageManager.fetch(insert2);
+ String insert2 = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
+ insert2 = insert2 + XMLUtils.serializeXML(requestData) + "
into
/nmwg:store[@type='";
+ if(summaryParam == null) {
+ insert2 = insert2 + LS_STORE_COLLECTION_TYPE + "']";
+ }
+ else {
+ insert2 = insert2 + LS_CACHE_COLLECTION_TYPE + "']";
+ }
+ xmlStorageManager.fetch(insert2);


- }
- else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
- {
- String insertData =
XMLUtils.serializeXML(requestData);
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).insertDocument(LS_STORE_CONTAINER,
insertData);
- }
-
-
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String insertData = null;
+ if(summaryParam == null) {
+ insertData = XMLUtils.serializeXML(requestMetadata);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insertDocument(LS_STORE_CONTAINER,
insertData);
+ }
+ else {
+ insertData = XMLUtils.serializeXML(requestMetadata);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insertDocument(LS_CACHE_CONTAINER,
insertData);
+ }
+ }
datanum++;
}

//if no errors and exceptions reported/thrown, put metadata and
data into DB

- logger.debug("LSRegisterAction: "+((removeUpdate!=null)?"remove old
entries":"")+", insert metadata and ["+updateData.length+"] data elements");
+ logger.debug("LSRegisterAction: "+((removeUpdate!=null)?"remove old
entries":"")+
+ ", insert metadata and ["+updateData.length+"] data
elements");

//update control time - last modification
updateTime(keyValue, xmlStorageManager); //TODO: change
xmlStorageManager to LSstorage-control
@@ -504,8 +534,8 @@

Data[] responseData = null;
if(rc.getData() !=null) {
- responseData = new Data[1];
- responseData[0] = rc.getData();
+ responseData = new Data[1];
+ responseData[0] = rc.getData();
}

Message response = new Message();
@@ -514,16 +544,16 @@
response.setType("LSRegisterResponse");

response.addChild(responseData[0]);
- for(int j=0; j<responseMetadata.length; j++){
- response.addChild(responseMetadata[j]);
+ for(int j=0; j < responseMetadata.length; j++){
+ response.addChild(responseMetadata[j]);
}
return response;
}


+
// -------------------------------------------------------- Private
methods
-
-
+
/**
* Create element containing lsKey.
*
xpath:////nmwg:key/nmwg:parameters/nmwg:parameter[@id='lsKey']
@@ -531,7 +561,6 @@
* @return Key element
*/
private org.ggf.ns.nmwg.base.v2_0.Key createLSKey(String keyValue) {
-
org.ggf.ns.nmwg.base.v2_0.Key key =
new org.ggf.ns.nmwg.base.v2_0.Key();

@@ -546,9 +575,7 @@
parameter.setParameterValue(keyValue);
parameters.addParameter(parameter);
key.setParameters(parameters);
-
return key;
-
}



Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSSummary.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSSummary.java
2006-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSSummary.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -6,12 +6,15 @@
import org.ggf.ns.nmwg.base.v2_0.Data;

import
org.perfsonar.commons.auxiliary.components.simplescheduler.SchedulerAction;
+
import org.perfsonar.commons.util.XMLUtils;
import org.perfsonar.commons.util.MathUtil;
+
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.XmlDbDataRepository;
@@ -19,6 +22,9 @@
import org.perfsonar.service.commons.storage.xmldb.exist.ExistDbFactory;
import org.perfsonar.service.commons.storage.xmldb.XmlDbConstants;
import
org.perfsonar.service.commons.storage.xmldb.exist.rest.ExistDbHTTPAccess;
+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;

import java.io.IOException;
import java.io.File;
@@ -36,214 +42,238 @@

/**
* Action that summarizes database content
- * @author Jason Zurawski
* @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/
-
public class LSSummary extends LSAction implements SchedulerAction {
+

- // ----------------------------------------------------- Constants
+ // ----------------------------------------------------- Constants

- /**
- * name of property in config file
- */
- private static final String LS_SUMMARY_STYLESHEET =
"component.ls_summary_loader.stylesheet";
+ /**
+ * name of property in config file
+ */
+ private static final String LS_SUMMARY_STYLESHEET =
"component.ls_summary_loader.stylesheet";


- // -------------------------------------------- Instance variables

- /**
- * location of summary sheet
- */
- private String summarySheet = "";
+ // -------------------------------------------- Instance variables

- /**
- * Storage Manager Type
- */
- private String smType;
+ /**
+ * location of summary sheet
+ */
+ private String summarySheet = "";

- /**
- * lsUtil
- */
- private LSUtilities lsUtil;
+
+ /**
+ * Storage Manager Type
+ */
+ private String smType;
+
+
+ /**
+ * lsUtil
+ */
+ private LSUtilities lsUtil;


- /**
- * number of iteration (for debugging)
- */
- long iterations = 0;
+ /**
+ * number of iteration (for debugging)
+ */
+ long iterations = 0;
+
+

- // --------------------------------------------------- Constructor
+ // --------------------------------------------------- Constructor

- /**
- * LSSummary constructor
- */
- public LSSummary(StorageManager xmlStorageManager)
- throws SystemException {
+ /**
+ * LSSummary constructor
+ */
+ public LSSummary(StorageManager xmlStorageManager)
+ throws SystemException {

- super(xmlStorageManager);
+ super(xmlStorageManager);

- String temp = null;
- try {
- temp = configuration.getProperty(LS_SUMMARY_STYLESHEET);
- }
- catch (SystemException e) {
- temp = null;
- }
+ String temp = null;
+ try {
+ temp = configuration.getProperty(LS_SUMMARY_STYLESHEET);
+ }
+ catch(SystemException e) {
+ temp = null;
+ }

- if(temp != null) {
- setSummarySheet(temp);
- }
- else {
- // we need to throw an error or something...
- }
- logger.debug("LSSummary: LS XSLT=" + getSummarySheet());
+ if(temp != null) {
+ setSummarySheet(temp);
+ }
+ else {
+ // we need to throw an error or something...
+ }
+ logger.debug("LSSummary: LS XSLT=" + getSummarySheet());

- smType = configuration.getProperty("service.ls.db_type");
+ smType = configuration.getProperty("service.ls.db_type");

- lsUtil = new LSUtilities();
- }
+ lsUtil = new LSUtilities();
+ }

- /**
- * Set the value of the summary sheet
- */
- public void setSummarySheet(String newSummarySheet) {
- summarySheet = newSummarySheet;
- return;
- }

- /**
- * get the value of the summary sheet
- */
- public String getSummarySheet() {
- return summarySheet;
- }
+ /**
+ * Set the value of the summary sheet
+ */
+ public void setSummarySheet(String newSummarySheet) {
+ summarySheet = newSummarySheet;
+ return;
+ }

- /**
- * Scheduler Action for LS Summary
- */
- public Message performAction(Message request)
- throws SystemException, RequestException, DataFormatException {
- String output = null;
-
- logger.debug("LSSummary: Entering Action");

- //get the contents of LSStore
-
- String query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE + "']";
- String[] results = lsUtil.getDBContents(xmlStorageManager, query) ;
+ /**
+ * get the value of the summary sheet
+ */
+ public String getSummarySheet() {
+ return summarySheet;
+ }

- //Make sure we got something (don't want to do this on an empty set)
- if(results[0] != null) {
- logger.debug("LSSummary: XSLT Starting...");
- try {
+
+ /**
+ * Scheduler Action for LS Summary
+ */
+ public Message performAction(Message request)
+ throws SystemException, RequestException, DataFormatException {
+ String output = null;
+ String query = null;
+ String[] results = null;
+ XmlDbResult edbres = null;
+
+ logger.debug("LSSummary: Entering Action");
+
+ //get the contents of LSStore
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE + "']";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_STORE_CONTAINER + "\"))";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else {
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
+ }
+
+ //Make sure we got something (don't want to do this on an empty set)
+ if(results[0] != null) {
+ logger.debug("LSSummary: XSLT Starting...");
+ try {

- //create a factory and transformer using the stylesheet
- TransformerFactory factory = TransformerFactory.newInstance();
- Transformer transformer = factory.newTemplates(new StreamSource(new
- File(getSummarySheet()))).newTransformer();
+ //create a factory and transformer using the stylesheet
+ TransformerFactory factory =
TransformerFactory.newInstance();
+ Transformer transformer = factory.newTemplates(new
StreamSource(new File(getSummarySheet()))).newTransformer();

- //need a spot to store the output (temporarily)

- StringWriter sw = new StringWriter();
- transformer.transform(new StreamSource(new StringReader(
- results[0])), new StreamResult(sw));
+ //need a spot to store the output (temporarily)

+ StringWriter sw = new StringWriter();
+ transformer.transform(new StreamSource(new
StringReader(results[0])), new StreamResult(sw));

- output = sw.toString();

- } catch (Exception err) {
- logger.error("LSSummary: Caught XSLT Processing Error");
- }
+ output = sw.toString();

+ }
+ catch(Exception err) {
+ logger.error("LSSummary: Caught XSLT Processing Error");

+ }

- //We essentually get back a string (but its really a message) so
- // using a new XMLUtils function we can get this into NMWG format
- Message result = (Message)XMLUtils.stringToElement(output,
lsUtil.getParserFile(), "message");
+ //We essentually get back a string (but its really a message) so
+ // using a new XMLUtils function we can get this into NMWG format
+ Message result = (Message)XMLUtils.stringToElement(output,
lsUtil.getParserFile(), "message");

- //Get the Metadata from the summary
- Metadata resultMetadata = getMetadataFromRequest(result);
- if(resultMetadata == null) {
- String m="LSSummary: No metadata in request in summary";
- logger.error(m);
- throw new SystemException("error.ls.no_metadata", m);
- }
+ //Get the Metadata from the summary
+ Metadata resultMetadata = getMetadataFromRequest(result);
+ if(resultMetadata == null) {
+ String m="LSSummary: No metadata in request in summary";
+ logger.error(m);
+ throw new SystemException("error.ls.no_metadata", m);
+ }

- //Get the data from the summary (check and make sure we have at least
one)
- Collection resultDataArr = result.getDataMap().values();
- if(resultDataArr.size() < 1) {
- String m = "LSSummary: " +
- "Request must have at least one data element - trigger) ";
- logger.error(m);
- throw new SystemException("error.ls.no_data_trigger", m);
- }
+ //Get the data from the summary (check and make sure we have at
least one)
+ Collection resultDataArr = result.getDataMap().values();
+ if(resultDataArr.size() < 1) {
+ String m = "LSSummary: " +
+ "Request must have at least one data element -
trigger) ";
+ logger.error(m);
+ throw new SystemException("error.ls.no_data_trigger", m);
+ }

- logger.debug("LSSummary: Summary Information Complete");
+ logger.debug("LSSummary: Summary Information Complete");

- String metadataId = MathUtil.calculateId(lsUtil.getLsAccessPoint(),
lsUtil.getLsServiceRank());
+ String metadataId =
MathUtil.calculateId(lsUtil.getLsAccessPoint(), lsUtil.getLsServiceRank());

- //Take the metadata, and the data, and place them inside of
- // a larger data block (this is the summary)
- Data reqData = new Data();
- reqData.setId("summaryData");
- reqData.setMetadataIdRef(metadataId);
- reqData.addChild(resultMetadata);
- Iterator resultDataArrIterator = resultDataArr.iterator();
- while (resultDataArrIterator.hasNext()) {
- reqData.addChild((Data)resultDataArrIterator.next());
- }
+ //Take the metadata, and the data, and place them inside of
+ // a larger data block (this is the summary)
+ Data reqData = new Data();
+ reqData.setId("summaryData");
+ reqData.setMetadataIdRef(metadataId);
+ reqData.addChild(resultMetadata);
+ Iterator resultDataArrIterator = resultDataArr.iterator();

+ while (resultDataArrIterator.hasNext()) {
+ reqData.addChild((Data)resultDataArrIterator.next());

+ }

- //now we make a metadata that describes who we are...
- Metadata reqMetadata = new Metadata();
- reqMetadata = lsUtil.createLSMetadata(reqMetadata, metadataId);
+ //now we make a metadata that describes who we are...
+ Metadata reqMetadata = new Metadata();
+ reqMetadata = lsUtil.createLSMetadata(reqMetadata, metadataId);

- //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",
"local");
+ //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",
"local");

- //put them in a message, then insert
- Message registerMessage = new Message();
- registerMessage.setType("LSRegisterRequest");
- registerMessage.addChild(reqData);
- registerMessage.addChild(reqMetadata);
- registerMessage.addChild(reqParams);
+ //put them in a message, then insert
+ Message registerMessage = new Message();
+ registerMessage.setType("LSRegisterRequest");
+ registerMessage.addChild(reqData);
+ registerMessage.addChild(reqMetadata);
+ registerMessage.addChild(reqParams);

- logger.debug("LSSummary: Created Message: " +
registerMessage.toString());
+ logger.debug("LSSummary: Created Message: " +
registerMessage.toString());

- XmlDbStorageManager xmlDbStorageManager =
XmlTypeLSServiceEngine.getStorageManager(smType);
+ XmlDbStorageManager xmlDbStorageManager =
XmlTypeLSServiceEngine.getStorageManager(smType);

- //register the new stuff
- LSAction action2 = new LSRegisterAction(xmlDbStorageManager);
- Message resp2 = null;
- resp2 = action2.performAction(registerMessage);
- if(resp2 != null) {
- logger.debug("LSSummary: Got Response: " + resp2.toString());
- }
- else {
- //does it matter if we fail?
- }
+ //register the new stuff
+ LSAction action2 = new LSRegisterAction(xmlDbStorageManager);
+ Message resp2 = null;
+ resp2 = action2.performAction(registerMessage);
+ if(resp2 != null) {
+ logger.debug("LSSummary: Got Response: " +
resp2.toString());
+ }
+ else {
+ //does it matter if we fail?
+ }

- }
- else {
- //the LSStore has no data, so do we need to do anything here?
+ }
+ else {
+ //the LSStore has no data, so do we need to do anything here?
+ }
+
+ logger.debug("LSSummary: Leaving Action");
+ return null; //result unimportant
}
-
- logger.debug("LSSummary: Leaving Action");
- return null; //result unimportant
- }
+

- public void runAction() {
- iterations++;
- if(iterations <= 1) {
- logger.info("LSSummary: Don't run the first time (let the data
register)");
- }
- else {
- logger.info("LSSummary: Run as scheduled action for the [" +
- iterations + "] time");
- try {
- performAction(null); //input unimportant
- }
- catch (PerfSONARException e) {
- //Catch nothing for now?
- }
+ public void runAction() {
+ iterations++;
+ if(iterations <= 1) {
+ logger.info("LSSummary: Don't run the first time (let the data
register)");
+ }
+ else {
+ logger.info("LSSummary: Run as scheduled action for the [" +
+ iterations + "] time");
+ try {
+ performAction(null); //input unimportant
+ }
+ catch (PerfSONARException e) {
+ //Catch nothing for now?
+ }
+ }
}
- }
+

} //LSSummary

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSSummaryLoader.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSSummaryLoader.java
2006-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSSummaryLoader.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -11,138 +11,142 @@

/**
* Initializes summary mechanism into the simple scheduler
- * @author Jason Zurawski
* @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/

public class LSSummaryLoader implements AuxiliaryComponent {

- // ----------------------------------------------------- constants
+
+ // ----------------------------------------------------- constants

- private static final int DEFAULT_RUN_INTERVAL = 30; //seconds
+ private static final int DEFAULT_RUN_INTERVAL = 30; //seconds

- private static final int MINIMAL_RUN_INTERVAL = 10; //seconds

+ private static final int MINIMAL_RUN_INTERVAL = 10; //seconds

+

- //---------------------------------------------- private variables
+ //---------------------------------------------- private variables

- private String componentName = "ls_summary_loader";
+ private String componentName = "ls_summary_loader";
+

- private LoggerComponent logger;
+ private LoggerComponent logger;
+

- private ConfigurationComponent config;
+ private ConfigurationComponent config;
+

- private Scheduler scheduler;
+ private Scheduler scheduler;
+

- private StorageManager storage;
+ private StorageManager storage;



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

- public void initComponent() throws SystemException {
+ public void initComponent() throws SystemException {

- //get Logger
- try {
- logger = (LoggerComponent)AuxiliaryComponentManager.
- getInstance().getComponent(ComponentNames.LOGGER);
- }
- catch (SystemException e) {
- String m = "Cannot get logger component ";
- throw new SystemException("error.common.no_logger",m);
- }
+ //get Logger
+ try {
+ logger =
(LoggerComponent)AuxiliaryComponentManager.getInstance().getComponent(ComponentNames.LOGGER);

+ }
+ catch(SystemException e) {
+ String m = "Cannot get logger component ";
+ throw new SystemException("error.common.no_logger",m);

+ }

- //get config (base)
- try {
- config = (ConfigurationComponent)AuxiliaryComponentManager.
- getInstance().getComponent(ComponentNames.CONFIG);
- }
- catch (SystemException e) {
- String m = "Cannot get config component ";
- throw new SystemException("error.common.no_configuration", m);

- }
+ //get config (base)
+ try {
+ config =
(ConfigurationComponent)AuxiliaryComponentManager.getInstance().getComponent(ComponentNames.CONFIG);
+ }
+ catch (SystemException e) {
+ String m = "Cannot get config component ";
+ throw new SystemException("error.common.no_configuration", m);

+ }

- //get interval - parameter "component.ls_summary_loader.interval"
- int interval = DEFAULT_RUN_INTERVAL;
- try {
- String intervalVal = config.getProperty("component." +
- componentName +
- ".interval");
- interval = Integer.parseInt(intervalVal);
- }
- catch (RuntimeException e) {
- //possibly not an integer - keep default interval
- interval = DEFAULT_RUN_INTERVAL;
- }
- catch (SystemException e) {
- //no property - keep default interval
- interval = DEFAULT_RUN_INTERVAL;
- }
+ //get interval - parameter "component.ls_summary_loader.interval"
+ int interval = DEFAULT_RUN_INTERVAL;
+ try {
+ String intervalVal = config.getProperty("component." +
componentName + ".interval");
+ interval = Integer.parseInt(intervalVal);
+ }
+ catch (RuntimeException e) {
+ //possibly not an integer - keep default interval
+ interval = DEFAULT_RUN_INTERVAL;
+ }
+ catch (SystemException e) {
+ //no property - keep default interval
+ interval = DEFAULT_RUN_INTERVAL;
+ }

- //if too small take default?
- if (interval < MINIMAL_RUN_INTERVAL) {
- interval = DEFAULT_RUN_INTERVAL;
- }
+ //if too small take default?
+ if (interval < MINIMAL_RUN_INTERVAL) {
+ interval = DEFAULT_RUN_INTERVAL;
+ }

- logger.debug("LSSummaryLoader: parameter RUN_INTERVAL = [" +
- interval + "] seconds");
+ logger.debug("LSSummaryLoader: parameter RUN_INTERVAL = [" +
interval + "] seconds");

- //get scheduler - parameter
"component.ls_summary_loader.scheduler_component"
- try {
- String schedulerVal = config.getProperty("component." +
- componentName +
- ".scheduler_component");
- logger.debug("LSSummaryLoader: parameter SCHEDULER=" + schedulerVal);

- scheduler = (Scheduler)AuxiliaryComponentManager.
- getInstance().getComponent(schedulerVal);
+ //get scheduler - parameter
"component.ls_summary_loader.scheduler_component"
+ try {
+ String schedulerVal = config.getProperty("component." +
+ componentName +
+ ".scheduler_component");
+ logger.debug("LSSummaryLoader: parameter SCHEDULER=" +
schedulerVal);
+ scheduler =
(Scheduler)AuxiliaryComponentManager.getInstance().getComponent(schedulerVal);

- if (scheduler == null) {
- throw new SystemException("error.ls.no_scheduler",
- "No such component in Auxiliary" +
- "ComponentManager: " + schedulerVal);
- }
- }
- catch (SystemException e) {
- throw new SystemException("error.ls.no_scheduler",
- "LSSummaryLoader: no [component." +
- componentName + ".scheduler_component] " +
- "parameter. " + e.getMessage());
- }
+ if (scheduler == null) {
+ throw new SystemException("error.ls.no_scheduler",
+ "No such component in Auxiliary" +
+ "ComponentManager: " +
schedulerVal);
+ }
+ }
+ catch (SystemException e) {
+ throw new SystemException("error.ls.no_scheduler",
+ "LSSummaryLoader: no [component." +
+ componentName + ".scheduler_component]
" +
+ "parameter. " + e.getMessage());
+ }

- //get storage
- try {
+ //get storage
+ try {

- String smType = config.getProperty("service.ls.db_type");
- storage = XmlTypeLSServiceEngine.getStorageManager(smType);
- logger.debug("LSSummaryLoader: parameter STORAGE=" + smType);

- if (storage == null) {
- throw new SystemException("error.ls.no_storage",
- "No such component in AuxiliaryComponent"
+
- "Manager");
- }
- }
- catch (SystemException e) {
- throw new SystemException("error.ls.no_storage",
- "LSSummaryLoader: no [component." +
- componentName +
- ".storage_component] parameter. " +
- e.getMessage());
- }
+ String smType = config.getProperty("service.ls.db_type");
+ storage = XmlTypeLSServiceEngine.getStorageManager(smType);

+ logger.debug("LSSummaryLoader: parameter STORAGE=" + smType);

+ if(storage == null) {
+ throw new SystemException("error.ls.no_storage",
+ "No such component in
AuxiliaryComponent" +
+ "Manager");
+ }
+ }
+ catch (SystemException e) {
+ throw new SystemException("error.ls.no_storage",
+ "LSSummaryLoader: no [component." +
+ componentName +
+ ".storage_component] parameter. " +
+ e.getMessage());
+ }

- //add summary action to scheduler (note time*1000 because it's
- // in seconds and scheduler needs time in ms
+ //add summary action to scheduler (note time*1000 because it's
+ // in seconds and scheduler needs time in ms

- scheduler.addSchedulerTask(interval * 1000, new LSSummary(storage));
- }
+ scheduler.addSchedulerTask(interval * 1000, new LSSummary(storage));

+ }
+

- public String getComponentName() {
- return componentName;
- }
+ public String getComponentName() {
+ return componentName;
+ }

- public void setComponentName(String name) {
- componentName = name;
- }
+
+ public void setComponentName(String name) {
+ componentName = name;
+ }
+

}

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSTokenUtilities.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSTokenUtilities.java
2006-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSTokenUtilities.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -6,19 +6,24 @@
import java.util.Map;

import org.ggf.ns.nmwg.base.v2_0.*;
+import org.ggf.ns.nmwg.base.v2_0.Message;
+import org.ggf.ns.nmwg.base.v2_0.Store;
+
import org.perfsonar.commons.util.XMLUtils;
import org.perfsonar.commons.util.MathUtil;
+
import org.perfsonar.service.commons.exceptions.DataFormatException;
import org.perfsonar.service.commons.exceptions.RequestException;
import org.perfsonar.service.commons.exceptions.SystemException;
+import org.perfsonar.service.commons.exceptions.PerfSONARException;
+
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;
+import
org.perfsonar.service.commons.storage.xmldb.exist.rest.ExistDbHttpXmlStorageManager;

-import org.ggf.ns.nmwg.base.v2_0.Message;
-import org.ggf.ns.nmwg.base.v2_0.Store;
import
org.perfsonar.commons.auxiliary.components.simplescheduler.SchedulerAction;
-import org.perfsonar.service.commons.exceptions.PerfSONARException;
-import org.perfsonar.service.commons.storage.xmldb.XmlDbResult;
-
import org.perfsonar.commons.auxiliary.AuxiliaryComponent;
import org.perfsonar.commons.auxiliary.AuxiliaryComponentManager;
import org.perfsonar.commons.auxiliary.ComponentNames;
@@ -51,790 +56,953 @@
/**
* Utilities File
*
- * @author Jason Zurawski
+ * @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/
public class LSTokenUtilities {

- private final String LS_STORE_COLLECTION_TYPE = "LSStore";
- private final String LS_CACHE_COLLECTION_TYPE = "LSCache";
- private final String LS_STORE_CONTROL_COLLECTION_TYPE = "LSStore-control";
- private final String LS_LOCAL_PEER_COLLECTION_TYPE = "LSLocalPeers";
- private final String LS_GLOBAL_PEER_COLLECTION_TYPE = "LSGlobalPeers";
+ private final String LS_STORE_COLLECTION_TYPE = "LSStore";
+ private final String LS_CACHE_COLLECTION_TYPE = "LSCache";
+ private final String LS_STORE_CONTROL_COLLECTION_TYPE =
"LSStore-control";
+ private final String LS_LOCAL_PEER_COLLECTION_TYPE = "LSLocalPeers";
+ private final String LS_GLOBAL_PEER_COLLECTION_TYPE = "LSGlobalPeers";

+ private final String LS_STORE_CONTAINER = LS_STORE_COLLECTION_TYPE +
".dbxml";
+ private final String LS_CACHE_CONTAINER = LS_CACHE_COLLECTION_TYPE +
".dbxml";
+ private final String LS_STORE_CONTROL_CONTAINER =
LS_STORE_CONTROL_COLLECTION_TYPE + ".dbxml";
+ private final String LS_LOCAL_PEER_CONTAINER =
LS_LOCAL_PEER_COLLECTION_TYPE + ".dbxml";
+ private final String LS_GLOBAL_PEER_CONTAINER =
LS_GLOBAL_PEER_COLLECTION_TYPE + ".dbxml";

- private final String XQUERY_UPDATE_DECLARE = "declare " +
+ private final String XQUERY_UPDATE_DECLARE = "declare " +
"namespace nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; ";
- private final String XQUERY_UPDATE_INSERT = "update insert ";
- private final String XQUERY_UPDATE_REPLACE = "update replace ";
- private final String XQUERY_UPDATE_VALUE = "update value ";
- private final String XQUERY_UPDATE_DELETE = "update delete ";
- private final String XQUERY_UPDATE_RENAME = "update rename ";
+ private final String XQUERY_UPDATE_INSERT = "update insert ";
+ private final String XQUERY_UPDATE_REPLACE = "update replace ";
+ private final String XQUERY_UPDATE_VALUE = "update value ";
+ private final String XQUERY_UPDATE_DELETE = "update delete ";
+ private final String XQUERY_UPDATE_RENAME = "update rename ";
+
+ /**
+ * The object to log control/debugging messages
+ */
+ private LoggerComponent logger = null;

- /**
- * The object to log control/debugging messages
- */
- private LoggerComponent logger = null;
+ /**
+ * Reference to configuration
+ */
+ protected ConfigurationComponent configuration = null;

- /**
- * Reference to configuration
- */
- protected ConfigurationComponent configuration = null;
-
- /**
- * lsUtil
- */
- private LSUtilities lsUtil = null;
+ /**
+ * lsUtil
+ */
+ private LSUtilities lsUtil = null;

- /**
- * ls token frequency
- */
- private String lsTokenFrequency = "";
+ /**
+ * ls token frequency
+ */
+ private String lsTokenFrequency = "";


- /**
- * name of property in config file
- */
- private static final String LS_SUMMARY_STYLESHEET =
"component.ls_summary_loader.stylesheet_external";
+ /**
+ * name of property in config file
+ */
+ private static final String LS_SUMMARY_STYLESHEET =
"component.ls_summary_loader.stylesheet_external";

- /**
- * location of summary sheet
- */
- private String summarySheet = "";
+ /**
+ * location of summary sheet
+ */
+ private String summarySheet = "";


- public LSTokenUtilities(LoggerComponent logger,
- ConfigurationComponent configuration,
- LSUtilities lsUtil,
- String lsTokenInterval) throws SystemException {
+ public LSTokenUtilities(LoggerComponent logger, ConfigurationComponent
configuration,
+ LSUtilities lsUtil, String lsTokenInterval) throws SystemException {

- this.logger = logger;
+ this.logger = logger;

- this.configuration = configuration;
+ this.configuration = configuration;

- this.lsUtil = lsUtil;
+ this.lsUtil = lsUtil;

- if(!(lsTokenInterval.equals("null"))) {
+ if(!(lsTokenInterval.equals("null"))) {

- String temp = "";
- try {
- temp = configuration.getProperty(lsTokenInterval);
- }
- catch (SystemException e) {
- temp = null;
- }
+ String temp = "";
+ try {
+ temp = configuration.getProperty(lsTokenInterval);
+ }
+ catch(SystemException e) {
+ temp = null;
+ }

- if(temp != null) {
- setLsTokenFrequency(temp);
- }
- else {
- // we need to throw an error or something...
- }
- logger.debug("LSTokenUtilities: LS TOKEN_INTERVAL=" +
getLsTokenFrequency());
- }
+ if(temp != null) {
+ setLsTokenFrequency(temp);
+ }
+ else {
+ // we need to throw an error or something...
+ }
+ logger.debug("LSTokenUtilities: LS TOKEN_INTERVAL=" +
getLsTokenFrequency());
+ }

- String temp = null;
- try {
- temp = configuration.getProperty(LS_SUMMARY_STYLESHEET);
- }
- catch (SystemException e) {
- temp = null;
- }
+ String temp = null;
+ try {
+ temp = configuration.getProperty(LS_SUMMARY_STYLESHEET);
+ }
+ catch (SystemException e) {
+ temp = null;
+ }

- if(temp != null) {
- setSummarySheet(temp);
- }
- else {
- // we need to throw an error or something...
+ if(temp != null) {
+ setSummarySheet(temp);
+ }
+ else {
+ // we need to throw an error or something...
+ }
+ logger.debug("LSSummary: LS XSLT=" + getSummarySheet());
+
+ }
+
+
+ /**
+ * set the value of the Token Frequency
+ */
+ public void setLsTokenFrequency(String newLsTokenFrequency) {
+ lsTokenFrequency = newLsTokenFrequency;
+ return;
}
- logger.debug("LSSummary: LS XSLT=" + getSummarySheet());
-
- }

- /**
- * set the value of the Token Frequency
- */
- public void setLsTokenFrequency(String newLsTokenFrequency) {
- lsTokenFrequency = newLsTokenFrequency;
- return;
- }

- /**
- * get the value of the Token Frequency
- */
- public String getLsTokenFrequency() {
- return lsTokenFrequency;
- }
+ /**
+ * get the value of the Token Frequency
+ */
+ public String getLsTokenFrequency() {
+ return lsTokenFrequency;
+ }

- /**
- * Set the value of the summary sheet
- */
- public void setSummarySheet(String newSummarySheet) {
- summarySheet = newSummarySheet;
- return;
- }

- /**
- * get the value of the summary sheet
- */
- public String getSummarySheet() {
- return summarySheet;
- }
+ /**
+ * Set the value of the summary sheet
+ */
+ public void setSummarySheet(String newSummarySheet) {
+ summarySheet = newSummarySheet;
+ return;
+ }

- public Message sendRequest(String endPoint,
org.ggf.ns.nmwg.base.v2_0.Message requestDocument)
- throws Exception {
- try {
- //prepare to call - set service elements
+
+ /**
+ * get the value of the summary sheet
+ */
+ public String getSummarySheet() {
+ return summarySheet;
+ }
+
+
+ public Message sendRequest(String endPoint,
org.ggf.ns.nmwg.base.v2_0.Message requestDocument)
+ throws Exception {
+ try {
+ //prepare to call - set service elements

- logger.debug("LSTokenUtilities: Preparing to Call endPoint");
+ logger.debug("LSTokenUtilities: Preparing to Call endPoint");

- Service service = new Service();
- Call call = (Call)service.createCall();
- call.setTargetEndpointAddress(new URL(endPoint));
- call.setOperationName(new QName("http://soapinterop.org/","submit";));
- call.setTimeout(5000);
- logger.debug("LSTokenUtilities: Making Message - timeout: " +
call.getTimeout());
+ Service service = new Service();
+ Call call = (Call)service.createCall();
+ call.setTargetEndpointAddress(new URL(endPoint));
+ call.setOperationName(new
QName("http://soapinterop.org/","submit";));
+ call.setTimeout(5000);
+ logger.debug("LSTokenUtilities: Making Message - timeout: " +
call.getTimeout());

- //build a SOAPBodyElement from the document
- SOAPBodyElement requestMessage = new SOAPBodyElement(
- XMLUtils.convertMessageToDOM(requestDocument).getDocumentElement());
+ //build a SOAPBodyElement from the document
+ SOAPBodyElement requestMessage = new SOAPBodyElement(
+
XMLUtils.convertMessageToDOM(requestDocument).getDocumentElement());

- logger.debug("LSTokenUtilities: Starting Call");
+ logger.debug("LSTokenUtilities: Starting Call");

- //call on the end point
- Object resultObject = call.invoke(new Object[] {requestMessage});
+ //call on the end point
+ Object resultObject = call.invoke(new Object[] {requestMessage});

- logger.debug("LSTokenUtilities: Call Returned");
+ logger.debug("LSTokenUtilities: Call Returned");

- //result object is a vector - strange!!! But this is how the world
works :-D
- // we will now extract the result from the vector
- SOAPBodyElement resultSBE;
- Document resultDocument = null;
- resultSBE= (SOAPBodyElement)((Vector)resultObject).get(0);
- resultDocument = resultSBE.getAsDocument();
+ //result object is a vector - strange!!! But this is how the
world works :-D
+ // we will now extract the result from the vector
+ SOAPBodyElement resultSBE;
+ Document resultDocument = null;
+ resultSBE= (SOAPBodyElement)((Vector)resultObject).get(0);
+ resultDocument = resultSBE.getAsDocument();

- logger.debug("LSTokenUtilities: Result Being Returned");
+ logger.debug("LSTokenUtilities: Result Being Returned");

- return XMLUtils.convertToMessage(resultDocument,
lsUtil.getParserFile());
- }
- catch(Exception e) {
- logger.debug("LSTokenUtilities: Exception: " + e.toString());
- return null;
- }
- }
+ return XMLUtils.convertToMessage(resultDocument,
lsUtil.getParserFile());
+ }
+ catch(Exception e) {
+ logger.debug("LSTokenUtilities: Exception: " + e.toString());
+ return null;
+ }
+ }

- public String[][] formPeerArray(Collection metadataCol) throws
SystemException {
- String[][] rawData = null;
- String[][] sortedData = null;
- int myRank = 0, c = 0, d = 0;
+
+ public String[][] formPeerArray(Collection metadataCol)
+ throws SystemException {
+ String[][] rawData = null;
+ String[][] sortedData = null;
+ int myRank = 0, c = 0, d = 0;

- rawData = new String[metadataCol.size()][2];
- Map temp = new HashMap();
+ rawData = new String[metadataCol.size()][2];
+ Map temp = new HashMap();

- //this the long way to do things...we have IDs that are longs, and
- // they dont really fit well into the 'normal' data structures so we
need to
- // iterate through and make our own searchable list.
+ //this the long way to do things...we have IDs that are longs, and
+ // they dont really fit well into the 'normal' data structures so we
need to
+ // iterate through and make our own searchable list.

- for(int a = 0; a < metadataCol.size(); a++) {
- Iterator metadataColIterator = metadataCol.iterator();
- long small = Long.MAX_VALUE;
- String accessPoint = "", familiar = "";
+ for(int a = 0; a < metadataCol.size(); a++) {
+ Iterator metadataColIterator = metadataCol.iterator();
+ long small = Long.MAX_VALUE;
+ String accessPoint = "", familiar = "";

- while (metadataColIterator.hasNext()) {
- Metadata tempMetadata = (Metadata)metadataColIterator.next();

-
if((Long.parseLong(tempMetadata.getKey().getParameterByName("id").
- getParameterValue()) < small) &&
!(temp.containsValue(tempMetadata.getKey().
- getParameterByName("accessPoint").getParameterValue()))) {
- small =
Long.parseLong(tempMetadata.getKey().getParameterByName("id").getParameterValue());
- accessPoint =
tempMetadata.getKey().getParameterByName("accessPoint").getParameterValue();
- familiar =
tempMetadata.getKey().getParameterByName("familiar").getParameterValue();
- }
- }
- temp.put(a, accessPoint);
- rawData[a][0] = accessPoint;
- rawData[a][1] = familiar;
- }
- temp.clear();
+ while (metadataColIterator.hasNext()) {
+ Metadata tempMetadata = (Metadata)metadataColIterator.next();

+
if((Long.parseLong(tempMetadata.getKey().getParameterByName("id").
+ getParameterValue()) < small) &&
!(temp.containsValue(tempMetadata.getKey().
+ getParameterByName("accessPoint").getParameterValue()))) {
+ small =
Long.parseLong(tempMetadata.getKey().getParameterByName("id").getParameterValue());
+ accessPoint =
tempMetadata.getKey().getParameterByName("accessPoint").getParameterValue();
+ familiar =
tempMetadata.getKey().getParameterByName("familiar").getParameterValue();
+ }
+ }
+ temp.put(a, accessPoint);
+ rawData[a][0] = accessPoint;
+ rawData[a][1] = familiar;
+ }
+ temp.clear();

- sortedData = new String[metadataCol.size()][2];
+ sortedData = new String[metadataCol.size()][2];

- for(c = 0; c < metadataCol.size(); c++) {
- if(rawData[c][0].equals(lsUtil.getLsAccessPoint())) {
- myRank = c;
- break;
+ for(c = 0; c < metadataCol.size(); c++) {
+ if(rawData[c][0].equals(lsUtil.getLsAccessPoint())) {
+ myRank = c;
+ break;
+ }
+ }
+
+ sortedData[0][0] = rawData[myRank][0];
+ sortedData[0][1] = rawData[myRank][1];
+ for(c = 0, d = 1; c < metadataCol.size(); c++) {
+ if(c != myRank) {
+ sortedData[d][0] = rawData[c][0];
+ sortedData[d][1] = rawData[c][1];
+ d++;
}
- }
-
- sortedData[0][0] = rawData[myRank][0];
- sortedData[0][1] = rawData[myRank][1];
- for(c = 0, d = 1; c < metadataCol.size(); c++) {
- if(c != myRank) {
-
- sortedData[d][0] = rawData[c][0];
- sortedData[d][1] = rawData[c][1];
- d++;
- }
-
- }
-
- return sortedData;
- }
+ }
+ return sortedData;
+ }

- public org.ggf.ns.nmwg.base.v2_0.Key getLSPeerKey() throws SystemException
{
- org.ggf.ns.nmwg.base.v2_0.Parameters peerParams = new
org.ggf.ns.nmwg.base.v2_0.Parameters();
+
+ public org.ggf.ns.nmwg.base.v2_0.Key getLSPeerKey() throws
SystemException {
+ org.ggf.ns.nmwg.base.v2_0.Parameters peerParams = new
org.ggf.ns.nmwg.base.v2_0.Parameters();

- org.ggf.ns.nmwg.base.v2_0.Parameter peerParam1 = new
org.ggf.ns.nmwg.base.v2_0.Parameter();
- peerParam1.setParameterName("id");
- peerParam1.addText(MathUtil.calculateId(lsUtil.getLsAccessPoint(),
lsUtil.getLsServiceRank()));
- peerParams.addParameter(peerParam1);
+ org.ggf.ns.nmwg.base.v2_0.Parameter peerParam1 = new
org.ggf.ns.nmwg.base.v2_0.Parameter();
+ peerParam1.setParameterName("id");
+ peerParam1.addText(MathUtil.calculateId(lsUtil.getLsAccessPoint(),
lsUtil.getLsServiceRank()));
+ peerParams.addParameter(peerParam1);

- org.ggf.ns.nmwg.base.v2_0.Parameter peerParam2 = new
org.ggf.ns.nmwg.base.v2_0.Parameter();
- peerParam2.setParameterName("familiar");
- peerParam2.addText("1");
- peerParams.addParameter(peerParam2);
+ org.ggf.ns.nmwg.base.v2_0.Parameter peerParam2 = new
org.ggf.ns.nmwg.base.v2_0.Parameter();
+ peerParam2.setParameterName("familiar");
+ peerParam2.addText("1");
+ peerParams.addParameter(peerParam2);

- org.ggf.ns.nmwg.base.v2_0.Parameter peerParam3 = new
org.ggf.ns.nmwg.base.v2_0.Parameter();
- peerParam3.setParameterName("accessPoint");
- peerParam3.addText(lsUtil.getLsAccessPoint());
- peerParams.addParameter(peerParam3);
- peerParams.setId(lsUtil.getLsAccessPoint());
+ org.ggf.ns.nmwg.base.v2_0.Parameter peerParam3 = new
org.ggf.ns.nmwg.base.v2_0.Parameter();
+ peerParam3.setParameterName("accessPoint");
+ peerParam3.addText(lsUtil.getLsAccessPoint());
+ peerParams.addParameter(peerParam3);
+ peerParams.setId(lsUtil.getLsAccessPoint());

- org.ggf.ns.nmwg.base.v2_0.Key peerKey = new
org.ggf.ns.nmwg.base.v2_0.Key();
- peerKey.addChild(peerParams);
- return peerKey;
- }
+ org.ggf.ns.nmwg.base.v2_0.Key peerKey = new
org.ggf.ns.nmwg.base.v2_0.Key();
+ peerKey.addChild(peerParams);
+ return peerKey;
+ }

- public void sendSummaryMessage(StorageManager xmlStorageManager, String
kind) throws SystemException, RequestException, DataFormatException {
- String query = null;
- String[] results = null;
- XmlDbResult edbres = null;
+
+ public void sendSummaryMessage(StorageManager xmlStorageManager, String
kind) throws SystemException,
+ RequestException, DataFormatException {
+ String query = null;
+ String[] results = null;
+ XmlDbResult edbres = null;

- Collection metadataCol = null;
- String[][] sortedList = null;
- int c = 0, d = 0;
+ Collection metadataCol = null;
+ String[][] sortedList = null;
+ int c = 0, d = 0;

- //get the contents of LS(Local|Global)Peers
- if(kind.equals("local")) {
- query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE + "']";
- }
- else if(kind.equals("global")) {
- query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE + "']";
- }
- results = lsUtil.getDBContents(xmlStorageManager, query);
-
- if(results[0].equals("")) {
- String m = "LSTokenUtilities: " +
- "Peer List is empty; please populate it with at least one
peer.";
- logger.error(m);
- throw new SystemException("error.ls.peer_list_empty", m);
- }
+ //get the contents of LS(Local|Global)Peers
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+ if(kind.equals("local")) {
+ query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE + "']";
+ }
+ else if(kind.equals("global")) {
+ query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE + "']";
+ }
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {
+ if(kind.equals("local")) {
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_LOCAL_PEER_CONTAINER + "\"))";
+ }
+ else if(kind.equals("global")) {
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_GLOBAL_PEER_CONTAINER + "\"))";
+ }
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else {
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
+ }

- org.ggf.ns.nmwg.base.v2_0.Store result =
- (org.ggf.ns.nmwg.base.v2_0.Store)XMLUtils.stringToElement(results[0],
lsUtil.getParserFile(), "store");
+ if(results[0].equals("")) {
+ String m = "LSTokenUtilities: " +
+ "Peer List is empty; please populate it with at least
one peer.";
+ logger.error(m);
+ throw new SystemException("error.ls.peer_list_empty", m);
+ }
+
+ org.ggf.ns.nmwg.base.v2_0.Store result =
+
(org.ggf.ns.nmwg.base.v2_0.Store)XMLUtils.stringToElement(results[0],
lsUtil.getParserFile(), "store");

- metadataCol = result.getMetadataMap().values();
- if(metadataCol.size() < 1) {
- String m = "LSTokenUtilities: " +
- "Peer List is empty; please populate it with at least one
peer.";
- logger.error(m);
- throw new SystemException("error.ls.peer_list_empty", m);
- }
- sortedList = formPeerArray(metadataCol);
+ metadataCol = result.getMetadataMap().values();
+ if(metadataCol.size() < 1) {
+ String m = "LSTokenUtilities: " +
+ "Peer List is empty; please populate it with at least
one peer.";
+ logger.error(m);
+ throw new SystemException("error.ls.peer_list_empty", m);
+ }
+ sortedList = formPeerArray(metadataCol);


- //get the metadata blocks from the cache (that belong to me)
- query = XQUERY_UPDATE_DECLARE;
-
- query = query +
"/nmwg:store[@type='"
+ LS_CACHE_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"
+
- lsUtil.getLsAccessPoint() + "']";
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE +
"/nmwg:store[@type='"
+ LS_CACHE_COLLECTION_TYPE +
+
"']/nmwg:metadata[@id='"
+ lsUtil.getLsAccessPoint() + "']";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_CACHE_COLLECTION_TYPE +
+
"\")/nmwg:metadata[@id='"
+ lsUtil.getLsAccessPoint() + "'])";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else {
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
+ }

- logger.debug("LSTokenUtilities: Query: " + query);
- results = lsUtil.getDBContents(xmlStorageManager, query);
-
- org.ggf.ns.nmwg.base.v2_0.Metadata resultMetadata = null;
- if(results.length > 0) {
- //We essentually get back a string (but its really a metadata) so
- // using a new XMLUtils function we can get this into NMWG format
+ org.ggf.ns.nmwg.base.v2_0.Metadata resultMetadata = null;
+ if(results.length > 0) {
+ //We essentually get back a string (but its really a metadata) so
+ // using a new XMLUtils function we can get this into NMWG format

- resultMetadata =
(org.ggf.ns.nmwg.base.v2_0.Metadata)XMLUtils.stringToElement(results[0],
- lsUtil.getParserFile(), "metadata");
- logger.debug("LSTokenUtilities: Metadata: " +
resultMetadata.toString());
- }
-
- //get the data blocks from the cache (that belong to me)
- query = XQUERY_UPDATE_DECLARE;
- query = query +
"/nmwg:store[@type='"
+ LS_CACHE_COLLECTION_TYPE +
"']/nmwg:data[@metadataIdRef='"
+
- lsUtil.getLsAccessPoint() + "']";
+ resultMetadata =
(org.ggf.ns.nmwg.base.v2_0.Metadata)XMLUtils.stringToElement(results[0],
+ lsUtil.getParserFile(), "metadata");
+ logger.debug("LSTokenUtilities: Metadata: " +
resultMetadata.toString());
+ }

- logger.debug("LSTokenUtilities: Query: " + query);
-
- results = lsUtil.getDBContents(xmlStorageManager, query);
-
- org.ggf.ns.nmwg.base.v2_0.Data resultData = null;
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE;
+ query = query +
"/nmwg:store[@type='"
+ LS_CACHE_COLLECTION_TYPE +
"']/nmwg:data[@metadataIdRef='"
+
+ lsUtil.getLsAccessPoint() + "']";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_CACHE_COLLECTION_TYPE +
+
"\")/nmwg:data[@metadataIdRef='"
+ lsUtil.getLsAccessPoint() + "'])";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else {
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
+ }

- if(results.length > 0) {
- //We essentually get back a string (but its really a metadata) so
- // using a new XMLUtils function we can get this into NMWG format
+ org.ggf.ns.nmwg.base.v2_0.Data resultData = null;
+ if(results.length > 0) {
+ //We essentually get back a string (but its really a metadata) so
+ // using a new XMLUtils function we can get this into NMWG format

- resultData =
(org.ggf.ns.nmwg.base.v2_0.Data)XMLUtils.stringToElement(results[0],
- lsUtil.getParserFile(), "data");
- logger.debug("LSTokenUtilities: Data: " + resultData.toString());
- }
+ resultData =
(org.ggf.ns.nmwg.base.v2_0.Data)XMLUtils.stringToElement(results[0],
+ lsUtil.getParserFile(), "data");
+ logger.debug("LSTokenUtilities: Data: " + resultData.toString());
+ }

- //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", kind);
+ //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",
kind);

- //put them in a message, then insert
- org.ggf.ns.nmwg.base.v2_0.Message registerMessage = new Message();
- registerMessage.setType("LSRegisterRequest");
- registerMessage.addChild(resultMetadata);
- registerMessage.addChild(resultData);
- registerMessage.addChild(reqParams);
+ //put them in a message, then insert
+ org.ggf.ns.nmwg.base.v2_0.Message registerMessage = new Message();
+ registerMessage.setType("LSRegisterRequest");
+ registerMessage.addChild(resultMetadata);
+ registerMessage.addChild(resultData);
+ registerMessage.addChild(reqParams);

- logger.debug("LSTokenUtilities: Created Message: " +
registerMessage.toString());
+ logger.debug("LSTokenUtilities: Created Message: " +
registerMessage.toString());

- //now try to send the message to people
- for(int b = 0; b < metadataCol.size(); b++) {
+ //now try to send the message to people
+ for(int b = 0; b < metadataCol.size(); b++) {

- //don't insert into ourself...
- //if(!(sortedList[b][0].equals(lsUtil.getLsAccessPoint()))) {
+ //don't insert into ourself...
+ //if(!(sortedList[b][0].equals(lsUtil.getLsAccessPoint()))) {

- logger.debug("LSTokenUtilities: Sending message to: " +
sortedList[b][0] + " - " + sortedList[b][1]);
- try {
- org.ggf.ns.nmwg.base.v2_0.Message response =
sendRequest(sortedList[b][0], registerMessage);
- if(response != null) {
- //check to see if we succeeded:
+ logger.debug("LSTokenUtilities: Sending message to: " +
sortedList[b][0] + " - " + sortedList[b][1]);
+ try {
+ org.ggf.ns.nmwg.base.v2_0.Message response =
sendRequest(sortedList[b][0], registerMessage);
+ if(response != null) {
+ //check to see if we succeeded:

- org.ggf.ns.nmwg.base.v2_0.Metadata requestMetadata[] =
response.getMetadataArray();
- if(requestMetadata.length > 0){
+ org.ggf.ns.nmwg.base.v2_0.Metadata requestMetadata[]
= response.getMetadataArray();
+ if(requestMetadata.length > 0){

- logger.debug("LSTokenUtilities: response: " +
requestMetadata[0].toString());
-
if((requestMetadata[0].getEventType().getEventType()).equals("result.success"))
{
- if(Integer.parseInt(sortedList[b][1]) < 3) {
+ logger.debug("LSTokenUtilities: response: " +
requestMetadata[0].toString());
+
if((requestMetadata[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;
-
- if(kind.equals("local")) {
- 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) + "'";

- }
- else if(kind.equals("global")) {
- update = update +
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
-
"']//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
-
"[@name='familiar']
with '" + (int)((Integer.parseInt(sortedList[b][1]))+1) + "'";
- }
-
+ //update the peers list

+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ String update =
XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_VALUE;
+ if(kind.equals("local")) {

+ 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) + "'";

+ }
+ else if(kind.equals("global")) {
+ update = update +
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
+
"']//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
+
"[@name='familiar']
with '" + (int)((Integer.parseInt(sortedList[b][1]))+1) + "'";
+ }
+ xmlStorageManager.fetch(update);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ if(kind.equals("local")) {

+ String xPath =
"//nmwg:parameters[@id='"
+ sortedList[b][0] +
+
"']/nmwg:parameter[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_LOCAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath,
Integer.toString((Integer.parseInt(sortedList[b][1]))+1));
+ }
+ else if(kind.equals("global")) {
+ String xPath =
"//nmwg:parameters[@id='"
+ sortedList[b][0] +
+
"']/nmwg:parameter[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_GLOBAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath,
Integer.toString((Integer.parseInt(sortedList[b][1]))+1));
+ }

+ }
+
+ sortedList[b][1] =
Integer.toString(Integer.parseInt(sortedList[b][1]) + 1);
+ }
+ b = metadataCol.size() + 1;

- xmlStorageManager.fetch(update);
- sortedList[b][1] =
Integer.toString(Integer.parseInt(sortedList[b][1]) + 1);
- }
- b = metadataCol.size() + 1;
-
- //advance the scheduler (wait for the real token)
- //scheduler.advanceScheduler(1000 *
Integer.parseInt(getLsTokenFrequency()) * metadataCol.size());
- }
- else {
- logger.debug("LSTokenUtilities: Success Code from peer not
found");
- }
+ //advance the scheduler (wait for the real
token)
+ //scheduler.advanceScheduler(1000 *
Integer.parseInt(getLsTokenFrequency()) * metadataCol.size());
+ }
+ else {
+ logger.debug("LSTokenUtilities: Success Code
from peer not found");
+ }
+ }
+ else {
+ logger.debug("LSTokenUtilities: No metadata in
peer response");
+ }
+ }
+ else {
+ logger.debug("LSTokenUtilities: Null response when
talking to peer");
+ if(Integer.parseInt(sortedList[b][1]) > 0) {
+ //update the peers list
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ String update = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_VALUE;
+ if(kind.equals("local")) {
+ 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) + "'";

+ }
+ else if(kind.equals("global")) {
+ update = update +
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
+
"']//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
+
"[@name='familiar']
with '" + (int)(Integer.parseInt(sortedList[b][1])-1) + "'";
+ }
+ xmlStorageManager.fetch(update);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ if(kind.equals("local")) {
+ String xPath =
"//nmwg:parameters[@id='"
+ sortedList[b][0] +
+
"']/nmwg:parameter[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_LOCAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath,
Integer.toString((Integer.parseInt(sortedList[b][1]))-1));
+ }
+ else if(kind.equals("global")) {
+ String xPath =
"//nmwg:parameters[@id='"
+ sortedList[b][0] +
+
"']/nmwg:parameter[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_GLOBAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath,
Integer.toString((Integer.parseInt(sortedList[b][1]))-1));
+ }

+ }
+ sortedList[b][1] =
Integer.toString(Integer.parseInt(sortedList[b][1])-1);
+ }
+ }
+ }
+ catch(Exception e) {
+ logger.debug("LSTokenUtilities: Exception: " +
e.toString());
+ throw new SystemException("error.ls.client_error",
+ "Error sending to client LS " +
+ e.getMessage());
+ }
+ //}
+ }
+ return;
+ }
+
+
+ public void addToPeerList(StorageManager xmlStorageManager, Metadata
requestMetadata, String kind)
+ throws SystemException, RequestException, DataFormatException {
+ //is this peer in the list? (yes, update its familarity, no add it)
+ logger.debug("LSTokenUtilities: MESSAGE Testing to make sure THIS LS
is in the peer list");
+
+ String[] results = null;
+ String query = null;
+ XmlDbResult edbres = null;
+
+ //get the contents of LSStore
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+ if(kind.equals("local")) {
+ query = XQUERY_UPDATE_DECLARE +
"/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE +
+
"']/nmwg:metadata[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+ requestMetadata.getSubject()).getService().
+ getAccessPoint().getAccessPoint() + "']";
}
- else {
- logger.debug("LSTokenUtilities: No metadata in peer response");
- }
- }
- else {
- logger.debug("LSTokenUtilities: 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;
-
- if(kind.equals("local")) {
- 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) + "'";

- }
- else if(kind.equals("global")) {
- update = update +
"/nmwg:store[@type='"
+ LS_GLOBAL_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);
- }
- }
+ else if(kind.equals("global")) {
+ query = XQUERY_UPDATE_DECLARE +
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
+
"']/nmwg:metadata[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+ requestMetadata.getSubject()).getService().
+ getAccessPoint().getAccessPoint() + "']";
+ }
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
}
- catch(Exception e) {
- logger.debug("LSTokenUtilities: Exception: " + e.toString());
- throw new SystemException("error.ls.client_error",
- "Error sending to client LS " +
- e.getMessage());
- }
- //}
- }
- return;
- }
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {

+ if(kind.equals("local")) {
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_LOCAL_PEER_CONTAINER +
+
"\")/nmwg:metadata[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+ requestMetadata.getSubject()).getService().
+ getAccessPoint().getAccessPoint() + "'])";
+ }
+ else if(kind.equals("global")) {
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_GLOBAL_PEER_CONTAINER +
+
"\")/nmwg:metadata[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+ requestMetadata.getSubject()).getService().
+ getAccessPoint().getAccessPoint() + "'])";
+ }
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else {
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
+ }


- public void addToPeerList(StorageManager xmlStorageManager, Metadata
requestMetadata, String kind)
- throws SystemException, RequestException, DataFormatException {
- //is this peer in the list? (yes, update its familarity, no add it)
- logger.debug("LSTokenUtilities: MESSAGE Testing to make sure THIS LS is
in the peer list");
+ if(results[0].equals("")) {

- String query = XQUERY_UPDATE_DECLARE;
- if(kind.equals("local")) {
- query = query +
"/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
- requestMetadata.getSubject()).getService().
- getAccessPoint().getAccessPoint() + "']";
- }
- else if(kind.equals("global")) {
- query = query +
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
- requestMetadata.getSubject()).getService().
- getAccessPoint().getAccessPoint() + "']";
- }
-
- logger.debug("LSTokenUtilities: Query: " + query);
-
- String[] results = null;
- results = lsUtil.getDBContents(xmlStorageManager, query);
-
- if(results[0].equals("")) {
+ logger.debug("LSTokenUtilities: MESSAGE LS is not In there!");
+ //if we are not, make us

- logger.debug("LSTokenUtilities: MESSAGE LS is not In there!");
- //if we are not, make us
-
- org.ggf.ns.nmwg.base.v2_0.Parameters peerParams = new
org.ggf.ns.nmwg.base.v2_0.Parameters();
+ org.ggf.ns.nmwg.base.v2_0.Parameters peerParams = new
org.ggf.ns.nmwg.base.v2_0.Parameters();

- org.ggf.ns.nmwg.base.v2_0.Parameter peerParam1 = new
org.ggf.ns.nmwg.base.v2_0.Parameter();
- peerParam1.setParameterName("id");
- peerParam1.addText(requestMetadata.getId());
- peerParams.addParameter(peerParam1);
+ org.ggf.ns.nmwg.base.v2_0.Parameter peerParam1 = new
org.ggf.ns.nmwg.base.v2_0.Parameter();
+ peerParam1.setParameterName("id");
+ peerParam1.addText(requestMetadata.getId());
+ peerParams.addParameter(peerParam1);

- org.ggf.ns.nmwg.base.v2_0.Parameter peerParam2 = new
org.ggf.ns.nmwg.base.v2_0.Parameter();
- peerParam2.setParameterName("familiar");
- peerParam2.addText("1");
- peerParams.addParameter(peerParam2);
+ org.ggf.ns.nmwg.base.v2_0.Parameter peerParam2 = new
org.ggf.ns.nmwg.base.v2_0.Parameter();
+ peerParam2.setParameterName("familiar");
+ peerParam2.addText("1");
+ peerParams.addParameter(peerParam2);

- org.ggf.ns.nmwg.base.v2_0.Parameter peerParam3 = new
org.ggf.ns.nmwg.base.v2_0.Parameter();
- peerParam3.setParameterName("accessPoint");
- peerParam3.addText(((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
- requestMetadata.getSubject()).getService().
- getAccessPoint().getAccessPoint());
- peerParams.addParameter(peerParam3);
- peerParams.setId(((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
- requestMetadata.getSubject()).getService().
- getAccessPoint().getAccessPoint());
+ org.ggf.ns.nmwg.base.v2_0.Parameter peerParam3 = new
org.ggf.ns.nmwg.base.v2_0.Parameter();
+ peerParam3.setParameterName("accessPoint");
+
peerParam3.addText(((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+ requestMetadata.getSubject()).getService().
+ getAccessPoint().getAccessPoint());
+ peerParams.addParameter(peerParam3);
+
peerParams.setId(((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+ requestMetadata.getSubject()).getService().
+ getAccessPoint().getAccessPoint());

- org.ggf.ns.nmwg.base.v2_0.Key peerKey = new
org.ggf.ns.nmwg.base.v2_0.Key();
- peerKey.addChild(peerParams);
+ org.ggf.ns.nmwg.base.v2_0.Key peerKey = new
org.ggf.ns.nmwg.base.v2_0.Key();
+ peerKey.addChild(peerParams);

- Metadata peerMetadata = new Metadata();
- peerMetadata.setId(((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
- requestMetadata.getSubject()).getService().
- getAccessPoint().getAccessPoint());
- peerMetadata.addChild(peerKey);
+ Metadata peerMetadata = new Metadata();
+
peerMetadata.setId(((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+ requestMetadata.getSubject()).getService().
+ getAccessPoint().getAccessPoint());
+ peerMetadata.addChild(peerKey);

- //insert us
- logger.debug("LSTokenUtilities: MESSAGE MD Ready, inserting...");
+ //insert us
+ logger.debug("LSTokenUtilities: MESSAGE MD Ready,
inserting...");

- String insert = null;
- if(kind.equals("local")) {
- insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT +
- XMLUtils.serializeXML(peerMetadata) + " into
/nmwg:store[@type='"
+
- LS_LOCAL_PEER_COLLECTION_TYPE + "']";
- }
- else if(kind.equals("global")) {
- insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT +
- XMLUtils.serializeXML(peerMetadata) + " into
/nmwg:store[@type='"
+
- LS_GLOBAL_PEER_COLLECTION_TYPE + "']";
- }
-
- xmlStorageManager.fetch(insert);
-
- logger.debug("LSTokenUtilities: MESSAGE Done Adding");
- }
- else {
- logger.debug("LSTokenUtilities: MESSAGE We are already in the LS,
update the " +
- "familar list : results[0]" + results[0]);
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+ String insert = null;
+ if(kind.equals("local")) {
+ insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT +
+ XMLUtils.serializeXML(peerMetadata) + " into
/nmwg:store[@type='"
+
+ LS_LOCAL_PEER_COLLECTION_TYPE + "']";
+ }
+ else if(kind.equals("global")) {
+ insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT +
+ XMLUtils.serializeXML(peerMetadata) + " into
/nmwg:store[@type='"
+
+ LS_GLOBAL_PEER_COLLECTION_TYPE + "']";
+ }
+ xmlStorageManager.fetch(insert);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ if(kind.equals("local")) {
+ String xPath = "/";
+ String insertData = XMLUtils.serializeXML(peerMetadata);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insert(LS_LOCAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath, insertData);
+ }
+ else if(kind.equals("global")) {
+ String xPath = "/";
+ String insertData = XMLUtils.serializeXML(peerMetadata);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insert(LS_GLOBAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath, insertData);
+ }
+ }

- if(!(((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)requestMetadata
- .getSubject()).getService().getAccessPoint().getAccessPoint()
- .equals(lsUtil.getLsAccessPoint()))) {
-
- query = XQUERY_UPDATE_DECLARE;
- if(kind.equals("local")) {
- query = query +
"/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
-
requestMetadata.getSubject()).getService().getAccessPoint().getAccessPoint()
+
-
"']/nmwg:key/nmwg:parameters/nmwg:parameter[@name='familiar']/text()";
- }
- else if(kind.equals("global")) {
- query = query +
"/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
-
requestMetadata.getSubject()).getService().getAccessPoint().getAccessPoint()
+
-
"']/nmwg:key/nmwg:parameters/nmwg:parameter[@name='familiar']/text()";
- }
-
- logger.debug("LSTokenUtilities: Query: " + query);
+ logger.debug("LSTokenUtilities: MESSAGE Done Adding");
+ }
+ else {
+ logger.debug("LSTokenUtilities: MESSAGE We are already in the
LS, update the " +
+ "familar list : results[0]" + results[0]);

- String results2[] = null;
- results2 = lsUtil.getDBContents(xmlStorageManager, query);
+
if(!(((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)requestMetadata
+ .getSubject()).getService().getAccessPoint().getAccessPoint()
+ .equals(lsUtil.getLsAccessPoint()))) {

- if((int)(Integer.parseInt(String.valueOf(results2[0].charAt(0)))) <
3) {
- String update = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_VALUE;
-
- if(kind.equals("local")) {
- update = update +
"/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE +
-
"']//nmwg:parameters[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
- requestMetadata.getSubject()).getService().
- getAccessPoint().getAccessPoint() + "']/nmwg:parameter"
+
-
"[@name='familiar']
with '" + (int)((Integer.parseInt(String.valueOf(results2[0].charAt(0))))+1)
+
- "'";
- }
- else if(kind.equals("global")) {
- update = update +
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
-
"']//nmwg:parameters[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
- requestMetadata.getSubject()).getService().
- getAccessPoint().getAccessPoint() + "']/nmwg:parameter"
+
-
"[@name='familiar']
with '" + (int)((Integer.parseInt(String.valueOf(results2[0].charAt(0))))+1)
+
- "'";
- }
-
- logger.debug("LSTokenUtilities: Update: " + update);
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE;
+ if(kind.equals("local")) {
+ query = query +
"/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE +
+
"']/nmwg:metadata[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+
requestMetadata.getSubject()).getService().getAccessPoint().getAccessPoint()
+
+
"']/nmwg:key/nmwg:parameters/nmwg:parameter[@name='familiar']/text()";
+ }
+ else if(kind.equals("global")) {
+ query = query +
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
+
"']/nmwg:metadata[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+
requestMetadata.getSubject()).getService().getAccessPoint().getAccessPoint()
+
+
"']/nmwg:key/nmwg:parameters/nmwg:parameter[@name='familiar']/text()";
+ }
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ if(kind.equals("local")) {
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\""
+ LS_LOCAL_PEER_CONTAINER +
+
"\")/nmwg:metadata[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+
requestMetadata.getSubject()).getService().getAccessPoint().getAccessPoint()
+
+
"']/nmwg:key/nmwg:parameters/nmwg:parameter[@name='familiar']/text())";
+ }
+ else if(kind.equals("global")) {
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\""
+ LS_GLOBAL_PEER_CONTAINER +
+
"\")/nmwg:metadata[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+
requestMetadata.getSubject()).getService().getAccessPoint().getAccessPoint()
+
+
"']/nmwg:key/nmwg:parameters/nmwg:parameter[@name='familiar']/text())";
+ }
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else {
+ throw new
SystemException("error.common.storage.xmldb.query", "No database exists");
+ }

- xmlStorageManager.fetch(update);
- }
- }
- }
- return;
- }

+ String results2[] = null;
+ results2 = lsUtil.getDBContents(xmlStorageManager, query);

- public void sendExternalSummaryMessage(StorageManager xmlStorageManager)
+
if((int)(Integer.parseInt(String.valueOf(results2[0].charAt(0)))) < 3) {
+
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ String update = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_VALUE;
+ if(kind.equals("local")) {
+ update = update +
"/nmwg:store[@type='"
+ LS_LOCAL_PEER_COLLECTION_TYPE +
+
"']//nmwg:parameters[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+
requestMetadata.getSubject()).getService().
+ getAccessPoint().getAccessPoint() +
"']/nmwg:parameter" +
+
"[@name='familiar']
with '" + (int)((Integer.parseInt(String.valueOf(results2[0].charAt(0))))+1)
+ "'";
+ }
+ else if(kind.equals("global")) {
+ update = update +
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
+
"']//nmwg:parameters[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+
requestMetadata.getSubject()).getService().
+ getAccessPoint().getAccessPoint() +
"']/nmwg:parameter" +
+
"[@name='familiar']
with '" + (int)((Integer.parseInt(String.valueOf(results2[0].charAt(0))))+1)
+ "'";
+ }
+ xmlStorageManager.fetch(update);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ if(kind.equals("local")) {
+ String xPath =
"//nmwg:parameters[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+
requestMetadata.getSubject()).getService().
+ getAccessPoint().getAccessPoint()
+ "']/nmwg:parameter" +
+
"[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_LOCAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath,
Integer.toString((Integer.parseInt(String.valueOf(results2[0].charAt(0))))+1));

+ }
+ else if(kind.equals("global")) {
+ String xPath =
"//nmwg:parameters[@id='"
+ ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+
requestMetadata.getSubject()).getService().
+ getAccessPoint().getAccessPoint()
+ "']/nmwg:parameter" +
+
"[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_GLOBAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath,
Integer.toString((Integer.parseInt(String.valueOf(results2[0].charAt(0))))+1));

+ }
+ }
+ }
+ }
+ }
+ return;
+ }
+
+
+ public void sendExternalSummaryMessage(StorageManager xmlStorageManager)
throws SystemException, RequestException, DataFormatException {

- String output = null;
- String query = null;
- String[] results = null;
- XmlDbResult edbres = null;
+ String output = null;
+ String query = null;
+ String[] results = null;
+ XmlDbResult edbres = null;

- Collection metadataCol = null;
- String[][] sortedList = null;
- int c = 0, d = 0;
+ Collection metadataCol = null;
+ String[][] sortedList = null;
+ int c = 0, d = 0;

- //get the contents of LS(Local|Global)Peers
-
- query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE + "']";
-
- results = lsUtil.getDBContents(xmlStorageManager, query);
+ //get the contents of LSGlobal Peers
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE + "']";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_GLOBAL_PEER_CONTAINER + "\"))";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else {
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
+ }
+

- if(results[0].equals("")) {
- String m = "LSTokenUtilities: " +
- "Peer List is empty; please populate it with at least one
peer.";
- logger.error(m);
- throw new SystemException("error.ls.peer_list_empty", m);
- }
+ if(results[0].equals("")) {
+ String m = "LSTokenUtilities: " +
+ "Peer List is empty; please populate it with at least
one peer.";
+ logger.error(m);
+ throw new SystemException("error.ls.peer_list_empty", m);
+ }

- org.ggf.ns.nmwg.base.v2_0.Store result =
- (org.ggf.ns.nmwg.base.v2_0.Store)XMLUtils.stringToElement(results[0],
lsUtil.getParserFile(), "store");
+ org.ggf.ns.nmwg.base.v2_0.Store result =
+
(org.ggf.ns.nmwg.base.v2_0.Store)XMLUtils.stringToElement(results[0],
lsUtil.getParserFile(), "store");

- metadataCol = result.getMetadataMap().values();
- if(metadataCol.size() < 1) {
- String m = "LSTokenUtilities: " +
- "Peer List is empty; please populate it with at least one
peer.";
- logger.error(m);
- throw new SystemException("error.ls.peer_list_empty", m);
- }
- sortedList = formPeerArray(metadataCol);
-
-
+ metadataCol = result.getMetadataMap().values();
+ if(metadataCol.size() < 1) {
+ String m = "LSTokenUtilities: " +
+ "Peer List is empty; please populate it with at least
one peer.";
+ logger.error(m);
+ throw new SystemException("error.ls.peer_list_empty", m);
+ }
+ sortedList = formPeerArray(metadataCol);

+ //get the contents of LSStore
+ if(xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof ExistDbHttpXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_CACHE_COLLECTION_TYPE + "']";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else if(xmlStorageManager instanceof BerkeleyDbXmlStorageManager) {
+ query = XQUERY_UPDATE_DECLARE + "data(collection(\"" +
LS_CACHE_CONTAINER + "\"))";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else {
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
+ }


-
-
- //get the contents of LSStore
-
- query = XQUERY_UPDATE_DECLARE +
"//nmwg:store[@type='"
+ LS_CACHE_COLLECTION_TYPE + "']";
- results = lsUtil.getDBContents(xmlStorageManager, query) ;
-
- //Make sure we got something (don't want to do this on an empty set)
- if(results[0] != null) {
- logger.debug("LSTokenUtilities: XSLT Starting...");
- try {
+ //Make sure we got something (don't want to do this on an empty set)
+ if(results[0] != null) {
+ logger.debug("LSTokenUtilities: XSLT Starting...");
+ try {

- //create a factory and transformer using the stylesheet
- TransformerFactory factory = TransformerFactory.newInstance();
- Transformer transformer = factory.newTemplates(new StreamSource(new
- File(getSummarySheet()))).newTransformer();
+ //create a factory and transformer using the stylesheet
+ TransformerFactory factory =
TransformerFactory.newInstance();
+ Transformer transformer = factory.newTemplates(new
StreamSource(new File(getSummarySheet()))).newTransformer();

- //need a spot to store the output (temporarily)

- StringWriter sw = new StringWriter();
- transformer.transform(new StreamSource(new StringReader(
- results[0])), new StreamResult(sw));
+ //need a spot to store the output (temporarily)

+ StringWriter sw = new StringWriter();
+ transformer.transform(new StreamSource(new
StringReader(results[0])), new StreamResult(sw));

- output = sw.toString();

- }
- catch (Exception err) {
- logger.error("LSTokenUtilities: Caught XSLT Processing Error");
- }
+ output = sw.toString();

+ }
+ catch (Exception err) {
+ logger.error("LSTokenUtilities: Caught XSLT Processing
Error");
+ }

- //We essentually get back a string (but its really a message) so
- // using a new XMLUtils function we can get this into NMWG format
- Message resultM = (Message)XMLUtils.stringToElement(output,
lsUtil.getParserFile(), "message");
+ //We essentually get back a string (but its really a message) so
+ // using a new XMLUtils function we can get this into NMWG format
+ Message resultM = (Message)XMLUtils.stringToElement(output,
lsUtil.getParserFile(), "message");

- //Get the Metadata from the summary
- Metadata requestMetadata2[] = resultM.getMetadataArray();
- Metadata resultMetadata = null;
- if(requestMetadata2.length > 0){
- resultMetadata = requestMetadata2[0];
- }
+ //Get the Metadata from the summary
+ Metadata requestMetadata2[] = resultM.getMetadataArray();
+ Metadata resultMetadata = null;
+ if(requestMetadata2.length > 0){
+ resultMetadata = requestMetadata2[0];
+ }

- if(resultMetadata == null) {
- String m="LSTokenUtilities: No metadata in request in summary";
- logger.error(m);
- throw new SystemException("error.ls.no_metadata", m);
- }
+ if(resultMetadata == null) {
+ String m="LSTokenUtilities: No metadata in request in
summary";
+ logger.error(m);
+ throw new SystemException("error.ls.no_metadata", m);
+ }

- //Get the data from the summary (check and make sure we have at least
one)
- Collection resultDataArr = resultM.getDataMap().values();
- if(resultDataArr.size() < 1) {
- String m = "LSTokenUtilities: " +
- "Request must have at least one data element - trigger) ";
- logger.error(m);
- throw new SystemException("error.ls.no_data_trigger", m);
- }
+ //Get the data from the summary (check and make sure we have at
least one)
+ Collection resultDataArr = resultM.getDataMap().values();
+ if(resultDataArr.size() < 1) {
+ String m = "LSTokenUtilities: " +
+ "Request must have at least one data element -
trigger) ";
+ logger.error(m);
+ throw new SystemException("error.ls.no_data_trigger", m);
+ }

- logger.debug("LSTokenUtilities: Summary Information Complete");
+ logger.debug("LSTokenUtilities: Summary Information Complete");

- String metadataId = MathUtil.calculateId(lsUtil.getLsAccessPoint(),
lsUtil.getLsServiceRank());
+ String metadataId =
MathUtil.calculateId(lsUtil.getLsAccessPoint(), lsUtil.getLsServiceRank());

- //Take the metadata, and the data, and place them inside of
- // a larger data block (this is the summary)
- Data reqData = new Data();
- reqData.setId("summaryData");
- reqData.setMetadataIdRef(metadataId);
- reqData.addChild(resultMetadata);
- Iterator resultDataArrIterator = resultDataArr.iterator();
- while (resultDataArrIterator.hasNext()) {
- reqData.addChild((Data)resultDataArrIterator.next());
- }
+ //Take the metadata, and the data, and place them inside of
+ // a larger data block (this is the summary)
+ Data reqData = new Data();
+ reqData.setId("summaryData");
+ reqData.setMetadataIdRef(metadataId);
+ reqData.addChild(resultMetadata);
+ Iterator resultDataArrIterator = resultDataArr.iterator();

+ while (resultDataArrIterator.hasNext()) {
+ reqData.addChild((Data)resultDataArrIterator.next());

+ }

- //now we make a metadata that describes who we are...
- Metadata reqMetadata = new Metadata();
- reqMetadata = lsUtil.createLSMetadata(reqMetadata, metadataId);
+ //now we make a metadata that describes who we are...
+ Metadata reqMetadata = new Metadata();
+ reqMetadata = lsUtil.createLSMetadata(reqMetadata, metadataId);

- //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");
+ //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");

- //put them in a message, then insert
- Message registerMessage = new Message();
- registerMessage.setType("LSRegisterRequest");
- registerMessage.addChild(reqData);
- registerMessage.addChild(reqMetadata);
- registerMessage.addChild(reqParams);
+ //put them in a message, then insert
+ Message registerMessage = new Message();
+ registerMessage.setType("LSRegisterRequest");
+ registerMessage.addChild(reqData);
+ registerMessage.addChild(reqMetadata);
+ registerMessage.addChild(reqParams);

- logger.debug("LSTokenUtilities: Created Message: " +
registerMessage.toString());
+ logger.debug("LSTokenUtilities: Created Message: " +
registerMessage.toString());


- //now try to send the message to people
- for(int b = 0; b < metadataCol.size(); b++) {
+ //now try to send the message to people
+ for(int b = 0; b < metadataCol.size(); b++) {

- //don't insert into ourself...
- //if(!(sortedList[b][0].equals(lsUtil.getLsAccessPoint()))) {
+ //don't insert into ourself...
+ //if(!(sortedList[b][0].equals(lsUtil.getLsAccessPoint()))) {

- logger.debug("LSTokenUtilities: Sending message to: " +
sortedList[b][0] + " - " + sortedList[b][1]);
- try {
- org.ggf.ns.nmwg.base.v2_0.Message response =
sendRequest(sortedList[b][0], registerMessage);
- if(response != null) {
- //check to see if we succeeded:
+ logger.debug("LSTokenUtilities: Sending message to: " +
sortedList[b][0] + " - " + sortedList[b][1]);
+ try {
+ org.ggf.ns.nmwg.base.v2_0.Message response =
sendRequest(sortedList[b][0], registerMessage);
+ if(response != null) {
+ //check to see if we succeeded:

- org.ggf.ns.nmwg.base.v2_0.Metadata requestMetadata[] =
response.getMetadataArray();
- if(requestMetadata.length > 0){
+ org.ggf.ns.nmwg.base.v2_0.Metadata
requestMetadata[] = response.getMetadataArray();
+ if(requestMetadata.length > 0){

- logger.debug("LSTokenUtilities: response: " +
requestMetadata[0].toString());
-
if((requestMetadata[0].getEventType().getEventType()).equals("result.success"))
{
- if(Integer.parseInt(sortedList[b][1]) < 3) {
+ logger.debug("LSTokenUtilities: response: " +
requestMetadata[0].toString());
+
if((requestMetadata[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_GLOBAL_PEER_COLLECTION_TYPE +
-
"']//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
-
"[@name='familiar']
with '" + (int)((Integer.parseInt(sortedList[b][1]))+1) + "'";
-
-
+ //update the peers list
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ String update =
XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_VALUE;
+ update = update +
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
+
"']//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
+
"[@name='familiar']
with '" + (int)((Integer.parseInt(sortedList[b][1]))+1) + "'";
+ xmlStorageManager.fetch(update);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath =
"//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
+
"[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_GLOBAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath,
Integer.toString((Integer.parseInt(sortedList[b][1]))+1));
+ }
+ sortedList[b][1] =
Integer.toString(Integer.parseInt(sortedList[b][1]) + 1);
+ }
+ b = metadataCol.size() + 1;

- xmlStorageManager.fetch(update);
- sortedList[b][1] =
Integer.toString(Integer.parseInt(sortedList[b][1]) + 1);
- }
- b = metadataCol.size() + 1;
-
- //advance the scheduler (wait for the real token)
- //scheduler.advanceScheduler(1000 *
Integer.parseInt(getLsTokenFrequency()) * metadataCol.size());
- }
- else {
- logger.debug("LSTokenUtilities: Success Code from peer not
found");
- }
- }
- else {
- logger.debug("LSTokenUtilities: No metadata in peer
response");
- }
- }
- else {
- logger.debug("LSTokenUtilities: 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_GLOBAL_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("LSTokenUtilities: Exception: " + e.toString());
- throw new SystemException("error.ls.client_error",
- "Error sending to client LS " +
- e.getMessage());
- }
- //}
- }
+ //advance the scheduler (wait for the
real token)
+ //scheduler.advanceScheduler(1000 *
Integer.parseInt(getLsTokenFrequency()) * metadataCol.size());
+ }
+ else {
+ logger.debug("LSTokenUtilities: Success
Code from peer not found");
+ }
+ }
+ else {
+ logger.debug("LSTokenUtilities: No metadata
in peer response");
+ }
+ }
+ else {
+ logger.debug("LSTokenUtilities: Null response
when talking to peer");
+ if(Integer.parseInt(sortedList[b][1]) > 0) {
+ //update the peers list

-
- }
- else {
- //the LSStore has no data, so do we need to do anything here?
+ if(xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager ||
+ xmlStorageManager instanceof
ExistDbHttpXmlStorageManager) {
+ String update = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_VALUE;
+ update = update +
"/nmwg:store[@type='"
+ LS_GLOBAL_PEER_COLLECTION_TYPE +
+
"']//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
+
"[@name='familiar']
with '" + (int)(Integer.parseInt(sortedList[b][1])-1) + "'";
+ xmlStorageManager.fetch(update);
+ }
+ else if(xmlStorageManager instanceof
BerkeleyDbXmlStorageManager) {
+ String xPath =
"//nmwg:parameters[@id='"
+ sortedList[b][0] + "']/nmwg:parameter" +
+
"[@name='familiar']";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_GLOBAL_PEER_CONTAINER,

+ XQUERY_UPDATE_DECLARE, xPath,
Integer.toString((Integer.parseInt(sortedList[b][1]))-1));
+ }
+
+
+ sortedList[b][1] =
Integer.toString(Integer.parseInt(sortedList[b][1])-1);
+ }
+ }
+ }
+ catch(Exception e) {
+ logger.debug("LSTokenUtilities: Exception: " +
e.toString());
+ throw new SystemException("error.ls.client_error",
+ "Error sending to client LS
" +
+ e.getMessage());
+ }
+ //}
+ }
+ }
+ else {
+ //the LSStore has no data, so do we need to do anything here?
+ }
+ return;
}

- return;
- }

-
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSUtilities.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSUtilities.java
2006-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSUtilities.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -12,10 +12,12 @@

import org.perfsonar.commons.util.XMLUtils;
import org.perfsonar.commons.util.MathUtil;
+
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.XmlDbDataRepository;
@@ -23,6 +25,7 @@
import org.perfsonar.service.commons.storage.xmldb.exist.ExistDbFactory;
import org.perfsonar.service.commons.storage.xmldb.XmlDbConstants;
import
org.perfsonar.service.commons.storage.xmldb.exist.rest.ExistDbHTTPAccess;
+import
org.perfsonar.service.commons.storage.xmldb.exist.rest.ExistDbHttpXmlStorageManager;

import java.io.IOException;
import java.io.File;
@@ -35,351 +38,373 @@

/**
* Action that summarizes database content
- * @author Jason Zurawski
+ * @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/
-
public class LSUtilities {

- /**
- * The object to log control/debugging messages
- */
- private LoggerComponent logger = null;

- /**
- * Reference to configuration
- */
- protected ConfigurationComponent configuration;
+ /**
+ * The object to log control/debugging messages
+ */
+ private LoggerComponent logger = null;

- /**
- * name of property in config file
- */
- private static final String LS_ACCESS_POINT = "service.r.access_point";

- /**
- * name of property in config file
- */
- private static final String LS_SERVICE_NAME = "service.r.service_name";
+ /**
+ * Reference to configuration
+ */
+ protected ConfigurationComponent configuration;
+
+
+ /**
+ * name of property in config file
+ */
+ private static final String LS_ACCESS_POINT = "service.r.access_point";
+
+
+ /**
+ * name of property in config file
+ */
+ private static final String LS_SERVICE_NAME = "service.r.service_name";
+

- /**
- * name of property in config file
- */
- private static final String LS_SERVICE_TYPE = "service.r.service_type";
+ /**
+ * name of property in config file
+ */
+ private static final String LS_SERVICE_TYPE = "service.r.service_type";

- /**
- * name of property in config file
- */
- private static final String LS_SERVICE_DESCRIPTION =
"service.r.service_description";

- /**
- * name of property in config file
- */
- private static final String SAX_PARSER_FILE = "service.sax_parser.config";
+ /**
+ * name of property in config file
+ */
+ private static final String LS_SERVICE_DESCRIPTION =
"service.r.service_description";
+
+
+ /**
+ * name of property in config file
+ */
+ private static final String SAX_PARSER_FILE =
"service.sax_parser.config";
+

- /**
- * name of property in config file
- */
- private static final String LS_SERVICE_RANK = "service.r.service_rank";
+ /**
+ * name of property in config file
+ */
+ private static final String LS_SERVICE_RANK = "service.r.service_rank";

- /**
- * ls access point (used to fabricate the md)
- */
- private String lsAccessPoint = "";

- /**
- * ls service name (used to fabricate the md)
- */
- private String lsServiceName = "";
+ /**
+ * ls access point (used to fabricate the md)
+ */
+ private String lsAccessPoint = "";

- /**
- * ls service type (used to fabricate the md)
- */
- private String lsServiceType = "";

- /**
- * ls service description (used to fabricate the md)
- */
- private String lsServiceDescription = "";
+ /**
+ * ls service name (used to fabricate the md)
+ */
+ private String lsServiceName = "";

- /**
- * location of sax parser file
- */
- private String parserFile = "";

- /**
- * ls service rank (used to manipulate the ID value)
- */
- private String lsServiceRank = "";
+ /**
+ * ls service type (used to fabricate the md)
+ */
+ private String lsServiceType = "";

- /**
- * LSUtilities constructor
- */
- public LSUtilities() throws SystemException {

- //get logger
- logger = (LoggerComponent)AuxiliaryComponentManager.
- getInstance().getComponent(ComponentNames.LOGGER);
+ /**
+ * ls service description (used to fabricate the md)
+ */
+ private String lsServiceDescription = "";
+
+
+ /**
+ * location of sax parser file
+ */
+ private String parserFile = "";
+
+
+ /**
+ * ls service rank (used to manipulate the ID value)
+ */
+ private String lsServiceRank = "";
+
+
+ /**
+ * LSUtilities constructor
+ */
+ public LSUtilities() throws SystemException {
+
+ //get logger
+ logger = (LoggerComponent)AuxiliaryComponentManager.
+ getInstance().getComponent(ComponentNames.LOGGER);

- //get configuration
- configuration = (ConfigurationComponent)AuxiliaryComponentManager.
- getInstance().getComponent(ComponentNames.CONFIG);
+ //get configuration
+ configuration = (ConfigurationComponent)AuxiliaryComponentManager.
+ getInstance().getComponent(ComponentNames.CONFIG);

- String temp = "";
- try {
- temp = configuration.getProperty(LS_ACCESS_POINT);
- }
- catch (SystemException e) {
- temp = null;
- }
+ String temp = "";
+ try {
+ temp = configuration.getProperty(LS_ACCESS_POINT);
+ }
+ catch (SystemException e) {
+ temp = null;
+ }

- if(temp != null) {
- setLsAccessPoint(temp);
- }
- else {
- // we need to throw an error or something...
- }
- logger.debug("LSUtilities: LS ACCESS_POINT=" + getLsAccessPoint());
+ if(temp != null) {
+ setLsAccessPoint(temp);
+ }
+ else {
+ // we need to throw an error or something...
+ }
+ logger.debug("LSUtilities: LS ACCESS_POINT=" + getLsAccessPoint());

-

- try {
- temp = configuration.getProperty(LS_SERVICE_NAME);
- }
- catch (SystemException e) {
- temp = null;
- }
+ try {
+ temp = configuration.getProperty(LS_SERVICE_NAME);
+ }
+ catch (SystemException e) {
+ temp = null;
+ }

- if(temp != null) {
- setLsServiceName(temp);
- }
- else {
- // we need to throw an error or something...
- }
- logger.debug("LSUtilities: LS SERVICE_NAME=" + getLsServiceName());
+ if(temp != null) {
+ setLsServiceName(temp);
+ }
+ else {
+ // we need to throw an error or something...
+ }
+ logger.debug("LSUtilities: LS SERVICE_NAME=" + getLsServiceName());



- try {
- temp = configuration.getProperty(LS_SERVICE_TYPE);
- }
- catch (SystemException e) {
- temp = null;
- }
+ try {
+ temp = configuration.getProperty(LS_SERVICE_TYPE);
+ }
+ catch (SystemException e) {
+ temp = null;
+ }

- if(temp != null) {
- setLsServiceType(temp);
- }
- else {
- // we need to throw an error or something...
- }
- logger.debug("LSUtilities: LS SERVICE_TYPE=" + getLsServiceType());
+ if(temp != null) {
+ setLsServiceType(temp);
+ }
+ else {
+ // we need to throw an error or something...
+ }
+ logger.debug("LSUtilities: LS SERVICE_TYPE=" + getLsServiceType());



- try {
- temp = configuration.getProperty(LS_SERVICE_DESCRIPTION);
- }
- catch (SystemException e) {
- temp = null;
- }
+ try {
+ temp = configuration.getProperty(LS_SERVICE_DESCRIPTION);
+ }
+ catch (SystemException e) {
+ temp = null;
+ }

- if(temp != null) {
- setLsServiceDescription(temp);
- }
- else {
- // we need to throw an error or something...
- }
- logger.debug("LSUtilities: LS SERVICE_DESCRIPTION=" +
getLsServiceDescription());
+ if(temp != null) {
+ setLsServiceDescription(temp);
+ }
+ else {
+ // we need to throw an error or something...
+ }
+ logger.debug("LSUtilities: LS SERVICE_DESCRIPTION=" +
getLsServiceDescription());

- try {
- temp = configuration.getProperty(SAX_PARSER_FILE);
- }
- catch (SystemException e) {
- temp = null;
- }
+ try {
+ temp = configuration.getProperty(SAX_PARSER_FILE);
+ }
+ catch (SystemException e) {
+ temp = null;
+ }

- if(temp != null) {
- setParserFile(temp);
- }
- else {
- // we need to throw an error or something...
- }
- logger.debug("LSUtilities: LS SAX=" + getParserFile());
+ if(temp != null) {
+ setParserFile(temp);
+ }
+ else {
+ // we need to throw an error or something...
+ }
+ logger.debug("LSUtilities: LS SAX=" + getParserFile());

- try {
- temp = configuration.getProperty(LS_SERVICE_RANK);
- }
- catch (SystemException e) {
- temp = null;
- }
+ try {
+ temp = configuration.getProperty(LS_SERVICE_RANK);
+ }
+ catch (SystemException e) {
+ temp = null;
+ }

- if(temp != null) {
- setLsServiceRank(temp);
- }
- else {
- // we need to throw an error or something...
+ if(temp != null) {
+ setLsServiceRank(temp);
+ }
+ else {
+ // we need to throw an error or something...
+ }
+ logger.debug("LSUtilities: LS SERVICE_RANK=" + getLsServiceRank());

+
}
- logger.debug("LSUtilities: LS SERVICE_RANK=" + getLsServiceRank());
-
- }

- /**
- * set the value of the access point
- */
- public void setLsAccessPoint(String newLsAccessPoint) {
- lsAccessPoint = newLsAccessPoint;
- return;
- }
+
+ /**
+ * set the value of the access point
+ */
+ public void setLsAccessPoint(String newLsAccessPoint) {
+ lsAccessPoint = newLsAccessPoint;
+ return;
+ }
+

- /**
- * get the value of the access point
- */
- public String getLsAccessPoint() {
- return lsAccessPoint;
- }
+ /**
+ * get the value of the access point
+ */
+ public String getLsAccessPoint() {
+ return lsAccessPoint;
+ }

- /**
- * set the value of the service name
- */
- public void setLsServiceName(String newLsServiceName) {
- lsServiceName = newLsServiceName;
- return;
- }

- /**
- * get the value of the service name
- */
- public String getLsServiceName() {
- return lsServiceName;
- }
+ /**
+ * set the value of the service name
+ */
+ public void setLsServiceName(String newLsServiceName) {
+ lsServiceName = newLsServiceName;
+ return;
+ }

- /**
- * set the value of the service type
- */
- public void setLsServiceType(String newLsServiceType) {
- lsServiceType = newLsServiceType;
- return;
- }
+
+ /**
+ * get the value of the service name
+ */
+ public String getLsServiceName() {
+ return lsServiceName;
+ }
+
+
+ /**
+ * set the value of the service type
+ */
+ public void setLsServiceType(String newLsServiceType) {
+ lsServiceType = newLsServiceType;
+ return;
+ }

- /**
- * get the value of the service type
- */
- public String getLsServiceType() {
- return lsServiceType;
- }

- /**
- * set the value of the service description
- */
- public void setLsServiceDescription(String newLsServiceDescription) {
- lsServiceDescription = newLsServiceDescription;
- return;
- }
+ /**
+ * get the value of the service type
+ */
+ public String getLsServiceType() {
+ return lsServiceType;
+ }

- /**
- * get the value of the service description
- */
- public String getLsServiceDescription() {
- return lsServiceDescription;
- }
+
+ /**
+ * set the value of the service description
+ */
+ public void setLsServiceDescription(String newLsServiceDescription) {
+ lsServiceDescription = newLsServiceDescription;
+ return;
+ }
+
+ /**
+ * get the value of the service description
+ */
+ public String getLsServiceDescription() {
+ return lsServiceDescription;
+ }

- /**
- * Set the value of the parser file
- */
- public void setParserFile(String newParserFile) {
- parserFile = newParserFile;
- return;
- }
+ /**
+ * Set the value of the parser file
+ */
+ public void setParserFile(String newParserFile) {
+ parserFile = newParserFile;
+ return;
+ }

- /**
- * get the value of the parser file
- */
- public String getParserFile() {
- return parserFile;
- }
+ /**
+ * get the value of the parser file
+ */
+ public String getParserFile() {
+ return parserFile;
+ }

- /**
- * set the value of the service rank
- */
- public void setLsServiceRank(String newLsServiceRank) {
- lsServiceRank = newLsServiceRank;
- return;
- }
+ /**
+ * set the value of the service rank
+ */
+ public void setLsServiceRank(String newLsServiceRank) {
+ lsServiceRank = newLsServiceRank;
+ return;
+ }

- /**
- * get the value of the service rank
- */
- public String getLsServiceRank() {
- return lsServiceRank;
- }
+ /**
+ * get the value of the service rank
+ */
+ public String getLsServiceRank() {
+ return lsServiceRank;
+ }

- /**
- * Create element containing md describing the LS
- */
- public org.ggf.ns.nmwg.base.v2_0.Metadata createLSMetadata(
- org.ggf.ns.nmwg.base.v2_0.Metadata reqMetadata, String metadataId) {
+ /**
+ * Create element containing md describing the LS
+ */
+ public org.ggf.ns.nmwg.base.v2_0.Metadata createLSMetadata(
+ org.ggf.ns.nmwg.base.v2_0.Metadata reqMetadata, String metadataId) {


- reqMetadata.setId(metadataId);
+ reqMetadata.setId(metadataId);

- org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject reqSub = new
org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject();
+ org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject reqSub = new
org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject();

- org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.Service reqServ = new
org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.Service();
+ org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.Service reqServ =
new org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.Service();

- org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.ServiceName reqSN =
new org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.ServiceName();
- org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.AccessPoint reqAP =
new org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.AccessPoint();
- org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.ServiceType reqST =
new org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.ServiceType();
- org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.ServiceDescription
reqSD = new
org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.ServiceDescription();
+ org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.ServiceName reqSN =
new org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.ServiceName();
+ org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.AccessPoint reqAP =
new org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.AccessPoint();
+ org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.ServiceType reqST =
new org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.ServiceType();
+ org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.ServiceDescription
reqSD = new
org.ggf.ns.nmwg.tools.org.perfsonar.service.v1_0.ServiceDescription();

- reqSN.setServiceName(getLsServiceName());
- reqServ.setServiceName(reqSN);
+ reqSN.setServiceName(getLsServiceName());
+ reqServ.setServiceName(reqSN);

- reqAP.setAccessPoint(getLsAccessPoint());
- reqServ.setAccessPoint(reqAP);
+ reqAP.setAccessPoint(getLsAccessPoint());
+ reqServ.setAccessPoint(reqAP);

- reqST.setServiceType(getLsServiceType());
- reqServ.setServiceType(reqST);
+ reqST.setServiceType(getLsServiceType());
+ reqServ.setServiceType(reqST);

- reqSD.setServiceDescription(getLsServiceDescription());
- reqServ.setServiceDescription(reqSD);
+ reqSD.setServiceDescription(getLsServiceDescription());
+ reqServ.setServiceDescription(reqSD);

- reqServ.setId("summaryService");
+ reqServ.setId("summaryService");

- reqSub.setService(reqServ);
- reqSub.setId("summarySubject");
- reqMetadata.addChild(reqSub);
- return reqMetadata;
- }
+ reqSub.setService(reqServ);
+ reqSub.setId("summarySubject");
+ reqMetadata.addChild(reqSub);
+ return reqMetadata;
+ }

- /**
- * Create element containing parameters for the summary message
- */
- public org.ggf.ns.nmwg.base.v2_0.Parameters createSummaryParameters(
- org.ggf.ns.nmwg.base.v2_0.Parameters reqParams, String name, String
value) {
+ /**
+ * Create element containing parameters for the summary message
+ */
+ public org.ggf.ns.nmwg.base.v2_0.Parameters createSummaryParameters(
+ org.ggf.ns.nmwg.base.v2_0.Parameters reqParams, String name, String
value) {

- org.ggf.ns.nmwg.base.v2_0.Parameter reqParam = new
org.ggf.ns.nmwg.base.v2_0.Parameter();
- reqParam.unSetUseText();
- reqParam.setParameterName(name);
- reqParam.setParameterValue(value);
- reqParams.addParameter(reqParam);
+ org.ggf.ns.nmwg.base.v2_0.Parameter reqParam = new
org.ggf.ns.nmwg.base.v2_0.Parameter();
+ reqParam.unSetUseText();
+ reqParam.setParameterName(name);
+ reqParam.setParameterValue(value);
+ reqParams.addParameter(reqParam);

- return reqParams;
- }
+ return reqParams;
+ }

- /**
- * Return the contents of the LSStore file in the collection.
- */
- public String[] getDBContents(StorageManager xmlStorageManager, String
query) throws
- SystemException, RequestException, DataFormatException {
- String output = null;
- String[] results;
+ /**
+ * Return the contents of the LSStore file in the collection.
+ */
+ public String[] getDBContents(StorageManager xmlStorageManager, String
query) throws
+ SystemException, RequestException, DataFormatException {
+ String output = null;
+ String[] results;

- query = XMLUtils.convertEntitiesToCharacters(query);
+ query = XMLUtils.convertEntitiesToCharacters(query);

- XmlDbResult edbres = (XmlDbResult)xmlStorageManager.fetch(query);
- results = (String[])edbres.getResultAsStringArray();
+ XmlDbResult edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();

- logger.debug("LSUtilities: result[0]: " + results[0]);
- return results;
- }
+ logger.debug("LSUtilities: result[0]: " + results[0]);
+ return results;
+ }

}

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-11-09 12:48:39 UTC (rev 1750)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
2006-11-13 07:58:28 UTC (rev 1751)
@@ -5,15 +5,19 @@
package org.perfsonar.service.lookupService.xmlType;

import org.ggf.ns.nmwg.base.v2_0.Message;
+
import org.perfsonar.commons.auxiliary.AuxiliaryComponentManager;
import org.perfsonar.commons.auxiliary.ComponentNames;
import
org.perfsonar.commons.auxiliary.components.configuration.ConfigurationComponent;
import org.perfsonar.commons.auxiliary.components.logger.LoggerComponent;
+
import org.perfsonar.service.commons.engine.ActionType;
import org.perfsonar.service.commons.engine.ServiceEngine;
+
import org.perfsonar.service.commons.exceptions.DataFormatException;
import org.perfsonar.service.commons.exceptions.RequestException;
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;
@@ -27,7 +31,9 @@
* taken from the service config file
*
* @see org.perfsonar.service.commons.ServiceEngine
- * @author Maciej Glowiak
+ * @author Maciej Glowiak
+ * @author Jason Zurawski (contrib.)
+ * @author Yi Hu (contrib.)
*
*/
public class XmlTypeLSServiceEngine implements ServiceEngine {
@@ -35,22 +41,22 @@

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

- /**
+ /**
* Service database type: "eXist or BDB"
*/
-// private static final String SERVICE_DATABASE_TYPE = "BDB";
- private static final String SERVICE_DATABASE_TYPE = "eXist";
-
-
+// private static final String SERVICE_DATABASE_TYPE = "BDB";
+ private static final String SERVICE_DATABASE_TYPE = "eXist";
+
+
/**
* Service engine type
*/
private static final String SERVICE_ENGINE_TYPE =
"service.LookupService";


+
// ---------------------------------------------------------- class
fields

-
/**
* Type of service angine.
*/
@@ -68,15 +74,18 @@
*/
private LoggerComponent logger = null;

+
/**
* The object to configuration
*/
private ConfigurationComponent config;
+

/**
* Storage Manager Type
*/
private String smType;
+

/**
* Construction for the service engine
@@ -214,31 +223,29 @@

org.ggf.ns.nmwg.base.v2_0.Parameter summaryParam = null;
if(request.getParameters() != null) {
- summaryParam =
request.getParameters().getParameterByName("token");
- if(summaryParam != null) {
- if(summaryParam.getParameterValue().equals("local")) {
- XmlDbStorageManager xmlDbStorageManager =
- getStorageManager(smType);
- LSAction action = new
LSLocalTokenAction(xmlDbStorageManager);
- response = action.performAction(request);
+ summaryParam =
request.getParameters().getParameterByName("token");
+ if(summaryParam != null) {
+ if(summaryParam.getParameterValue().equals("local")) {
+ XmlDbStorageManager xmlDbStorageManager =
getStorageManager(smType);
+ LSAction action = new
LSLocalTokenAction(xmlDbStorageManager);
+ response = action.performAction(request);
+ }
+ else
if(summaryParam.getParameterValue().equals("global")) {
+ XmlDbStorageManager xmlDbStorageManager =
getStorageManager(smType);
+ LSAction action = new
LSGlobalTokenAction(xmlDbStorageManager);
+ response = action.performAction(request);
+ }
+ else {
+ throw new
SystemException("error.ls.action_parameters_wrong",
+ "XmlTypeLSServiceEngine:
Action ["
+ +actionType+"] is missing
(local|global) summary parameters");
+ }
}
- else if(summaryParam.getParameterValue().equals("global")) {
- XmlDbStorageManager xmlDbStorageManager =
- getStorageManager(smType);
- LSAction action = new
LSGlobalTokenAction(xmlDbStorageManager);
- response = action.performAction(request);
- }
- else {
+ else {
throw new
SystemException("error.ls.action_parameters_wrong",
- "XmlTypeLSServiceEngine: Action ["
- +actionType+"] is missing (local|global) summary
parameters");
- }
- }
- else {
- throw new
SystemException("error.ls.action_parameters_wrong",
- "XmlTypeLSServiceEngine: Action ["
- +actionType+"] is missing summary parameters");
- }
+ "XmlTypeLSServiceEngine:
Action ["
+ +actionType+"] is missing
summary parameters");
+ }
}
else {
throw new
SystemException("error.ls.action_parameters_missing",



  • r1751 - in branches/yi-udel/perfsonar/src/org/perfsonar: commons/auxiliary/components/simplescheduler commons/util service/commons/storage/xmldb/bdbxml service/lookupService/xmlType, svnlog, 11/13/2006

Archive powered by MHonArc 2.6.16.

Top of Page