|
|
@ -4,7 +4,7 @@ import java.io.BufferedReader; |
|
|
|
import java.io.DataOutputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStreamReader; |
|
|
|
|
|
|
|
import java.net.InetAddress; |
|
|
|
import java.net.ServerSocket; |
|
|
|
import java.net.Socket; |
|
|
|
|
|
|
@ -48,6 +48,7 @@ class TCPTimeCounterServer { |
|
|
|
|
|
|
|
if (input != null) { |
|
|
|
number = new Long(input); |
|
|
|
|
|
|
|
// Verbindung zum Redis Cluster (Amazon ElastiCache) |
|
|
|
//JedisPool pool = new JedisPool(new JedisPoolConfig(), redisClusterURL); |
|
|
|
//Jedis jedis = pool.getResource(); |
|
|
@ -63,7 +64,6 @@ class TCPTimeCounterServer { |
|
|
|
//long counter = new Long(jedisCluster.get("vertsys-counter")); |
|
|
|
//jedisCluster.close(); |
|
|
|
//System.out.println("TTL:" + jedisCluster.ttl("vertsys-counter")); |
|
|
|
//System.out.println("Anfrage von Client " + connectionSocket.getInetAddress() + ":" + connectionSocket.getPort() + " Zahl: " + number + " Zählerstand: " + counter); |
|
|
|
|
|
|
|
//Verbindung zu S3 |
|
|
|
AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient(); |
|
|
@ -76,11 +76,13 @@ class TCPTimeCounterServer { |
|
|
|
counter = counter + number; |
|
|
|
s3Client.putObject(bucketName, region, new Long(counter).toString()); |
|
|
|
|
|
|
|
System.out.println("Anfrage von Client " + connectionSocket.getInetAddress() + ":" + connectionSocket.getPort() + " Zahl: " + number + " Zählerstand: " + counter); |
|
|
|
|
|
|
|
// Try/Catch hinzugefügt, nachdem bei Einsatz Amazon AWS (Healthcheck des ELB) clientSentence null war |
|
|
|
try { |
|
|
|
// Antwort vom Server senden |
|
|
|
String output = (Long.toString(counter) + " Zeit: " + System.currentTimeMillis() + " " |
|
|
|
+ df.format(new Date(System.currentTimeMillis()))); |
|
|
|
+ df.format(new Date(System.currentTimeMillis())) + InetAddress.getLocalHost() + " " + InetAddress.getLocalHost().getHostName()); |
|
|
|
System.out.println("Antwort des Servers: " + output); |
|
|
|
// Zeilenumbruch anfügen, da Client mit readLine auf komplette Zeile wartet |
|
|
|
outToClient.writeBytes(output + '\n'); |
|
|
|