Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r5446 - in branches/new-structure-with-base2/ps-mdm-ls/src/main: java/org/perfsonar/service/lookupservice/schedulerActions resources/perfsonar/conf

Subject: perfsonar development work

List archive

perfsonar: r5446 - in branches/new-structure-with-base2/ps-mdm-ls/src/main: java/org/perfsonar/service/lookupservice/schedulerActions resources/perfsonar/conf


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r5446 - in branches/new-structure-with-base2/ps-mdm-ls/src/main: java/org/perfsonar/service/lookupservice/schedulerActions resources/perfsonar/conf
  • Date: Thu, 31 Dec 2009 05:53:37 -0500

Author: trzaszcz
Date: 2009-12-31 05:53:37 -0500 (Thu, 31 Dec 2009)
New Revision: 5446

Modified:

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/GLSRegistrationAction.java

branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
Log:
gls registration enhancement

Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/GLSRegistrationAction.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/GLSRegistrationAction.java
2009-12-30 15:05:19 UTC (rev 5445)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/GLSRegistrationAction.java
2009-12-31 10:53:37 UTC (rev 5446)
@@ -1,10 +1,13 @@
package org.perfsonar.service.lookupservice.schedulerActions;

import java.net.URL;
+import java.util.ArrayList;
import java.util.LinkedList;
+import java.util.List;

import org.apache.log4j.Logger;
import org.perfsonar.base2.service.configuration.ConfigurationManager;
+import org.perfsonar.base2.service.configuration.Option;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
import org.perfsonar.base2.service.registration.LSRegistrationAction;
import org.perfsonar.base2.service.requesthandler.ServiceMessage;
@@ -14,23 +17,28 @@

