Skip to Content.
Sympa Menu

perfsonar-dev - r1607 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType

Subject: perfsonar development work

List archive

r1607 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType


Chronological Thread 
  • From:
  • To:
  • Subject: r1607 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType
  • Date: Wed, 6 Sep 2006 06:44:57 -0400

Author: mac
Date: 2006-09-06 06:44:57 -0400 (Wed, 06 Sep 2006)
New Revision: 1607

Modified:

trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.java

trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanupLoader.java

trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
Log:
Changes for Bug #67. Now both HTTP and XMLRPC connectors work with LSCleanup.
HTTP access to eXist DB has been updated as well as ant configuration targets.
More info will be provided in bugzilla

Modified:
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.java
2006-09-06 10:43:08 UTC (rev 1606)
+++
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.java
2006-09-06 10:44:57 UTC (rev 1607)
@@ -20,19 +20,35 @@

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

+ /**
+ * default value of LS TTL
+ */
+ 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";

- public static final long DEFAULT_CLEANUP_TIMEOUT = 60;
-
// -------------------------------------------- Instance variables

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

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


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


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

@@ -41,89 +57,127 @@
//read service.ls.lookup_info_timeout
String prop = null;
try {
- prop = configuration.getProperty(
- "service.ls.lookup_info_timeout");
+ prop = configuration.getProperty(LS_TTL_PROPERTY);
} catch (SystemException sex) {
prop=null;
}

if (prop!=null) {
try {
- timeout = Long.parseLong(prop);
+ lsTTL = Long.parseLong(prop);
} catch (Exception ex) {
- logger.debug("LSRegisterAction:
lookup_info_timeout=default");
- timeout = DEFAULT_CLEANUP_TIMEOUT;
+ logger.debug("LSRegisterAction: LS TTL=default");
+ lsTTL = DEFAULT_LS_TTL;
}
} else {
- logger.debug("LSRegisterAction: lookup_info_timeout=default");
- timeout = DEFAULT_CLEANUP_TIMEOUT;
+ logger.debug("LSRegisterAction: LS TTL=default");
+ lsTTL = DEFAULT_LS_TTL;
}
- logger.debug("LSRegisterAction: lookup_info_timeout="+timeout);
+ 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
+
+
+ long now = System.currentTimeMillis(); // current timestamp
+
+ //process all keys from Database
String[] keys = getMetadataKeys(xmlStorageManager);

- long now = System.currentTimeMillis();
-
+ //for each of them check timestamp parameter
for (int i=0; i<keys.length; i++) {
+ if ("".equals(keys[i])) break;

- logger.debug("LSCleanup: key="+keys[i]);
+ logger.debug("LSCleanup: checking key ["+keys[i]+"]");

String timestampStr = getControlParameter(
- keys[i],"timestamp",xmlStorageManager);
+ keys[i],
+ "timestamp",
+ xmlStorageManager);

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

if (uptime==0) {
- logger.debug("LSCleanup: **** omitting, timestamp=0 or no
timestamp");
+ logger.debug("LSCleanup: omitting key ["+keys[i]+"],
timestamp=0 or no timestamp parameter");
+
//TODO: what to do?
//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 > (now-timeout)) {
+ if ( (uptime + getLsTTLInMillis() - now ) < 0) {

- logger.info("LSCleanup: Time exceeded - Removing
metadata for key ["+keys[i]+"] and related data");
+ logger.info("LSCleanup: Time exceeded - " +
+ "REMOVING metadata for key ["+
+ keys[i]+"] and related data");
+
//generate XUpdate that removes data
//removes data from ALL schemas (LSStore,
LSStore-control)
String query;
query = XUPDATE_HEADER +
- "<xu:remove
select=\"/nmwg:store/nmwg:metadata[@id='"+keys[i]+"']\"/>\n"
+
- "<xu:remove
select=\"/nmwg:store/nmwg:data[@metadataIdRef='"+keys[i]+"']\"/>\n"
+
+ "<xu:remove
select=\"/nmwg:store/nmwg:metadata[@id='"+
+ keys[i]+"']\"/>\n" +
+ "<xu:remove
select=\"/nmwg:store/nmwg:data[@metadataIdRef='"+
+ keys[i]+"']\"/>\n" +
XUPDATE_FOOTER;
+
+ //remove

- //TODO: uncomment!!!!!!!!!!!!!!!!1
+ /****/
xmlStorageManager.store(query); //XUpdate
+ /****/

- }
+ } //if

- }
+ } //else

- }
+ } //for

