|
|
@ -35,10 +35,19 @@ class TCPTimeCounterServer { |
|
|
|
// Anfrage vom Client empfangen |
|
|
|
BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); |
|
|
|
DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream()); |
|
|
|
String input = null; |
|
|
|
|
|
|
|
// 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) |
|
|
|
//JedisPool pool = new JedisPool(new JedisPoolConfig(), redisClusterURL); |
|
|
|
//Jedis jedis = pool.getResource(); |
|
|
@ -67,7 +76,6 @@ class TCPTimeCounterServer { |
|
|
|
counter = counter + number; |
|
|
|
s3Client.putObject(bucketName, region, new Long(counter).toString()); |
|
|
|
|
|
|
|
|
|
|
|
// Try/Catch hinzugefügt, nachdem bei Einsatz Amazon AWS (Healthcheck des ELB) clientSentence null war |
|
|
|
try { |
|
|
|
// Antwort vom Server senden |
|
|
@ -78,9 +86,11 @@ class TCPTimeCounterServer { |
|
|
|
outToClient.writeBytes(output + '\n'); |
|
|
|
} catch (IOException ioe) { |
|
|
|
ioe.printStackTrace(); |
|
|
|
} catch (NullPointerException npe) { |
|
|
|
npe.printStackTrace(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
connectionSocket.close(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |