- Update the "getUrls" and "getTestUrls" endpoints to take the data from the workers, in http-request-parameters instead of the http-body.
- Fix tasksLimit-check. - Code cleanup.
This commit is contained in:
parent
e2cc320baf
commit
d20fcf9cce
|
@ -6,11 +6,10 @@ buildscript {
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'org.springframework.boot' version '2.4.5'
|
id 'org.springframework.boot' version '2.4.5'
|
||||||
|
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||||
id 'java'
|
id 'java'
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'java'
|
|
||||||
apply plugin: 'io.spring.dependency-management'
|
|
||||||
|
|
||||||
group = 'eu.openaire.urls_controller'
|
group = 'eu.openaire.urls_controller'
|
||||||
version = '0.0.1-SNAPSHOT'
|
version = '0.0.1-SNAPSHOT'
|
||||||
|
|
|
@ -3,7 +3,6 @@ package eu.openaire.urls_controller.controllers;
|
||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
import eu.openaire.urls_controller.models.Assignment;
|
import eu.openaire.urls_controller.models.Assignment;
|
||||||
import eu.openaire.urls_controller.models.Task;
|
import eu.openaire.urls_controller.models.Task;
|
||||||
import eu.openaire.urls_controller.payloads.requests.WorkerRequest;
|
|
||||||
import eu.openaire.urls_controller.payloads.responces.AssignmentResponse;
|
import eu.openaire.urls_controller.payloads.responces.AssignmentResponse;
|
||||||
import eu.openaire.urls_controller.util.FileUtils;
|
import eu.openaire.urls_controller.util.FileUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -11,6 +10,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -28,10 +28,7 @@ public class UrlController {
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("")
|
@GetMapping("")
|
||||||
public ResponseEntity<?> getUrls(WorkerRequest workerRequest) {
|
public ResponseEntity<?> getUrls(@RequestParam String workerId, @RequestParam int tasksLimit) {
|
||||||
|
|
||||||
String workerId = workerRequest.getWorkerId();
|
|
||||||
int tasksLimit = workerRequest.getTasksLimit();
|
|
||||||
|
|
||||||
List<Task> tasks = new ArrayList<>();
|
List<Task> tasks = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -46,10 +43,7 @@ public class UrlController {
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("test")
|
@GetMapping("test")
|
||||||
public ResponseEntity<?> getTestUrls(WorkerRequest workerRequest) {
|
public ResponseEntity<?> getTestUrls(@RequestParam String workerId, @RequestParam int tasksLimit) {
|
||||||
|
|
||||||
String workerId = workerRequest.getWorkerId();
|
|
||||||
int tasksLimit = workerRequest.getTasksLimit();
|
|
||||||
|
|
||||||
List<Task> tasks = new ArrayList<>();
|
List<Task> tasks = new ArrayList<>();
|
||||||
new FileUtils(); // Find the input file.
|
new FileUtils(); // Find the input file.
|
||||||
|
@ -72,7 +66,7 @@ public class UrlController {
|
||||||
|
|
||||||
for ( Map.Entry<String,String> pair : pairs )
|
for ( Map.Entry<String,String> pair : pairs )
|
||||||
{
|
{
|
||||||
if ( tasks.size() > tasksLimit ) {
|
if ( tasks.size() >= tasksLimit ) {
|
||||||
tasksLimitReached = true;
|
tasksLimitReached = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
package eu.openaire.urls_controller.payloads.requests;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
|
||||||
|
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
@JsonPropertyOrder({
|
|
||||||
"workerId",
|
|
||||||
"tasksLimit"
|
|
||||||
})
|
|
||||||
public class WorkerRequest {
|
|
||||||
|
|
||||||
@JsonProperty("workerId")
|
|
||||||
private String workerId;
|
|
||||||
|
|
||||||
@JsonProperty("tasksLimit")
|
|
||||||
private int tasksLimit;
|
|
||||||
|
|
||||||
public String getWorkerId() {
|
|
||||||
return workerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWorkerId(String workerId) {
|
|
||||||
this.workerId = workerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTasksLimit() {
|
|
||||||
return tasksLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTasksLimit(int tasksLimit) {
|
|
||||||
this.tasksLimit = tasksLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "WorkerRequest{" +
|
|
||||||
"id='" + workerId + '\'' +
|
|
||||||
", tasksLimit=" + tasksLimit +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue