Search in sources :

Example 6 with EventUser

use of com.vmware.flowgate.common.model.redis.message.EventUser in project flowgate by vmware.

the class NlyteDataService method executeAsync.

@Override
public void executeAsync(EventMessage message) {
    if (message.getType() != EventType.Nlyte) {
        logger.warn("Drop none Nlyte 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.NLYTE_SyncData:
                // it will sync all the data depend on the type in the nlyteJobList.
                String messageString = null;
                while ((messageString = template.opsForList().rightPop(EventMessageUtil.nlyteJobList)) != 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 nlyte = null;
                    try {
                        nlyte = mapper.readValue(payloadMessage.getContent(), FacilitySoftwareConfig.class);
                    } catch (IOException e) {
                        logger.error("Cannot process message", e);
                    }
                    if (null == nlyte) {
                        continue;
                    }
                    if (!nlyte.checkIsActive()) {
                        continue;
                    }
                    for (EventUser payloadCommand : payloadMessage.getTarget().getUsers()) {
                        executeJob(payloadCommand.getId(), nlyte);
                    }
                }
                break;
            default:
                FacilitySoftwareConfig nlyteInfo = null;
                try {
                    nlyteInfo = mapper.readValue(message.getContent(), FacilitySoftwareConfig.class);
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    logger.info("Failed to convert message", e);
                }
                if (nlyteInfo != null) {
                    executeJob(EventMessageUtil.NLYTE_SyncMappedAssetData, nlyteInfo);
                }
                break;
        }
    }
}
Also used : EventMessage(com.vmware.flowgate.common.model.redis.message.EventMessage) EventUser(com.vmware.flowgate.common.model.redis.message.EventUser) EventMessageImpl(com.vmware.flowgate.common.model.redis.message.impl.EventMessageImpl) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig) IOException(java.io.IOException)

Example 7 with EventUser

use of com.vmware.flowgate.common.model.redis.message.EventUser in project flowgate by vmware.

the class OpenManageJobService method executeAsync.

@Override
public void executeAsync(EventMessage message) {
    if (message.getType() != EventType.OpenManage) {
        logger.warn("Drop non-OpenManage message " + message.getType());
        return;
    }
    logger.info("message received");
    String messageString = null;
    while ((messageString = template.opsForList().rightPop(EventMessageUtil.OpenManageJobList)) != 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 integration = null;
        try {
            integration = mapper.readValue(payloadMessage.getContent(), FacilitySoftwareConfig.class);
        } catch (IOException e) {
            logger.error("Cannot process message", e);
        }
        if (null == integration) {
            continue;
        }
        if (!integration.checkIsActive()) {
            continue;
        }
        for (EventUser payloadCommand : payloadMessage.getTarget().getUsers()) {
            executeJob(payloadCommand.getId(), integration);
        }
    }
}
Also used : EventMessage(com.vmware.flowgate.common.model.redis.message.EventMessage) EventMessageImpl(com.vmware.flowgate.common.model.redis.message.impl.EventMessageImpl) EventUser(com.vmware.flowgate.common.model.redis.message.EventUser) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig) IOException(java.io.IOException)

Example 8 with EventUser

use of com.vmware.flowgate.common.model.redis.message.EventUser 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;
        }
    }
}
Also used : EventMessage(com.vmware.flowgate.common.model.redis.message.EventMessage) EventUser(com.vmware.flowgate.common.model.redis.message.EventUser) EventMessageImpl(com.vmware.flowgate.common.model.redis.message.impl.EventMessageImpl) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig) IOException(java.io.IOException)

Example 9 with EventUser

use of com.vmware.flowgate.common.model.redis.message.EventUser in project flowgate by vmware.

the class AdapterJobService method executeAsync.

@Override
public void executeAsync(EventMessage message) {
    // TODO Auto-generated method stub
    logger.info("message received");
    String messageString = null;
    while ((messageString = template.opsForList().rightPop(queueName)) != 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 integration = null;
        try {
            integration = mapper.readValue(payloadMessage.getContent(), FacilitySoftwareConfig.class);
        } catch (IOException e) {
            logger.error("Cannot process message", e);
        }
        if (null == integration) {
            continue;
        }
        if (!integration.checkIsActive()) {
            continue;
        }
        for (EventUser payloadCommand : payloadMessage.getTarget().getUsers()) {
            excuteJob(payloadCommand.getId(), integration);
        }
    }
}
Also used : EventMessage(com.vmware.flowgate.common.model.redis.message.EventMessage) EventMessageImpl(com.vmware.flowgate.common.model.redis.message.impl.EventMessageImpl) EventUser(com.vmware.flowgate.common.model.redis.message.EventUser) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig) IOException(java.io.IOException)

Aggregations

EventUser (com.vmware.flowgate.common.model.redis.message.EventUser)9 EventMessage (com.vmware.flowgate.common.model.redis.message.EventMessage)8 EventMessageImpl (com.vmware.flowgate.common.model.redis.message.impl.EventMessageImpl)7 IOException (java.io.IOException)7 FacilitySoftwareConfig (com.vmware.flowgate.common.model.FacilitySoftwareConfig)5 Async (org.springframework.scheduling.annotation.Async)4 SDDCSoftwareConfig (com.vmware.flowgate.common.model.SDDCSoftwareConfig)2 EventTarget (com.vmware.flowgate.common.model.redis.message.EventTarget)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1