|
@ -35,10 +35,19 @@ class TCPTimeCounterServer { |
|
|
// Anfrage vom Client empfangen |
|
|
// Anfrage vom Client empfangen |
|
|
BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); |
|
|
BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); |
|
|
DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream()); |
|
|
DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream()); |
|
|
|
|
|
String input = null; |
|
|
|
|
|
|
|
|
// Vom Client gesendete Zahl einlesen und auf aktuellen Zählerstand addieren |
|
|
// Vom Client gesendete Zahl einlesen und auf aktuellen Zählerstand addieren |
|
|
long number = new Long(new String(inFromClient.readLine())); |
|
|
|
|
|
|
|
|
long number; |
|
|
|
|
|
try { |
|
|
|
|
|
input = inFromClient.readLine(); |
|
|
|
|
|
} catch (IOException ie) { |
|
|
|
|
|
// TODO Auto-generated catch block |
|
|
|
|
|
ie.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (input != null) { |
|
|
|
|
|
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(); |
|
@ -67,7 +76,6 @@ class TCPTimeCounterServer { |
|
|
counter = counter + number; |
|
|
counter = counter + number; |
|
|
s3Client.putObject(bucketName, region, new Long(counter).toString()); |
|
|
s3Client.putObject(bucketName, region, new Long(counter).toString()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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 |
|
@ -78,9 +86,11 @@ class TCPTimeCounterServer { |
|
|
outToClient.writeBytes(output + '\n'); |
|
|
outToClient.writeBytes(output + '\n'); |
|
|
} catch (IOException ioe) { |
|
|
} catch (IOException ioe) { |
|
|
ioe.printStackTrace(); |
|
|
ioe.printStackTrace(); |
|
|
} catch (NullPointerException npe) { |
|
|
|
|
|
npe.printStackTrace(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
connectionSocket.close(); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |