Merging dev to main #107

Merged
Maece97 merged 52 commits from dev into main 2021-12-23 16:12:19 +00:00
17 changed files with 66 additions and 42 deletions
Showing only changes of commit 56788d7150 - Show all commits

View File

@ -67,8 +67,9 @@ services:
- ./:/data/ - ./:/data/
environment: environment:
mqtt.broker.uri: tcp://broker.hivemq.com:1883 mqtt.broker.uri: tcp://broker.hivemq.com:1883
discovery.endpoint.uri: https://tapas-auction-house.86.119.35.213.nip.io/discovery/ discovery.endpoint.uri: https://tapas-auction-house.86-119-34-242.nip.io
auction.house.uri: https://tapas-auction-house.86-119-35-40.nip.io auction.house.uri: https://tapas-auction-house.86-119-35-40.nip.io
tasks.list.uri: https://tapas-tasks.86-119-35-40.nip.io
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.tapas-auction-house.rule=Host(`tapas-auction-house.${PUB_IP}.nip.io`)" - "traefik.http.routers.tapas-auction-house.rule=Host(`tapas-auction-house.${PUB_IP}.nip.io`)"

View File

@ -107,5 +107,6 @@ jobs:
cd /home/${{ secrets.SSH_USER }}/ cd /home/${{ secrets.SSH_USER }}/
touch acme.json touch acme.json
sudo chmod 0600 acme.json sudo chmod 0600 acme.json
sudo docker-compose down --remove-orphans
sudo echo "PUB_IP=$(wget -qO- http://ipecho.net/plain | xargs echo)" | sed -e 's/\./-/g' > .env sudo echo "PUB_IP=$(wget -qO- http://ipecho.net/plain | xargs echo)" | sed -e 's/\./-/g' > .env
sudo docker-compose up -d --build --force-recreate sudo docker-compose up -d

View File

@ -67,6 +67,17 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId> <artifactId>spring-boot-test</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js</artifactId>
<version>21.3.0</version>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js-scriptengine</artifactId>
<version>21.3.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -11,7 +11,7 @@
</parent> </parent>
<groupId>ch.unisg</groupId> <groupId>ch.unisg</groupId>
<artifactId>executor-humidity</artifactId> <artifactId>executor-humidity</artifactId>
<version>1.0-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<name>executor-humidity</name> <name>executor-humidity</name>
<description>Demo project for Spring Boot</description> <description>Demo project for Spring Boot</description>
<properties> <properties>

View File

@ -21,7 +21,8 @@ public class Executor extends ExecutorBase {
@Override @Override
protected protected
String execution(String input) { String execution(String input) {
return userToRobotPort.userToRobot(); userToRobotPort.userToRobot();
return "";
} }
} }

View File

@ -51,9 +51,11 @@ public class TapasAuctionHouseApplication {
WebSubSubscriber subscriber = new WebSubSubscriber(ENVIRONMENT.getProperty("auction.house.uri")); WebSubSubscriber subscriber = new WebSubSubscriber(ENVIRONMENT.getProperty("auction.house.uri"));
for (AuctionHouseDiscoveryInformation endpoint : AuctionHouseDiscovery.getInstance().getAuctionHouseDiscoveryList()) { for (AuctionHouseDiscoveryInformation endpoint : AuctionHouseDiscovery.getInstance().getAuctionHouseDiscoveryList()) {
System.out.println(endpoint.getWebSubUri().getValue()); // Don't subscribe to our own auction house
if (!endpoint.getWebSubUri().getValue().toString().equalsIgnoreCase("https://tapas-auction-house.86-119-35-40.nip.io/websub/auctions")) {
subscriber.subscribeToAuctionHouseEndpoint(endpoint.getWebSubUri().getValue()); subscriber.subscribeToAuctionHouseEndpoint(endpoint.getWebSubUri().getValue());
} }
}
// try { // try {
// subscriber.subscribeToAuctionHouseEndpoint(new URI("http://6b4e-130-82-250-227.ngrok.io/websub-discovery")); // subscriber.subscribeToAuctionHouseEndpoint(new URI("http://6b4e-130-82-250-227.ngrok.io/websub-discovery"));
// } catch (URISyntaxException e) { // } catch (URISyntaxException e) {

View File

@ -101,6 +101,9 @@ public class WebSubSubscriber {
return; return;
} }
System.out.println("HUB: " + hub);
System.out.println("TOPIC: " + topic);
HttpRequest request = HttpRequest.newBuilder() HttpRequest request = HttpRequest.newBuilder()
.uri(hubURI) .uri(hubURI)
.header("Content-Type", "application/x-www-form-urlencoded") .header("Content-Type", "application/x-www-form-urlencoded")

View File

