Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r5260 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: data/topology level0 level1

Subject: perfsonar development work

List archive

perfsonar: r5260 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: data/topology level0 level1


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r5260 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: data/topology level0 level1
  • Date: Wed, 12 Aug 2009 05:33:29 -0400

Author: krzjed
Date: 2009-08-12 05:33:27 -0400 (Wed, 12 Aug 2009)
New Revision: 5260

Modified:

trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/EndPointTopologyElement.java

trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/GenericTopologyElement.java

trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/HandlersManager.java

trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/NetworkInterfaceTopologyElement.java

trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/NetworkTopologyElement.java

trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/NodeTopologyElement.java

trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/ServiceTopologyElement.java

trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UnknownTopologyElement.java

trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level0/Level0Impl.java

trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/DiscoveryProcessImpl.java

trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/Level1Impl.java

trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/RootGlses.java
Log:
some refactoring

Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/EndPointTopologyElement.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/EndPointTopologyElement.java
2009-08-12 07:50:45 UTC (rev 5259)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/EndPointTopologyElement.java
2009-08-12 09:33:27 UTC (rev 5260)
@@ -1,5 +1,8 @@
package org.perfsonar.ri.lsclient.data.topology;

+import java.net.URI;
+import java.net.URISyntaxException;
+
import org.perfsonar.lsclient.data.TopologyElement;

/**
@@ -12,6 +15,8 @@

String direction = "";

+ private String id = "";
+
String port = "";

String type = "";
@@ -20,7 +25,7 @@

EndPointTopologyElement() {
}
-
+
/**
* Synonym for
{@link
EndPointTopologyElement}
*
@@ -33,6 +38,9 @@
public String getDirection() {
return direction;
}
+ public String getId() {
+ return id;
+ }

public String getPort() {
return port;
@@ -42,6 +50,22 @@
return type;
}

+ /*
+ * (non-Javadoc)
+ *
+ * @see org.perfsonar.lsclient.data.TopologyElement#getURI()
+ */
+ public URI getURI() {
+ if (id != null) {
+ try {
+ return new URI(id);
+ } catch (URISyntaxException e) {
+ logger.error(e);
+ }
+ }
+ return null;
+ }
+
public String getValue() {
return value;
}
@@ -50,6 +74,10 @@
this.direction = direction;
}

+ void setId(String id) {
+ this.id = id;
+ }
+
void setPort(String port) {
this.port = port;
}

Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/GenericTopologyElement.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/GenericTopologyElement.java
2009-08-12 07:50:45 UTC (rev 5259)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/GenericTopologyElement.java
2009-08-12 09:33:27 UTC (rev 5260)
@@ -1,7 +1,5 @@
package org.perfsonar.ri.lsclient.data.topology;

-import java.net.URI;
-import java.net.URISyntaxException;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -18,14 +16,13 @@
* @author krzjed (PSNC)
*
*/
-public class GenericTopologyElement implements TopologyElement {
+public abstract class GenericTopologyElement implements TopologyElement {

/**
*
{@link
Set} of event types
*/
private Set<EventType> eventTypes = new HashSet<EventType>();
- private String id = "";
-
+
protected final Logger logger = Logger.getLogger(getClass());

/**
@@ -53,9 +50,6 @@
return Collections.unmodifiableSet(eventTypes);
}

- public String getId() {
- return id;
- }

/**
* Getter for parameter
@@ -90,21 +84,6 @@
return subjectNamespace;
}

- /*
- * (non-Javadoc)
- *
- * @see org.perfsonar.lsclient.data.TopologyElement#getURI()
- */
- public URI getURI() {
- if (id != null) {
- try {
- return new URI(id);
- } catch (URISyntaxException e) {
- logger.error(e);
- }
- }
- return null;
- }

/**
* Setter for event types
{@link
Set}
@@ -116,9 +95,6 @@
this.eventTypes = eventTypes;
}

- void setId(String id) {
- this.id = id;
- }

/**
* Setter for parameter

Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/HandlersManager.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/HandlersManager.java
2009-08-12 07:50:45 UTC (rev 5259)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/HandlersManager.java
2009-08-12 09:33:27 UTC (rev 5260)
@@ -79,6 +79,12 @@
Class<? extends SpecificTopologyElementHandler> handlerClass) {
synchronized (this) {
Handler annotation = handlerClass.getAnnotation(Handler.class);
+ if (annotation == null) {
+ throw new IllegalArgumentException(
+ "Handler class needs to have "
+ +
"org.perfsonar.ri.lsclient.data.topology.Handler "
+ + "annotation describing it.");
+ }
String uri = annotation.uri();
String name = annotation.name();
int priority = annotation.priority();

Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/NetworkInterfaceTopologyElement.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/NetworkInterfaceTopologyElement.java
2009-08-12 07:50:45 UTC (rev 5259)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/NetworkInterfaceTopologyElement.java
2009-08-12 09:33:27 UTC (rev 5260)
@@ -1,5 +1,7 @@
package org.perfsonar.ri.lsclient.data.topology;

+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -29,6 +31,7 @@

private String hostName = "";

+ private String id = "";
private String name = "";

NetworkInterfaceTopologyElement() {
@@ -90,10 +93,30 @@
return hostName;
}

+ public String getId() {
+ return id;
+ }
+
public String getName() {
return name;
}

+ /*
+ * (non-Javadoc)
+ *
+ * @see org.perfsonar.lsclient.data.TopologyElement#getURI()
+ */
+ public URI getURI() {
+ if (id != null) {
+ try {
+ return new URI(id);
+ } catch (URISyntaxException e) {
+ logger.error(e);
+ }
+ }
+ return null;
+ }
+
void setAuthRealm(String authRealm) {
this.authRealm = authRealm;
}
@@ -110,6 +133,10 @@
this.hostName = hostName;
}

+ void setId(String id) {
+ this.id = id;
+ }
+
void setName(String name) {
this.name = name;
}

Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/NetworkTopologyElement.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/NetworkTopologyElement.java
2009-08-12 07:50:45 UTC (rev 5259)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/NetworkTopologyElement.java
2009-08-12 09:33:27 UTC (rev 5260)
@@ -1,21 +1,49 @@
package org.perfsonar.ri.lsclient.data.topology;

+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class NetworkTopologyElement extends GenericTopologyElement {
+ private String id = "";
+
private Set<Subnet> subnets = new HashSet<Subnet>();

+ void addSubnet(Subnet subnet) {
+ this.subnets.add(subnet);
+ }
+
+ public String getId() {
+ return id;
+ }
+
public Set<Subnet> getSubnets() {
return Collections.unmodifiableSet(subnets);
}

+ /*
+ * (non-Javadoc)
+ *
+ * @see org.perfsonar.lsclient.data.TopologyElement#getURI()
+ */
+ public URI getURI() {
+ if (id != null) {
+ try {
+ return new URI(id);
+ } catch (URISyntaxException e) {
+ logger.error(e);
+ }
+ }
+ return null;
+ }
+
+ void setId(String id) {
+ this.id = id;
+ }
+
void setSubnets(Set<Subnet> subnets) {
this.subnets = subnets;
}
-
- void addSubnet(Subnet subnet) {
- this.subnets.add(subnet);
- }
}

Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/NodeTopologyElement.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/NodeTopologyElement.java
2009-08-12 07:50:45 UTC (rev 5259)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/NodeTopologyElement.java
2009-08-12 09:33:27 UTC (rev 5260)
@@ -1,5 +1,7 @@
package org.perfsonar.ri.lsclient.data.topology;

+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -15,6 +17,8 @@
*
*/
public class NodeTopologyElement extends GenericTopologyElement {
+ private String id = "";
+
private Map<String, String> names = new HashMap<String, String>();

private Set<Port> ports = new HashSet<Port>();
@@ -26,6 +30,10 @@
names.put(address, type);
}

+ public String getId() {
+ return id;
+ }
+
public Set<String> getNames() {
return names.keySet();
}
@@ -42,6 +50,26 @@
return Collections.unmodifiableSet(ports);
}

+ /*
+ * (non-Javadoc)
+ *
+ * @see org.perfsonar.lsclient.data.TopologyElement#getURI()
+ */
+ public URI getURI() {
+ if (id != null) {
+ try {
+ return new URI(id);
+ } catch (URISyntaxException e) {
+ logger.error(e);
+ }
+ }
+ return null;
+ }
+
+ void setId(String id) {
+ this.id = id;
+ }
+
void setNamesMap(Map<String, String> names) {
this.names = names;
}

Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/ServiceTopologyElement.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/ServiceTopologyElement.java
2009-08-12 07:50:45 UTC (rev 5259)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/ServiceTopologyElement.java
2009-08-12 09:33:27 UTC (rev 5260)
@@ -1,5 +1,7 @@
package org.perfsonar.ri.lsclient.data.topology;

