Skip to Content.
Sympa Menu

perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r6229 - in trunk/perfsonar-base/base/src: main/java/net/geant/perfsonar test/java/net/geant/perfsonar test/java/net/geant/perfsonar/configuration test/java/net/geant/perfsonar/helpers test/java/net/geant/perfsonar/mp/sshtelnet test/resources/net/geant/perfsonar/mp/sshtelnet

Subject: perfsonar development work

List archive

[pS-dev] [GEANT/SA2/ps-java-services] r6229 - in trunk/perfsonar-base/base/src: main/java/net/geant/perfsonar test/java/net/geant/perfsonar test/java/net/geant/perfsonar/configuration test/java/net/geant/perfsonar/helpers test/java/net/geant/perfsonar/mp/sshtelnet test/resources/net/geant/perfsonar/mp/sshtelnet


Chronological Thread 
  • From:
  • To:
  • Subject: [pS-dev] [GEANT/SA2/ps-java-services] r6229 - in trunk/perfsonar-base/base/src: main/java/net/geant/perfsonar test/java/net/geant/perfsonar test/java/net/geant/perfsonar/configuration test/java/net/geant/perfsonar/helpers test/java/net/geant/perfsonar/mp/sshtelnet test/resources/net/geant/perfsonar/mp/sshtelnet
  • Date: Wed, 20 Mar 2013 21:49:14 +0000 (GMT)
  • Authentication-results: sfpop-ironport01.merit.edu; dkim=neutral (message not signed) header.i=none

Author: psnc.pietrzak
Date: 2013-03-20 21:49:14 +0000 (Wed, 20 Mar 2013)
New Revision: 6229

Removed:
trunk/perfsonar-base/base/src/main/java/net/geant/perfsonar/nmwg/

trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/SSHTelnetMPWebServiceTest.java
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/messaging/

trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/mp/sshtelnet/SSHTelnetMPService.java

trunk/perfsonar-base/base/src/test/resources/net/geant/perfsonar/mp/sshtelnet/MetadataKeyResponse.template

trunk/perfsonar-base/base/src/test/resources/net/geant/perfsonar/mp/sshtelnet/SetupDataResponse.template
Modified:
trunk/perfsonar-base/base/src/main/java/net/geant/perfsonar/PerfSONAR.java

trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/PerfSONARTest.java

trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/SchedulerTest.java

trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/configuration/ConfigurationTest.java

trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/helpers/PerfSONARClient.java

trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/helpers/Response.java

trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/mp/sshtelnet/ServiceController.java
Log:
Extracted sample-service project.