@ -22,11 +22,9 @@ import java.net.http.HttpResponse;
public class ExternalAuctionStartedEventListenerMqttAdapter extends AuctionEventMqttListener{ public class ExternalAuctionStartedEventListenerMqttAdapter extends AuctionEventMqttListener{
private static final Logger LOGGER = LogManager.getLogger(ExternalAuctionStartedEventListenerMqttAdapter.class); private static final Logger LOGGER = LogManager.getLogger(ExternalAuctionStartedEventListenerMqttAdapter.class);
// String auctionHouseURI = "https://tapas-auction-house.86-119-35-40.nip.io/"; String auctionHouseURI = "https://tapas-auction-house.86-119-35-40.nip.io/";
String auctionHouseURI = "http://a888-77-59-152-182.eu.ngrok.io";
// String taskListURI = "https://tapas-tasks.86-119-35-40.nip.io"; String taskListURI = "https://tapas-tasks.86-119-35-40.nip.io";
String taskListURI = "http://e021-77-59-152-182.ngrok.io";
@Override @Override
public boolean handleEvent(MqttMessage message){ public boolean handleEvent(MqttMessage message){

View File

@ -69,11 +69,9 @@ public class AuctionStartedEventListenerWebSubAdapter {
// } // }
// String auctionHouseURI = "https://tapas-auction-house.86-119-35-40.nip.io/"; String auctionHouseURI = "https://tapas-auction-house.86-119-35-40.nip.io/";
String auctionHouseURI = "http://b311-130-82-247-153.eu.ngrok.io";
// String taskListURI = "https://tapas-tasks.86-119-35-40.nip.io"; String taskListURI = "https://tapas-tasks.86-119-35-40.nip.io";
String taskListURI = "http://c64f-130-82-247-153.ngrok.io";
// TODO Sanitize URIs // TODO Sanitize URIs
String auctionId = auction.getString("auctionId"); String auctionId = auction.getString("auctionId");

View File

@ -30,7 +30,7 @@ public class AuctionHouseDiscoveryWebController {
this.auctionHouseDiscoveryUseCase = auctionHouseDiscoveryUseCase; this.auctionHouseDiscoveryUseCase = auctionHouseDiscoveryUseCase;
} }
@GetMapping(path="/discovery/", consumes = AuctionHouseDiscoveryJsonRepresentation.MEDIA_TYPE) @GetMapping(path="/discovery/")
public ResponseEntity<String> auctionHouseDiscovery() { public ResponseEntity<String> auctionHouseDiscovery() {
List<AuctionHouseDiscoveryInformation> auctionHouseDiscoveryInformation = auctionHouseDiscoveryUseCase.auctionHouseDiscovery(); List<AuctionHouseDiscoveryInformation> auctionHouseDiscoveryInformation = auctionHouseDiscoveryUseCase.auctionHouseDiscovery();

View File

@ -27,9 +27,11 @@ public class WinningBidWebController {
@PostMapping(path = "/taskwinner", consumes = TaskJsonRepresentation.MEDIA_TYPE) @PostMapping(path = "/taskwinner", consumes = TaskJsonRepresentation.MEDIA_TYPE)
public ResponseEntity<String> winningBid(@RequestBody TaskJsonRepresentation payload){ public ResponseEntity<String> winningBid(@RequestBody TaskJsonRepresentation payload){
LOGGER.info("New Task Winner");
try { try {
var body = payload.serialize(); var body = payload.serialize();
LOGGER.info(body); LOGGER.info("Task Winner body: " + body);
LOGGER.info("Task Winner taskListURI: " + taskListURI);
var postURI = URI.create(taskListURI + "/tasks/"); var postURI = URI.create(taskListURI + "/tasks/");
HttpRequest postRequest = HttpRequest.newBuilder() HttpRequest postRequest = HttpRequest.newBuilder()
.uri(postURI) .uri(postURI)
@ -40,7 +42,7 @@ public class WinningBidWebController {
HttpClient client = HttpClient.newHttpClient(); HttpClient client = HttpClient.newHttpClient();
var postResponse = client.send(postRequest, HttpResponse.BodyHandlers.ofString()); var postResponse = client.send(postRequest, HttpResponse.BodyHandlers.ofString());
LOGGER.info(postResponse.statusCode()); LOGGER.info("Create task internally with status code: " + postResponse.statusCode());
HttpHeaders responseHeaders = new HttpHeaders(); HttpHeaders responseHeaders = new HttpHeaders();

View File

@ -32,6 +32,7 @@ public class PublishAuctionStartedEventWebSubAdapter implements AuctionStartedEv
@Override @Override
public void publishAuctionStartedEvent(AuctionStartedEvent event) { public void publishAuctionStartedEvent(AuctionStartedEvent event) {
logger.info("AuctionHouse | Publish auction started over WebSub!"); logger.info("AuctionHouse | Publish auction started over WebSub!");
logger.info("AuctionHouse | AuctionHouseURI: " + auctionHouseUri + " WebSubHubUri: " + webSubHubUri);
HttpClient client = HttpClient.newHttpClient(); HttpClient client = HttpClient.newHttpClient();

View File

@ -6,6 +6,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.springframework.http.HttpStatus;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
@ -22,16 +23,16 @@ public class AuctionHouseDiscoveryHttpAdapter implements AuctionHouseDiscoveryPo
public List<AuctionHouseDiscoveryInformation> fetchAuctionHouseInformation(URI auctionHouseURI){ public List<AuctionHouseDiscoveryInformation> fetchAuctionHouseInformation(URI auctionHouseURI){
System.out.println(auctionHouseURI);
try{ try{
var client = HttpClient.newHttpClient(); var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder() var request = HttpRequest.newBuilder()
.uri(auctionHouseURI) .uri(auctionHouseURI)
.GET() .GET()
.build(); .build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString()); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
LOGGER.info(response.body()); LOGGER.info("Response status code: " + response.statusCode());
LOGGER.info("Response body:" + response.body());
if (response.statusCode() == HttpStatus.OK.value()) {
var responseBody = new JSONObject(response.body()); var responseBody = new JSONObject(response.body());
var arrayOfInformation = responseBody.getJSONArray("auctionHouseInfo"); var arrayOfInformation = responseBody.getJSONArray("auctionHouseInfo");
@ -51,7 +52,8 @@ public class AuctionHouseDiscoveryHttpAdapter implements AuctionHouseDiscoveryPo
} }
return returnList; return returnList;
}
return Collections.<AuctionHouseDiscoveryInformation>emptyList();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
return Collections.<AuctionHouseDiscoveryInformation>emptyList(); return Collections.<AuctionHouseDiscoveryInformation>emptyList();

View File

@ -52,13 +52,18 @@ public class AuctionWonEventHttpAdapter implements AuctionWonEventPort {
LOGGER.info(response.body()); LOGGER.info(response.body());
JSONObject responseBody = new JSONObject(response.body()); JSONObject responseBody = new JSONObject(response.body());
String inputData = "";
if (!responseBody.isNull("inputData")) {
inputData = responseBody.getString("inputData");
}
var task = new Task( var task = new Task(
new Task.TaskName(responseBody.getString("taskName")), new Task.TaskName(responseBody.getString("taskName")),
new Task.TaskType(responseBody.getString("taskType")), new Task.TaskType(responseBody.getString("taskType")),
new Task.OriginalTaskUri(auction.get().getTaskUri().getValue().toString()), new Task.OriginalTaskUri(auction.get().getTaskUri().getValue().toString()),
new Task.TaskStatus(ch.unisg.tapas.auctionhouse.domain.Task.Status.ASSIGNED), new Task.TaskStatus(ch.unisg.tapas.auctionhouse.domain.Task.Status.ASSIGNED),
new Task.TaskId(responseBody.getString("taskId")), new Task.TaskId(responseBody.getString("taskId")),
new Task.InputData(responseBody.getString("inputData")), new Task.InputData(inputData),
new Task.ServiceProvider("TODO") new Task.ServiceProvider("TODO")
); );

View File

@ -7,7 +7,6 @@ websub.hub.publish=https://websub.appspot.com/
group=tapas-group-1 group=tapas-group-1
auction.house.uri=https://tapas-auction-house.86-119-35-40.nip.io auction.house.uri=https://tapas-auction-house.86-119-35-40.nip.io
# auction.house.uri=http://a888-77-59-152-182.eu.ngrok.io
tasks.list.uri=http://localhost:8081 tasks.list.uri=http://localhost:8081
application.environment=development application.environment=development

View File

@ -43,7 +43,7 @@ public class ExternalTaskExecutedWebAdapter implements ExternalTaskExecutedEvent
op2 = new JSONObject() op2 = new JSONObject()
.put("op", "add") .put("op", "add")
.put("path", "/outputData") .put("path", "/outputData")
.put("value", externalTaskExecutedEvent.getOutputData()); .put("value", externalTaskExecutedEvent.getOutputData().getValue());
} catch (JSONException e) { } catch (JSONException e) {
logger.log(Level.SEVERE, e.getLocalizedMessage(), e); logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
return; return;

View File

@ -2,7 +2,7 @@ server.port=8081
spring.data.mongodb.uri=mongodb://root:password@localhost:27017/ spring.data.mongodb.uri=mongodb://root:password@localhost:27017/
spring.data.mongodb.database=tapas-tasks spring.data.mongodb.database=tapas-tasks
# baseuri=http://e021-77-59-152-182.ngrok.io/ # baseuri=http://e021-77-59-152-182.ngrok.io/
baseuri=https://tapas-tasks.86-119-34-23.nip.io/ baseuri=https://tapas-tasks.86-119-35-40.nip.io/
roster.uri=http://127.0.0.1:8082 roster.uri=http://127.0.0.1:8082