This program takes two arguments:
- --service: The service that will run, supports DNS_LOOKUP, DATE_TIME, ENCRYPTOR, CALCULATOR
- --port: The port that the service run on
Exits when either of them are invalid.
Example:
java --jar service.jar --port 8089 --service DNS_LOOKUP
Receives UDP calls and responds them with the Address of it's GenericExecutionServer.
/**
* UDP Socket listener that responds with a TCP
*/
public void run();
/**
* Formats incoming UDP Request
*
* @param message Message format
* @return Formatted UDP Request
* @throws InvalidRequestException upon receiving invalid request
*/
public UDPRequest resolveMessage(String message) throws InvalidRequestException;
/**
* Generates a TCP message that contains port number and load
* message format : "code ip:port load"
*
* @param request {@link UDPRequest}
* @return message if server type matches, null if otherwise
*/
private Optional<String> generateTCPResponse(Address address, UDPRequest request);
/**
* Responds incoming UDP request with given message
*
* @param address Address values
* @param message Response message
* @throws Exception Socket related exceptions
*/
public void respondWithTCP(Address address, String message) throws Exception;
A thread that executes given service on any request
Returns OK
followed by the response upon success,
Returns ERR
upon receiving InvalidRequestException.
public void run();
/**
* getLoad returns a random number for test purposes.
* Normally it should return how busy the service is.
*/
public int getLoad();
Executors are run in GenericExecutionServer. The executor implementations are:
/**
* @param args String : Arguments received from the TCP Request
* @return response String : Response from the class
* @throws InvalidRequestException : When invalid arguments were entered
*/
String execute(String args) throws InvalidRequestException;
/**
* @return serviceType {@link ServiceType} of the Executor implementation
*/
ServiceType getServiceType();