Code Review
/
nonrtric.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Use Lombok to add builder to EiJob
[nonrtric.git]
/
enrichment-coordinator-service
/
src
/
main
/
java
/
org
/
oransc
/
enrichment
/
controllers
/
producer
/
ProducerController.java
diff --git
a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java
b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java
index
d67b8ed
..
e517b3a
100644
(file)
--- a/
enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java
+++ b/
enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java
@@
-33,10
+33,9
@@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Collection;
import java.util.List;
-import org.oransc.enrichment.clients.ProducerCallbacks;
-import org.oransc.enrichment.clients.ProducerJobInfo;
import org.oransc.enrichment.controllers.ErrorResponse;
import org.oransc.enrichment.controllers.VoidResponse;
import org.oransc.enrichment.controllers.ErrorResponse;
import org.oransc.enrichment.controllers.VoidResponse;
+import org.oransc.enrichment.controllers.consumer.ConsumerCallbacks;
import org.oransc.enrichment.controllers.producer.ProducerRegistrationInfo.ProducerEiTypeRegistrationInfo;
import org.oransc.enrichment.repository.EiJob;
import org.oransc.enrichment.repository.EiJobs;
import org.oransc.enrichment.controllers.producer.ProducerRegistrationInfo.ProducerEiTypeRegistrationInfo;
import org.oransc.enrichment.repository.EiJob;
import org.oransc.enrichment.repository.EiJobs;
@@
-64,9
+63,7
@@
public class ProducerController {
private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private static Gson gson = new GsonBuilder() //
- .serializeNulls() //
- .create(); //
+ private static Gson gson = new GsonBuilder().create();
@Autowired
private EiJobs eiJobs;
@Autowired
private EiJobs eiJobs;
@@
-80,6
+77,9
@@
public class ProducerController {
@Autowired
ProducerCallbacks producerCallbacks;
@Autowired
ProducerCallbacks producerCallbacks;
+ @Autowired
+ ConsumerCallbacks consumerCallbacks;
+
@GetMapping(path = ProducerConsts.API_ROOT + "/eitypes", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "EI type identifiers", notes = "")
@ApiResponses(
@GetMapping(path = ProducerConsts.API_ROOT + "/eitypes", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "EI type identifiers", notes = "")
@ApiResponses(
@@
-101,7
+101,7
@@
public class ProducerController {
}
@GetMapping(path = ProducerConsts.API_ROOT + "/eitypes/{eiTypeId}", produces = MediaType.APPLICATION_JSON_VALUE)
}
@GetMapping(path = ProducerConsts.API_ROOT + "/eitypes/{eiTypeId}", produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(value = "Individual EI
T
ype", notes = "")
+ @ApiOperation(value = "Individual EI
t
ype", notes = "")
@ApiResponses(
value = { //
@ApiResponse(code = 200, message = "EI type", response = ProducerEiTypeInfo.class), //
@ApiResponses(
value = { //
@ApiResponse(code = 200, message = "EI type", response = ProducerEiTypeInfo.class), //
@@
-146,7
+146,7
@@
public class ProducerController {
@ApiOperation(value = "Individual EI producer", notes = "")
@ApiResponses(
value = { //
@ApiOperation(value = "Individual EI producer", notes = "")
@ApiResponses(
value = { //
- @ApiResponse(code = 200, message = "EI
J
obs", response = ProducerRegistrationInfo.class), //
+ @ApiResponse(code = 200, message = "EI
j
obs", response = ProducerRegistrationInfo.class), //
@ApiResponse(
code = 404,
message = "Enrichment Information producer is not found",
@ApiResponse(
code = 404,
message = "Enrichment Information producer is not found",
@@
-239,10
+239,12
@@
public class ProducerController {
}
}
}
}
- registerProducer(eiProducerId, registrationInfo);
+
EiProducer producer =
registerProducer(eiProducerId, registrationInfo);
if (previousDefinition != null) {
purgeTypes(previousDefinition.getEiTypes());
if (previousDefinition != null) {
purgeTypes(previousDefinition.getEiTypes());
+ this.consumerCallbacks.notifyConsumersProducerDeleted(previousDefinition);
}
}
+ this.consumerCallbacks.notifyConsumersProducerAdded(producer);
return new ResponseEntity<>(previousDefinition == null ? HttpStatus.CREATED : HttpStatus.OK);
} catch (Exception e) {
return new ResponseEntity<>(previousDefinition == null ? HttpStatus.CREATED : HttpStatus.OK);
} catch (Exception e) {
@@
-253,7
+255,7
@@
public class ProducerController {
private void purgeTypes(Collection<EiType> types) {
for (EiType type : types) {
if (type.getProducerIds().isEmpty()) {
private void purgeTypes(Collection<EiType> types) {
for (EiType type : types) {
if (type.getProducerIds().isEmpty()) {
- this.eiTypes.
deregisterType(type, this.eiJobs
);
+ this.eiTypes.
remove(type
);
}
}
}
}
}
}
@@
-271,6
+273,7
@@
public class ProducerController {
try {
final EiProducer producer = this.eiProducers.getProducer(eiProducerId);
this.eiProducers.deregisterProducer(producer, this.eiTypes, this.eiJobs);
try {
final EiProducer producer = this.eiProducers.getProducer(eiProducerId);
this.eiProducers.deregisterProducer(producer, this.eiTypes, this.eiJobs);
+ this.consumerCallbacks.notifyConsumersProducerDeleted(producer);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} catch (Exception e) {
return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} catch (Exception e) {
return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
@@
-282,30
+285,28
@@
public class ProducerController {
if (type == null) {
type = new EiType(typeInfo.eiTypeId, typeInfo.jobDataSchema);
this.eiTypes.put(type);
if (type == null) {
type = new EiType(typeInfo.eiTypeId, typeInfo.jobDataSchema);
this.eiTypes.put(type);
+ this.consumerCallbacks.notifyConsumersTypeAdded(type);
}
return type;
}
EiProducer createProducer(Collection<EiType> types, String producerId, ProducerRegistrationInfo registrationInfo) {
}
return type;
}
EiProducer createProducer(Collection<EiType> types, String producerId, ProducerRegistrationInfo registrationInfo) {
- return new EiProducer(producerId, types, registrationInfo.jobC
reationC
allbackUrl,
- registrationInfo.
jobDeletionCallbackUrl, registrationInfo.
producerSupervisionCallbackUrl);
+ return new EiProducer(producerId, types, registrationInfo.jobCallbackUrl,
+ registrationInfo.producerSupervisionCallbackUrl);
}
private EiProducer registerProducer(String producerId, ProducerRegistrationInfo registrationInfo) {
}
private EiProducer registerProducer(String producerId, ProducerRegistrationInfo registrationInfo) {
- ArrayList<EiType> types = new ArrayList<>();
+ ArrayList<EiType> typesForProducer = new ArrayList<>();
+ EiProducer producer = createProducer(typesForProducer, producerId, registrationInfo);
for (ProducerEiTypeRegistrationInfo typeInfo : registrationInfo.types) {
for (ProducerEiTypeRegistrationInfo typeInfo : registrationInfo.types) {
- types.add(registerType(typeInfo));
+ EiType type = registerType(typeInfo);
+ typesForProducer.add(type);
+ type.addProducer(producer); //
}
}
- EiProducer producer = createProducer(types, producerId, registrationInfo);
this.eiProducers.put(producer);
this.eiProducers.put(producer);
- for (EiType type : types) {
- for (EiJob job : this.eiJobs.getJobsForType(type)) {
- this.producerCallbacks.notifyProducerJobStarted(producer, job) //
- .subscribe();
- }
- type.addProducer(producer);
- }
+ producerCallbacks.restartJobs(producer, this.eiJobs);
+
return producer;
}
return producer;
}
@@
-314,8
+315,7
@@
public class ProducerController {
for (EiType type : p.getEiTypes()) {
types.add(toEiTypeRegistrationInfo(type));
}
for (EiType type : p.getEiTypes()) {
types.add(toEiTypeRegistrationInfo(type));
}
- return new ProducerRegistrationInfo(types, p.getJobCreationCallbackUrl(), p.getJobDeletionCallbackUrl(),
- p.getProducerSupervisionCallbackUrl());
+ return new ProducerRegistrationInfo(types, p.getJobCallbackUrl(), p.getProducerSupervisionCallbackUrl());
}
private ProducerEiTypeRegistrationInfo toEiTypeRegistrationInfo(EiType type) {
}
private ProducerEiTypeRegistrationInfo toEiTypeRegistrationInfo(EiType type) {