diff options
author | Simon Rettberg | 2016-06-13 15:21:58 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-06-13 15:21:58 +0200 |
commit | b33d152301c4c334a51899e5c4d6b2a0cfd2f014 (patch) | |
tree | 46bfb8eacb6ca03f7cf2a2f47f838a7f5bde273a | |
parent | Clustering in graph (diff) | |
download | dnbd3-status-b33d152301c4c334a51899e5c4d6b2a0cfd2f014.tar.gz dnbd3-status-b33d152301c4c334a51899e5c4d6b2a0cfd2f014.tar.xz dnbd3-status-b33d152301c4c334a51899e5c4d6b2a0cfd2f014.zip |
Addresses changed (should be configurable...)
6 files changed, 19 insertions, 12 deletions
diff --git a/src/main/java/org/openslx/dnbd3/status/App.java b/src/main/java/org/openslx/dnbd3/status/App.java index 9f7ef5f..65ff524 100644 --- a/src/main/java/org/openslx/dnbd3/status/App.java +++ b/src/main/java/org/openslx/dnbd3/status/App.java @@ -7,6 +7,8 @@ public class App public static void main( String[] args ) throws IOException { + System.setProperty( "com.example.jndi.dns.timeout.initial", "400" ); + System.setProperty( "com.example.jndi.dns.timeout.retries", "2" ); WebServer ws = new WebServer( 8888 ); ws.run(); } diff --git a/src/main/java/org/openslx/dnbd3/status/StatisticsGenerator.java b/src/main/java/org/openslx/dnbd3/status/StatisticsGenerator.java index 1f3c25a..fb94275 100644 --- a/src/main/java/org/openslx/dnbd3/status/StatisticsGenerator.java +++ b/src/main/java/org/openslx/dnbd3/status/StatisticsGenerator.java @@ -2,10 +2,10 @@ package org.openslx.dnbd3.status; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; +import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; @@ -28,7 +28,7 @@ public class StatisticsGenerator { private final List<ServerPoller> pollers; private volatile long lastUpdate = 0; - private ExecutorService threadPool = new ThreadPoolExecutor( 1, 6, 1, TimeUnit.MINUTES, new ArrayBlockingQueue<Runnable>( 100 ) ); + private ExecutorService threadPool = new ThreadPoolExecutor( 3, 8, 1, TimeUnit.MINUTES, new SynchronousQueue<Runnable>() ); private List<Future<Status>> futureStatusList = new ArrayList<>(); private List<Status> statusList = new ArrayList<>(); private final Gson jsonBuilder; @@ -59,14 +59,18 @@ public class StatisticsGenerator { futureStatusList.clear(); for ( final ServerPoller p : pollers ) { - Future<Status> ret = threadPool.submit( new Callable<Status>() { + Callable<Status> task = new Callable<Status>() { @Override public Status call() throws Exception { return p.update(); } - } ); - futureStatusList.add( ret ); + }; + try { + Future<Status> ret = threadPool.submit( task ); + futureStatusList.add( ret ); + } catch ( Exception e ) { + } } statusList.clear(); output.servers.clear(); @@ -136,7 +140,7 @@ public class StatisticsGenerator public String getJson() { ensureUpToDate(); - synchronized ( graph ) { + synchronized ( output ) { return jsonBuilder.toJson( output ); } } diff --git a/src/main/java/org/openslx/dnbd3/status/WebServer.java b/src/main/java/org/openslx/dnbd3/status/WebServer.java index 70978c1..3e1a65c 100644 --- a/src/main/java/org/openslx/dnbd3/status/WebServer.java +++ b/src/main/java/org/openslx/dnbd3/status/WebServer.java @@ -25,8 +25,8 @@ public class WebServer extends NanoHTTPD pollers.add( new ServerPoller( "132.230.4.2", 5003 ) ); pollers.add( new ServerPoller( "132.230.8.113", 5003 ) ); pollers.add( new ServerPoller( "132.230.4.60", 5003 ) ); - pollers.add( new ServerPoller( "10.16.0.1", 5003 ) ); - pollers.add( new ServerPoller( "10.16.0.2", 5003 ) ); + pollers.add( new ServerPoller( "10.4.128.240", 5003 ) ); + pollers.add( new ServerPoller( "10.3.56.43", 5003 ) ); imageGenerator = new StatisticsGenerator( pollers ); } diff --git a/src/main/java/org/openslx/dnbd3/status/poller/ServerPoller.java b/src/main/java/org/openslx/dnbd3/status/poller/ServerPoller.java index bfa70fb..446ab2a 100644 --- a/src/main/java/org/openslx/dnbd3/status/poller/ServerPoller.java +++ b/src/main/java/org/openslx/dnbd3/status/poller/ServerPoller.java @@ -35,7 +35,7 @@ public class ServerPoller con.setRequestMethod( "GET" ); con.setConnectTimeout( 1000 ); - con.setReadTimeout( 3000 ); + con.setReadTimeout( 2000 ); if ( con.getResponseCode() != HttpURLConnection.HTTP_OK ) { return null; diff --git a/src/main/java/org/openslx/graph/Edge.java b/src/main/java/org/openslx/graph/Edge.java index 9d03aeb..c896651 100644 --- a/src/main/java/org/openslx/graph/Edge.java +++ b/src/main/java/org/openslx/graph/Edge.java @@ -51,6 +51,7 @@ public class Edge implements java.io.Serializable _health--;
}
_age++;
+ _weight = 0;
}
public boolean isAlive()
@@ -58,9 +59,9 @@ public class Edge implements java.io.Serializable return _health > 0;
}
- public void setWeight( double weight )
+ public void addWeight( double weight )
{
- _weight = weight;
+ _weight += weight;
_health = _maxHealth;
}
diff --git a/src/main/java/org/openslx/graph/Graph.java b/src/main/java/org/openslx/graph/Graph.java index 65110f6..7f7ca64 100644 --- a/src/main/java/org/openslx/graph/Graph.java +++ b/src/main/java/org/openslx/graph/Graph.java @@ -99,7 +99,7 @@ public class Graph implements java.io.Serializable _edges.put( edge, edge );
}
// Set the edge weight.
- edge.setWeight( weight );
+ edge.addWeight( weight );
}
// Remove a Node from the Graph, along with all of its emanating Edges.
|