+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -18,8 +20,9 @@

private String description;

+ private String id = "";
+
private String name;
-
private String type;

ServiceTopologyElement() {
@@ -41,6 +44,10 @@
return description;
}

+ public String getId() {
+ return id;
+ }
+
public String getName() {
return name;
}
@@ -49,6 +56,22 @@
return type;
}

+ /*
+ * (non-Javadoc)
+ *
+ * @see org.perfsonar.lsclient.data.TopologyElement#getURI()
+ */
+ public URI getURI() {
+ if (id != null) {
+ try {
+ return new URI(id);
+ } catch (URISyntaxException e) {
+ logger.error(e);
+ }
+ }
+ return null;
+ }
+
void setAddressesMap(Map<String, String> addresses) {
this.addresses = addresses;
}
@@ -57,6 +80,10 @@
this.description = description;
}

+ void setId(String id) {
+ this.id = id;
+ }
+
void setName(String name) {
this.name = name;
}

Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UnknownTopologyElement.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UnknownTopologyElement.java
2009-08-12 07:50:45 UTC (rev 5259)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UnknownTopologyElement.java
2009-08-12 09:33:27 UTC (rev 5260)
@@ -1,5 +1,8 @@
package org.perfsonar.ri.lsclient.data.topology;

+import java.net.URI;
+import java.net.URISyntaxException;
+
/**
*
{@link
TopologyElementParser} implementation in case when there is no element
* handler for metadata
@@ -9,15 +12,41 @@
*/
public class UnknownTopologyElement extends GenericTopologyElement {

+ private String id = "";
+
private String xmlDescription;

UnknownTopologyElement() {
}

+ public String getId() {
+ return id;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.perfsonar.lsclient.data.TopologyElement#getURI()
+ */
+ public URI getURI() {
+ if (id != null) {
+ try {
+ return new URI(id);
+ } catch (URISyntaxException e) {
+ logger.error(e);
+ }
+ }
+ return null;
+ }
+
public String getXmlDescription() {
return xmlDescription;
}

+ void setId(String id) {
+ this.id = id;
+ }
+
void setXmlDescription(String xmlDescription) {
this.xmlDescription = xmlDescription;
}

Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level0/Level0Impl.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level0/Level0Impl.java
2009-08-12 07:50:45 UTC (rev 5259)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level0/Level0Impl.java
2009-08-12 09:33:27 UTC (rev 5260)
@@ -22,149 +22,180 @@
import org.xml.sax.InputSource;

public class Level0Impl implements Level0LsClientInterface {
-
- protected final Logger logger = Logger.getLogger(getClass());
- private static final String QUERY_EVENTTYPE =
"http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/query/xquery/2.0";;
- private final MessageFactory messageFactory;
-
- public Level0Impl() {
- MessageFactory factory = null;
- try {
- factory =
MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
- } catch (SOAPException e) {
- logger.error("couldn't create MessageFactory", e);
- }
- messageFactory = factory;
- }
-
- /* (non-Javadoc)
- * @see
org.perfsonar.lsclient.Level0LsClientInterface#getRawQueryResult(org.perfsonar.lsclient.data.LookupService,
java.lang.String)
- */
- public InputStream getRawQueryResult(LookupService lookupService,
String xquery) throws LsQueryException, IllegalArgumentException {
- String xml = makeXml("<xquery:subject id=\"sub1\">", xquery,
"</xquery:subject>", QUERY_EVENTTYPE);
- SOAPMessage message = createMessage(xml);
- logger.debug("Executing raw xquery ["+xquery+"]");
- InputStream inputStream = send(message, lookupService);
- return new BufferedSoapStrippingStream(inputStream);
- }
-
- private SOAPMessage createMessage(String bodyXml) throws
LsQueryException {
- if(messageFactory == null) {
- logger.error("messageFactory is null most likely it
could not be created please check earlier logs");
- throw new LsQueryException("messageFactory is null");
- }
-
- SOAPMessage message;
- try {
- message = messageFactory.createMessage();
- } catch (SOAPException e) {
- logger.error("Can't create a message", e);
- throw new LsQueryException(e);
- }
-
- Document document = getDocumentFromString(bodyXml);
-
- try {
- message.getSOAPBody().addDocument(document);
- } catch (SOAPException e) {
- logger.error("Can't create a message", e);
- new LsQueryException(e);
- }
-
- return message;
- }

- private Document getDocumentFromString(String xml) throws
LsQueryException {
- try {
- DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- DocumentBuilder builder = factory.newDocumentBuilder();
- return builder.parse(new InputSource(new
StringReader(xml)));
- } catch (Exception e) {
- logger.error("Mailformed xml passed["+xml+"] to
method Level0Impl.getDocumentFromString() -> this is very likely a bug", e);
- throw new LsQueryException("Can't create a document
from String",e);
- }
- }
-
- private InputStream send(SOAPMessage message, LookupService target)
throws LsQueryException {
- SOAPEndpoint endpoint = new SOAPEndpoint(getURL(target));

- try {
- return endpoint.send(message);
- } catch (SOAPException e) {
- logger.warn("SOAP exception occoured during sending
message", e);
- throw new LsQueryException(e);
- } catch (SocketTimeoutException e) {
- //stack trace is useless.
- logger.warn("IOException occoured during sending
message - SocketTimeoutException connecting to "+target.getEndPoint());
- throw new LsQueryException(e);
- } catch (IOException e) {
- logger.warn("IOException occoured during sending
message", e);
- throw new LsQueryException(e);
- }
- }
-
- private URL getURL(LookupService lookupService) {
- try {
- return lookupService.getEndPoint().toURL();
- } catch (MalformedURLException e) {
- logger.warn("The lookup service demotes a URI that
this implementation doesn't know how to contact. (it's not a http(s)
address)", e);
- throw new UnsupportedOperationException("the
lookupservice contains a URI that this implementation doesn't
understand(expecting http/https URL)");
- }
- }
-
- private static String makeXml(String subjectOpenTag, String subject,
String subjectCloseTag, String eventType) {
- StringBuilder builder = new StringBuilder();
- builder
- .append("<nmwg:message type=\"LSQueryRequest\" " +
- "id=\"msg1\" " +
- "xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; " +
-
"xmlns:xquery=\"http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/xquery/2.0/\";>")
- .append("<nmwg:metadata id=\"meta1\">")
- .append(subjectOpenTag)
- .append(subject)
- .append(subjectCloseTag)
- .append("<nmwg:eventType>")
- .append(eventType)
- .append("</nmwg:eventType>")
- .append("<xquery:parameters id=\"param.1\">")
- .append("<nmwg:parameter
name=\"lsOutput\">escaped</nmwg:parameter>")
- .append("</xquery:parameters>")
- .append("</nmwg:metadata>")
- .append("<nmwg:data metadataIdRef=\"meta1\" id=\"d1\"/>")
- .append("</nmwg:message>");
-
- return builder.toString();
- }
-
- public InputStream getRawDiscoveryResponse(LookupService
lookupService, String summaryDescription) throws LsQueryException {
- String xml = makeDiscoveryXml(summaryDescription);
- SOAPMessage message = createMessage(xml);
- logger.debug("Executing raw discovery query
["+summaryDescription+"]");
- InputStream inputStream = send(message, lookupService);
- return new BufferedSoapStrippingStream(inputStream);
- }
-
- private static String makeDiscoveryXml(String summaryDescription) {
- StringBuilder builder = new StringBuilder();
- builder
- .append("<nmwg:message type=\"LSQueryRequest\" ")
- .append("id=\"LSDiscoveryRequest\" ")
-
.append("xmlns:perfsonar=\"http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/\";
")
- .append("xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";
")
-
.append("xmlns:psservice=\"http://ggf.org/ns/nmwg/tools/org/perfsonar/service/1.0/\";
")
-
.append("xmlns:nmwgt=\"http://ggf.org/ns/nmwg/topology/2.0/\"; ")
-
.append("xmlns:nmtb=\"http://ogf.org/schema/network/topology/base/20070828/\";
")
-
.append("xmlns:nmtl3=\"http://ogf.org/schema/network/topology/l3/20070828/\";
>")
- .append("<nmwg:metadata id=\"meta1\">")
- .append("<summary:subject
xmlns:summary=\"http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/summarization/2.0/\";
id=\"subject.1\">")
- .append(summaryDescription)
- .append("</summary:subject>")
-
.append("<nmwg:eventType>http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/discovery/summary/2.0</nmwg:eventType>")

- .append("</nmwg:metadata>")
- .append("<nmwg:data metadataIdRef=\"meta1\" id=\"d1\"/>")
- .append("</nmwg:message>");
-
- return builder.toString();
- }
-
+ protected final Logger logger = Logger.getLogger(getClass());
+ private static final String QUERY_EVENTTYPE =
"http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/query/xquery/2.0";;
+ private final MessageFactory messageFactory;
+
+ public Level0Impl() {
+ MessageFactory factory = null;
+ try {
+ factory = MessageFactory
+ .newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+ } catch (SOAPException e) {
+ logger.error("couldn't create MessageFactory", e);
+ }
+ messageFactory = factory;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.perfsonar.lsclient.Level0LsClientInterface#getRawQueryResult(org.
+ * perfsonar.lsclient.data.LookupService, java.lang.String)
+ */
+ public InputStream getRawQueryResult(LookupService lookupService,
+ String xquery) throws LsQueryException, IllegalArgumentException
{
+ String xml = makeXml("<xquery:subject id=\"sub1\">", xquery,
+ "</xquery:subject>", QUERY_EVENTTYPE);
+ SOAPMessage message = createMessage(xml);
+ logger.debug("Executing raw xquery [" + xquery + "]");
+ InputStream inputStream = send(message, lookupService);
+ return new BufferedSoapStrippingStream(inputStream);
+ }
+
+ private SOAPMessage createMessage(String bodyXml) throws
LsQueryException {
+ if (messageFactory == null) {
+ logger
+ .error("messageFactory is null most likely it could not
be created please check earlier logs");
+ throw new LsQueryException("messageFactory is null");
+ }
+
+ SOAPMessage message;
+ try {
+ message = messageFactory.createMessage();
+ } catch (SOAPException e) {
+ logger.error("Can't create a message", e);
+ throw new LsQueryException(e);
+ }
+
+ Document document = getDocumentFromString(bodyXml);
+
+ try {
+ message.getSOAPBody().addDocument(document);
+ } catch (SOAPException e) {
+ logger.error("Can't create a message", e);
+ new LsQueryException(e);
+ }
+
+ return message;
+ }
+
+ private Document getDocumentFromString(String xml) throws
LsQueryException {
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ return builder.parse(new InputSource(new StringReader(xml)));
+ } catch (Exception e) {
+ logger
+ .error(
+ "Mailformed xml passed["
+ + xml
+ + "] to method
Level0Impl.getDocumentFromString() -> this is very likely a bug",
+ e);
+ throw new LsQueryException("Can't create a document from
String", e);
+ }
+ }
+
+ private InputStream send(SOAPMessage message, LookupService target)
+ throws LsQueryException {
+ SOAPEndpoint endpoint = new SOAPEndpoint(getURL(target));
+ try {
+ return endpoint.send(message);
+ } catch (SOAPException e) {
+ logger.warn("SOAP exception occoured during sending message", e);
+ throw new LsQueryException(e);
+ } catch (SocketTimeoutException e) {
+ // stack trace is useless.
+ logger
+ .warn("IOException occoured during sending message -
SocketTimeoutException connecting to "
+ + target.getEndPoint());
+ throw new LsQueryException(e);
+ } catch (IOException e) {
+ logger.warn("IOException occoured during sending message", e);
+ throw new LsQueryException(e);
+ }
+ }
+
+ private URL getURL(LookupService lookupService) {
+ try {
+ return lookupService.getEndPoint().toURL();
+ } catch (MalformedURLException e) {
+ logger
+ .warn(
+ "The lookup service demotes a URI that this
implementation doesn't know how to contact. (it's not a http(s) address)",
+ e);
+ throw new UnsupportedOperationException(
+ "the lookupservice contains a URI that this
implementation doesn't understand(expecting http/https URL)");
+ }
+ }
+
+ private static String makeXml(String subjectOpenTag, String subject,
+ String subjectCloseTag, String eventType) {
+ StringBuilder builder = new StringBuilder();
+ builder
+ .append(
+ "<nmwg:message type=\"LSQueryRequest\" "
+ + "id=\"msg1\" "
+ +
"xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; "
+ +
"xmlns:xquery=\"http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/xquery/2.0/\";>")
+ .append("<nmwg:metadata id=\"meta1\">")
+ .append(subjectOpenTag)
+ .append(subject)
+ .append(subjectCloseTag)
+ .append("<nmwg:eventType>")
+ .append(eventType)
+ .append("</nmwg:eventType>")
+ .append("<xquery:parameters id=\"param.1\">")
+ .append(
+ "<nmwg:parameter
name=\"lsOutput\">escaped</nmwg:parameter>")
+ .append("</xquery:parameters>").append("</nmwg:metadata>")
+ .append("<nmwg:data metadataIdRef=\"meta1\" id=\"d1\"/>")
+ .append("</nmwg:message>");
+
+ return builder.toString();
+ }
+
+ public InputStream getRawDiscoveryResponse(LookupService lookupService,
+ String summaryDescription) throws LsQueryException {
+ String xml = makeDiscoveryXml(summaryDescription);
+ SOAPMessage message = createMessage(xml);
+ logger.debug("Executing raw discovery query [" + summaryDescription
+ + "]");
+ InputStream inputStream = send(message, lookupService);
+ return new BufferedSoapStrippingStream(inputStream);
+ }
+
+ private static String makeDiscoveryXml(String summaryDescription) {
+ StringBuilder builder = new StringBuilder();
+ builder
+ .append("<nmwg:message type=\"LSQueryRequest\" ")
+ .append("id=\"LSDiscoveryRequest\" ")
+ .append(
+
"xmlns:perfsonar=\"http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/\"; ")
+ .append("xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; ")
+ .append(
+
"xmlns:psservice=\"http://ggf.org/ns/nmwg/tools/org/perfsonar/service/1.0/\";
")
+
.append("xmlns:nmwgt=\"http://ggf.org/ns/nmwg/topology/2.0/\"; ")
+ .append(
+
"xmlns:nmtb=\"http://ogf.org/schema/network/topology/base/20070828/\"; ")
+ .append(
+
"xmlns:nmtl3=\"http://ogf.org/schema/network/topology/l3/20070828/\"; >")
+ .append("<nmwg:metadata id=\"meta1\">")
+ .append(
+ "<summary:subject
xmlns:summary=\"http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/summarization/2.0/\";
id=\"subject.1\">")
+ .append(summaryDescription)
+ .append("</summary:subject>")
+ .append(
+
"<nmwg:eventType>http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/discovery/summary/2.0</nmwg:eventType>")
+ .append("</nmwg:metadata>").append(
+ "<nmwg:data metadataIdRef=\"meta1\" id=\"d1\"/>")
+ .append("</nmwg:message>");
+
+ return builder.toString();
+ }
+
}

Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/DiscoveryProcessImpl.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/DiscoveryProcessImpl.java
2009-08-12 07:50:45 UTC (rev 5259)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/DiscoveryProcessImpl.java
2009-08-12 09:33:27 UTC (rev 5260)
@@ -85,7 +85,6 @@
rootServices.demote(service,e);
continue;
}
-
try {
Collection<ServiceImpl> services =
JaxbTools.unMarshallPerfsonarMessage(context, inputStream, ServiceImpl.class);
logger.debug("First step succeded without
error. Result: ["+services+"]");

Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/Level1Impl.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/Level1Impl.java
2009-08-12 07:50:45 UTC (rev 5259)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/Level1Impl.java
2009-08-12 09:33:27 UTC (rev 5260)
@@ -203,9 +203,10 @@
public void processLSQueryContent(LookupService hls, Service service,
ServiceMeasurementMetadataHandler handler) throws
LsQueryException {
LSMeasuredTopologyQuery query = new LSMeasuredTopologyQuery(service);
- logger.info("Created query: \n" + query.toString());
+ String queryString = query.toString();
+ logger.info("Created query: \n" + queryString);
InputStream stream;
- stream = level0.getRawQueryResult(hls, query.toString());
+ stream = level0.getRawQueryResult(hls, queryString);
try {
ResponseParser.parseServiceMeasurementMetadata(stream, handler);
} catch (ParserConfigurationException e) {

Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/RootGlses.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/RootGlses.java
2009-08-12 07:50:45 UTC (rev 5259)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/RootGlses.java
2009-08-12 09:33:27 UTC (rev 5260)
@@ -90,7 +90,6 @@
if (data.peek() == service) {
data.add(data.poll());
}
- // ignore
}
}




  • perfsonar: r5260 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: data/topology level0 level1, svnlog, 08/12/2009

Archive powered by MHonArc 2.6.16.

Top of Page