Browse Source

merged

master
Sebastian Rieger 7 years ago
parent
commit
3981fbf4a8
  1. 23
      VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterRESTService.java

23
VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterRESTService.java

@ -14,9 +14,6 @@ public class TCPTimeCounterRESTService {
static final String bucketName = "vertsys-counter"; static final String bucketName = "vertsys-counter";
static final String bucketRegion = "eu-central-1"; static final String bucketRegion = "eu-central-1";
static final String dnsNameELB = "cloudcomp-loadbalancer-1492513132.eu-central-1.elb.amazonaws.com";
static final int portELBTarget = 36042;
private Long getCounter() { private Long getCounter() {
// Verbindung zu S3 // Verbindung zu S3
AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient(); AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient();
@ -41,8 +38,11 @@ public class TCPTimeCounterRESTService {
public String getCounterHtml() { public String getCounterHtml() {
return "<html><head><title>TCPTimeCounter REST Service</title>" + return "<html><head><title>TCPTimeCounter REST Service</title>" +
"<meta http-equiv=\"refresh\" content=\"5\"/></head><body>" + "<meta http-equiv=\"refresh\" content=\"5\"/></head><body>" +
"<h2>Cloud Computing HS Fulda - TCPTimeCounter REST Service</h2>"+
"<p><b>HTML-Output:</b> " + getCounter() + "</p></body></html>";
"<h2>HS Fulda - TCPTimeCounter REST Service</h2>"+
"<p><b>HTML-Output:</b> " + getCounter() + "</p></body>"+
"<form method=POST action=\"/counter\">" +
"<input type=\"hidden\" name=\"input\" value=\"1\">"+
"<input type=\"submit\" value=\"Increment\"></form></body></html>";
} }
@GET @GET
@ -68,12 +68,13 @@ public class TCPTimeCounterRESTService {
Long currentCounterValue = getCounter(); Long currentCounterValue = getCounter();
currentCounterValue = currentCounterValue + (new Long(input)).longValue(); currentCounterValue = currentCounterValue + (new Long(input)).longValue();
setCounter(currentCounterValue); setCounter(currentCounterValue);
return "<html><head><title>TCPTimeCounter REST Service</title></head></body>" +
"<h2>Cloud Computing HS Fulda - TCPTimeCounter REST Service</h2>" +
"<p><b>HTML-Output:</b> counter increased by " +
input + " to " + currentCounterValue + "</p>" +
"<form method=POST action=\"http://" + dnsNameELB + ":" + portELBTarget + webContextPath +"\">" +
"<input name=\"input\" value=\"\"></form></body></html>";
return "<html><head><title>TCPTimeCounter REST Service</title>" +
"<meta http-equiv=\"refresh\" content=\"5\"/></head><body>" +
"<h2>HS Fulda - TCPTimeCounter REST Service</h2>"+
"<p><b>HTML-Output:</b> " + getCounter() + "</p></body>"+
"<form method=POST action=\"/counter\">" +
"<input type=\"hidden\" name=\"input\" value=\"1\">"+
"<input type=\"submit\" value=\"Increment\"></form></body></html>";
} }
@POST @POST

Loading…
Cancel
Save