- return null;
+ return null; //result unimportant

}


// -------------------------------------------------------- private
methods

+
/**
+ * get LS TTL in milliseconds
+ */
+ private long getLsTTLInMillis() {
+
+ return lsTTL * 1000; //because lsTTP is in seconds
+
+ }
+
+
+ /**
* Get all metadata keys / metadata ids
*/
- protected String[] getMetadataKeys(StorageManager xmlStorageManager)
throws SystemException, RequestException, DataFormatException {
+ protected String[] getMetadataKeys(StorageManager xmlStorageManager)
+ throws SystemException, RequestException, DataFormatException {

String query =
"declare namespace nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
@@ -147,16 +201,17 @@

String query =
"declare namespace nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
-
"/nmwg:store[@type='"+LS_STORE_COLLECTION_TYPE+
+
"/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);
String[] resArray = (String[])edbres.getResultAsStringArray();
+
try {
String result = resArray[0];
- return result;
+ return result.trim();
} catch (Exception ex) {
return null;
}
@@ -171,14 +226,12 @@
logger.info("LSCleanup: Run as scheduled action for the ["+
iterations+"] time");

- try {
- performAction(null);
+ try {
+ performAction(null); //input unimportant
} catch (PerfSONARException e) {
}

}


-
-
} //LSCleanup

Modified:
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanupLoader.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanupLoader.java
2006-09-06 10:43:08 UTC (rev 1606)
+++
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanupLoader.java
2006-09-06 10:44:57 UTC (rev 1607)
@@ -20,9 +20,9 @@
// ----------------------------------------------------- constants


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

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


//---------------------------------------------- private variables
@@ -62,7 +62,6 @@
String m = "Cannot get config component ";
throw new SystemException("error.common.no_configuration", m);

}
-

//Get configuration

@@ -83,7 +82,8 @@
interval = DEFAULT_RUN_INTERVAL;
}

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

//get scheduler - parameter "component.CName.scheduler_component"
try {
@@ -108,16 +108,20 @@
+e.getMessage());
}

- //get storage component - parameter
"component.CName.storage_component
+ //get storage component of specified type
try {
- String storageVal = config.getProperty(
- "component."+componentName+".storage_component");
- logger.debug("LSCleanupLoader: parameter STORAGE="+storageVal);

- storage = (StorageManager)
- AuxiliaryComponentManager.getInstance().
- getComponent(storageVal);
+ String smType = config.getProperty("service.ls.db_type");
+ storage = XmlTypeLSServiceEngine.getStorageManager(smType);

+// String storageVal = config.getProperty(
+// "component."+componentName+".storage_component");
+// logger.debug("LSCleanupLoader: parameter STORAGE="+storageVal);
+//
+// storage = (StorageManager)
+// AuxiliaryComponentManager.getInstance().
+// getComponent(storageVal);
+
if (storage==null)
throw new SystemException("error.ls.no_storage",
"No such component in AuxiliaryComponentManager");
@@ -130,8 +134,9 @@
}


- //add cleanup action to scheduler
- scheduler.addSchedulerTask(interval, new LSCleanup(storage));
+ //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.


Modified:
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
2006-09-06 10:43:08 UTC (rev 1606)
+++
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
2006-09-06 10:44:57 UTC (rev 1607)
@@ -226,12 +226,12 @@



- protected XmlDbStorageManager getStorageManager(String type)
+ protected static XmlDbStorageManager getStorageManager(String type)
throws SystemException {

XmlDbDataRepository dataRepository =
ExistDbFactory.getDataRepositoryByProperties(
- smType,
+ type,
"service.ls.db_uri",
"service.ls.db_username",
"service.ls.db_password");



  • r1607 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType, svnlog, 09/06/2006

Archive powered by MHonArc 2.6.16.

Top of Page