diff --git a/VerteilteSysteme-Examples/build/TCPTimeCounterRESTServer.jar b/VerteilteSysteme-Examples/build/TCPTimeCounterRESTServer.jar index cac647e2862306f1aaa00de42314e12d779a92f1..e383e28b313b02d67478ba596c31924fde3f6866 100644 Binary files a/VerteilteSysteme-Examples/build/TCPTimeCounterRESTServer.jar and b/VerteilteSysteme-Examples/build/TCPTimeCounterRESTServer.jar differ diff --git a/VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterRESTService.java b/VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterRESTService.java index 08bd24ba5fecfd7d7950a8c81f303aa97a162554..be853b6e479c90203ac3a1257cca036c277ae59c 100644 --- a/VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterRESTService.java +++ b/VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterRESTService.java @@ -11,14 +11,15 @@ import com.amazonaws.services.s3.AmazonS3ClientBuilder; public class TCPTimeCounterRESTService { static final String webContextPath = "/counter"; static final String bucketName = "vertsys-counter"; - + static final String dnsNameELB = "VertSys-ELB1-b88aad9416b2929b.elb.eu-central-1.amazonaws.com"; + private Long getCounter() { // Verbindung zu S3 AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient(); String region = s3Client.getRegionName(); return new Long(s3Client.getObjectAsString(bucketName, region)); } - + private boolean setCounter(Long counter) { // Verbindung zu S3 AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient(); @@ -36,7 +37,10 @@ public class TCPTimeCounterRESTService { @GET @Produces(MediaType.TEXT_HTML) public String getCounterHtml() { - return "<html><head><title>TCPTimeCounter REST Service</title><meta http-equiv=\"refresh\" content=\"5\"/></head><body><h2>HTML: " + getCounter() + "</h2></body></html>"; + return "<html><head><title>TCPTimeCounter REST Service</title>" + + "<meta http-equiv=\"refresh\" content=\"5\"/></head><body>" + + "<h2>Verteilte Systeme HS Fulda - TCPTimeCounter REST Service</h2>"+ + "<p><b>HTML-Output:</b> " + getCounter() + "</p></body></html>"; } @GET @@ -50,7 +54,7 @@ public class TCPTimeCounterRESTService { @Produces(MediaType.TEXT_PLAIN) public String incrCounterPlain(@FormParam("input") String input) { Long currentCounterValue = getCounter(); - currentCounterValue = currentCounterValue + (new Long(input)).longValue(); + currentCounterValue = currentCounterValue + (new Long(input)).longValue(); setCounter(currentCounterValue); return "Plain-Text: TCPTimeCounter counter increased by " + input + " to " + currentCounterValue; } @@ -60,9 +64,14 @@ public class TCPTimeCounterRESTService { @Produces(MediaType.TEXT_HTML) public String incrCounterHtml(@FormParam("input") String input) { Long currentCounterValue = getCounter(); - currentCounterValue = currentCounterValue + (new Long(input)).longValue(); + currentCounterValue = currentCounterValue + (new Long(input)).longValue(); setCounter(currentCounterValue); - return "<html><title>TCPTimeCounter counter increased by " + input + " to " + currentCounterValue + "</h2></body></html>"; + return "<html><head><title>TCPTimeCounter REST Service</title></head></body>" + + "<h2>Verteilte Systeme HS Fulda - TCPTimeCounter REST Service</h2>" + + "<p><b>HTML-Output:</b> counter increased by " + + input + " to " + currentCounterValue + "</p>" + + "<form method=POST action=\"http://" + dnsNameELB + ":36042/counter\">" + + "<input name=\"input\" value=\"\"></form></body></html>"; } @POST @@ -72,7 +81,8 @@ public class TCPTimeCounterRESTService { Long currentCounterValue = getCounter(); currentCounterValue = currentCounterValue + (new Long(input)).longValue(); setCounter(currentCounterValue); - return "{\n \"type\": \"JSON\",\n \"output\": \"Plain-Text: TCPTimeCounter counter increased by " + input + " to " + currentCounterValue + "\"\n}"; - } - + return "{\n \"type\": \"JSON\",\n \"output\": \"Plain-Text: TCPTimeCounter counter increased by " + input + + " to " + currentCounterValue + "\"\n}"; + } + } \ No newline at end of file