Modified:
trunk/perfsonar-base/base/src/main/java/net/geant/perfsonar/PerfSONAR.java
===================================================================
---
trunk/perfsonar-base/base/src/main/java/net/geant/perfsonar/PerfSONAR.java
2013-03-20 21:48:23 UTC (rev 6228)
+++
trunk/perfsonar-base/base/src/main/java/net/geant/perfsonar/PerfSONAR.java
2013-03-20 21:49:14 UTC (rev 6229)
@@ -38,44 +38,48 @@
*/
public abstract class PerfSONAR implements Provider<StreamSource> {
public static final Object ANY = null;
-
+
private static int defaultThreadPoolSize = 10;

- /* FIXME: do we really need our own Logger?
- protected static final net.geant.perfsonar.Logger logger =
- new net.geant.perfsonar.Logger() {
- public void error(String msg, Throwable ex) {
-
LoggerFactory.getLogger(PerfSONAR.class).error(msg, ex);
- }
- };
- */
- protected Logger logger = LoggerFactory.getLogger(getClass());
-
+ /*
+ * FIXME: do we really need our own Logger? protected static final
+ * net.geant.perfsonar.Logger logger = new
net.geant.perfsonar.Logger() {
+ * public void error(String msg, Throwable ex) {
+ * LoggerFactory.getLogger(PerfSONAR.class).error(msg, ex); } };
+ */
+ protected Logger logger = LoggerFactory.getLogger(getClass());
+
static {
try {
declarePrefix("nmwg",
"http://ggf.org/ns/nmwg/base/2.0/";);
declarePrefix("nmwgr",
"http://ggf.org/ns/nmwg/result/2.0/";);
declarePrefix("nmwgtopo",
"http://ggf.org/ns/nmwg/topology/2.0/";);
-
whenXPath("nmwg:message/@type").then(NMWGMessage.class).setType(any(String.class));
-
whenXPath("nmwg:message/@id").then(NMWGMessage.class).setId(any(String.class));
-
whenXPath("nmwg:message/nmwg:metadata[@id='meta']/nmwg:eventType/text()").then(NMWGMessage.class).setEventType(any(String.class));
-
whenXPath("nmwg:message/nmwg:metadata/nmwg:key/text()").then(NMWGMessage.class).setKey(any(String.class));
+
whenXPath("nmwg:message/@type").then(NMWGMessage.class).setType(
+ any(String.class));
+
whenXPath("nmwg:message/@id").then(NMWGMessage.class).setId(
+ any(String.class));
+ whenXPath(
+
"nmwg:message/nmwg:metadata[@id='meta']/nmwg:eventType/text()")
+
.then(NMWGMessage.class).setEventType(any(String.class));
+
whenXPath("nmwg:message/nmwg:metadata/nmwg:key/text()").then(
+
NMWGMessage.class).setKey(any(String.class));
} catch (Exception ex) {
- //FIXME: What should we do with this exception?
+ // FIXME: What should we do with this exception?
}
}
-
+
private static SelfTestResponse response;
-
+
protected Scheduler scheduler = createThreadPool();

public PerfSONAR() {
loadConfiguration();
}
-
+
/**
- * It creates an instance of net.geant.perfsonar.SelfTestRunnerImpl.
- * If you would like to use a different implementation of
SelfTestRunner you must override this method.
+ * It creates an instance of net.geant.perfsonar.SelfTestRunnerImpl.
If you
+ * would like to use a different implementation of SelfTestRunner you
must
+ * override this method.
*
*/
protected SelfTestRunner newSelfTestRunner() throws
InstantiationException,
@@ -83,36 +87,73 @@
return (SelfTestRunner) Class.forName(

"net.geant.perfsonar.SelfTestRunnerImpl").newInstance();
}
-
+
private void loadConfiguration() {
try {
-
Class.forName("net.geant.perfsonar.XPaths").newInstance();
+ configure(getXPathAnnotations());
} catch (Exception ex) {
- //FIXME: What should we do with this exception?
+ // When @XPath annotations are not found do nothing
}
try {
-
Class.forName("net.geant.perfsonar.Handlers").newInstance();
+ configure(getHandlerAnnotations());
} catch (Exception ex) {
- //FIXME: What should we do with this exception?
+ // When handler annotations (@MetadataKey etc.) are
not found do
+ // nothing
}
try {
-
Class.forName("net.geant.perfsonar.LookupServiceRegister").newInstance();
+ configure(getLookupServiceRegisterAnnotations());
} catch (Exception ex) {
- //FIXME: What should we do with this exception?
+ // When @LookupServiceRegister annotations are not
found do nothing
}
}

+ protected static Class<?> getLookupServiceRegisterAnnotations() {
+ try {
+ return
Class.forName("net.geant.perfsonar.LookupServiceRegister");
+ } catch (ClassNotFoundException ex) {
+ return null;
+ }
+ }
+
+ protected static Class<?> getHandlerAnnotations() {
+ try {
+ return Class.forName("net.geant.perfsonar.Handlers");
+ } catch (ClassNotFoundException ex) {
+ return null;
+ }
+ }
+
+ protected static Class<?> getXPathAnnotations() {
+ try {
+ return Class.forName("net.geant.perfsonar.XPaths");
+ } catch (ClassNotFoundException ex) {
+ return null;
+ }
+ }
+
+ protected static boolean isUsingAPT() {
+ return (getHandlerAnnotations() != null)
+ || (getXPathAnnotations() != null)
+ || (getLookupServiceRegisterAnnotations() !=
null);
+ }
+
+ private void configure(Class<?> annotations) throws Exception {
+ annotations.newInstance();
+ }
+
private static Scheduler createThreadPool() {
return new Scheduler() {
- private ScheduledExecutorService pool =
Executors.newScheduledThreadPool(defaultThreadPoolSize);
+ private ScheduledExecutorService pool = Executors
+
.newScheduledThreadPool(defaultThreadPoolSize);
private Map<Runnable, ScheduledFuture<?>> tasks = new
Hashtable<Runnable, ScheduledFuture<?>>();
-
+
public void runInParallel(Runnable task) {
pool.execute(task);
}

public void runEvery(int seconds, final Runnable
task) {
- tasks.put(task,
pool.scheduleAtFixedRate(task, 0, seconds, TimeUnit.SECONDS));
+ tasks.put(task,
pool.scheduleAtFixedRate(task, 0, seconds,
+ TimeUnit.SECONDS));
}

public void stop(Runnable task) {
@@ -121,11 +162,11 @@
tasks.get(task).cancel(false);
tasks.remove(task);
}
-
+
public void stopAll() {
for (ScheduledFuture<?> task :
tasks.values()) {
if (task.cancel(false) == false)
- System.out.println("Task: " +
task + " did not stop.");
+ System.out.println("Task: " +
task + " did not stop.");
}
pool.shutdownNow();
tasks.clear();
@@ -148,54 +189,65 @@
final XPathDeserializer deserializer = new
XPathDeserializer();
final List<Object> objects;
try {
- objects = (List<Object>)
deserializer.deserialize(toInputSource(request));//.getCharacterStream());
+ objects = (List<Object>) deserializer
+
.deserialize(toInputSource(request));// .getCharacterStream());
} catch (Exception e1) {
logger.error("Could not deserialize the request.",
e1);
return null;
}
-
+
if (deserializer.getObjects(NMWGMessage.class,
objects).size() <= 0)
- throw new RuntimeException("NMWG message was not
found in the payload.");
-
- final NMWGMessage msg =
deserializer.getObjects(NMWGMessage.class, objects).get(0);
+ throw new RuntimeException(
+ "NMWG message was not found in the
payload.");

+ final NMWGMessage msg =
deserializer.getObjects(NMWGMessage.class,
+ objects).get(0);
+
final StringWriter writer = new StringWriter();
- logger.debug("Dispatching an incoming message");
+ logger.debug("Dispatching an incoming message");
if (msg.isEchoRequest()) {
- logger.debug("We received an echo request");
+ logger.debug("We received an echo request");
return handleEcho(msg, writer);
} else if (msg.isSelfTestRequest()) {
- logger.debug("We received a self test request");
+ logger.debug("We received a self test request");
return handleSelfTest(msg, writer);
} else {
try {
String msgType = msg.getType();
- logger.debug(msgType);
+ logger.debug(msgType);
final Method m =
Configuration.getHandler(msgType);
if (m.getParameterTypes().length > 1)
- throw new RuntimeException(m + ":
Controller methods must have zero or one argument.");
-
+ throw new RuntimeException(
+ m
+ + ":
Controller methods must have zero or one argument.");
+
TemplateEngine.put("requestId", msg.getId());
-
+
if (m.getParameterTypes().length < 1) {
- TemplateEngine.put("result",
m.invoke(m.getDeclaringClass().newInstance()));
+ TemplateEngine.put("result",
+
m.invoke(m.getDeclaringClass().newInstance()));
} else {
final List<Object> result = new
ArrayList<Object>();
- for (Object obj :
deserializer.getObjects(m.getParameterTypes()[0], objects)) {
-
result.add(m.invoke(m.getDeclaringClass().newInstance(), obj));
+ for (Object obj :
deserializer.getObjects(
+
m.getParameterTypes()[0], objects)) {
+ result.add(m.invoke(
+
m.getDeclaringClass().newInstance(), obj));
}
TemplateEngine.put("result", result);
}
try {
- TemplateEngine.evaluate(writer,
m.getDeclaringClass(), msg.getType().replace("Request", "Response.template"));
+ TemplateEngine.evaluate(writer,
m.getDeclaringClass(), msg
+
.getType().replace("Request", "Response.template"));
} catch (IOException e) {
- logger.error("Could not fill in the
template for the response.", e);
+ logger.error(
+ "Could not fill in
the template for the response.",
+ e);
}
} catch (Exception ex) {
logger.error("Could not process the
request.", ex);
return null;
}
-
+
return new StreamSource(new
StringReader(writer.toString()));
}
}
@@ -207,15 +259,16 @@
return new InputSource(request.getReader());
}

- private StreamSource handleSelfTest(final NMWGMessage msg, final
StringWriter writer) {
+ private StreamSource handleSelfTest(final NMWGMessage msg,
+ final StringWriter writer) {
try {
- logger.debug("Generating self test response.");
+ logger.debug("Generating self test response.");
response = new SelfTestResponse(getServiceType(),
getServiceName());
} catch (Exception ex) {
- logger.error("Self Test response couldn't be generated.",
ex);
+ logger.error("Self Test response couldn't be
generated.", ex);
}
try {
- logger.debug("Now streaming the response.");
+ logger.debug("Now streaming the response.");
response.begin(writer, msg.getId());
newSelfTestRunner().runSuite(scheduler, response);
} catch (Exception ex) {
@@ -224,14 +277,15 @@
try {
response.end();
} catch (IOException ex) {
- //FIXME: what should we do with this exception?
+ // FIXME: what should we do with this
exception?
}
}

return new StreamSource(new StringReader(writer.toString()));
}

- private StreamSource handleEcho(final NMWGMessage msg, final
StringWriter writer) {
+ private StreamSource handleEcho(final NMWGMessage msg,
+ final StringWriter writer) {
try {
EchoResponse.writeEcho(writer, msg.getId());
} catch (IOException e) {
@@ -246,16 +300,17 @@
public Scheduler getScheduler() {
return scheduler;
}
-
+
/**
* Sets thread pool size used by scheduler.
+ *
* @param size
*/
public void setThreadPoolSize(int size) {
PerfSONAR.defaultThreadPoolSize = size;
scheduler = createThreadPool();
}
-
+
public void stop() {
scheduler.stopAll();
}

Modified:
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/PerfSONARTest.java
===================================================================
---
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/PerfSONARTest.java
2013-03-20 21:48:23 UTC (rev 6228)
+++
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/PerfSONARTest.java
2013-03-20 21:49:14 UTC (rev 6229)
@@ -4,14 +4,9 @@
import static net.geant.perfsonar.templates.SelfTestResult.success;
import static org.junit.Assert.assertEquals;

-import java.io.IOException;
-import java.io.Reader;
-
import net.geant.perfsonar.templates.NMWG;
import net.geant.perfsonar.helpers.PerfSONARClient;
import net.geant.perfsonar.helpers.Response;
-import net.geant.perfsonar.mp.sshtelnet.Command;
-import net.geant.perfsonar.mp.sshtelnet.SSHTelnetMPService;
import net.geant.perfsonar.templates.SelfTestResult;

import org.junit.Before;
@@ -26,8 +21,19 @@

static final String REQUEST_ID = "request1";
private PerfSONARClient client;
- private SSHTelnetMPService service = new SSHTelnetMPService();
+ private PerfSONAR service = new PerfSONAR() {

+ @Override
+ public ServiceType getServiceType() {
+ return ServiceType.MP;
+ }
+
+ @Override
+ public String getServiceName() {
+ return "SSHTELNET";
+ }
+ };
+
@Before
public void givenPerfSONARClient() {
client = new PerfSONARClient(service);
@@ -49,29 +55,4 @@

failure("test2", "Test failed.", "SSHTELNET", "MP"), })),
client.selfTest(REQUEST_ID));
}
-
- @Test
- public void checkMetadataKey() throws SAXException, IOException {
- print(client.listAvailableCommands(REQUEST_ID).getReader());
- }
-
- @Test
- public void checkSetupDataRequest() throws Exception {
- final Command command1 = (Command) Command.SHOW_ENVIRONMENT
- .newInstance();
- command1.setRouterName("host1");
- final Command command2 = (Command)
Command.PING_IPV6.newInstance();
- command2.setRouterName("host2");
- print(client.executeCommands(REQUEST_ID, command1, command2)
- .getReader());
- }
-
- private void print(Reader reader) throws IOException {
- String printed = "";
- for (int i = reader.read(); i != -1; i = reader.read()) {
- printed += (char) i;
- }
-
- logger.debug(printed);
- }
}

Deleted:
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/SSHTelnetMPWebServiceTest.java
===================================================================
---
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/SSHTelnetMPWebServiceTest.java
2013-03-20 21:48:23 UTC (rev 6228)
+++
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/SSHTelnetMPWebServiceTest.java
2013-03-20 21:49:14 UTC (rev 6229)
@@ -1,44 +0,0 @@
-package net.geant.perfsonar;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-
-import javax.xml.ws.Endpoint;
-
-import net.geant.perfsonar.templates.NMWG;
-import net.geant.perfsonar.helpers.PerfSONARServiceClient;
-import net.geant.perfsonar.helpers.Response;
-import net.geant.perfsonar.mp.sshtelnet.SSHTelnetMPService;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.xml.sax.SAXException;
-
-public class SSHTelnetMPWebServiceTest {
- private static final String REQUEST_ID = "request1";
- private static final String SERVICE_URL =
"http://localhost:9000/perfsonar-java-sshtelnet-mp";;
-
- private SSHTelnetMPService service = new SSHTelnetMPService();
- private Endpoint endpoint;
-
- @Before
- public void givenSSHTelnetMPWebService() throws InterruptedException,
IOException {
- endpoint = Endpoint.publish(SERVICE_URL, service);
- }
-
- @After
- public void stopServices() {
- endpoint.stop();
- service.stop();
- endpoint = null;
- service = null;
- }
-
- @Test
- public void shouldSayEcho() throws SAXException, InterruptedException
{
- final PerfSONARServiceClient client = new
PerfSONARServiceClient(SERVICE_URL);
- assertEquals(new Response(NMWG.toEchoResponse(REQUEST_ID)),
client.echo(REQUEST_ID));
- }
-}

Modified:
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/SchedulerTest.java
===================================================================
---
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/SchedulerTest.java
2013-03-20 21:48:23 UTC (rev 6228)
+++
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/SchedulerTest.java
2013-03-20 21:49:14 UTC (rev 6229)
@@ -3,13 +3,24 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import net.geant.perfsonar.base.Scheduler;
-import net.geant.perfsonar.mp.sshtelnet.SSHTelnetMPService;

import org.junit.Before;
import org.junit.Test;

public class SchedulerTest {
- private PerfSONAR service = new SSHTelnetMPService();
+ private PerfSONAR service = new PerfSONAR() {
+
+ @Override
+ public ServiceType getServiceType() {
+ return ServiceType.MA;
+ }
+
+ @Override
+ public String getServiceName() {
+ return "RRD";
+ }
+
+ };
private boolean executed1 = false;
private boolean executed2 = false;
private Scheduler scheduler;

Modified:
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/configuration/ConfigurationTest.java
===================================================================
---
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/configuration/ConfigurationTest.java
2013-03-20 21:48:23 UTC (rev 6228)
+++
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/configuration/ConfigurationTest.java
2013-03-20 21:49:14 UTC (rev 6229)
@@ -3,7 +3,6 @@
import static org.junit.Assert.*;

import net.geant.perfsonar.Configuration;
-import net.geant.perfsonar.mp.sshtelnet.Command;
import net.geant.perfsonar.mp.sshtelnet.ServiceController;

import org.junit.Before;
@@ -33,10 +32,10 @@
@Test
public void shouldExecuteCommand() throws Exception {

configure(when("SetupDataRequest").then(ServiceController.class)
- .execute(any(Command.class)));
+ .execute(any(String.class)));

assertEquals(
- ServiceController.class.getMethod("execute",
Command.class),
+ ServiceController.class.getMethod("execute",
String.class),
Configuration.getHandler("SetupDataRequest"));
}
}

Modified:
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/helpers/PerfSONARClient.java
===================================================================
---
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/helpers/PerfSONARClient.java
2013-03-20 21:48:23 UTC (rev 6228)
+++
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/helpers/PerfSONARClient.java
2013-03-20 21:49:14 UTC (rev 6229)
@@ -26,9 +26,9 @@
return new Response(invoke(NMWG.toSelfTestRequest(id)));
}

- public Reader invoke(Reader request) throws SAXException {
+ public StreamSource invoke(Reader request) throws SAXException {
final StreamSource source = service.invoke(new
StreamSource(request));
- return source.getReader();
+ return source;
}

public Response listAvailableCommands(String id) throws SAXException {

Modified:
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/helpers/Response.java
===================================================================
---
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/helpers/Response.java
2013-03-20 21:48:23 UTC (rev 6228)
+++
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/helpers/Response.java
2013-03-20 21:49:14 UTC (rev 6229)
@@ -5,6 +5,8 @@
import java.io.InputStreamReader;
import java.io.Reader;

+import javax.xml.transform.stream.StreamSource;
+
import org.custommonkey.xmlunit.Diff;

public class Response {
@@ -14,6 +16,13 @@
this.input = new InputStreamReader(input);
}

+ public Response(StreamSource source) {
+ if (source.getInputStream() == null)
+ this.input = source.getReader();
+ else
+ this.input = new InputStreamReader(source.getInputStream());
+ }
+
public Response(Reader input) {
this.input = input;
}

Deleted:
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/mp/sshtelnet/SSHTelnetMPService.java
===================================================================
---
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/mp/sshtelnet/SSHTelnetMPService.java
2013-03-20 21:48:23 UTC (rev 6228)
+++
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/mp/sshtelnet/SSHTelnetMPService.java
2013-03-20 21:49:14 UTC (rev 6229)
@@ -1,90 +0,0 @@
-package net.geant.perfsonar.mp.sshtelnet;
-
-import static net.geant.perfsonar.Configuration.configure;
-import static net.geant.perfsonar.Configuration.when;
-import static net.geant.perfsonar.messaging.XPathDeserializer.any;
-import static net.geant.perfsonar.messaging.XPathDeserializer.whenXPath;
-
-import javax.xml.ws.WebServiceProvider;
-
-import net.geant.perfsonar.PerfSONAR;
-import net.geant.perfsonar.ServiceType;
-
-@WebServiceProvider
-public class SSHTelnetMPService extends PerfSONAR {
-
-// 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 SSHTelnetMPService() {
- super();
-
- /*scheduler.runEvery(HOUR, lsRegistrationTask);
- scheduler.runEvery(SECOND, new
ConfigurationFileChecker(this));*/
- }
-
- @Override
- public ServiceType getServiceType() {
- return ServiceType.MP;
- }
-
- @Override
- public String getServiceName() {
- return "SSHTELNET";
- }
-
- static {
- try {
-
configure(when("MetadataKeyRequest").then(ServiceController.class)
- .listAvailableRoutersAndCommands());
-
-
configure(when("SetupDataRequest").then(ServiceController.class)
- .execute(any(Command.class)));
-
-//
configure(registerToLookupService(ServiceController.class)
-// .listAvailableRoutersAndCommands());
-
- whenXPath(
-
"nmwg:message/nmwg:metadata/nmwg:subject/nmwgtopo:endPoint/text()")
-
.then(Command.class).setRouterName(any(String.class));
-
-
whenXPath("nmwg:message/nmwg:metadata/nmwg:eventType/text()").then(
-
Command.class).setEventType(any(String.class));
-
- whenXPath(
-
"nmwg:message/nmwg:metadata/nmwg:parameters/nmwg:parameter[@name='command']/@value")
-
.then(Command.class).setName(any(String.class));
-
- whenXPath(
-
"nmwg:message/nmwg:metadata/nmwg:parameters/nmwg:parameter[@name='description']/@value")
-
.then(Command.class).setDescription(any(String.class));
-
- whenXPath(
-
"nmwg:message/nmwg:metadata/nmwg:parameters/nmwg:parameter[@name='syntax']/@value")
-
.then(Command.class).setSyntax(any(String.class));
- } 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;
-// }
-}

Modified:
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/mp/sshtelnet/ServiceController.java
===================================================================
---
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/mp/sshtelnet/ServiceController.java
2013-03-20 21:48:23 UTC (rev 6228)
+++
trunk/perfsonar-base/base/src/test/java/net/geant/perfsonar/mp/sshtelnet/ServiceController.java
2013-03-20 21:49:14 UTC (rev 6229)
@@ -1,24 +1,17 @@
package net.geant.perfsonar.mp.sshtelnet;

import java.io.IOException;
-import java.net.InetAddress;
import java.net.UnknownHostException;
-import java.util.Arrays;
import java.util.List;

public class ServiceController {
public ServiceController() { }

- public List<Router> listAvailableRoutersAndCommands() throws
UnknownHostException {
- return Arrays.asList(
- new Router("metadata0", "Cisco",
InetAddress.getAllByName("10.10.14.4")[0],
- Command.SHOW_ENVIRONMENT, Command.PING),
- new Router("metadata1", "JuniperGeantAmsterdam",
InetAddress.getByName("10.10.14.5"),
- Command.SHOW_INTERFACES_FILTERS));
+ public List<String> listAvailableRoutersAndCommands() throws
UnknownHostException {
+ return null;
}

- public Command execute(Command command) throws IOException {
- command.execute();
- return command;
+ public String execute(String command) throws IOException {
+ return null;
}
}

Deleted:
trunk/perfsonar-base/base/src/test/resources/net/geant/perfsonar/mp/sshtelnet/MetadataKeyResponse.template
===================================================================
---
trunk/perfsonar-base/base/src/test/resources/net/geant/perfsonar/mp/sshtelnet/MetadataKeyResponse.template
2013-03-20 21:48:23 UTC (rev 6228)
+++
trunk/perfsonar-base/base/src/test/resources/net/geant/perfsonar/mp/sshtelnet/MetadataKeyResponse.template
2013-03-20 21:49:14 UTC (rev 6229)
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<nmwg:message id="${requestId}_resp" messageIdRef="${requestId}"
type="MetadataKeyResponse" xmlns:nmwg="http://ggf.org/ns/nmwg/base/2.0/";>
-#set( $idx = 0 )
-#foreach ($router in $result)
- <nmwg:metadata id="metadata${idx}">
- <nmwg:subject id="subject${idx}">${router.name}</nmwg:subject>
- <nmwg:parameters id="metaParams${idx}">
- <nmwg:parameter name="url" value="${router.address.hostAddress}"
/>
- </nmwg:parameters>
- </nmwg:metadata>
- <nmwg:metadata id="resultCodeMeta_${idx}">
- <nmwg:subject id="resultCodeSubj_${idx}"
metadataIdRef="metadata${idx}" />
- <nmwg:eventType>success.mp.sshtelnet</nmwg:eventType>
- </nmwg:metadata>
- <nmwg:data id="resultCodeData_${idx}"
metadataIdRef="resultCodeMeta_${idx}">
- <nmwgr:datum
xmlns:nmwgr="http://ggf.org/ns/nmwg/result/2.0/";>Successfully executed
MetaDataKeyRequest</nmwgr:datum>
- </nmwg:data>
-#set( $idx = $idx + 1 )
-#end
-#set( $idx = 0 )
-#foreach ($router in $result)
- <nmwg:data id="data${idx}" metadataIdRef="metadata${idx}">
-#foreach ($command in $router.commands)
- <nmwgr:datum xmlns:nmwgr="http://ggf.org/ns/nmwg/result/2.0/";>
- <nmwg:parameters id="params${idx}">
- <nmwg:parameter name="command" value="${command.name}" />
- <nmwg:parameter name="description"
value="${command.description}" />
-#if (${command.syntax})
- <nmwg:parameter name="syntax" />
-#else
- <nmwg:parameter name="syntax" value="${command.syntax} />
-#end
- </nmwg:parameters>
- <nmwg:eventType>${command.eventType}</nmwg:eventType>
- </nmwgr:datum>
-#end
- </nmwg:data>
-#set( $idx = $idx + 1 )
-#end
-</nmwg:message>
\ No newline at end of file

Deleted:
trunk/perfsonar-base/base/src/test/resources/net/geant/perfsonar/mp/sshtelnet/SetupDataResponse.template
===================================================================
---
trunk/perfsonar-base/base/src/test/resources/net/geant/perfsonar/mp/sshtelnet/SetupDataResponse.template
2013-03-20 21:48:23 UTC (rev 6228)
+++
trunk/perfsonar-base/base/src/test/resources/net/geant/perfsonar/mp/sshtelnet/SetupDataResponse.template
2013-03-20 21:49:14 UTC (rev 6229)
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<nmwg:message xmlns:nmwg="http://ggf.org/ns/nmwg/base/2.0/";
id="${requestId}_resp" messageIdRef="${requestId}" type="SetupDataResponse">
-#set ($idx = 0)
-#foreach ($command in $result)
- <nmwg:metadata id="meta${idx}">
- <nmwg:subject id="subject${idx}">
- <nmwgtopo:endPoint
xmlns:nmwgtopo="http://ggf.org/ns/nmwg/topology/2.0/";
type="hostname">${command.routerName}</nmwgtopo:endPoint>
- </nmwg:subject>
- <nmwg:parameters id="params${idx}" />
- <nmwg:eventType>${command.eventType}</nmwg:eventType>
- </nmwg:metadata>
- <nmwg:data id="data${idx}" metadataIdRef="meta${idx}">
- <nmwg:datum>${command.result}</nmwg:datum>
- </nmwg:data>
- <nmwg:metadata id="resultCodeMeta_meta${idx}">
- <nmwg:subject id="resultCodeSubj_meta${idx}"
metadataIdRef="meta${idx}" />
- <nmwg:eventType>success.mp.sshtelnet</nmwg:eventType>
- </nmwg:metadata>
- <nmwg:data id="resultCodeData_meta${idx}"
metadataIdRef="resultCodeMeta_meta${idx}">
- <nmwgr:datum
xmlns:nmwgr="http://ggf.org/ns/nmwg/result/2.0/";>Successfully executed
request</nmwgr:datum>
- </nmwg:data>
-#set ($idx = $idx + 1)
-#end
-</nmwg:message>



  • [pS-dev] [GEANT/SA2/ps-java-services] r6229 - in trunk/perfsonar-base/base/src: main/java/net/geant/perfsonar test/java/net/geant/perfsonar test/java/net/geant/perfsonar/configuration test/java/net/geant/perfsonar/helpers test/java/net/geant/perfsonar/mp/sshtelnet test/resources/net/geant/perfsonar/mp/sshtelnet, svn-noreply, 03/20/2013

Archive powered by MHonArc 2.6.16.

Top of Page