perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r6146 - in trunk/psBase3/perfsonar-ls-register: . src src/main src/main/java src/main/java/net src/main/java/net/geant src/main/java/net/geant/perfsonar src/main/java/net/geant/perfsonar/ls src/test src/test/java src/test/java/net src/test/java/net/geant src/test/java/net/geant/perfsonar src/test/java/net/geant/perfsonar/ls src/test/resources src/test/resources/net src/test/resources/net/geant src/test/resources/net/geant/perfsonar src/test/resources/net/geant/perfsonar/mp src/test/resources/net/geant/perfsonar/mp/sshtelnet
Subject: perfsonar development work
List archive
[pS-dev] [GEANT/SA2/ps-java-services] r6146 - in trunk/psBase3/perfsonar-ls-register: . src src/main src/main/java src/main/java/net src/main/java/net/geant src/main/java/net/geant/perfsonar src/main/java/net/geant/perfsonar/ls src/test src/test/java src/test/java/net src/test/java/net/geant src/test/java/net/geant/perfsonar src/test/java/net/geant/perfsonar/ls src/test/resources src/test/resources/net src/test/resources/net/geant src/test/resources/net/geant/perfsonar src/test/resources/net/geant/perfsonar/mp src/test/resources/net/geant/perfsonar/mp/sshtelnet
Chronological Thread
- From:
- To:
- Subject: [pS-dev] [GEANT/SA2/ps-java-services] r6146 - in trunk/psBase3/perfsonar-ls-register: . src src/main src/main/java src/main/java/net src/main/java/net/geant src/main/java/net/geant/perfsonar src/main/java/net/geant/perfsonar/ls src/test src/test/java src/test/java/net src/test/java/net/geant src/test/java/net/geant/perfsonar src/test/java/net/geant/perfsonar/ls src/test/resources src/test/resources/net src/test/resources/net/geant src/test/resources/net/geant/perfsonar src/test/resources/net/geant/perfsonar/mp src/test/resources/net/geant/perfsonar/mp/sshtelnet
- Date: Mon, 18 Feb 2013 19:39:36 +0000 (GMT)
- Authentication-results: sfpop-ironport05.merit.edu; dkim=neutral (message not signed) header.i=none
Author: psnc.pietrzak
Date: 2013-02-18 19:39:36 +0000 (Mon, 18 Feb 2013)
New Revision: 6146
Added:
trunk/psBase3/perfsonar-ls-register/pom.xml
trunk/psBase3/perfsonar-ls-register/src/
trunk/psBase3/perfsonar-ls-register/src/main/
trunk/psBase3/perfsonar-ls-register/src/main/java/
trunk/psBase3/perfsonar-ls-register/src/main/java/net/
trunk/psBase3/perfsonar-ls-register/src/main/java/net/geant/
trunk/psBase3/perfsonar-ls-register/src/main/java/net/geant/perfsonar/
trunk/psBase3/perfsonar-ls-register/src/main/java/net/geant/perfsonar/ls/
trunk/psBase3/perfsonar-ls-register/src/main/java/net/geant/perfsonar/ls/LSRegistrationTask.java
trunk/psBase3/perfsonar-ls-register/src/test/
trunk/psBase3/perfsonar-ls-register/src/test/java/
trunk/psBase3/perfsonar-ls-register/src/test/java/net/
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/ConfigurationFileChecker.java
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/LSEnabledService.java
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/LSRegisterTest.java
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/MockLSService.java
trunk/psBase3/perfsonar-ls-register/src/test/resources/
trunk/psBase3/perfsonar-ls-register/src/test/resources/configuration.xml
trunk/psBase3/perfsonar-ls-register/src/test/resources/net/
trunk/psBase3/perfsonar-ls-register/src/test/resources/net/geant/
trunk/psBase3/perfsonar-ls-register/src/test/resources/net/geant/perfsonar/
trunk/psBase3/perfsonar-ls-register/src/test/resources/net/geant/perfsonar/mp/
trunk/psBase3/perfsonar-ls-register/src/test/resources/net/geant/perfsonar/mp/sshtelnet/
trunk/psBase3/perfsonar-ls-register/src/test/resources/net/geant/perfsonar/mp/sshtelnet/LSRegister.template
Modified:
trunk/psBase3/perfsonar-ls-register/
Log:
Extracted Lookup Service functions from perfsonar-base.
Property changes on: trunk/psBase3/perfsonar-ls-register
___________________________________________________________________
Added: svn:ignore
+ .settings
.classpath
.project
Added: trunk/psBase3/perfsonar-ls-register/pom.xml
===================================================================
--- trunk/psBase3/perfsonar-ls-register/pom.xml (rev
0)
+++ trunk/psBase3/perfsonar-ls-register/pom.xml 2013-02-18 19:39:36 UTC (rev
6146)
@@ -0,0 +1,85 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>net.geant.perfsonar</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../../parent/</relativePath>
+ </parent>
+
+ <artifactId>perfsonar-ls-register</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>Functions to register, update and remove service information
from perfSONAR LS service</name>
+
+ <developers>
+ <developer>
+ <id>blazej.pietrzak</id>
+ <name>Blazej Pietrzak</name>
+
<email></email>
+ <organization>PSNC</organization>
+
<organizationUrl>http://www.man.poznan.pl/</organizationUrl>
+ <roles>
+ <role>architect</role>
+ <role>developer</role>
+ </roles>
+ <timezone>+1</timezone>
+ </developer>
+ </developers>
+
+ <properties>
+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.9</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.geant.perfsonar</groupId>
+ <artifactId>perfsonar-base</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>net.geant.perfsonar</groupId>
+ <artifactId>perfsonar-base</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.geant.perfsonar</groupId>
+ <artifactId>perfsonar-messaging</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-bundle</artifactId>
+ <version>2.4.2</version>
+ <type>bundle</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+
<Export-Package>net.geant.perfsonar.*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added:
trunk/psBase3/perfsonar-ls-register/src/main/java/net/geant/perfsonar/ls/LSRegistrationTask.java
===================================================================
---
trunk/psBase3/perfsonar-ls-register/src/main/java/net/geant/perfsonar/ls/LSRegistrationTask.java
(rev 0)
+++
trunk/psBase3/perfsonar-ls-register/src/main/java/net/geant/perfsonar/ls/LSRegistrationTask.java
2013-02-18 19:39:36 UTC (rev 6146)
@@ -0,0 +1,155 @@
+package net.geant.perfsonar.ls;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.io.Writer;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+
+import net.geant.perfsonar.Configuration;
+import net.geant.perfsonar.HandlerConfiguration;
+import net.geant.perfsonar.Logger;
+import net.geant.perfsonar.NMWGMessage;
+import net.geant.perfsonar.PerfSONAR;
+import net.geant.perfsonar.messaging.XPathDeserializer;
+import net.geant.perfsonar.templates.TemplateEngine;
+import net.sf.cglib.proxy.Enhancer;
+
+import org.xml.sax.InputSource;
+
+/**
+ * Scheduler task that registers a service to Lookup Service.
+ * If the service is already registered (key was returned from LS
successfully) it sends keepalive messages.
+ * It uses LSRegister.template template found in the directory where the
controller method that provides data for registration is defined.
+ *
+ * In order to configure the handler for the Lookup Service registration the
following
+ * code snippet must be used:
+ *
<code>configure(registerToLookupService(ServiceController.class).details())</code>
+ * where configure method belongs to Configuration class.
+ *
+ * @author <a
href="mailto:">Blazej
Pietrzak</a>
+ */
+public class LSRegistrationTask implements Runnable {
+
+ private static List<String> lsAddresses = new ArrayList<String>();
+
+ public List<String> getLSAddresses() {
+ return lsAddresses;
+ }
+
+ public void addLSAddress(String address) {
+ if (address == null)
+ return;
+
+ if (!lsAddresses.contains(address))
+ lsAddresses.add(address);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T> T registerToLookupService(Class<T> controller) {
+ return (T) Enhancer.create(controller, new
HandlerConfiguration("LSRegister"));
+ }
+
+ private Map<String, String> keys = new Hashtable<String, String>();
+ private Logger logger;
+ private PerfSONAR service;
+
+ public LSRegistrationTask(Logger logger, PerfSONAR service) {
+ this.logger = logger;
+ this.service = service;
+ }
+
+ public LSRegistrationTask() {
+ this(null, null);
+ }
+
+ public void run() {
+ for (String address : getLSAddresses()) {
+ try {
+ registerToLookupService(address);
+ } catch (Exception ex) {
+ logger.error("Could not register to Lookup
Service at: " + address, ex);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected synchronized void registerToLookupService(final String
address) throws IllegalArgumentException, IllegalAccessException,
InvocationTargetException, InstantiationException, IOException {
+ final Method m = Configuration.getHandler("LSRegister");
+ if (m == null)
+ return;
+
+ final PipedInputStream in = new PipedInputStream();
+ final PipedOutputStream out = new PipedOutputStream(in);
+
service.getScheduler().runInParallel(createLSMessageTask(address, m, out));
+
+ if (keys.get(address) == null) {
+ final XPathDeserializer deserializer = new
XPathDeserializer();
+ final NMWGMessage msg;
+ try {
+ msg =
deserializer.getObjects(NMWGMessage.class, (List<Object>)
deserializer.deserialize(new InputSource(getLSClient(address).invoke(new
StreamSource(in)).getInputStream()))).get(0);
+ if (msg.getKey() != null) {
+ keys.put(address, msg.getKey());
+ }
+ } catch (Exception e) {
+ logger.error("Could not deserialize key from
Lookup Service response.", e);
+ }
+ } else
+ getLSClient(address).invoke(new StreamSource(in));
+ }
+
+ private Runnable createLSMessageTask(final String address, final
Method m, final OutputStream out) {
+ return new Runnable() {
+
+ private final Writer writer = new
OutputStreamWriter(out);
+
+ public void run() {
+ try {
+ if (keys.get(address) == null) {
+
TemplateEngine.put("requestId", "request1");
+ TemplateEngine.put("result",
m.invoke(m.getDeclaringClass().newInstance()));
+ TemplateEngine.put("service",
service);
+
TemplateEngine.evaluate(writer, m.getDeclaringClass(), "LSRegister.template");
+ } else {
+
writer.write(getKeepAliveMessage(keys.get(address)));
+ }
+ writer.flush();
+ writer.close();
+ out.close();
+ } catch (Exception ex) {
+ logger.error("Could not register in
LookupService.", ex);
+ }
+ }
+
+ private String getKeepAliveMessage(String key) {
+ return "<?xml version='1.0'
encoding='UTF-8'?>"
+ + "<nmwg:message id='request1'
type='LSKeepaliveRequest' xmlns:nmwg='http://ggf.org/ns/nmwg/base/2.0/'>"
+ + "<nmwg:metadata
id='key_to_keepalive'><nmwg:key>" + key + "</nmwg:key></nmwg:metadata>"
+ + "<nmwg:data id='d1'
metadataIdRef='key_to_keepalive' />"
+ + "</nmwg:message>\n";
+ }
+ };
+ }
+
+ private Dispatch<StreamSource> getLSClient(final String address) {
+ final String NAMESPACE = "http://base3.perfsonar.geant.net/";
+ final QName PORT = new QName(NAMESPACE, "PerfSONARPort");
+ final Service service = Service.create(new QName(NAMESPACE,
"PerfSONARService"));
+ service.addPort(PORT, SOAPBinding.SOAP11HTTP_BINDING,
address);
+ final Dispatch<StreamSource> client =
service.createDispatch(PORT, StreamSource.class, Service.Mode.PAYLOAD);
+ return client;
+ }
+}
Added:
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/ConfigurationFileChecker.java
===================================================================
---
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/ConfigurationFileChecker.java
(rev 0)
+++
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/ConfigurationFileChecker.java
2013-02-18 19:39:36 UTC (rev 6146)
@@ -0,0 +1,70 @@
+package net.geant.perfsonar.ls;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import net.geant.perfsonar.ls.LSRegistrationTask;
+import net.geant.perfsonar.messaging.Helper;
+import net.geant.perfsonar.messaging.XPathDeserializer;
+
+import org.xml.sax.InputSource;
+
+import static net.geant.perfsonar.messaging.XPathDeserializer.any;
+import static net.geant.perfsonar.messaging.XPathDeserializer.declarePrefix;
+import static net.geant.perfsonar.messaging.XPathDeserializer.whenXPath;
+
+/**
+ * Scheduler task that checks every second whether configuration file has
changed.
+ * When it's changed it reads the configuration and injects to object model.
+ *
+ * @author <a
href="mailto:">Blazej
Pietrzak</a>
+ */
+public class ConfigurationFileChecker implements Runnable {
+
+ private File file = new File("src/test/resources/configuration.xml");
+ private long lastModified = 0;
+ private final LSEnabledService service;
+
+ public ConfigurationFileChecker(LSEnabledService service) {
+ this.service = service;
+ }
+
+ public void run() {
+ if (!file.exists()) {
+ System.err.println("Configuration file: " +
file.getAbsolutePath()
+ + " is missing");
+ return;
+ }
+
+ if (file.lastModified() > lastModified) {
+ lastModified = file.lastModified();
+ configureDeserialization();
+ XPathDeserializer deserializer = new
XPathDeserializer();
+ try {
+ deserializer.deserialize(new InputSource(new
FileInputStream(file)));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ private void configureDeserialization() {
+ //When configuring XPath the configurator creates a subclass
of SSHTelnetMPService that registers method invocations.
+ //The instance executes base class constructor of
SSHTelnetMPService which creates this task.
+ //This guard prevents calls from subclass instances forever
when configuring XPath.
+ if (Helper.isConfigurationInstance(service))
+ return;
+
+ declarePrefix("ns",
"http://service.perfsonar.org/ns/config/base/0.9/");
+
+ try {
+ whenXPath(
+
"ns:configuration/ns:service/ns:auxiliaryComponents/ns:component[@name='scheduling']/ns:actions/ns:action[@name='registration']/ns:option[@name='interval']/@value")
+ .then(LSEnabledService.class,
service).setLookupServiceInterval(any(String.class));
+
+ whenXPath(
+
"ns:configuration/ns:service/ns:auxiliaryComponents/ns:component[@name='scheduling']/ns:actions/ns:action[@name='registration']/ns:option[starts-with(@name,
'lsAddress')]/@value")
+
.then(LSRegistrationTask.class).addLSAddress(any(String.class));
+ } catch (Exception ex) { }
+ }
+}
Added:
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/LSEnabledService.java
===================================================================
---
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/LSEnabledService.java
(rev 0)
+++
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/LSEnabledService.java
2013-02-18 19:39:36 UTC (rev 6146)
@@ -0,0 +1,51 @@
+package net.geant.perfsonar.ls;
+
+import static net.geant.perfsonar.Configuration.configure;
+import static
net.geant.perfsonar.ls.LSRegistrationTask.registerToLookupService;
+import net.geant.perfsonar.ls.LSRegistrationTask;
+import net.geant.perfsonar.mp.sshtelnet.SSHTelnetMPService;
+import net.geant.perfsonar.mp.sshtelnet.ServiceController;
+
+/**
+ * Sample service that has LS registration functionality.
+ *
+ * @author <a
href="mailto:">Blazej
Pietrzak</a>
+ */
+public class LSEnabledService extends SSHTelnetMPService {
+ private static final int HOUR = 60 * 60;
+ private static final int SECOND = 1;
+
+ private final LSRegistrationTask lsRegistrationTask = new
LSRegistrationTask(logger, this);
+ private int lsInterval = HOUR;
+
+ public LSEnabledService() {
+ super();
+
+ scheduler.runEvery(HOUR, lsRegistrationTask);
+ scheduler.runEvery(SECOND, new
ConfigurationFileChecker(this));
+ }
+
+ static {
+ try {
+
configure(registerToLookupService(ServiceController.class).listAvailableRoutersAndCommands());
+ } catch (Exception ex) { }
+ }
+
+ /**
+ * Sets timeout in seconds between subsequent
registrations/keepalives to Lookup
+ * Service.
+ */
+ public synchronized void setLookupServiceInterval(String interval) {
+ lsInterval = Integer.parseInt(interval);
+ scheduler.stop(lsRegistrationTask);
+ scheduler.runEvery(lsInterval, lsRegistrationTask);
+ }
+
+ /**
+ * Returns timeout in seconds between subsequent
registrations/keepalives to Lookup
+ * Service.
+ */
+ public synchronized int getLookupServiceInterval() {
+ return lsInterval;
+ }
+}
Added:
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/LSRegisterTest.java
===================================================================
---
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/LSRegisterTest.java
(rev 0)
+++
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/LSRegisterTest.java
2013-02-18 19:39:36 UTC (rev 6146)
@@ -0,0 +1,52 @@
+package net.geant.perfsonar.ls;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import javax.xml.ws.Endpoint;
+
+import net.geant.perfsonar.PerfSONAR;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Checks whether service registers to LS service and sends keep alive
messages.
+ *
+ * @author <a
href="mailto:>Blazej
Pietrzak</a>
+ */
+public class LSRegisterTest {
+ private static final int TWO_SECONDS = 2000;
+ private MockLSService ls = new MockLSService();
+
+ private PerfSONAR service = new LSEnabledService();
+ private Endpoint endpoint;
+
+ @Before
+ public void publishServices() throws InterruptedException,
IOException {
+ ls.publish("http://localhost:9000/perfsonar-ls");
+ endpoint =
Endpoint.publish("http://localhost:9000/perfsonar-java-sshtelnet-mp",
service);
+ }
+
+ @After
+ public void stopServices() {
+ endpoint.stop();
+ service.stop();
+ ls.stop();
+ endpoint = null;
+ ls = null;
+ service = null;
+ }
+
+ @Test
+ public void shouldRegisterToLookupService() throws Exception {
+ Thread.sleep(TWO_SECONDS * 3 + 500);
+ assertEquals(1, ls.getRegisterCount());
+ assertTrue(
+ "Keep alive should be sent at least 3x but was "
+ + ls.getKeepAliveCount(),
ls.getKeepAliveCount() >= 3);
+ }
+}
Added:
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/MockLSService.java
===================================================================
---
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/MockLSService.java
(rev 0)
+++
trunk/psBase3/perfsonar-ls-register/src/test/java/net/geant/perfsonar/ls/MockLSService.java
2013-02-18 19:39:36 UTC (rev 6146)
@@ -0,0 +1,62 @@
+package net.geant.perfsonar.ls;
+
+import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Provider;
+import javax.xml.ws.WebServiceProvider;
+
+import net.geant.perfsonar.NMWGMessage;
+import net.geant.perfsonar.templates.NMWG;
+import net.geant.perfsonar.messaging.XPathDeserializer;
+
+import org.xml.sax.InputSource;
+
+/**
+ * Mock implementation of Lookup Service.
+ * It is used in automated tests.
+ *
+ * @author <a
href="mailto:">Blazej
Pietrzak</a>
+ */
+@WebServiceProvider
+public class MockLSService implements Provider<StreamSource> {
+ private int lsKeepAliveCount = 0;
+ private int lsRegisterCount = 0;
+ private Endpoint endpoint;
+
+ @SuppressWarnings("unchecked")
+ public StreamSource invoke(StreamSource input) {
+ final XPathDeserializer deserializer = new
XPathDeserializer();
+ NMWGMessage msg;
+ try {
+ msg = deserializer.getObjects(NMWGMessage.class,
(List<Object>) deserializer.deserialize(new
InputSource(input.getInputStream()))).get(0);
+ if (msg.getType().equals("LSKeepaliveRequest"))
+ lsKeepAliveCount++;
+ else if (msg.getType().equals("LSRegisterRequest"))
+ lsRegisterCount++;
+ return new
StreamSource(NMWG.toLSResponse(msg.getId()));
+ } catch (Exception ex) {
+ fail(ex.toString());
+ }
+ return null;
+ }
+
+ public int getKeepAliveCount() {
+ return lsKeepAliveCount;
+ }
+
+ public int getRegisterCount() {
+ return lsRegisterCount;
+ }
+
+ public void publish(String url) {
+ endpoint = Endpoint.publish(url, this);
+ }
+
+ public void stop() {
+ endpoint.stop();
+ }
+}
Added:
trunk/psBase3/perfsonar-ls-register/src/test/resources/configuration.xml
===================================================================
--- trunk/psBase3/perfsonar-ls-register/src/test/resources/configuration.xml
(rev 0)
+++ trunk/psBase3/perfsonar-ls-register/src/test/resources/configuration.xml
2013-02-18 19:39:36 UTC (rev 6146)
@@ -0,0 +1,132 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<configuration xmlns="http://service.perfsonar.org/ns/config/base/0.9/">
+ <service name="sshtelnet-mp">
+ <lookupInformation>
+ <option name="accessPoint"
value="http://localhost:${tomcat.port}/${project.artifactId}/services/SSHTelnet"/>
+ <option name="serviceName" value="Geant3 JAVA - SSHTelnet MP"/>
+ <option name="serviceType" value="MP"/>
+ </lookupInformation>
+
+ <!-- Message Handlers - message types and service engines -->
+
+ <messageHandler>
+
+ <message type="EchoRequest"
+
handler="org.perfsonar.base2.service.messages.GenericMessageHandler">
+ <option name="ServiceEngine"
+
value="org.perfsonar.service.measurementPoint.EchoServiceEngine" />
+ <option name="authN" value="no" />
+ </message>
+
+ <message type="MetadataKeyRequest"
+
handler="org.perfsonar.base2.service.messages.GenericMessageHandler">
+ <option name="ServiceEngine"
+
value="org.perfsonar.service.measurementPoint.ServiceCapabilitiesEngine" />
+ <option name="authN" value="no" />
+ </message>
+
+ <message type="SetupDataRequest"
+
handler="org.perfsonar.base2.service.messages.GenericMessageHandler">
+ <option name="ServiceEngine"
+
value="org.perfsonar.service.measurementPoint.SetupDataServiceEngine" />
+ <option name="authN" value="no" />
+ </message>
+
+ </messageHandler>
+
+ <!-- Additional auxiliary components -->
+
+ <auxiliaryComponents>
+ <component name="migrator"
className="org.perfsonar.base2.service.configuration.migration.MigratorComponent">
+ <option name="config-directory" value="${old-config-directory}" />
+ </component>
+ <component name="XMLDB"
className="org.perfsonar.base2.service.storage.xml.XMLDBComponent">
+ <option name="dataStorageClassName"
value="org.perfsonar.base2.service.storage.xml.exist.ExistHTTPDataStorage" />
+ <option name="uri"
value="http://localhost:${tomcat.port}/exist/rest/db"/>
+ <option name="username" value="sshtelnet"/>
+ <option name="password" value="sshtelnet"/>
+ </component>
+
+ <component name="Configuration"
className="org.perfsonar.service.measurementPoint.Configuration">
+ <option name="metadata-file"
value="${config.path}/sshtelnetmetadata.xml" />
+ <option name="token-path" value="${token.path}" />
+ </component>
+
+ <!-- auth configuration -->
+ <component name="auth"
className="org.perfsonar.base2.service.authn.component.wssec.WSSecAuthNComponent">
+ <option name="as_endpoint"
value="http://homer.rediris.es:8080/geant2-java-as-1.2/services/SimpleService"/>
+ <option name="comp_id" value="urn:compId"/>
+ </component>
+
+ <!-- Scheduler -->
+ <component name="scheduling"
className="org.perfsonar.base2.service.scheduler.SchedulingComponent">
+ <option name="schedulerClassName"
value="org.perfsonar.base2.service.scheduler.SimpleScheduler"/>
+ <option name="interval" value="60"/>
+
+ <actions>
+ <action name="registration"
className="org.perfsonar.base2.service.registration.LSRegistrationAction">
+ <option name="status" value="on" />
+ <option name="interval" value="2" />
+ <option name="registerDataSource"
value="org.perfsonar.base2.service.registration.MetadataExistDBRegisterDataSource"/>
+ <option name="registerEventType"
value="http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/registration/summary/2.0"/>
+ <option name="registrator"
value="org.perfsonar.base2.service.registration.GenericLSRegistrator"/>
+ <option name="lsAddress-1"
value="http://localhost:9000/perfsonar-ls"/>
+ </action>
+
+ <!-- Checks whether a given metadata file has changed and updates
it in the database.
+ If the given metadata file is not stored in the database it
is added. -->
+ <action name="metadata-updater"
className="org.perfsonar.service.measurementPoint.MetadataUpdater">
+ <!-- Should the user configured in the "Configuration" section
be created if it does not exist -->
+ <option name="create-user" value="yes" />
+
+ <!-- login and password for the user that has rights to create
user accounts. Obligatory only when "create-user" option is set to "yes" -->
+ <option name="username" value="admin" />
+ <option name="password" value="" />
+ </action>
+ </actions>
+ </component>
+ </auxiliaryComponents>
+
+ <extension name="registerExtension-registerDataSource">
+ <option name="exist-config" value="XMLDB" />
+ </extension>
+
+ <!--
....................................................................................
-->
+
+ <!-- Protocol mappings, XML elements and their bingings -->
+
+ <protocolMappings>
+
+
+ <!-- default mapping -->
+
+
+ <!-- general mappings -->
+ <element name="{*}message"
+ mapping="org.perfsonar.base2.xml.nmwg.Message"/>
+ <element name="{*}metadata"
+ mapping="org.perfsonar.base2.xml.nmwg.Metadata"/>
+ <element name="{*}eventType"
+ mapping="org.perfsonar.base2.xml.nmwg.EventType"/>
+ <element name="{*}data"
+ mapping="org.perfsonar.base2.xml.nmwg.Data"/>
+ <element name="{*}subject"
+ mapping="org.perfsonar.base2.xml.nmwg.Subject"/>
+ <element name="{*}parameters"
+ mapping="org.perfsonar.base2.xml.nmwg.Parameters"/>
+ <element name="{*}parameter"
+ mapping="org.perfsonar.base2.xml.nmwg.Parameter"/>
+ <element name="*"
+ mapping="org.perfsonar.base2.xml.Element"/>
+ <element
name="{http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/xquery/1.0/}subject"
+ mapping="org.perfsonar.base2.xml.TextElement"/>
+
+
+ </protocolMappings>
+
+
+ </service>
+
+
+</configuration>
Added:
trunk/psBase3/perfsonar-ls-register/src/test/resources/net/geant/perfsonar/mp/sshtelnet/LSRegister.template
===================================================================
---
trunk/psBase3/perfsonar-ls-register/src/test/resources/net/geant/perfsonar/mp/sshtelnet/LSRegister.template
(rev 0)
+++
trunk/psBase3/perfsonar-ls-register/src/test/resources/net/geant/perfsonar/mp/sshtelnet/LSRegister.template
2013-02-18 19:39:36 UTC (rev 6146)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nmwg:message id="${requestId}" type="LSRegisterRequest"
xmlns:nmwg="http://ggf.org/ns/nmwg/base/2.0/">
+ <nmwg:metadata id="serviceLookupInfo">
+
<nmwg:eventType>http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/registration/service/2.0</nmwg:eventType>
+ <nmwg:subject id="commonParameters" name="perfsonar">
+ <psservice:service id="serviceParameters"
xmlns:psservice="http://ggf.org/ns/nmwg/tools/org/perfsonar/service/1.0/">
+
<psservice:accessPoint>http://localhost:9000/perfsonar-sshtelnet-mp</psservice:accessPoint>
+
<psservice:serviceName>${service.serviceName}</psservice:serviceName>
+
<psservice:serviceType>${service.serviceType}</psservice:serviceType>
+ </psservice:service>
+ </nmwg:subject>
+ </nmwg:metadata>
+ <nmwg:data metadataIdRef="serviceLookupInfo">
+ <nmwg:metadata id="metadata0">
+ <nmwg:subject
id="subject0">DummyCiscoRouter</nmwg:subject>
+ <nmwg:parameters id="metaParams0">
+ <nmwg:parameter name="class_name"
value="org.perfsonar.service.measurementPoint.lookingGlassType.engine.adapters.CiscoAdapter"
/>
+ <nmwg:parameter name="url" value="0.0.0.0" />
+ <nmwg:parameter name="port" value="0" />
+ <nmwg:parameter name="prompt"
value="DummyRouter>" />
+ <nmwg:parameter name="rate" value="500" />
+ <nmwg:parameter name="username"
value="dummyUser" />
+ <nmwg:parameter name="password"
value="ab05D8Z22537EdEzaWmlmA==" />
+ <nmwg:parameter name="timeout" value="10000"
/>
+ <nmwg:parameter name="numberOfUsers"
value="0" />
+ <nmwg:parameter name="cache" value="0" />
+ </nmwg:parameters>
+ </nmwg:metadata>
+ </nmwg:data>
+</nmwg:message>
- [pS-dev] [GEANT/SA2/ps-java-services] r6146 - in trunk/psBase3/perfsonar-ls-register: . src src/main src/main/java src/main/java/net src/main/java/net/geant src/main/java/net/geant/perfsonar src/main/java/net/geant/perfsonar/ls src/test src/test/java src/test/java/net src/test/java/net/geant src/test/java/net/geant/perfsonar src/test/java/net/geant/perfsonar/ls src/test/resources src/test/resources/net src/test/resources/net/geant src/test/resources/net/geant/perfsonar src/test/resources/net/geant/perfsonar/mp src/test/resources/net/geant/perfsonar/mp/sshtelnet, svn-noreply, 02/18/2013
Archive powered by MHonArc 2.6.16.