Browse Source

initial elasticache implementation

master
Sebastian Rieger 7 years ago
parent
commit
dd9ed4ac21
  1. 47
      VerteilteSysteme-Examples/.classpath
  2. BIN
      VerteilteSysteme-Examples/build/RMIEchoServer.jar
  3. BIN
      VerteilteSysteme-Examples/build/RMIMandelbrotCalculationsServer.jar
  4. BIN
      VerteilteSysteme-Examples/build/TCPPerfServer.jar
  5. BIN
      VerteilteSysteme-Examples/build/TCPServer.jar
  6. BIN
      VerteilteSysteme-Examples/build/TCPServerMulti.jar
  7. BIN
      VerteilteSysteme-Examples/build/TCPTimeCounterServer.jar
  8. BIN
      VerteilteSysteme-Examples/build/UDPServer.jar
  9. BIN
      VerteilteSysteme-Examples/build/UDPServerMulti.jar
  10. BIN
      VerteilteSysteme-Examples/build/UDPTimeCounterServer.jar
  11. BIN
      VerteilteSysteme-Examples/lib-aws/jedis-2.9.0.jar
  12. 22
      VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterServer.java

47
VerteilteSysteme-Examples/.classpath

@ -1,23 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/grizzly-http-all-2.4.2.jar"/>
<classpathentry kind="lib" path="lib/hk2-api-2.5.0-b42.jar"/>
<classpathentry kind="lib" path="lib/hk2-locator-2.5.0-b42.jar"/>
<classpathentry kind="lib" path="lib/hk2-utils-2.5.0-b42.jar"/>
<classpathentry kind="lib" path="lib/javax.annotation-api-1.2.jar"/>
<classpathentry kind="lib" path="lib/javax.inject-2.5.0-b42.jar"/>
<classpathentry kind="lib" path="lib/javax.json.bind-api-1.0.jar"/>
<classpathentry kind="lib" path="lib/javax.ws.rs-api-2.1.jar"/>
<classpathentry kind="lib" path="lib/jersey-client.jar"/>
<classpathentry kind="lib" path="lib/jersey-common.jar"/>
<classpathentry kind="lib" path="lib/jersey-container-grizzly2-http-2.26.jar"/>
<classpathentry kind="lib" path="lib/jersey-hk2.jar"/>
<classpathentry kind="lib" path="lib/jersey-server.jar"/>
<classpathentry kind="lib" path="lib/validation-api-1.1.0.Final.jar"/>
<classpathentry kind="lib" path="lib/activemq-all-5.15.2.jar"/>
<classpathentry kind="lib" path="lib-aws/aws-java-sdk-ec2-1.11.257.jar"/>
<classpathentry kind="lib" path="lib-aws/aws-java-sdk-core-1.11.257.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/grizzly-http-all-2.4.2.jar"/>
<classpathentry kind="lib" path="lib/hk2-api-2.5.0-b42.jar"/>
<classpathentry kind="lib" path="lib/hk2-locator-2.5.0-b42.jar"/>
<classpathentry kind="lib" path="lib/hk2-utils-2.5.0-b42.jar"/>
<classpathentry kind="lib" path="lib/javax.annotation-api-1.2.jar"/>
<classpathentry kind="lib" path="lib/javax.inject-2.5.0-b42.jar"/>
<classpathentry kind="lib" path="lib/javax.json.bind-api-1.0.jar"/>
<classpathentry kind="lib" path="lib/javax.ws.rs-api-2.1.jar"/>
<classpathentry kind="lib" path="lib/jersey-client.jar"/>
<classpathentry kind="lib" path="lib/jersey-common.jar"/>
<classpathentry kind="lib" path="lib/jersey-container-grizzly2-http-2.26.jar"/>
<classpathentry kind="lib" path="lib/jersey-hk2.jar"/>
<classpathentry kind="lib" path="lib/jersey-server.jar"/>
<classpathentry kind="lib" path="lib/validation-api-1.1.0.Final.jar"/>
<classpathentry kind="lib" path="lib/activemq-all-5.15.2.jar"/>
<classpathentry kind="lib" path="lib-aws/aws-java-sdk-ec2-1.11.257.jar"/>
<classpathentry kind="lib" path="lib-aws/aws-java-sdk-core-1.11.257.jar"/>
<classpathentry kind="lib" path="lib-aws/jedis-2.9.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

BIN
VerteilteSysteme-Examples/build/RMIEchoServer.jar

BIN
VerteilteSysteme-Examples/build/RMIMandelbrotCalculationsServer.jar

BIN
VerteilteSysteme-Examples/build/TCPPerfServer.jar

BIN
VerteilteSysteme-Examples/build/TCPServer.jar

BIN
VerteilteSysteme-Examples/build/TCPServerMulti.jar

BIN
VerteilteSysteme-Examples/build/TCPTimeCounterServer.jar

BIN
VerteilteSysteme-Examples/build/UDPServer.jar

BIN
VerteilteSysteme-Examples/build/UDPServerMulti.jar

BIN
VerteilteSysteme-Examples/build/UDPTimeCounterServer.jar

BIN
VerteilteSysteme-Examples/lib-aws/jedis-2.9.0.jar

22
VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterServer.java

@ -9,14 +9,12 @@ import java.net.Socket;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import redis.clients.jedis.Jedis;
class TCPTimeCounterServer {
// Variable für Zählerstand des Servers, dieser Zähler wird durch Anfragen der
// Clients erhöht
private static long counter = 0;
public static void main(String args[]) throws Exception {
int tcpPort = 36038;
String redisClusterURL = "vertsys-ec1-0001-002.71rxr9.0001.euc1.cache.amazonaws.com";
DateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
// Socket erzeugen
@ -35,8 +33,20 @@ class TCPTimeCounterServer {
// Vom Client gesendete Zahl einlesen und auf aktuellen Zählerstand addieren
long number = new Long(new String(inFromClient.readLine()));
counter += number;
// Verbindung zum Redis Cluster (Amazon ElastiCache)
Jedis jedis = new Jedis(redisClusterURL, 6379);
System.out.println("Connected to redis server");
// check whether server is running or not
//System.out.println("redis server is running: " + jedis.ping());
//System.out.println("redis server cluster info: " + jedis.clusterInfo());
// Variable für Zählerstand des Servers, dieser Zähler wird durch Anfragen der
// Clients erhöht
jedis.incrBy("vertsys-counter", number);
long counter = new Long(jedis.get("vertsys-counter"));
jedis.close();
System.out.println("TTL:" + jedis.ttl("vertsys-counter"));
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
@ -51,7 +61,7 @@ class TCPTimeCounterServer {
ioe.printStackTrace();
} catch (NullPointerException npe) {
npe.printStackTrace();
}
}
}
}
}
Loading…
Cancel
Save