perfsonar-dev - perfsonar: r5196 - in trunk/ps-mdm-lsclient-impl: . src/main/java/org/perfsonar/ri/lsclient src/main/java/org/perfsonar/ri/lsclient/data src/main/java/org/perfsonar/ri/lsclient/data/implementation src/main/java/org/perfsonar/ri/lsclient/level1 src/main/java/org/perfsonar/ri/lsclient/xml
Subject: perfsonar development work
List archive
perfsonar: r5196 - in trunk/ps-mdm-lsclient-impl: . src/main/java/org/perfsonar/ri/lsclient src/main/java/org/perfsonar/ri/lsclient/data src/main/java/org/perfsonar/ri/lsclient/data/implementation src/main/java/org/perfsonar/ri/lsclient/level1 src/main/java/org/perfsonar/ri/lsclient/xml
Chronological Thread
- From:
- To:
- Subject: perfsonar: r5196 - in trunk/ps-mdm-lsclient-impl: . src/main/java/org/perfsonar/ri/lsclient src/main/java/org/perfsonar/ri/lsclient/data src/main/java/org/perfsonar/ri/lsclient/data/implementation src/main/java/org/perfsonar/ri/lsclient/level1 src/main/java/org/perfsonar/ri/lsclient/xml
- Date: Thu, 18 Jun 2009 10:44:57 -0400
Author: krzjed
Date: 2009-06-18 10:44:57 -0400 (Thu, 18 Jun 2009)
New Revision: 5196
Added:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/EventTypeImpl.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/LookupServiceImpl.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/NetworkInterfaceImpl.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/LSMeasuredServicesQuery.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/LsTopologyQuery.java
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/xml/
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/MeasuredInterfacesHandler.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/ResponseParser.java
Modified:
trunk/ps-mdm-lsclient-impl/pom.xml
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/LsClientImpl.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/DiscoveryStepImpl.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/Level1Impl.java
Log:
Querying for measured interfaces added
Modified: trunk/ps-mdm-lsclient-impl/pom.xml
===================================================================
--- trunk/ps-mdm-lsclient-impl/pom.xml 2009-06-18 14:41:54 UTC (rev 5195)
+++ trunk/ps-mdm-lsclient-impl/pom.xml 2009-06-18 14:44:57 UTC (rev 5196)
@@ -23,7 +23,7 @@
</roles>
</developer>
<developer>
- <id>krzjed</id>
+ <id>kjedrzejewski</id>
<name>Krzysztof Jedrzejewski</name>
<email></email>
<organization>Poznan Supercomputing and Networing
Center</organization>
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/LsClientImpl.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/LsClientImpl.java
2009-06-18 14:41:54 UTC (rev 5195)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/LsClientImpl.java
2009-06-18 14:44:57 UTC (rev 5196)
@@ -1,5 +1,6 @@
package org.perfsonar.ri.lsclient;
+import org.apache.log4j.Logger;
import org.perfsonar.lsclient.Level0LsClientInterface;
import org.perfsonar.lsclient.Level1LsClientInterface;
import org.perfsonar.lsclient.Level2LsClientInterface;
@@ -8,7 +9,6 @@
import org.perfsonar.ri.lsclient.level0.Level0Impl;
import org.perfsonar.ri.lsclient.level1.Level1Impl;
import org.perfsonar.ri.lsclient.level2.Level2Impl;
-import org.apache.log4j.Logger;
/**
@@ -57,5 +57,4 @@
protected Level2LsClientInterface getLevel2() {
return level2;
}
-
}
Added:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/EventTypeImpl.java
Added:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/LookupServiceImpl.java
Added:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/NetworkInterfaceImpl.java
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-06-18 14:41:54 UTC (rev 5195)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/DiscoveryProcessImpl.java
2009-06-18 14:44:57 UTC (rev 5196)
@@ -14,12 +14,12 @@
import org.perfsonar.lsclient.DiscoveryStep;
import org.perfsonar.lsclient.Level0LsClientInterface;
import org.perfsonar.lsclient.LsQueryException;
-import org.perfsonar.lsclient.data.AuthorativeLookupservice;
+import org.perfsonar.lsclient.data.AuthorativeLookupService;
import org.perfsonar.lsclient.data.EventType;
import org.perfsonar.lsclient.data.LookupService;
import org.perfsonar.lsclient.data.ServiceType;
import org.perfsonar.lsclient.data.TopologyElement;
-import org.perfsonar.ri.lsclient.level1.Level1Impl.RootGlses;
+import org.perfsonar.ri.lsclient.level1.RootGlses;
import org.perfsonar.ri.lsclient.level1.jaxb.JaxbTools;
import org.perfsonar.ri.lsclient.level1.jaxb.ServiceImpl;
import org.apache.log4j.Logger;
@@ -90,7 +90,7 @@
try {
Collection<ServiceImpl> services =
JaxbTools.unMarshallPerfsonarMessage(context, inputStream, ServiceImpl.class);
logger.debug("First step succeded without
error. Result: ["+services+"]");
- return new DiscoveryStepImpl(new
HashSet<AuthorativeLookupservice>(services));
+ return new DiscoveryStepImpl(new
HashSet<AuthorativeLookupService>(services));
} catch (JAXBException e) {
rootServices.demote(service,e);
continue;
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/DiscoveryStepImpl.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/DiscoveryStepImpl.java
2009-06-18 14:41:54 UTC (rev 5195)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/DiscoveryStepImpl.java
2009-06-18 14:44:57 UTC (rev 5196)
@@ -5,15 +5,15 @@
import java.util.Set;
import org.perfsonar.lsclient.DiscoveryStep;
-import org.perfsonar.lsclient.data.AuthorativeLookupservice;
+import org.perfsonar.lsclient.data.AuthorativeLookupService;
public class DiscoveryStepImpl implements DiscoveryStep {
- private final Set<AuthorativeLookupservice> services;
+ private final Set<AuthorativeLookupService> services;
private final Throwable throwable;
- public DiscoveryStepImpl(Set<AuthorativeLookupservice> services) {
- this.services = new
HashSet<AuthorativeLookupservice>(services);
+ public DiscoveryStepImpl(Set<AuthorativeLookupService> services) {
+ this.services = new
HashSet<AuthorativeLookupService>(services);
this.throwable = null;
}
@@ -26,7 +26,7 @@
return throwable;
}
- public Set<AuthorativeLookupservice> getServices() {
+ public Set<AuthorativeLookupService> getServices() {
if(hasFailed()) return null;
return Collections.unmodifiableSet(services);
}
Added:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/LSMeasuredServicesQuery.java
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-06-18 14:41:54 UTC (rev 5195)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/Level1Impl.java
2009-06-18 14:44:57 UTC (rev 5196)
@@ -2,31 +2,27 @@
import java.io.IOException;
import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URLConnection;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
+import java.util.List;
import java.util.Set;
-import java.util.SortedMap;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.TreeMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;
+import org.apache.log4j.Logger;
import org.perfsonar.lsclient.DiscoveryProcess;
import org.perfsonar.lsclient.Level0LsClientInterface;
import org.perfsonar.lsclient.Level1LsClientInterface;
import org.perfsonar.lsclient.LsQueryException;
-import org.perfsonar.lsclient.data.AuthorativeLookupservice;
+import org.perfsonar.lsclient.data.AuthorativeLookupService;
import org.perfsonar.lsclient.data.EventType;
import org.perfsonar.lsclient.data.LookupService;
+import org.perfsonar.lsclient.data.NetworkInterface;
import org.perfsonar.lsclient.data.Service;
import org.perfsonar.lsclient.data.ServiceMeasurementMetadata;
import org.perfsonar.lsclient.data.ServiceType;
@@ -34,138 +30,12 @@
import org.perfsonar.lsclient.helpers.AbstractLevel1;
import org.perfsonar.ri.lsclient.level1.jaxb.JaxbTools;
import org.perfsonar.ri.lsclient.level1.jaxb.ServiceImpl;
-import org.apache.log4j.Logger;
+import org.perfsonar.ri.lsclient.xml.ResponseParser;
+import org.xml.sax.SAXException;
public class Level1Impl extends AbstractLevel1 implements
Level1LsClientInterface {
- protected class RootGlses implements Iterable<LookupService> {
- private final ConcurrentLinkedQueue<LookupService> data = new
ConcurrentLinkedQueue<LookupService>();
- private final Object timerMutex;
- private final Object mutex;
- protected volatile Timer timer;
-
- public RootGlses() {
- this.mutex = this;
- this.timerMutex = new Object();
- }
-
- public boolean isEmpty() {
- return data.isEmpty();
- }
-
- public void replace(Collection<LookupService> values) {
- synchronized (mutex) {
- // TODO speed up by using parallel requests.
+ add cutoff
- // points.
- SortedMap<Long, LookupService> timedServices
= new TreeMap<Long, LookupService>();
- for (LookupService service : values) {
- try {
- URLConnection connection =
service.getEndPoint()
-
.toURL().openConnection();
-
connection.setConnectTimeout(2000); // We should be able
- // to be strict here
-
connection.setUseCaches(false);
- long startTime =
System.nanoTime();
- connection.connect();
-
timedServices.put(Long.valueOf(System.nanoTime()
- - startTime),
service);
- } catch (MalformedURLException e) {
- logger
- .error(
-
"Supplied service endpoint('"
-
+ service.getEndPoint()
-
+ "') is not a valid URL, this client only understands
http(s)",
-
e);
- } catch (IOException e) {
- logger.warn("Error occoured
while trying to time gls('"
- +
service.getEndPoint() + "')", e);
- logger.info("Dropping
supplied entry: "
- +
service.getEndPoint());
- }
- }
- if (timedServices.isEmpty()) {
- logger
- .error("None of the
supplied root services where accepted. falling back to old values");
- return;
- }
- data.clear();
- data.addAll(timedServices.values());
- }
- }
-
- public Iterator<LookupService> iterator() {
- return data.iterator();
- }
-
- /**
- * Demotes the service to the end of the queue and promotes
the rest.
- *
- * @param service
- * @param e
- */
- public void demote(LookupService service, Exception e) {
- synchronized (mutex) {
- logger.warn("Demoting Lookup service('" +
service.getEndPoint()
- + "')", e);
- if (!data.contains(service))
- return;
- if (data.peek() == service) {
- data.add(data.poll());
- }
- // ignore
- }
- }
-
- public void ensureFilled() {
- if (data.isEmpty())
- synchronized (mutex) {
- if (data.isEmpty()) {
- fill();
- }
- }
- }
-
- protected void fill() {
- fill(true);
- }
-
- protected void fill(boolean autorefresh) {
- replace(getDefaultLookupServices());
- if (autorefresh) {
- if (timer == null) {
- synchronized (timerMutex) {
- if (timer == null) {
- timer = new
Timer("Ls-GlsList-refresher",true);
-
timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void
run() {
-
synchronized (this) {
-
if (timer == null)
-
return;
-
replace(getDefaultLookupServices());
- }
- }
- }, 600000, 600000);
- }
- }
- }
- }
- }
-
- public void stopAutoRefresh() {
- if (timer != null) {
- synchronized (timerMutex) {
- if (timer != null) {
- logger.debug("Stopping
auto-refresh from root.hints");
- timer.cancel();
- timer = null;
- }
- }
- }
- }
- }
-
private static final String EAGER_SYSTEM_KEY =
"application.perfsonar.lsclient.eagerRootLses";
protected final Logger logger = Logger.getLogger(getClass());
@@ -220,7 +90,7 @@
* java.util.Set)
*/
public Set<ServiceMeasurementMetadata> getLSQueryContent(
- AuthorativeLookupservice hls, Set<TopologyElement>
elements,
+ AuthorativeLookupService hls, Set<TopologyElement>
elements,
Set<EventType> eventTypes, Set<ServiceType> type) {
if (logger.isDebugEnabled()) {
logger
@@ -233,13 +103,12 @@
+ " serviceType is any " + type == null ? ""
: Arrays.toString(type.toArray()));
}
- LsQuery query = new LsQuery(elements, eventTypes, type) {
+ LsTopologyQuery query = new LsTopologyQuery(elements,
eventTypes, type) {
@Override
public String toString() {
return null;
}
};
-
Collection<ServiceImpl> services;
try {
InputStream stream = level0
@@ -266,7 +135,7 @@
* .perfsonar.lsclient.data.HomeLookupService, java.util.Set,
java.util.Set,
* java.util.Set)
*/
- public Set<Service> getLSQueryLocation(AuthorativeLookupservice hls,
+ public Set<Service> getLSQueryLocation(AuthorativeLookupService hls,
Set<TopologyElement> elements, Set<EventType>
eventTypes,
Set<ServiceType> type) {
if (logger.isDebugEnabled()) {
@@ -318,9 +187,24 @@
rootGlses.replace(rootServices);
}
- public Set<LookupService> getDefaultLookupServices() {
- logger.debug("Getting default lookupservices from
root.hints");
- RootHintsFileDownloader downloader = new
RootHintsFileDownloader();
- return downloader.getGlobalLookupServices();
+ /*
+ * (non-Javadoc)
+ * @see
org.perfsonar.lsclient.Level1LsClientInterface#getLSMeasuredInterfaces(org.perfsonar.lsclient.data.LookupService,
org.perfsonar.lsclient.data.Service)
+ */
+ public List<NetworkInterface> getLSMeasuredInterfaces(LookupService
hls,
+ Service service) throws LsQueryException{
+ LSMeasuredServicesQuery query = new
LSMeasuredServicesQuery(service);
+ logger.info("Created query: \n" + query.toString());
+ InputStream stream;
+ stream = level0.getRawQueryResult(hls, query.toString());
+ try {
+ return ResponseParser.parseMeasuredInterfaces(stream);
+ } catch (ParserConfigurationException e) {
+ throw new LsQueryException(e);
+ } catch (SAXException e) {
+ throw new LsQueryException(e);
+ } catch (IOException e) {
+ throw new LsQueryException(e);
+ }
}
}
\ No newline at end of file
Added:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/LsTopologyQuery.java
Added:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/RootGlses.java
Added:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/MeasuredInterfacesHandler.java
Added:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/ResponseParser.java
- perfsonar: r5196 - in trunk/ps-mdm-lsclient-impl: . src/main/java/org/perfsonar/ri/lsclient src/main/java/org/perfsonar/ri/lsclient/data src/main/java/org/perfsonar/ri/lsclient/data/implementation src/main/java/org/perfsonar/ri/lsclient/level1 src/main/java/org/perfsonar/ri/lsclient/xml, svnlog, 06/18/2009
Archive powered by MHonArc 2.6.16.