Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r5360 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: level1 utils

Subject: perfsonar development work

List archive

perfsonar: r5360 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: level1 utils


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r5360 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: level1 utils
  • Date: Mon, 30 Nov 2009 07:59:54 -0500

Author: krzjed
Date: 2009-11-30 07:59:54 -0500 (Mon, 30 Nov 2009)
New Revision: 5360

Added:

trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/utils/ResultCollector.java

trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/utils/SortedResultCollector.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/RootGlses.java
Log:
gLS' timed in parallel

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-11-30 11:00:27 UTC (rev 5359)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/DiscoveryProcessImpl.java
2009-11-30 12:59:54 UTC (rev 5360)
@@ -95,14 +95,12 @@
}
};
threads.add(t);
+ t.setDaemon(true);
t.start();
}
try {
ServiceCollectionHandler sch = new ServiceCollectionHandler();
ResponseParser.parseDiscoveryResponse(sc.getValue(), sch);
- for (Thread t : threads) {
- t.destroy();
- }
Set<ServiceImpl> services = sch.getMetadataSet();
logger.debug("First step succeded without error. Result: [" +
services + "]");
return new DiscoveryStepImpl(new
HashSet<AuthorativeLookupservice>(services));

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-11-30 11:00:27 UTC (rev 5359)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/RootGlses.java
2009-11-30 12:59:54 UTC (rev 5360)
@@ -6,14 +6,13 @@
import java.util.Collection;
import java.util.Iterator;
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 org.apache.log4j.Logger;
import org.perfsonar.lsclient.data.LookupService;
+import org.perfsonar.ri.lsclient.utils.SortedResultCollector;

public class RootGlses implements Iterable<LookupService> {
private final ConcurrentLinkedQueue<LookupService> data = new
ConcurrentLinkedQueue<LookupService>();
@@ -21,6 +20,7 @@
private final Object mutex;
protected volatile Timer timer;
protected final Logger logger = Logger.getLogger(getClass());
+ private static final int TIMEOUT = 2000;

public RootGlses() {
this.mutex = this;
@@ -35,30 +35,72 @@
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());
- }
+ // SortedMap<Long, LookupService> timedServices = new
TreeMap<Long,
+ // LookupService>();
+ // for (LookupService service : values) {
+ // try {
+ // URLConnection connection =
+ // service.getEndPoint().toURL().openConnection();
+ // connection.setConnectTimeout(TIMEOUT); // 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());
+
+ final SortedResultCollector<Long, LookupService> collector = new
SortedResultCollector<Long, LookupService>();
+ for (final LookupService service : values) {
+ collector.signalMoreElements();
+ Thread t = new Thread() {
+ public void run() {
+ try {
+ URLConnection connection =
service.getEndPoint().toURL().openConnection();
+ connection.setConnectTimeout(TIMEOUT); // We
should
+ // be
+ // able
+ // to be strict here
+ connection.setUseCaches(false);
+ long startTime = System.nanoTime();
+ connection.connect();
+ collector.addPair(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);
+ collector.signalLackOfElement();
+ } catch (IOException e) {
+ logger.warn("Error occoured while trying to time
gls('" + service.getEndPoint() + "')", e);
+ logger.info("Dropping supplied entry: " +
service.getEndPoint());
+ collector.signalLackOfElement();
+ }
+ }
+ };
+ t.start();
}
- if (timedServices.isEmpty()) {
+ if (collector.isEmpty()) {
logger.error("None of the supplied root services where
accepted. falling back to old values");
return;
}
+
data.clear();
- data.addAll(timedServices.values());
+ data.addAll(collector.getValues());
}
}


Added:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/utils/ResultCollector.java

Added:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/utils/SortedResultCollector.java



  • perfsonar: r5360 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: level1 utils, svnlog, 11/30/2009

Archive powered by MHonArc 2.6.16.

Top of Page