use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.
the class VCDataService method executeAsync.
@Override
@Async("asyncServiceExecutor")
public void executeAsync(EventMessage message) {
// update the value.
if (message.getType() != EventType.VCenter) {
logger.warn("Drop none vcenter message " + message.getType());
return;
}
// TO, this should be comment out since it may contain vc password.
logger.info("message received");
Set<EventUser> users = message.getTarget().getUsers();
for (EventUser command : users) {
logger.info(command.getId());
switch(command.getId()) {
case EventMessageUtil.VCENTER_SyncData:
// it will sync all the data depend on the type in the vcjoblist.
String messageString = null;
while ((messageString = template.opsForList().rightPop(EventMessageUtil.vcJobList)) != null) {
EventMessage payloadMessage = null;
try {
payloadMessage = mapper.readValue(messageString, EventMessageImpl.class);
} catch (IOException ioException) {
logger.error("Cannot process message", ioException);
}
if (payloadMessage == null) {
continue;
}
SDDCSoftwareConfig vcInfo = null;
try {
vcInfo = mapper.readValue(payloadMessage.getContent(), SDDCSoftwareConfig.class);
} catch (IOException ioException) {
logger.error("Cannot process message", ioException);
}
if (null == vcInfo) {
continue;
}
for (EventUser payloadCommand : payloadMessage.getTarget().getUsers()) {
switch(payloadCommand.getId()) {
case EventMessageUtil.VCENTER_SyncCustomerAttrs:
syncCustomAttributes(vcInfo);
logger.info("Finish sync customer attributes for " + vcInfo.getName());
break;
case EventMessageUtil.VCENTER_SyncCustomerAttrsData:
syncCustomerAttrsData(vcInfo);
logger.info("Finish sync data for " + vcInfo.getName());
break;
case EventMessageUtil.VCENTER_QueryHostMetaData:
queryHostMetaData(vcInfo);
logger.info("Finish query host metadata for " + vcInfo.getName());
break;
case EventMessageUtil.VCENTER_QueryHostUsageData:
queryHostMetrics(vcInfo);
logger.info("Finish query host usage for " + vcInfo.getName());
break;
default:
break;
}
}
}
break;
case EventMessageUtil.VCENTER_SyncCustomerAttrs:
logger.warn("VCENTER_SyncCustomerAttrs command is depreacted. use VCENTER_SyncData instead");
break;
case EventMessageUtil.VCENTER_SyncCustomerAttrsData:
logger.warn("VCENTER_SyncCustomerAttrsData command is depreacted. use VCENTER_SyncData instead");
break;
default:
logger.warn("Not supported command");
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 VROAsyncJob method executeAsync.
@Override
@Async("asyncServiceExecutor")
public void executeAsync(EventMessage message) {
if (message.getType() != EventType.VROps) {
logger.warn("Drop none VROps message " + message.getType());
return;
}
// TO, this should be comment out since it may contain vc password.
logger.info("message received");
Set<EventUser> users = message.getTarget().getUsers();
for (EventUser command : users) {
logger.info(command.getId());
switch(command.getId()) {
case EventMessageUtil.VRO_SyncData:
String messageString = null;
while ((messageString = template.opsForList().rightPop(EventMessageUtil.vroJobList)) != null) {
EventMessage payloadMessage = null;
try {
payloadMessage = mapper.readValue(messageString, EventMessageImpl.class);
} catch (IOException e) {
logger.error("Cannot process message", e);
}
if (payloadMessage == null) {
continue;
}
SDDCSoftwareConfig vroInfo = null;
try {
vroInfo = mapper.readValue(payloadMessage.getContent(), SDDCSoftwareConfig.class);
} catch (IOException e) {
logger.error("Cannot process message", e);
}
if (null == vroInfo) {
continue;
}
for (EventUser payloadCommand : payloadMessage.getTarget().getUsers()) {
switch(payloadCommand.getId()) {
case EventMessageUtil.VRO_SyncMetricData:
syncVROMetricData(vroInfo);
logger.info("Finish Sync Metric data for " + vroInfo.getName());
break;
case EventMessageUtil.VRO_SyncMetricPropertyAndAlert:
syncVROMetricPropertyAlertDefinition(vroInfo);
logger.info("Finish Sync customer attributes and alerts for " + vroInfo.getName());
break;
default:
break;
}
}
}
break;
case EventMessageUtil.VRO_SyncMetricData:
logger.warn("VRO_SyncMetricData command is deprecated, please use VRO_SyncData");
break;
case EventMessageUtil.VRO_SyncMetricPropertyAndAlert:
logger.warn("VRO_SyncMetricPropertyAndAlert command is deprecated, please use VRO_SyncData");
break;
default:
logger.warn("Unknown command, ignore it: " + command.getId());
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 PowerIQService method executeAsync.
@Override
@Async("asyncServiceExecutor")
public void executeAsync(EventMessage message) {
// update the value.
if (message.getType() != EventType.PowerIQ) {
logger.warn("Drop none PowerIQ 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.POWERIQ_SyncData:
// it will sync all the data depend on the type in the powerIQJobList.
String messageString = null;
while ((messageString = template.opsForList().rightPop(EventMessageUtil.powerIQJobList)) != 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 powerIQinfo = null;
try {
powerIQinfo = mapper.readValue(payloadMessage.getContent(), FacilitySoftwareConfig.class);
} catch (IOException e) {
logger.error("Cannot process message", e);
}
if (null == powerIQinfo) {
continue;
}
if (!powerIQinfo.checkIsActive()) {
continue;
}
for (EventUser payloadCommand : payloadMessage.getTarget().getUsers()) {
executeJob(payloadCommand.getId(), powerIQinfo);
}
}
break;
default:
FacilitySoftwareConfig powerIQ = null;
try {
powerIQ = mapper.readValue(message.getContent(), FacilitySoftwareConfig.class);
} catch (IOException e1) {
// TODO Auto-generated catch block
logger.error("Failed to convert message", e1);
}
if (powerIQ != null) {
executeJob(command.getId(), powerIQ);
}
break;
}
}
}
Aggregations