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