perfsonar-dev - perfsonar: r5164 - in trunk/ps-mdm-lsclient-impl: . src/main/java src/main/java/org/perfsonar/ri/lsclient src/main/java/org/perfsonar/ri/lsclient/level0 src/main/java/org/perfsonar/ri/lsclient/level1
Subject: perfsonar development work
List archive
perfsonar: r5164 - in trunk/ps-mdm-lsclient-impl: . src/main/java src/main/java/org/perfsonar/ri/lsclient src/main/java/org/perfsonar/ri/lsclient/level0 src/main/java/org/perfsonar/ri/lsclient/level1
Chronological Thread
- From:
- To:
- Subject: perfsonar: r5164 - in trunk/ps-mdm-lsclient-impl: . src/main/java src/main/java/org/perfsonar/ri/lsclient src/main/java/org/perfsonar/ri/lsclient/level0 src/main/java/org/perfsonar/ri/lsclient/level1
- Date: Mon, 1 Jun 2009 06:13:53 -0400
Author: krzjed
Date: 2009-06-01 06:13:53 -0400 (Mon, 01 Jun 2009)
New Revision: 5164
Added:
trunk/ps-mdm-lsclient-impl/src/main/java/log4j.properties
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/level0/Level0Impl.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level0/SOAPEndpoint.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/DiscoveryQuery.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/RootHintsFileDownloader.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/TopologyElements.java
Log:
Logging system changed to Log4j
Fixed bug with cutting last char of ip/domain address
Autorefresh thread set to be a deamon
Modified: trunk/ps-mdm-lsclient-impl/pom.xml
===================================================================
--- trunk/ps-mdm-lsclient-impl/pom.xml 2009-05-29 15:03:12 UTC (rev 5163)
+++ trunk/ps-mdm-lsclient-impl/pom.xml 2009-06-01 10:13:53 UTC (rev 5164)
@@ -22,6 +22,17 @@
<role></role>
</roles>
</developer>
+ <developer>
+ <id>krzjed</id>
+ <name>Krzysztof Jedrzejewski</name>
+
<email></email>
+ <organization>Poznan Supercomputing and Networing
Center</organization>
+
<organizationUrl>http://www.man.poznan.pl</organizationUrl>
+ <timezone>1</timezone>
+ <roles>
+ <role></role>
+ </roles>
+ </developer>
</developers>
<contributors>
<contributor>
@@ -32,6 +43,13 @@
<Note>Provided an initial version</Note>
</properties>
</contributor>
+ <contributor>
+ <name>Poznan Supercomputing and Networing
Center</name>
+ <url>http://www.man.poznan.pl</url>
+ <properties>
+ <Note>Further development (Geant3 SA2
T3)</Note>
+ </properties>
+ </contributor>
</contributors>
<organization>
<name>Controplex</name>
@@ -68,23 +86,16 @@
<optional>false</optional>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.5.5</version>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.8</version>
<optional>false</optional>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>1.5.5</version>
- <scope>test</scope>
- <optional>false</optional>
- </dependency>
- <dependency>
<groupId>perfsonar</groupId>
<artifactId>LS-client-api</artifactId>
<version>1.0RC2</version>
- <optional>false</optional>
+ <optional>true</optional>
</dependency>
</dependencies>
@@ -154,4 +165,4 @@
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
Added: trunk/ps-mdm-lsclient-impl/src/main/java/log4j.properties
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-05-29 15:03:12 UTC (rev 5163)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/LsClientImpl.java
2009-06-01 10:13:53 UTC (rev 5164)
@@ -8,8 +8,7 @@
import org.perfsonar.ri.lsclient.level0.Level0Impl;
import org.perfsonar.ri.lsclient.level1.Level1Impl;
import org.perfsonar.ri.lsclient.level2.Level2Impl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.log4j.Logger;
/**
@@ -20,7 +19,7 @@
*/
public class LsClientImpl extends AbstractLsClient implements LsClient {
- protected final Logger logger = LoggerFactory.getLogger(getClass());
+ protected final Logger logger = Logger.getLogger(getClass());
private final Level0LsClientInterface level0 = new Level0Impl();
private final Level1LsClientInterface level1 = new Level1Impl(level0);
@@ -39,7 +38,7 @@
} else {
logger.info("Creating LSClient.");
}
- if(logger.isTraceEnabled()) {
+ if(logger.isInfoEnabled()) {
logger.warn("Because we are tracing performance is crippled
some what as streams are buffered as a whole and used for logging. - Don't
enable tracing for the LSClient in production environment.");
}
}
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-05-29 15:03:12 UTC (rev 5163)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level0/Level0Impl.java
2009-06-01 10:13:53 UTC (rev 5164)
@@ -17,15 +17,14 @@
import org.perfsonar.lsclient.Level0LsClientInterface;
import org.perfsonar.lsclient.LsQueryException;
import org.perfsonar.lsclient.data.LookupService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.log4j.Logger;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
public class Level0Impl implements Level0LsClientInterface {
- protected final Logger logger = LoggerFactory.getLogger(getClass());
- private static final String QUERY_EVENTTYPE =
"http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/query/xquery/1.0/";
+ 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() {
@@ -119,7 +118,7 @@
.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/1.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)
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level0/SOAPEndpoint.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level0/SOAPEndpoint.java
2009-05-29 15:03:12 UTC (rev 5163)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level0/SOAPEndpoint.java
2009-06-01 10:13:53 UTC (rev 5164)
@@ -16,11 +16,11 @@
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.log4j.Logger;
+
public class SOAPEndpoint {
- protected final Logger logger = LoggerFactory.getLogger(getClass());
+ protected final Logger logger = Logger.getLogger(getClass());
private URL endPoint;
@@ -56,11 +56,11 @@
boolean success = checkResponse(httpConnection);
InputStream httpIn = (success ? httpConnection.getInputStream() :
httpConnection.getErrorStream());
- if(logger.isTraceEnabled()) {
+ if(logger.isInfoEnabled()) {
Reader reader = new InputStreamReader(httpIn);
StringBuilder builder = new StringBuilder();
int i; while((i = reader.read())!=-1) builder.append((char)i);
- logger.trace("Recieved Message ["+builder.toString()+"]");
+ logger.info("Recieved Message ["+builder.toString()+"]");
httpIn = new
ByteArrayInputStream(builder.toString().getBytes());
}
@@ -80,10 +80,10 @@
}
protected void sendMessage(SOAPMessage message, HttpURLConnection
httpConnection) throws IOException, SOAPException {
- if(logger.isTraceEnabled()) {
+ if(logger.isInfoEnabled()) {
ByteArrayOutputStream log = new
ByteArrayOutputStream();
message.writeTo(log);
- logger.trace("Sending message
["+log.toString("UTF-8")+"]");
+ logger.info("Sending message
["+log.toString("UTF-8")+"]");
}
OutputStream out = httpConnection.getOutputStream();
httpConnection.connect();
@@ -93,10 +93,10 @@
}
private boolean checkResponse(HttpURLConnection httpConnection)
throws SOAPException, IOException {
- logger.trace("cheching result code of request
(connection["+httpConnection+"])");
+ logger.info("cheching result code of request
(connection["+httpConnection+"])");
int responseCode = httpConnection.getResponseCode();
- logger.trace("Responsecode for connection["+httpConnection+"]
is "+responseCode);
+ logger.info("Responsecode for connection["+httpConnection+"]
is "+responseCode);
// let HTTP_INTERNAL_ERROR (500) through because it is used for SOAP
faults
if (responseCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
return false;
@@ -172,7 +172,7 @@
}
protected HttpURLConnection prepareConnection() throws IOException {
- logger.trace("Setting connection settings[ Method:POST
allowUserInteraction:false DoOutput:true DoInput:true UserCaches:false
Timeout:5000msec FollowRedirects:true ]");
+ logger.info("Setting connection settings[ Method:POST
allowUserInteraction:false DoOutput:true DoInput:true UserCaches:false
Timeout:5000msec FollowRedirects:true ]");
HttpURLConnection httpConnection = (HttpURLConnection)
endPoint.openConnection();
httpConnection.setRequestMethod("POST");
httpConnection.setAllowUserInteraction(false);
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-05-29 15:03:12 UTC (rev 5163)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/DiscoveryProcessImpl.java
2009-06-01 10:13:53 UTC (rev 5164)
@@ -22,12 +22,11 @@
import org.perfsonar.ri.lsclient.level1.Level1Impl.RootGlses;
import org.perfsonar.ri.lsclient.level1.jaxb.JaxbTools;
import org.perfsonar.ri.lsclient.level1.jaxb.ServiceImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.log4j.Logger;
public class DiscoveryProcessImpl implements DiscoveryProcess {
- protected final Logger logger = LoggerFactory.getLogger(getClass());
+ protected final Logger logger = Logger.getLogger(getClass());
private final Level0LsClientInterface level0;
private final RootGlses rootServices;
private final Set<TopologyElement> elements;
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/DiscoveryQuery.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/DiscoveryQuery.java
2009-05-29 15:03:12 UTC (rev 5163)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/DiscoveryQuery.java
2009-06-01 10:13:53 UTC (rev 5164)
@@ -5,12 +5,11 @@
import org.perfsonar.lsclient.data.EventType;
import org.perfsonar.lsclient.data.ServiceType;
import org.perfsonar.lsclient.data.TopologyElement;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.log4j.Logger;
public class DiscoveryQuery {
- protected final Logger logger = LoggerFactory.getLogger(getClass());
+ protected final Logger logger = Logger.getLogger(getClass());
private final String summeryDesciption;
public DiscoveryQuery(Set<TopologyElement> elements, Set<EventType>
eventTypes, Set<ServiceType> type) {
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-05-29 15:03:12 UTC (rev 5163)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/Level1Impl.java
2009-06-01 10:13:53 UTC (rev 5164)
@@ -34,47 +34,59 @@
import org.perfsonar.lsclient.helpers.AbstractLevel1;
import org.perfsonar.ri.lsclient.level1.jaxb.JaxbTools;
import org.perfsonar.ri.lsclient.level1.jaxb.ServiceImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.log4j.Logger;
-public class Level1Impl extends AbstractLevel1 implements
Level1LsClientInterface {
+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.
+ // TODO speed up by using parallel requests.
+ add cutoff
+ // points.
SortedMap<Long, LookupService> timedServices
= new TreeMap<Long, LookupService>();
- for(LookupService service : values) {
+ for (LookupService service : values) {
try {
- URLConnection connection =
service.getEndPoint().toURL().openConnection();
-
connection.setConnectTimeout(2000); // We should be able to be strict here
+ 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);
+
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);
+ 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());
+ 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");
+ if (timedServices.isEmpty()) {
+ logger
+ .error("None of the
supplied root services where accepted. falling back to old values");
return;
}
data.clear();
@@ -88,167 +100,224 @@
/**
* 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) {
+ logger.warn("Demoting Lookup service('" +
service.getEndPoint()
+ + "')", e);
+ if (!data.contains(service))
+ return;
+ if (data.peek() == service) {
data.add(data.poll());
}
- //ignore
+ // ignore
}
}
public void ensureFilled() {
- if(data.isEmpty()) synchronized (mutex) {
- if(data.isEmpty()) {
- fill();
+ if (data.isEmpty())
+ synchronized (mutex) {
+ if (data.isEmpty()) {
+ fill();
+ }
}
- }
}
protected void fill() {
+ fill(true);
+ }
+
+ protected void fill(boolean autorefresh) {
replace(getDefaultLookupServices());
- if(timer==null) synchronized(timerMutex) {
- if(timer==null) {
- timer = new
Timer("Ls-GlsList-refresher");
- timer.scheduleAtFixedRate(new
TimerTask() {
- @Override
- public void run() {
- synchronized (this) {
-
if(timer==null) return;
-
replace(getDefaultLookupServices());
- }
- }
- }, 600000, 600000);
+ 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;
+ 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 = LoggerFactory.getLogger(getClass());
+
+ protected final Logger logger = Logger.getLogger(getClass());
protected final RootGlses rootGlses = new RootGlses();
protected final JAXBContext context;
-
+
@SuppressWarnings("boxing")
public Level1Impl(Level0LsClientInterface level0) {
super(level0);
JAXBContext newContext = null;
try {
- newContext = JAXBContext.newInstance(
-
"org.perfsonar.ri.lsclient.level1.jaxb"
- );
+ newContext = JAXBContext
+
.newInstance("org.perfsonar.ri.lsclient.level1.jaxb");
} catch (JAXBException e) {
- logger.error("Can't load JAXB context",e);
+ logger.error("Can't load JAXB context", e);
}
try {
String value = System.getProperty(EAGER_SYSTEM_KEY);
- if(Boolean.valueOf(value)) {
+ if (Boolean.valueOf(value)) {
rootGlses.ensureFilled();
}
} catch (SecurityException e) {
- logger.warn("Wasn't allowed to read system property
\"application.perfsonar.lsclient.eagerRootLses\"");
+ logger
+ .warn("Wasn't allowed to read system
property \"application.perfsonar.lsclient.eagerRootLses\"");
}
-
+
this.context = newContext;
}
- /**
- * Note: Getting the root's file must be lazy, because the root hint
file might not be avail when the application starts
- * (Internet availability might not be avail when the application
starts re-attempt till we actually get some glses)
- * @see
org.perfsonar.lsclient.Level1LsClientInterface#startDiscovery(java.util.Set,
java.util.Set, java.util.Set)
+ /**
+ * Note: Getting the root's file must be lazy, because the root hint
file
+ * might not be avail when the application starts (Internet
availability
+ * might not be avail when the application starts re-attempt till we
+ * actually get some glses)
+ *
+ * @see
org.perfsonar.lsclient.Level1LsClientInterface#startDiscovery(java.util.Set,
+ * java.util.Set, java.util.Set)
*/
- public DiscoveryProcess startDiscovery(Set<TopologyElement> elements,
Set<EventType> eventTypes, Set<ServiceType> types) {
+ public DiscoveryProcess startDiscovery(Set<TopologyElement> elements,
+ Set<EventType> eventTypes, Set<ServiceType> types) {
rootGlses.ensureFilled();
- return new DiscoveryProcessImpl(level0, context, rootGlses,
elements, eventTypes, types);
+ return new DiscoveryProcessImpl(level0, context, rootGlses,
elements,
+ eventTypes, types);
}
-
- /* (non-Javadoc)
- * @see
org.perfsonar.lsclient.Level1LsClientInterface#getLSQueryContent(org.perfsonar.lsclient.data.HomeLookupService,
java.util.Set, java.util.Set, java.util.Set)
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ *
org.perfsonar.lsclient.Level1LsClientInterface#getLSQueryContent(org.
+ * perfsonar.lsclient.data.HomeLookupService, java.util.Set,
java.util.Set,
+ * java.util.Set)
*/
- public Set<ServiceMeasurementMetadata>
getLSQueryContent(AuthorativeLookupservice hls, Set<TopologyElement>
elements, Set<EventType> eventTypes, Set<ServiceType> type) {
- if(logger.isDebugEnabled()) {
- logger.debug(
- "quering LS for service content from
"+ hls.getEndPoint() +
- " where"+
- " topologyElements is any "+ elements
== null ? "" : Arrays.toString(elements.toArray())+
- " eventypes is any "+ eventTypes ==
null ? "" : Arrays.toString(eventTypes.toArray())+
- " serviceType is any "+ type == null
? "" : Arrays.toString(type.toArray())
- );
+ public Set<ServiceMeasurementMetadata> getLSQueryContent(
+ AuthorativeLookupservice hls, Set<TopologyElement>
elements,
+ Set<EventType> eventTypes, Set<ServiceType> type) {
+ if (logger.isDebugEnabled()) {
+ logger
+ .debug("quering LS for service
content from "
+ + hls.getEndPoint() +
" where"
+ + " topologyElements
is any " + elements == null ? ""
+ :
Arrays.toString(elements.toArray())
+ + "
eventypes is any " + eventTypes == null ? ""
+ :
Arrays.toString(eventTypes.toArray())
+
+ " serviceType is any " + type == null ? ""
+
: Arrays.toString(type.toArray()));
}
- LsQuery query = new LsQuery(elements,eventTypes,type) {
+ LsQuery query = new LsQuery(elements, eventTypes, type) {
@Override
public String toString() {
return null;
}
};
-
+
Collection<ServiceImpl> services;
try {
- InputStream stream =
level0.getRawQueryResult(hls,query.toString());
- services =
JaxbTools.unMarshallPerfsonarMessage(context, stream, ServiceImpl.class);
- for(ServiceImpl service : services)
service.setAuthorativeLookupservice(hls);
+ InputStream stream = level0
+ .getRawQueryResult(hls,
query.toString());
+ services =
JaxbTools.unMarshallPerfsonarMessage(context, stream,
+ ServiceImpl.class);
+ for (ServiceImpl service : services)
+ service.setAuthorativeLookupservice(hls);
return null;
} catch (JAXBException e) {
- return null; //TODO
+ return null; // TODO
} catch (XMLStreamException e) {
- return null; //TODO
+ return null; // TODO
} catch (LsQueryException e) {
- return null; //TODO
- }
+ return null; // TODO
+ }
}
- /* (non-Javadoc)
- * @see
org.perfsonar.lsclient.Level1LsClientInterface#getLSQueryLocation(org.perfsonar.lsclient.data.HomeLookupService,
java.util.Set, java.util.Set, java.util.Set)
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ *
org.perfsonar.lsclient.Level1LsClientInterface#getLSQueryLocation(org
+ * .perfsonar.lsclient.data.HomeLookupService, java.util.Set,
java.util.Set,
+ * java.util.Set)
*/
- public Set<Service> getLSQueryLocation(AuthorativeLookupservice hls,
Set<TopologyElement> elements, Set<EventType> eventTypes, Set<ServiceType>
type) {
- if(logger.isDebugEnabled()) {
- logger.debug(
- "quering LS for service locations
from "+ hls.getEndPoint() +
- " where"+
- " topologyElements is any "+
(elements == null ? "" : Arrays.toString(elements.toArray()))+
- " eventypes is any "+ (eventTypes ==
null ? "" : Arrays.toString(eventTypes.toArray()))+
- " serviceType is any "+ (type == null
? "" : Arrays.toString(type.toArray()))
- );
+ public Set<Service> getLSQueryLocation(AuthorativeLookupservice hls,
+ Set<TopologyElement> elements, Set<EventType>
eventTypes,
+ Set<ServiceType> type) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("quering LS for service locations from "
+ + hls.getEndPoint()
+ + " where"
+ + " topologyElements is any "
+ + (elements == null ? "" :
Arrays.toString(elements
+ .toArray()))
+ + " eventypes is any "
+ + (eventTypes == null ? "" :
Arrays.toString(eventTypes
+ .toArray())) + "
serviceType is any "
+ + (type == null ? "" :
Arrays.toString(type.toArray())));
}
- DiscoveryQuery query = new
DiscoveryQuery(elements,eventTypes,type);
+ DiscoveryQuery query = new DiscoveryQuery(elements,
eventTypes, type);
try {
- InputStream stream =
level0.getRawDiscoveryResponse(hls,query.toString());
- Collection<ServiceImpl> result =
JaxbTools.unMarshallPerfsonarMessage(context, stream, ServiceImpl.class);
- for(ServiceImpl service : result)
service.setAuthorativeLookupservice(hls);
+ InputStream stream =
level0.getRawDiscoveryResponse(hls, query
+ .toString());
+ Collection<ServiceImpl> result = JaxbTools
+ .unMarshallPerfsonarMessage(context,
stream,
+ ServiceImpl.class);
+ for (ServiceImpl service : result)
+ service.setAuthorativeLookupservice(hls);
return new HashSet<Service>(result);
} catch (JAXBException e) {
- logger.error("JAXB exception occoured while quering
for location", e);
- return Collections.emptySet(); //TODO
+ logger.error("JAXB exception occoured while quering
for location",
+ e);
+ return Collections.emptySet(); // TODO
} catch (XMLStreamException e) {
- logger.error("XMLStream exception occoured while
quering for location", e);
- return Collections.emptySet(); //TODO
+ logger.error(
+ "XMLStream exception occoured while
quering for location",
+ e);
+ return Collections.emptySet(); // TODO
} catch (LsQueryException e) {
- logger.error("LsQuery exception occoured while
quering for location", e);
- return Collections.emptySet(); //TODO
+ logger.error(
+ "LsQuery exception occoured while
quering for location", e);
+ return Collections.emptySet(); // TODO
}
}
public void setKnownLookupServices(Set<LookupService> rootServices) {
- if(rootServices==null) throw new
IllegalArgumentException("new rootServices set cannot be null");
- if(rootServices.isEmpty()) throw new
IllegalArgumentException("new rootServices set cannot be empty");
+ if (rootServices == null)
+ throw new IllegalArgumentException(
+ "new rootServices set cannot be
null");
+ if (rootServices.isEmpty())
+ throw new IllegalArgumentException(
+ "new rootServices set cannot be
empty");
rootGlses.stopAutoRefresh();
rootGlses.replace(rootServices);
}
+
public Set<LookupService> getDefaultLookupServices() {
logger.debug("Getting default lookupservices from
root.hints");
RootHintsFileDownloader downloader = new
RootHintsFileDownloader();
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/RootHintsFileDownloader.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/RootHintsFileDownloader.java
2009-05-29 15:03:12 UTC (rev 5163)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/RootHintsFileDownloader.java
2009-06-01 10:13:53 UTC (rev 5164)
@@ -15,74 +15,86 @@
import org.perfsonar.lsclient.data.LookupService;
import org.perfsonar.ri.lsclient.level1.jaxb.ServiceImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.log4j.Logger;
public class RootHintsFileDownloader {
- protected final Logger logger = LoggerFactory.getLogger(getClass());
- protected final String rootHints;
-
+ protected final Logger logger = Logger.getLogger(getClass());
+ protected final String rootHints;
+
public RootHintsFileDownloader() {
String systemProperty;
-
+
try {
- systemProperty =
System.getProperty("application.perfsonar.lsclient.rootHints");
- if(systemProperty == null ||
systemProperty.equals("")) {
- logger.debug("System property
\"application.perfsonar.lsclient.rootHints\" was undefined or empty");
+ systemProperty = System
+
.getProperty("application.perfsonar.lsclient.rootHints");
+ if (systemProperty == null ||
systemProperty.equals("")) {
+ logger
+ .debug("System property
\"application.perfsonar.lsclient.rootHints\" was undefined or empty");
systemProperty =
"http://www.perfsonar.net/gls.root.hints";
}
} catch (SecurityException e) {
- logger.warn("Wasn't allowed to read
\"application.perfsonar.lsclient.rootHints\" falling back to
default(http://www.perfsonar.net/gls.root.hint)");
+ logger
+ .warn("Wasn't allowed to read
\"application.perfsonar.lsclient.rootHints\" falling back to
default(http://www.perfsonar.net/gls.root.hint)");
systemProperty =
"http://www.perfsonar.net/gls.root.hints";
- }
+ }
rootHints = systemProperty;
- logger.trace("Root hints url = '"+rootHints+"'");
+ logger.info("Root hints url = '" + rootHints + "'");
}
-
+
public Set<LookupService> getGlobalLookupServices() {
- logger.trace("Starting retrieval of GLS-es from root.hints");
+ logger.info("Starting retrieval of GLS-es from root.hints");
try {
return readFrom(getRootHintUrl().openConnection());
} catch (IOException e) {
logger.error("Can't retrieve gls-es from root.hints",
e);
- return Collections.emptySet(); //TODO
+ return Collections.emptySet(); // TODO
}
}
- protected Set<LookupService> readFrom(URLConnection hintFile) throws
UnsupportedEncodingException, IOException {
+ protected Set<LookupService> readFrom(URLConnection hintFile)
+ throws UnsupportedEncodingException, IOException {
BufferedReader reader = null;
String encoding = getEncodingOf(hintFile);
- logger.trace("Encoding of root.hints determined as beeing
"+encoding);
+ logger.info("Encoding of root.hints determined as beeing " +
encoding);
try {
- reader = new BufferedReader(new
InputStreamReader(hintFile.getInputStream(), encoding));
+ reader = new BufferedReader(new
InputStreamReader(hintFile
+ .getInputStream(), encoding));
return parse(reader);
} finally {
if (reader != null) {
- try { reader.close(); } catch (IOException e)
{
+ try {
+ reader.close();
+ } catch (IOException e) {
logger.warn("Exception occoured while
closing reader", e);
}
}
}
-
+
}
- protected Set<LookupService> parse(BufferedReader reader) throws
IOException {
- Set<LookupService> lses = new HashSet<LookupService>();
+ protected Set<LookupService> parse(BufferedReader reader)
+ throws IOException {
+ Set<LookupService> lses = new HashSet<LookupService>();
for (String line; (line = reader.readLine()) != null;) {
- logger.trace("Read line of root.hints: '"+line+"'");
+ logger.info("Read line of root.hints: '" + line +
"'");
try {
URL glsUrl = new URL(line);
lses.add(new ServiceImpl(glsUrl.toURI()));
} catch (MalformedURLException e) {
- logger.warn("Dropping malformed
url("+line+")", e);
+ logger.warn("Dropping malformed url(" + line
+ ")", e);
} catch (URISyntaxException e) {
- logger.error("Unasserted exception occoured !
this is a bug ! (URL should always be a valid URI, since one is a subset of
the other)", e);
- throw new AssertionError("Help: A valid URL
should always be a valid URI.");
+ logger
+ .error(
+ "Unasserted
exception occoured ! this is a bug ! (URL should always be a valid URI, since
one is a subset of the other)",
+ e);
+ throw new AssertionError(
+ "Help: A valid URL should
always be a valid URI.");
}
}
- if(logger.isDebugEnabled()) {
- logger.debug("Parsing yielded the following results:
" + Arrays.toString(lses.toArray()));
+ if (logger.isDebugEnabled()) {
+ logger.debug("Parsing yielded the following results: "
+ + Arrays.toString(lses.toArray()));
}
return lses;
}
@@ -91,8 +103,10 @@
try {
return new URL(rootHints);
} catch (MalformedURLException e) {
- logger.error("Programmer specified an malformed
URL("+rootHints+") ! this is a bug !", e);
- throw new AssertionError("Programmer specified an
malformed URL("+rootHints+"), this is a bug.");
+ logger.error("Programmer specified an malformed URL("
+ rootHints
+ + ") ! this is a bug !", e);
+ throw new AssertionError("Programmer specified an
malformed URL("
+ + rootHints + "), this is a bug.");
}
}
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/TopologyElements.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/TopologyElements.java
2009-05-29 15:03:12 UTC (rev 5163)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/TopologyElements.java
2009-06-01 10:13:53 UTC (rev 5164)
@@ -54,7 +54,7 @@
String mostSignificantBit = lastEllement(keyValuePairs);
int index = mostSignificantBit.lastIndexOf("=");
String key = mostSignificantBit.substring(0, index);
- String value = mostSignificantBit.substring(index+1,
mostSignificantBit.length()-1);
+ String value = mostSignificantBit.substring(index+1,
mostSignificantBit.length());
return getXmlFor(key,value);
}
- perfsonar: r5164 - in trunk/ps-mdm-lsclient-impl: . src/main/java src/main/java/org/perfsonar/ri/lsclient src/main/java/org/perfsonar/ri/lsclient/level0 src/main/java/org/perfsonar/ri/lsclient/level1, svnlog, 06/01/2009
Archive powered by MHonArc 2.6.16.