|
@ -11,6 +11,7 @@ import com.amazonaws.services.s3.AmazonS3ClientBuilder; |
|
|
public class TCPTimeCounterRESTService { |
|
|
public class TCPTimeCounterRESTService { |
|
|
static final String webContextPath = "/counter"; |
|
|
static final String webContextPath = "/counter"; |
|
|
static final String bucketName = "vertsys-counter"; |
|
|
static final String bucketName = "vertsys-counter"; |
|
|
|
|
|
static final String dnsNameELB = "VertSys-ELB1-b88aad9416b2929b.elb.eu-central-1.amazonaws.com"; |
|
|
|
|
|
|
|
|
private Long getCounter() { |
|
|
private Long getCounter() { |
|
|
// Verbindung zu S3 |
|
|
// Verbindung zu S3 |
|
@ -36,7 +37,10 @@ public class TCPTimeCounterRESTService { |
|
|
@GET |
|
|
@GET |
|
|
@Produces(MediaType.TEXT_HTML) |
|
|
@Produces(MediaType.TEXT_HTML) |
|
|
public String getCounterHtml() { |
|
|
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 |
|
|
@GET |
|
@ -62,7 +66,12 @@ 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><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 |
|
|
@POST |
|
@ -72,7 +81,8 @@ 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 "{\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}"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |