Dev #65
|
@ -1,23 +1,13 @@
|
||||||
package ch.unisg.common.valueobject;
|
package ch.unisg.common.valueobject;
|
||||||
|
|
||||||
import ch.unisg.common.exception.InvalidExecutorURIException;
|
import java.net.URI;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
@Value
|
@Value
|
||||||
public class ExecutorURI {
|
public class ExecutorURI {
|
||||||
private String value;
|
private URI value;
|
||||||
|
|
||||||
public ExecutorURI(String uri) throws InvalidExecutorURIException {
|
public ExecutorURI(String uri) {
|
||||||
String ip = uri.split(":")[0];
|
this.value = URI.create(uri);
|
||||||
int port = Integer.parseInt(uri.split(":")[1]);
|
|
||||||
// Check if valid ip4
|
|
||||||
if (!ip.equalsIgnoreCase("localhost") &&
|
|
||||||
!uri.matches("^((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)(\\.(?!$)|$)){4}$")) {
|
|
||||||
throw new InvalidExecutorURIException();
|
|
||||||
// Check if valid port
|
|
||||||
} else if (port < 1024 || port > 65535) {
|
|
||||||
throw new InvalidExecutorURIException();
|
|
||||||
}
|
|
||||||
this.value = uri;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package ch.unisg.executorbase.executor.domain;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import ch.unisg.common.exception.InvalidExecutorURIException;
|
|
||||||
import ch.unisg.common.valueobject.ExecutorURI;
|
import ch.unisg.common.valueobject.ExecutorURI;
|
||||||
import ch.unisg.executorbase.executor.adapter.out.web.ExecutionFinishedEventAdapter;
|
import ch.unisg.executorbase.executor.adapter.out.web.ExecutionFinishedEventAdapter;
|
||||||
import ch.unisg.executorbase.executor.adapter.out.web.GetAssignmentAdapter;
|
import ch.unisg.executorbase.executor.adapter.out.web.GetAssignmentAdapter;
|
||||||
|
@ -39,12 +38,7 @@ public abstract class ExecutorBase {
|
||||||
this.status = ExecutorStatus.STARTING_UP;
|
this.status = ExecutorStatus.STARTING_UP;
|
||||||
this.executorType = executorType;
|
this.executorType = executorType;
|
||||||
// TODO set this automaticly
|
// TODO set this automaticly
|
||||||
try {
|
this.executorURI = new ExecutorURI("localhost:8084");
|
||||||
this.executorURI = new ExecutorURI("localhost:8084");
|
|
||||||
} catch (InvalidExecutorURIException e) {
|
|
||||||
// Shutdown system if the executorURI is not valid
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify executor-pool about existence. If executor-pools response is successfull start with getting an assignment, else shut down executor.
|
// Notify executor-pool about existence. If executor-pools response is successfull start with getting an assignment, else shut down executor.
|
||||||
if(!notifyExecutorPoolService.notifyExecutorPool(this.executorURI, this.executorType)) {
|
if(!notifyExecutorPoolService.notifyExecutorPool(this.executorURI, this.executorType)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user