From c9fdf6af44cff860ee816c90ad12863ccdfadd70 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 8 Feb 2019 15:32:30 +0100 Subject: Support serverCount field from dnbd3 RPC --- src/main/java/org/openslx/dnbd3/status/App.java | 2 +- .../java/org/openslx/dnbd3/status/StatisticsGenerator.java | 5 ++++- .../java/org/openslx/dnbd3/status/output/ServerStats.java | 2 ++ src/main/java/org/openslx/dnbd3/status/rpc/Status.java | 12 ++++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/openslx/dnbd3/status/App.java b/src/main/java/org/openslx/dnbd3/status/App.java index 5c51e7a..1f03161 100644 --- a/src/main/java/org/openslx/dnbd3/status/App.java +++ b/src/main/java/org/openslx/dnbd3/status/App.java @@ -13,7 +13,7 @@ public class App System.exit( 1 ); } int port = Integer.parseInt( args[0] ); - String[] servers = Arrays.copyOfRange( args, 0, args.length ); + String[] servers = Arrays.copyOfRange( args, 1, args.length ); System.setProperty( "com.example.jndi.dns.timeout.initial", "400" ); System.setProperty( "com.example.jndi.dns.timeout.retries", "2" ); WebServer ws = new WebServer( port, servers ); diff --git a/src/main/java/org/openslx/dnbd3/status/StatisticsGenerator.java b/src/main/java/org/openslx/dnbd3/status/StatisticsGenerator.java index 4556378..ba0440c 100644 --- a/src/main/java/org/openslx/dnbd3/status/StatisticsGenerator.java +++ b/src/main/java/org/openslx/dnbd3/status/StatisticsGenerator.java @@ -75,6 +75,7 @@ public class StatisticsGenerator Future ret = threadPool.submit( task ); futureStatusList.add( ret ); } catch ( Exception e ) { + e.printStackTrace(); } } statusList.clear(); @@ -85,6 +86,7 @@ public class StatisticsGenerator try { status = future.get(); } catch ( Exception e ) { + System.out.println("Future timeout"); continue; } if ( status == null ) @@ -94,7 +96,8 @@ public class StatisticsGenerator srv.address = status.getAddress(); srv.bytesReceived = status.getBytesReceived(); srv.bytesSent = status.getBytesSent(); - srv.clientCount = status.getClients().size(); + srv.clientCount = status.getClientCount(); + srv.serverCount = status.getServerCount(); srv.uptime = status.getUptime(); srv.timestamp = status.getTimestamp(); output.servers.add( srv ); diff --git a/src/main/java/org/openslx/dnbd3/status/output/ServerStats.java b/src/main/java/org/openslx/dnbd3/status/output/ServerStats.java index 67dda59..97a8ea8 100644 --- a/src/main/java/org/openslx/dnbd3/status/output/ServerStats.java +++ b/src/main/java/org/openslx/dnbd3/status/output/ServerStats.java @@ -16,6 +16,8 @@ public class ServerStats implements Cloneable @Expose public int clientCount; @Expose + public int serverCount; + @Expose public long uptime; @Expose public long bytesSent; diff --git a/src/main/java/org/openslx/dnbd3/status/rpc/Status.java b/src/main/java/org/openslx/dnbd3/status/rpc/Status.java index 07fc782..22a32f6 100644 --- a/src/main/java/org/openslx/dnbd3/status/rpc/Status.java +++ b/src/main/java/org/openslx/dnbd3/status/rpc/Status.java @@ -12,6 +12,8 @@ public class Status private List clients = null; private String address = null; private long timeStamp = -1; + private int clientCount; + private int serverCount; public long getBytesReceived() { @@ -69,5 +71,15 @@ public class Status { return this.timeStamp; } + + public int getClientCount() + { + return clientCount; + } + + public int getServerCount() + { + return serverCount; + } } -- cgit v1.2.3-55-g7522