perfsonar-dev - [GEANT/SA2/ps-java-services] r5505 - in trunk: . perfsonar-java-xml-ls perfsonar-java-xml-ls/packaging perfsonar-java-xml-ls/packaging/deb perfsonar-java-xml-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions
Subject: perfsonar development work
List archive
[GEANT/SA2/ps-java-services] r5505 - in trunk: . perfsonar-java-xml-ls perfsonar-java-xml-ls/packaging perfsonar-java-xml-ls/packaging/deb perfsonar-java-xml-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions
Chronological Thread
- From:
- To:
- Subject: [GEANT/SA2/ps-java-services] r5505 - in trunk: . perfsonar-java-xml-ls perfsonar-java-xml-ls/packaging perfsonar-java-xml-ls/packaging/deb perfsonar-java-xml-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions
- Date: Thu, 25 Feb 2010 13:05:50 GMT
Author: psnc.trzaszczka
Date: 2010-02-25 13:05:49 +0000 (Thu, 25 Feb 2010)
New Revision: 5505
Added:
trunk/perfsonar-java-xml-ls/
trunk/perfsonar-java-xml-ls/packaging/
trunk/perfsonar-java-xml-ls/packaging/deb/install
trunk/perfsonar-java-xml-ls/packaging/deb/postinst
trunk/perfsonar-java-xml-ls/packaging/package.sh
trunk/perfsonar-java-xml-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/GLSRegistrationAction.java
Removed:
trunk/perfsonar-java-xml-ls/packaging/
trunk/perfsonar-java-xml-ls/packaging/deb/install
trunk/perfsonar-java-xml-ls/packaging/deb/postinst
trunk/perfsonar-java-xml-ls/packaging/package.sh
trunk/perfsonar-java-xml-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/GLSRegistrationAction.java
Log:
Copied: trunk/perfsonar-java-xml-ls (from rev 5490,
branches/new-structure-with-base2/ps-mdm-ls)
Copied: trunk/perfsonar-java-xml-ls/packaging (from rev 5495,
branches/new-structure-with-base2/ps-mdm-ls/packaging)
Deleted: trunk/perfsonar-java-xml-ls/packaging/deb/install
===================================================================
--- branches/new-structure-with-base2/ps-mdm-ls/packaging/deb/install
2010-02-19 08:29:37 UTC (rev 5495)
+++ trunk/perfsonar-java-xml-ls/packaging/deb/install 2010-02-25 13:05:49
UTC (rev 5505)
@@ -1,4 +0,0 @@
-build/perfsonar-java-xml-ls/*
/usr/lib/perfsonar/services/perfsonar-java-xml-ls
-doc/* /usr/lib/perfsonar/services/perfsonar-java-xml-ls/WEB-INF/doc
-samples/* /usr/lib/perfsonar/services/perfsonar-java-xml-ls/WEB-INF/samples
-
Copied: trunk/perfsonar-java-xml-ls/packaging/deb/install (from rev 5497,
branches/new-structure-with-base2/ps-mdm-ls/packaging/deb/install)
===================================================================
--- trunk/perfsonar-java-xml-ls/packaging/deb/install
(rev 0)
+++ trunk/perfsonar-java-xml-ls/packaging/deb/install 2010-02-25 13:05:49
UTC (rev 5505)
@@ -0,0 +1,4 @@
+build/perfsonar-java-xml-ls/*
/usr/lib/perfsonar/services/perfsonar-java-xml-ls
+doc/* /usr/lib/perfsonar/services/perfsonar-java-xml-ls/doc
+samples/* /usr/lib/perfsonar/services/perfsonar-java-xml-ls/samples
+
Deleted: trunk/perfsonar-java-xml-ls/packaging/deb/postinst
===================================================================
--- branches/new-structure-with-base2/ps-mdm-ls/packaging/deb/postinst
2010-02-19 08:29:37 UTC (rev 5495)
+++ trunk/perfsonar-java-xml-ls/packaging/deb/postinst 2010-02-25 13:05:49
UTC (rev 5505)
@@ -1,73 +0,0 @@
-#!/bin/sh
-# postinst script for geant2-java-xml-ls
-#
-# see: dh_installdeb(1)
-
-set -e
-
-# summary of how this script can be called:
-# * <postinst> `configure' <most-recently-configured-version>
-# * <old-postinst> `abort-upgrade' <new version>
-# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
-# <new-version>
-# * <postinst> `abort-remove'
-# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
-# <failed-install-package> <version> `removing'
-# <conflicting-package> <version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
-
-SERVICENAME="perfsonar-java-xml-ls"
-SERVICEPATH="/usr/lib/perfsonar/services"
-
-
-
-case "$1" in
- configure)
- if [ -h /var/lib/tomcat5.5/webapps/$SERVICENAME ]
- then
- rm -rf /var/lib/tomcat5.5/webapps/$SERVICENAME
- fi
- ln -sf $SERVICEPATH/$SERVICENAME /var/lib/tomcat5.5/webapps/$SERVICENAME
|| true
- if [ -h /etc/$SERVICENAME ]
- then
- rm -rf /etc/$SERVICENAME
- fi
- ln -sf $SERVICEPATH/$SERVICENAME/WEB-INF/classes/perfsonar/conf
/etc/$SERVICENAME || true
-
- if [ -h /var/log/$SERVICENAME ]
- then
- rm -rf /var/log/$SERVICENAME
- fi
- mkdir -p $SERVICEPATH/$SERVICENAME/WEB-INF/log
- ln -sf $SERVICEPATH/$SERVICENAME/WEB-INF/log /var/log/$SERVICENAME ||
true
-
- if [ -h /usr/share/doc/$SERVICENAME/spec ]
- then
- rm -rf /usr/share/doc/$SERVICENAME/spec
- fi
- ln -sf $SERVICEPATH/$SERVICENAME/WEB-INF/doc
/usr/share/doc/$SERVICENAME/spec || true
-
- chown -R tomcat55
$SERVICEPATH/$SERVICENAME/WEB-INF/classes/perfsonar/conf
- chown tomcat55 $SERVICEPATH/$SERVICENAME/WEB-INF/log
-
- /etc/init.d/tomcat5.5 restart
- ;;
-
- abort-upgrade|abort-remove|abort-deconfigure)
- ;;
-
- *)
- echo "postinst called with unknown argument \`$1'" >&2
- exit 1
- ;;
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
-
-
Copied: trunk/perfsonar-java-xml-ls/packaging/deb/postinst (from rev 5497,
branches/new-structure-with-base2/ps-mdm-ls/packaging/deb/postinst)
===================================================================
--- trunk/perfsonar-java-xml-ls/packaging/deb/postinst
(rev 0)
+++ trunk/perfsonar-java-xml-ls/packaging/deb/postinst 2010-02-25 13:05:49
UTC (rev 5505)
@@ -0,0 +1,73 @@
+#!/bin/sh
+# postinst script for geant2-java-xml-ls
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+# * <postinst> `configure' <most-recently-configured-version>
+# * <old-postinst> `abort-upgrade' <new version>
+# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+# <new-version>
+# * <postinst> `abort-remove'
+# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+# <failed-install-package> <version> `removing'
+# <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+SERVICENAME="perfsonar-java-xml-ls"
+SERVICEPATH="/usr/lib/perfsonar/services"
+
+
+
+case "$1" in
+ configure)
+ if [ -h /var/lib/tomcat5.5/webapps/$SERVICENAME ]
+ then
+ rm -rf /var/lib/tomcat5.5/webapps/$SERVICENAME
+ fi
+ ln -sf $SERVICEPATH/$SERVICENAME /var/lib/tomcat5.5/webapps/$SERVICENAME
|| true
+ if [ -h /etc/$SERVICENAME ]
+ then
+ rm -rf /etc/$SERVICENAME
+ fi
+ ln -sf $SERVICEPATH/$SERVICENAME/WEB-INF/classes/perfsonar/conf
/etc/$SERVICENAME || true
+
+ if [ -h /var/log/$SERVICENAME ]
+ then
+ rm -rf /var/log/$SERVICENAME
+ fi
+ mkdir -p $SERVICEPATH/$SERVICENAME/WEB-INF/log
+ ln -sf $SERVICEPATH/$SERVICENAME/WEB-INF/log /var/log/$SERVICENAME ||
true
+
+ if [ -h /usr/share/doc/$SERVICENAME/spec ]
+ then
+ rm -rf /usr/share/doc/$SERVICENAME/spec
+ fi
+ ln -sf $SERVICEPATH/$SERVICENAME/doc /usr/share/doc/$SERVICENAME/spec ||
true
+
+ chown -R tomcat55
$SERVICEPATH/$SERVICENAME/WEB-INF/classes/perfsonar/conf
+ chown tomcat55 $SERVICEPATH/$SERVICENAME/WEB-INF/log
+
+ /etc/init.d/tomcat5.5 restart
+ ;;
+
+ abort-upgrade|abort-remove|abort-deconfigure)
+ ;;
+
+ *)
+ echo "postinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
Deleted: trunk/perfsonar-java-xml-ls/packaging/package.sh
===================================================================
--- branches/new-structure-with-base2/ps-mdm-ls/packaging/package.sh
2010-02-19 08:29:37 UTC (rev 5495)
+++ trunk/perfsonar-java-xml-ls/packaging/package.sh 2010-02-25 13:05:49
UTC (rev 5505)
@@ -1,186 +0,0 @@
-
-#!/bin/sh
-
-. package.conf
-
-
-do_clean_up() {
-
- echo " CLEAN UP"
- cd $CURR_DIR
- rm -rf temp
- rm -rf target
- echo
-
-}
-
-#
-# build project using maven
-# 1) build project using maven
-# 2) unzip .war into webapps directory
-#
-do_structure() {
-
- echo " CREATE STRUCT"
-
- cd $CURR_DIR
- rm -rfv temp
- mkdir temp
- mkdir temp/webapps
-
- pwd
- unzip ../target/$SERVICE_NAME.war -d temp/webapps/$SERVICE_NAME
- echo "war unziped"
-
- echo "done !"
- echo
- echo
-
-}
-
-#
-# create debian structure
-# 1)create directories deb{debian,build}
-# 2)copy required configuration files for deb-packaging
-#
-do_deb_struct() {
-
- cd $CURR_DIR
- echo " CREATE DEB STRUCT"
- echo "[ ] Removing old deb"
- rm -rfv temp/deb
- mkdir -v temp/deb
- mkdir -v temp/deb/debian
- mkdir -v temp/deb/build
- mkdir -v temp/deb/doc
- mkdir -v temp/deb/samples
-
- rsync -r --exclude=.svn ../samples/requests temp/deb/samples
- rsync -r --exclude=.svn ../samples/responses temp/deb/samples
- cp -a deb/changelog temp/deb/doc
-
- echo "[ ] Copying package files"
- cp -v deb/* temp/deb/debian
- echo
- echo
-
-}
-
-
-#
-# build debian package
-#
-build_deb_package() {
-
- cd $CURR_DIR
- echo " CREATE DEB"
-
- cd temp/deb
- sudo dpkg-buildpackage -d
- echo
- echo
-}
-
-#
-# remove unnecessary files, copy *.deb package do target folder
-#
-cleanup_after_deb_packaging(){
-
- cd $CURR_DIR
- file=$(find temp -regex ".+\.deb$")
- mkdir target
- cp $file target
- sudo rm -rf temp
- echo
- echo
-}
-
-#
-# create rpm structure
-# 1)create directories rpm/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS,TMP}
-# 2)tar.gz project
-# 3)copy tar.gz to SOURCES directory
-# 4)copy required configuration file for deb-packaging
-#
-do_rpm_struct() {
-
- cd $CURR_DIR;
- echo " CREATE RPM STRUCT"
- rm -rfv temp/rpm
- mkdir temp/rpm
- mkdir -pv temp/rpm/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS,TMP}
- echo "[ ] Create symbolic link and create tar archive"
- cd temp/webapps
- LSVER=$(ls | grep $SERVICE_NAME)
- ln -sv $LSVER $SERVICE_NAME-$RPM_VERSION
- echo "[ ] TAR"
- tar -czhf $SERVICE_NAME-$RPM_VERSION.tar.gz $SERVICE_NAME-$RPM_VERSION
- cd ..
- echo "[ ] Copy tarball into SOURCES"
- pwd
- mv -v webapps/$SERVICE_NAME-$RPM_VERSION.tar.gz rpm/rpmbuild/SOURCES
- echo "[ ] Copy RPM .specs file"
- cp -v ../rpm/$RPM_SPEC_NAME rpm/rpmbuild
- echo
- echo
-}
-
-#
-# build debian package
-#
-build_rpm_package() {
-
- echo " CREATE RPM PACKAGE"
- cd $CURR_DIR
- cd temp/rpm
- rpmbuild -bb rpmbuild/$RPM_SPEC_NAME
- echo
- echo
-
-}
-
-#
-# remove unnecessary files, copy *.deb package do target folder
-#
-cleanup_after_rpm_packaging(){
-
- cd $CURR_DIR
- file=$(find temp/rpm/rpmbuild/RPMS/noarch -regex ".+\.rpm$")
- mkdir target
- cp $file target
- rm -rf temp
- echo
- echo
-
-}
-
-
-
-case "$1" in
- clean)
- do_clean_up
- ;;
- structure)
- do_structure
- ;;
- deb)
- do_clean_up
- do_structure
- do_deb_struct
- build_deb_package
- cleanup_after_deb_packaging
- ;;
- rpm)
- do_clean_up
- do_structure
- do_rpm_struct
- build_rpm_package
- cleanup_after_rpm_packaging
- ;;
- *)
- echo "Usage: $0 clean|deb|rpm" >&2
- exit 3
- ;;
-esac
-
-: exit 0
Copied: trunk/perfsonar-java-xml-ls/packaging/package.sh (from rev 5496,
branches/new-structure-with-base2/ps-mdm-ls/packaging/package.sh)
===================================================================
--- trunk/perfsonar-java-xml-ls/packaging/package.sh
(rev 0)
+++ trunk/perfsonar-java-xml-ls/packaging/package.sh 2010-02-25 13:05:49
UTC (rev 5505)
@@ -0,0 +1,190 @@
+
+#!/bin/sh
+
+. package.conf
+
+
+do_clean_up() {
+
+ echo " CLEAN UP"
+ cd $CURR_DIR
+ rm -rf temp
+ rm -rf target
+ echo
+
+}
+
+#
+# build project using maven
+# 1) build project using maven
+# 2) unzip .war into webapps directory
+#
+do_structure() {
+
+ echo " CREATE STRUCT"
+
+ cd $CURR_DIR
+ rm -rfv temp
+ mkdir temp
+ mkdir temp/webapps
+
+ pwd
+ unzip ../target/$SERVICE_NAME.war -d temp/webapps/$SERVICE_NAME
+ echo "war unziped"
+
+ echo "done !"
+ echo
+ echo
+
+}
+
+#
+# create debian structure
+# 1)create directories deb{debian,build}
+# 2)copy required configuration files for deb-packaging
+#
+do_deb_struct() {
+
+ cd $CURR_DIR
+ echo " CREATE DEB STRUCT"
+ echo "[ ] Removing old deb"
+ rm -rfv temp/deb
+ mkdir -v temp/deb
+ mkdir -v temp/deb/debian
+ mkdir -v temp/deb/build
+ mkdir -v temp/deb/doc
+ mkdir -v temp/deb/samples
+
+ rsync -r --exclude=.svn ../samples/requests temp/deb/samples
+ rsync -r --exclude=.svn ../samples/responses temp/deb/samples
+ cp -a deb/changelog temp/deb/doc
+
+ echo "[ ] Copying package files"
+ cp -v deb/* temp/deb/debian
+ echo
+ echo
+
+}
+
+
+#
+# build debian package
+#
+build_deb_package() {
+
+ cd $CURR_DIR
+ echo " CREATE DEB"
+
+ cd temp/deb
+ sudo dpkg-buildpackage -d
+ echo
+ echo
+}
+
+#
+# remove unnecessary files, copy *.deb package do target folder
+#
+cleanup_after_deb_packaging(){
+
+ cd $CURR_DIR
+ file=$(find temp -regex ".+\.deb$")
+ mkdir target
+ cp $file target
+ sudo rm -rf temp
+ echo
+ echo
+}
+
+#
+# create rpm structure
+# 1)create directories rpm/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS,TMP}
+# 2)tar.gz project
+# 3)copy tar.gz to SOURCES directory
+# 4)copy required configuration file for deb-packaging
+#
+do_rpm_struct() {
+
+ cd $CURR_DIR;
+ echo " CREATE RPM STRUCT"
+ rm -rfv temp/rpm
+ mkdir temp/rpm
+ mkdir -pv temp/rpm/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS,TMP}
+ echo "[ ] Create symbolic link and create tar archive"
+ cd temp/webapps
+ LSVER=$(ls | grep $SERVICE_NAME)
+ ln -sv $LSVER $SERVICE_NAME-$RPM_VERSION
+ echo "[ ] TAR"
+ rsync -r --exclude=.svn ../../../samples/requests
$SERVICE_NAME-$RPM_VERSION/samples
+ rsync -r --exclude=.svn ../../../samples/responses
$SERVICE_NAME-$RPM_VERSION/samples
+ mkdir $SERVICE_NAME-$RPM_VERSION/doc
+ cp -a ../../rpm/$RPM_SPEC_NAME $SERVICE_NAME-$RPM_VERSION/doc
+ tar -czhf $SERVICE_NAME-$RPM_VERSION.tar.gz $SERVICE_NAME-$RPM_VERSION
+ cd ..
+ echo "[ ] Copy tarball into SOURCES"
+ pwd
+ mv -v webapps/$SERVICE_NAME-$RPM_VERSION.tar.gz rpm/rpmbuild/SOURCES
+ echo "[ ] Copy RPM .specs file"
+ cp -v ../rpm/$RPM_SPEC_NAME rpm/rpmbuild
+ echo
+ echo
+}
+
+#
+# build debian package
+#
+build_rpm_package() {
+
+ echo " CREATE RPM PACKAGE"
+ cd $CURR_DIR
+ cd temp/rpm
+ rpmbuild -bb rpmbuild/$RPM_SPEC_NAME
+ echo
+ echo
+
+}
+
+#
+# remove unnecessary files, copy *.deb package do target folder
+#
+cleanup_after_rpm_packaging(){
+
+ cd $CURR_DIR
+ file=$(find temp/rpm/rpmbuild/RPMS/noarch -regex ".+\.rpm$")
+ mkdir target
+ cp $file target
+ rm -rf temp
+ echo
+ echo
+
+}
+
+
+
+case "$1" in
+ clean)
+ do_clean_up
+ ;;
+ structure)
+ do_structure
+ ;;
+ deb)
+ do_clean_up
+ do_structure
+ do_deb_struct
+ build_deb_package
+ cleanup_after_deb_packaging
+ ;;
+ rpm)
+ do_clean_up
+ do_structure
+ do_rpm_struct
+ build_rpm_package
+ cleanup_after_rpm_packaging
+ ;;
+ *)
+ echo "Usage: $0 clean|deb|rpm" >&2
+ exit 3
+ ;;
+esac
+
+: exit 0
Deleted:
trunk/perfsonar-java-xml-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
2010-02-18 15:05:49 UTC (rev 5490)
+++
trunk/perfsonar-java-xml-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/GLSRegistrationAction.java
2010-02-25 13:05:49 UTC (rev 5505)
@@ -1,186 +0,0 @@
-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;
-import org.perfsonar.base2.xml.Element;
-import org.perfsonar.base2.xml.nmwg.Message;
-import
org.perfsonar.service.lookupservice.components.ModificationCounterComponent;
-
-/**
- *
- * 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;
-
- /**
- * 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();
- registrationEventType = getRegistrationEventType();
- lookupInformation = getLookupInformation();
- modificationCounterComponent = (ModificationCounterComponent)
ConfigurationManager
-
.getInstance().getConfiguration().getAuxiliaryComponent(
-
"modificationCounterComponent");
- nrOfGLSRegistration = getNrOfGlsRegistration();
- glsAddresses = getLSAddresses();
- registrator = getLSRegistrator();
- }
-
- public void execute() {
-
- boolean sendKeekAlive = false;
- ServiceMessage response;
-
- if
(modificationCounterComponent.getDiffsBetweenRegistrationCounter() == 0) {
- // There are no changes - send KeepAlive to GLS
- logger.debug("no changes in DB");
- sendKeekAlive = true;
- } else {
- // Get summarization data and send it to GLS
- logger.debug("there are changes - send summarized
data");
- sendKeekAlive = false;
- }
-
-
modificationCounterComponent.resetDiffsBetweenRegistrationCounter();
-
- if (sendKeekAlive) {
-
- for (int c = 0; c < registeredKeys.size(); c++) {
- Element registeredKey = registeredKeys.get(c);
-
- // 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);
- }
- }
- }
-
- // if registration using KeepAlive message failed or there
wasn't any
- // registration before ...
- if (registeredKeys.isEmpty()) {
-
- ServiceMessage serviceRequestMessage = null;
- try {
- serviceRequestMessage =
getLSRegisterMessage();
- } catch (PerfSONARException e) {
- logger.warn("Cannot build registration
message !");
- logger.warn(e);
- }
-
- 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.get(registeredKeys.size());
- try {
- response =
registrator.register(requestMessage,
- glsAddress);
-
- logger.info("Registration
message sent");
- Element registeredKey =
getKeyFromResponse(response);
- if (registeredKey == null) {
- logger
-
.debug("no registerd key in registration response");
-
poolElement(glsAddresses);
- } else {
- // element registered
-
registeredKeys.add(registeredKey);
- if
(registeredKeys.size() == nrOfGLSRegistration) {
- break;
- }
- }
- } catch (PerfSONARException e) {
- logger
-
.warn("Problem with sending registration message to :"
-
+ glsAddress.toString());
- poolElement(glsAddresses);
- }
- nrOfGls--;
- }
- } else {
- logger.warn("Cannot build
glsRegistrationMessage");
- }
- }
-
- if (registeredKeys.isEmpty()) {
- logger.warn("Registration to GLS failed !!");
- } else {
- logger.debug("Registration completed");
- }
-
- }
-
- private void poolElement(LinkedList<URL> glsAddresses) {
- URL brokenGLSURL = glsAddresses.poll();
- glsAddresses.add(brokenGLSURL);
- }
-
- public void refresh() {
-
- }
-
- /*
- * 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;
- }
- }
-
-}
Copied:
trunk/perfsonar-java-xml-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/GLSRegistrationAction.java
(from rev 5500,
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/GLSRegistrationAction.java)
===================================================================
---
trunk/perfsonar-java-xml-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/GLSRegistrationAction.java
(rev 0)
+++
trunk/perfsonar-java-xml-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions/GLSRegistrationAction.java
2010-02-25 13:05:49 UTC (rev 5505)
@@ -0,0 +1,186 @@
+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.AbstractRegistrationAction;
+import org.perfsonar.base2.service.requesthandler.ServiceMessage;
+import org.perfsonar.base2.xml.Element;
+import org.perfsonar.base2.xml.nmwg.Message;
+import
org.perfsonar.service.lookupservice.components.ModificationCounterComponent;
+
+/**
+ *
+ * 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 AbstractRegistrationAction {
+
+ private Logger logger = Logger.getLogger(GLSRegistrationAction.class);
+
+ private ModificationCounterComponent modificationCounterComponent;
+ public final static String NR_OF_GLS_REGISTRATION_PARAM =
"nrOfGLSRegistration";
+
+ private LinkedList<URL> glsAddresses;
+
+ /**
+ * 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();
+ registrationEventType = getRegistrationEventType();
+ lookupInformation = getLookupInformation();
+ modificationCounterComponent = (ModificationCounterComponent)
ConfigurationManager
+
.getInstance().getConfiguration().getAuxiliaryComponent(
+
"modificationCounterComponent");
+ nrOfGLSRegistration = getNrOfGlsRegistration();
+ glsAddresses = getLSAddresses();
+ registrator = getLSRegistrator();
+ }
+
+ public void execute() {
+
+ boolean sendKeekAlive = false;
+ ServiceMessage response;
+
+ if
(modificationCounterComponent.getDiffsBetweenRegistrationCounter() == 0) {
+ // There are no changes - send KeepAlive to GLS
+ logger.debug("no changes in DB");
+ sendKeekAlive = true;
+ } else {
+ // Get summarization data and send it to GLS
+ logger.debug("there are changes - send summarized
data");
+ sendKeekAlive = false;
+ }
+
+
modificationCounterComponent.resetDiffsBetweenRegistrationCounter();
+
+ if (sendKeekAlive) {
+
+ for (int c = 0; c < registeredKeys.size(); c++) {
+ Element registeredKey = registeredKeys.get(c);
+
+ // 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);
+ }
+ }
+ }
+
+ // if registration using KeepAlive message failed or there
wasn't any
+ // registration before ...
+ if (registeredKeys.isEmpty()) {
+
+ ServiceMessage serviceRequestMessage = null;
+ try {
+ serviceRequestMessage =
getLSRegisterMessage();
+ } catch (PerfSONARException e) {
+ logger.warn("Cannot build registration
message !");
+ logger.warn(e);
+ }
+
+ 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.get(registeredKeys.size());
+ try {
+ response =
registrator.register(requestMessage,
+ glsAddress);
+
+ logger.info("Registration
message sent");
+ Element registeredKey =
getKeyFromResponse(response);
+ if (registeredKey == null) {
+ logger
+
.debug("no registerd key in registration response");
+
poolElement(glsAddresses);
+ } else {
+ // element registered
+
registeredKeys.add(registeredKey);
+ if
(registeredKeys.size() == nrOfGLSRegistration) {
+ break;
+ }
+ }
+ } catch (PerfSONARException e) {
+ logger
+
.warn("Problem with sending registration message to :"
+
+ glsAddress.toString());
+ poolElement(glsAddresses);
+ }
+ nrOfGls--;
+ }
+ } else {
+ logger.warn("Cannot build
glsRegistrationMessage");
+ }
+ }
+
+ if (registeredKeys.isEmpty()) {
+ logger.warn("Registration to GLS failed !!");
+ } else {
+ logger.debug("Registration completed");
+ }
+
+ }
+
+ private void poolElement(LinkedList<URL> glsAddresses) {
+ URL brokenGLSURL = glsAddresses.poll();
+ glsAddresses.add(brokenGLSURL);
+ }
+
+ public void refresh() {
+
+ }
+
+ /*
+ * 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;
+ }
+ }
+
+}
- [GEANT/SA2/ps-java-services] r5505 - in trunk: . perfsonar-java-xml-ls perfsonar-java-xml-ls/packaging perfsonar-java-xml-ls/packaging/deb perfsonar-java-xml-ls/src/main/java/org/perfsonar/service/lookupservice/schedulerActions, svn-noreply, 02/25/2010
Archive powered by MHonArc 2.6.16.