Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r4915 - in branches/simple-service-with-base2: conf src/main/java/org/perfsonar/base2/service/registration

Subject: perfsonar development work

List archive

perfsonar: r4915 - in branches/simple-service-with-base2: conf src/main/java/org/perfsonar/base2/service/registration


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r4915 - in branches/simple-service-with-base2: conf src/main/java/org/perfsonar/base2/service/registration
  • Date: Wed, 28 Jan 2009 07:13:25 -0500

Author: roman
Date: 2009-01-28 07:13:25 -0500 (Wed, 28 Jan 2009)
New Revision: 4915

Modified:
branches/simple-service-with-base2/conf/configuration-ma.xml

branches/simple-service-with-base2/src/main/java/org/perfsonar/base2/service/registration/LSRegistrationAction.java
Log:
Refreshing (periodically removing all keys) feature added.



Modified: branches/simple-service-with-base2/conf/configuration-ma.xml
===================================================================
--- branches/simple-service-with-base2/conf/configuration-ma.xml
2009-01-27 14:04:58 UTC (rev 4914)
+++ branches/simple-service-with-base2/conf/configuration-ma.xml
2009-01-28 12:13:25 UTC (rev 4915)
@@ -123,6 +123,8 @@
<option name ="lsAddress-5"></option>
<option name ="lsAddress-6"></option>
-->
+ <!--optional parameter -->
+ <option name="keyRefresh" value="0"/>
</action>

</actions>

Modified:
branches/simple-service-with-base2/src/main/java/org/perfsonar/base2/service/registration/LSRegistrationAction.java
===================================================================
---
branches/simple-service-with-base2/src/main/java/org/perfsonar/base2/service/registration/LSRegistrationAction.java
2009-01-27 14:04:58 UTC (rev 4914)
+++
branches/simple-service-with-base2/src/main/java/org/perfsonar/base2/service/registration/LSRegistrationAction.java
2009-01-28 12:13:25 UTC (rev 4915)
@@ -40,22 +40,70 @@

// ----------------------------------------------------------- Variables

-
+ /**
+ * Default data source class.
+ */
protected static final String DEFAULT_REGISTER_DATA_SOURCE =
"org.perfsonar.base2.service.registration.DumbRegisterDataSource";

+ /**
+ * Default value of refresh parameter. It is the number of iterations
(sending a request to LS(s)) after when refresh operation
+ * is peformed (all LS keys are removed).
+ * 0 - no refershing; 1- refershing after just 1 iteration; 2 -
refreshing after 2 iterations, ...
+ */
+ protected static final int DEFAULT_REFRESH = 100;
+
+ protected int refreshCounter = 0;
+ protected int refresh;
+
+ /**
+ * The name of extension section in the configuration. The extension
contains the address of remote file having LS addresses.
+ */
protected static final String REGISTER_LS_ADDRESSES_EXTENSION_NAME =
"registerExtension-lsAddresses";

+ /**
+ * EventType name which is included in the metadata of LSRegisterRequest
message.
+ */
protected static final String REGISTRATION_EVENT_TYPE =

"http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/registration/service/2.0";;

- protected static final String REGISTRATION_MESSAGE_TYPE =
"LSRegisterRequest";
+ /**
+ * Message type.
+ */
+ protected static final String REGISTRATION_REQUEST_MESSAGE_TYPE =
"LSRegisterRequest";

+ /**
+ * Message type.
+ */
+ protected static final String KEEPALIVE_RESPONSE_MESSAGE_TYPE =
"LSKeepaliveResponse";
+
+ /**
+ * Allows logging.
+ */
private static final Logger logger =
Logger.getLogger(LSRegistrationAction.class.getName());

+ /**
+ * Provides metadatat configuration which is sent to LS(s).
+ */
protected RegisterDataSource dataSource = null;
+
+ /**
+ * Set of information about the service taken from the configuration.
+ */
protected LookupInformation lookupInformation = null;
+
+ /**
+ * Sends messages to LS(s).
+ */
protected LSRegistrator registrator = null;
+
+ /**
+ * The array of LS addresses.
+ */
protected URL[] lsURLs;
+
+ /**
+ * The array of keys sent by LSs (the order of keys refer to LSs in
lsURLs array).
+ */
protected Element[] lsKeys;

protected boolean initiated = false;
@@ -80,6 +128,7 @@
initiated = true;
}
execute();
+ refresh();
} catch (Exception ex) {

logger.error(
@@ -102,6 +151,7 @@
for (int i = 0; i < lsURLs.length; i++) lsKeys[i] = null;

registrator = getLSRegistrator();
+ refresh = getRefreshParameter();

}

@@ -121,7 +171,7 @@
for (int i = 0; i < lsURLs.length; i++) {

if (lsKeys[i] == null) {
- // sending the LsRegisterRequest
+ // sending the LSRegisterRequest
serviceResponseMessage[i] =
registrator.register(requestMessage, lsURLs[i]);
} else {
// sending the LSKeepaliveRequest
@@ -144,11 +194,32 @@
lsKeys[i] =
responseMetadata.getChildren("key").iterator().next();
} else if (eventType.getText().trim().indexOf("success.ls")
== -1) {
lsKeys[i] = null;
+ try {
+ // in case of LSKeepaliveRequest failed
LsRegiserRequest should be sent
+ if
(responseMessage.getAttribute("type").equals(KEEPALIVE_RESPONSE_MESSAGE_TYPE))
{
+ i--;
+ continue;
+ }
+ } catch (Exception ex) {;}
}
} else {
lsKeys[i] = null;
}

+ } //for
+
+ }
+
+
+ /**
+ * Removes all existing keys
+ */
+ protected void refresh() {
+
+ refreshCounter++;
+ if (refreshCounter == refresh) {
+ refreshCounter = 0;
+ for (int i = 0; i < lsURLs.length; i++) lsKeys[i] = null;
}

}
@@ -331,12 +402,27 @@
}


+ protected int getRefreshParameter() throws PerfSONARException {
+
+ int refresh = DEFAULT_REFRESH;
+ try {
+ String refershStr = getOption("keyRefresh").getValue();
+ refresh = Integer.parseInt(refershStr);
+ } catch (NumberFormatException ex1) {
+ logger.warn("Wrong format of register refresh parameter.");
+ } catch (PerfSONARException ex2) {
+ logger.debug("Default value of refresh parameter is taken.");
+ }
+ return refresh;
+ }
+
+
protected ServiceMessage getLSRegsiterMessage() throws
PerfSONARException {

ServiceMessage serviceMessage = new ServiceMessage();

Message message = new Message();
- message.setType(REGISTRATION_MESSAGE_TYPE);
+ message.setType(REGISTRATION_REQUEST_MESSAGE_TYPE);
serviceMessage.setElement(message);

Metadata metadata = new Metadata();



  • perfsonar: r4915 - in branches/simple-service-with-base2: conf src/main/java/org/perfsonar/base2/service/registration, svnlog, 01/28/2009

Archive powered by MHonArc 2.6.16.

Top of Page