use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.
the class InfobloxServiceTest method testExecuteAsyncInvokeRecordHost.
@Test
public void testExecuteAsyncInvokeRecordHost() {
EventMessage eventMessage = EventMessageUtil.createEventMessage(EventType.InfoBlox, null, "10.161.71.154");
ResponseEntity<FacilitySoftwareConfig[]> infobloxFacilitySoftware = this.getInfobloxFacilitySoftware();
Mockito.doReturn(this.getInfoBloxIPInfoResults()).when(infobloxClient).queryHostRecordByIP(Mockito.anyString());
Mockito.doReturn(new ResponseEntity<>(new Asset(), HttpStatus.OK)).when(wormholeAPIClient).getAssetByName(Mockito.anyString());
Mockito.doReturn(infobloxFacilitySoftware).when(wormholeAPIClient).getFacilitySoftwareInternalByType(FacilitySoftwareConfig.SoftwareType.InfoBlox);
Mockito.doReturn(new ResponseEntity<>(new AssetIPMapping[0], HttpStatus.OK)).when(wormholeAPIClient).getHostnameIPMappingByIP(Mockito.anyString());
infoBloxService.executeAsync(eventMessage);
TestCase.assertEquals(IntegrationStatus.Status.ACTIVE, Objects.requireNonNull(infobloxFacilitySoftware.getBody())[0].getIntegrationStatus().getStatus());
}
use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.
the class InfobloxServiceTest method testExecuteAsyncInvokeIPv4.
@Test
public void testExecuteAsyncInvokeIPv4() {
EventMessage eventMessage = EventMessageUtil.createEventMessage(EventType.InfoBlox, null, "10.161.71.154");
ResponseEntity<FacilitySoftwareConfig[]> infobloxFacilitySoftware = this.getInfobloxFacilitySoftware();
Mockito.doReturn(new ArrayList<>()).when(infobloxClient).queryHostRecordByIP(Mockito.anyString());
Mockito.doReturn(this.getInfoBloxIPInfoResults()).when(infobloxClient).queryIpv4addressByIP(Mockito.anyString());
Mockito.doReturn(new ResponseEntity<>(new Asset(), HttpStatus.OK)).when(wormholeAPIClient).getAssetByName(Mockito.anyString());
Mockito.doReturn(infobloxFacilitySoftware).when(wormholeAPIClient).getFacilitySoftwareInternalByType(FacilitySoftwareConfig.SoftwareType.InfoBlox);
Mockito.doReturn(new ResponseEntity<>(new AssetIPMapping[0], HttpStatus.OK)).when(wormholeAPIClient).getHostnameIPMappingByIP(Mockito.anyString());
infoBloxService.executeAsync(eventMessage);
TestCase.assertEquals(IntegrationStatus.Status.WARNING, Objects.requireNonNull(infobloxFacilitySoftware.getBody())[0].getIntegrationStatus().getStatus());
}
use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.
the class LabsdbService method executeAsync.
@Override
public void executeAsync(EventMessage message) {
// TODO Auto-generated method stub
if (message.getType() != EventType.Labsdb) {
logger.warn("Drop none Labsdb message " + message.getType());
return;
}
logger.info("message received");
Set<EventUser> users = message.getTarget().getUsers();
for (EventUser command : users) {
logger.info(command.getId());
switch(command.getId()) {
case EventMessageUtil.Labsdb_SyncData:
// it will sync all the data depend on the type in the labsdbJobList.
String messageString = null;
while ((messageString = template.opsForList().rightPop(EventMessageUtil.labsdbJobList)) != null) {
EventMessage payloadMessage = null;
try {
payloadMessage = mapper.readValue(messageString, EventMessageImpl.class);
} catch (IOException e) {
logger.error("Cannot process message", e);
}
if (payloadMessage == null) {
continue;
}
FacilitySoftwareConfig labsdb = null;
try {
labsdb = mapper.readValue(payloadMessage.getContent(), FacilitySoftwareConfig.class);
} catch (IOException e) {
logger.error("Cannot process message", e);
}
if (null == labsdb) {
continue;
}
if (!labsdb.checkIsActive()) {
continue;
}
for (EventUser payloadCommand : payloadMessage.getTarget().getUsers()) {
excuteJob(payloadCommand.getId(), labsdb);
}
}
break;
default:
FacilitySoftwareConfig labsdb = null;
try {
labsdb = mapper.readValue(message.getContent(), FacilitySoftwareConfig.class);
} catch (IOException e1) {
// TODO Auto-generated catch block
logger.error("Failed to convert message", e1);
}
if (labsdb != null) {
excuteJob(command.getId(), labsdb);
}
break;
}
}
}
use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.
the class RedisMessageReceiver method receiveMessage.
@Override
public void receiveMessage(String message) {
try {
EventMessage eventMessage = mapper.readValue(message, EventMessageImpl.class);
asyncService.executeAsync(eventMessage);
} catch (IOException e) {
logger.info(String.format("Failed prase message %s", message));
}
}
use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.
the class JobsController method startFullMappingAggregation.
@ResponseStatus(HttpStatus.CREATED)
@RequestMapping(value = "/mergeservermapping", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
public void startFullMappingAggregation() {
try {
EventMessage eventMessage = EventMessageUtil.createEventMessage(EventType.Aggregator, EventMessageUtil.FullMappingCommand, "");
String message = EventMessageUtil.convertEventMessageAsString(eventMessage);
publisher.publish(EventMessageUtil.AggregatorTopic, message);
} catch (IOException e) {
log.error("Failed to create event message", e);
throw new WormholeRequestException("Failed to create event message");
}
}
Aggregations