@ -26,18 +26,25 @@ public class UrlController {
private static final Logger logger = LoggerFactory . getLogger ( UrlController . class ) ;
private static AtomicLong assignmentCounter = new AtomicLong ( ) ; // Just for the "getTestUrls"-endpoint.
private static AtomicLong assignmentCounter = new AtomicLong ( 0 ) ; // Just for the "getTestUrls"-endpoint.
}
@GetMapping ( "" )
public ResponseEntity < ? > getUrls ( @RequestParam String workerId , @RequestParam int worker Task sLimit) {
public ResponseEntity < ? > getUrls ( @RequestParam String workerId , @RequestParam int worker Assignment sLimit) {
List < Task > tasks = new ArrayList < > ( ) ;
// TODO - Create the Assignment from the id-urls stored in the database up to the tasks-limit.
Date date = new Date ( ) ; // Store it here, in order to have the same date for all current assignments.
// TODO - Make sure the Date is the same for all entries!
Date date = new Date ( ) ; // Store it here, in order to have the same for sure.
int assignmentsLimit = ControllerConstants . ASSIGNMENTS_LIMIT ;
if ( assignmentsLimit > workerAssignmentsLimit )
assignmentsLimit = workerAssignmentsLimit ;
int tasksLimitForAssignment = ControllerConstants . ASSIGNMENTS_LIMIT ;
@ -50,9 +57,9 @@ public class UrlController {
// TODO - Write the Assignment details to the database and then send it to the worker.
logger . info ( "Sending assignment_" + assignmentCounter . g et( ) + " to worker with ID: " + workerId ) ;
logger . info ( "Sending assignment_" + assignmentCounter . incrementAndG et( ) + " to worker with ID: " + workerId ) ;
return ResponseEntity . status ( 200 ) . header ( "Content-Type" , "application/json" ) . body ( new AssignmentResponse ( assignmentCounter . incrementAndG et( ) , assignments ) ) ;
return ResponseEntity . status ( 200 ) . header ( "Content-Type" , "application/json" ) . body ( new AssignmentResponse ( assignmentCounter . g et( ) , assignments ) ) ;
}
@PostMapping ( "addWorkerReport" )
@ -70,7 +77,7 @@ public class UrlController {
@GetMapping ( "test" )
public ResponseEntity < ? > getTestUrls ( @RequestParam String workerId , @RequestParam int a ssignmentsLimit) {
public ResponseEntity < ? > getTestUrls ( @RequestParam String workerId , @RequestParam int workerA ssignmentsLimit) {
try {
new FileUtils ( ) ; // Find the input file.
@ -98,7 +105,7 @@ public class UrlController {
for ( Map . Entry < String , String > pair : pairs )
{
if ( assignments . size ( ) > = a ssignmentsLimit ) {
if ( assignments . size ( ) > = workerA ssignmentsLimit ) {
assignmentsLimitReached = true ;
break ;
}
@ -108,7 +115,7 @@ public class UrlController {
} // end pairs-for-loop
if ( assignmentsLimitReached ) {
logger . debug ( "Done loading urls from the inputFile as the assignmentsLimit (" + a ssignmentsLimit + ") was reached." ) ;
logger . debug ( "Done loading urls from the inputFile as the assignmentsLimit (" + workerA ssignmentsLimit + ") was reached." ) ;
break ;
}
} // end loading-while-loop
@ -116,9 +123,9 @@ public class UrlController {
if ( FileUtils . inputScanner . get ( ) ! = null ) // Check if the initial value is null.
FileUtils . inputScanner . get ( ) . close ( ) ;
logger . info ( "Sending AssignmentResponse_" + assignmentCounter . g et( ) + " with " + assignments . size ( ) + " assignments (" + FileUtils . duplicateIdUrlEntries . get ( ) + " more assignments were discarded as duplicates), to worker with ID: " + workerId ) ;
logger . info ( "Sending AssignmentResponse_" + assignmentCounter . incrementAndG et( ) + " with " + assignments . size ( ) + " assignments (" + FileUtils . duplicateIdUrlEntries . get ( ) + " more assignments were discarded as duplicates), to worker with ID: " + workerId ) ;
return ResponseEntity . status ( 200 ) . header ( "Content-Type" , "application/json" ) . body ( new AssignmentResponse ( assignmentCounter . incrementAndG et( ) , assignments ) ) ;
return ResponseEntity . status ( 200 ) . header ( "Content-Type" , "application/json" ) . body ( new AssignmentResponse ( assignmentCounter . g et( ) , assignments ) ) ;
}
}