Change type of ExecutorURI value to URI
This commit is contained in:
parent
06172b34cd
commit
5606de7c26
|
@ -1,23 +1,13 @@
|
|||
package ch.unisg.common.valueobject;
|
||||
|
||||
import ch.unisg.common.exception.InvalidExecutorURIException;
|
||||
import java.net.URI;
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class ExecutorURI {
|
||||
private String value;
|
||||
private URI value;
|
||||
|
||||
public ExecutorURI(String uri) throws InvalidExecutorURIException {
|
||||
String ip = uri.split(":")[0];
|
||||
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;
|
||||
public ExecutorURI(String uri) {
|
||||
this.value = URI.create(uri);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package ch.unisg.executorbase.executor.domain;
|
|||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import ch.unisg.common.exception.InvalidExecutorURIException;
|
||||
import ch.unisg.common.valueobject.ExecutorURI;
|
||||
import ch.unisg.executorbase.executor.adapter.out.web.ExecutionFinishedEventAdapter;
|
||||
import ch.unisg.executorbase.executor.adapter.out.web.GetAssignmentAdapter;
|
||||
|
@ -39,12 +38,7 @@ public abstract class ExecutorBase {
|
|||
this.status = ExecutorStatus.STARTING_UP;
|
||||
this.executorType = executorType;
|
||||
// TODO set this automaticly
|
||||
try {
|
||||
this.executorURI = new ExecutorURI("localhost:8084");
|
||||
} catch (InvalidExecutorURIException e) {
|
||||
// Shutdown system if the executorURI is not valid
|
||||
System.exit(1);
|
||||
}
|
||||
this.executorURI = new ExecutorURI("localhost:8084");
|
||||
|
||||
// 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)) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user