/**
*
- * Action registering to other GLS. Configuration of the addresses is in
configuration.xml
- * There is 2 opportunities of definition GLS address:
- * - direct address to concrete GLS
- * - address to root.hints file that contains list of GLS
+ * Action registering to other GLS. Configuration of the addresses is in
+ * configuration.xml There is 2 opportunities of definition GLS address: -
+ * direct address to concrete GLS - address to root.hints file that contains
+ * list of GLS
*
* @author Slawomir Trzaszczka
*/
public class GLSRegistrationAction extends LSRegistrationAction {

-
private Logger logger = Logger.getLogger(GLSRegistrationAction.class);

private ModificationCounterComponent modificationCounterComponent;
+ public final static String NR_OF_GLS_REGISTRATION_PARAM =
"nrOfGLSRegistration";

private LinkedList<URL> glsAddresses;

- private Element registeredKey;
+ /**
+ * number of registration to GLS in one iteration
+ *
+ */
+ private int nrOfGLSRegistration = 1;
+ private List<Element> registeredKeys = new ArrayList<Element>();

public void init() throws PerfSONARException {
dataSource = getRegisterDataSource();
@@ -39,19 +47,16 @@
modificationCounterComponent = (ModificationCounterComponent)
ConfigurationManager

.getInstance().getConfiguration().getAuxiliaryComponent(

"modificationCounterComponent");
+ nrOfGLSRegistration = getNrOfGlsRegistration();
glsAddresses = getLSAddresses();
registrator = getLSRegistrator();
}

-
-
-
public void execute() {

boolean sendKeekAlive = false;
- boolean registrationSuccess = false;
ServiceMessage response;
-
+
if
(modificationCounterComponent.getDiffsBetweenRegistrationCounter() == 0) {
// There are no changes - send KeepAlive to GLS
logger.debug("no changes in DB");
@@ -64,34 +69,36 @@


modificationCounterComponent.resetDiffsBetweenRegistrationCounter();

- if (registeredKey != null && sendKeekAlive) {
- // send keep alive to last used GLS
- URL glsAddress = glsAddresses.getFirst();
- try {
- response =
registrator.keepalive(registeredKey, glsAddress);
- logger.debug("KeepAlive message registered "
+ glsAddress);
+ if (sendKeekAlive) {
+
+ for (int c = 0; c < registeredKeys.size(); c++) {
+ Element registeredKey = registeredKeys.get(c);

- if
(isResponseSuccess(getResponseMetadata(response))) {
- registrationSuccess = true;
- logger.debug("KEEP ALIVE accepted");
- } else {
- registrationSuccess = false;
- logger.debug("KEEP ALIVE rejected !");
+ // send keep alive to last used GLS
+ URL glsAddress = glsAddresses.getFirst();
+ try {
+ response =
registrator.keepalive(registeredKey, glsAddress);
+ logger.debug("KeepAlive message
registered " + glsAddress);
+
+ if
(isResponseSuccess(getResponseMetadata(response))) {
+ logger.debug("KEEP ALIVE
accepted");
+ } else {
+
registeredKeys.remove(registeredKey);
+ logger.debug("KEEP ALIVE
rejected !");
+ }
+
+ } catch (PerfSONARException e) {
+ logger.debug("Problem with sending
KeepAlive message to :"
+ +
glsAddress.toString());
+ poolElement(glsAddresses);
+ registeredKeys.remove(registeredKey);
}
-
- } catch (PerfSONARException e) {
- logger.debug("Problem with sending KeepAlive
message to :"
- + glsAddress.toString());
- poolElement(glsAddresses);
- registrationSuccess = false;
}
-
}
-
- // if registration using KeepAlive message failed or there
wasn't any registration before ...
- if (!registrationSuccess) {

- int nrOfGls = glsAddresses.size();
+ // if registration using KeepAlive message failed or there
wasn't any
+ // registration before ...
+ if (registeredKeys.isEmpty()) {

ServiceMessage serviceRequestMessage = null;
try {
@@ -100,27 +107,33 @@
logger.warn("Cannot build registration
message !");
logger.warn(e);
}
-
- //try to register to first working GLS from list of
all
- while (nrOfGls > 0) {

- if (serviceRequestMessage != null) {
+ int nrOfGls = glsAddresses.size();

+ if (serviceRequestMessage != null) {
+ // try to register to first n-working GLS
from list of all (n is a nrOfGLSRegistration)
+ while (nrOfGls > 0) {
+
Message requestMessage = (Message)
serviceRequestMessage
.getElement();

- URL glsAddress =
glsAddresses.getFirst();
+ URL glsAddress =
glsAddresses.get(registeredKeys.size());
try {
response =
registrator.register(requestMessage,
glsAddress);

logger.info("Registration
message sent");
- registeredKey =
getKeyFromResponse(response);
+ Element registeredKey =
getKeyFromResponse(response);
if (registeredKey == null) {
- logger.debug("no
registerd key in registration response");
+ logger
+
.debug("no registerd key in registration response");

poolElement(glsAddresses);
} else {
- break;
+ // element registered
+
registeredKeys.add(registeredKey);
+ if
(registeredKeys.size() == nrOfGLSRegistration) {
+ break;
+ }
}
} catch (PerfSONARException e) {
logger
@@ -128,21 +141,22 @@

+ glsAddress.toString());
poolElement(glsAddresses);
}
-
+ nrOfGls--;
}
- nrOfGls--;
+ } else {
+ logger.warn("Cannot build
glsRegistrationMessage");
}
}

- if (registeredKey == null) {
+ if (registeredKeys.isEmpty()) {
logger.warn("Registration to GLS failed !!");
} else {
logger.debug("Registration completed");
}

}
-
- private void poolElement(LinkedList<URL> urls){
+
+ private void poolElement(LinkedList<URL> urls) {
URL brokenGLSURL = glsAddresses.poll();
glsAddresses.add(brokenGLSURL);
}
@@ -151,4 +165,22 @@

}

+ /*
+ * returns value of nrOfGLSRegistration defined in configuration.xml
+ */
+ private int getNrOfGlsRegistration() {
+ Option option = getOption(NR_OF_GLS_REGISTRATION_PARAM);
+ if (option != null) {
+ try {
+ return Integer.valueOf(option.getValue());
+ } catch (NumberFormatException ex) {
+ ex.printStackTrace();
+ return nrOfGLSRegistration;
+ }
+
+ } else {
+ return nrOfGLSRegistration;
+ }
+ }
+
}

Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
2009-12-30 15:05:19 UTC (rev 5445)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/resources/perfsonar/conf/configuration.xml
2009-12-31 10:53:37 UTC (rev 5446)
@@ -167,6 +167,9 @@

<option name="lsList-1"
value="http://www.perfsonar.net/gls.root.hints"/>

+ <!-- number of registration to GLS in a single iteration -->
+ <option name="nrOfGLSRegistration" value="1"/>
+
</action>

</actions>



  • perfsonar: r5446 - in branches/new-structure-with-base2/ps-mdm-ls/src/main: java/org/perfsonar/service/lookupservice/schedulerActions resources/perfsonar/conf, svnlog, 12/31/2009

Archive powered by MHonArc 2.6.16.

Top of Page