Search in sources :

Example 11 with IntegrationStatus

use of com.vmware.flowgate.common.model.IntegrationStatus in project flowgate by vmware.

the class VROAsyncJob method syncVROMetricPropertyAlertDefinition.

private void syncVROMetricPropertyAlertDefinition(SDDCSoftwareConfig config) {
    if (!config.checkIsActive()) {
        return;
    }
    VROConfig vroConf = new VROConfig(config);
    MetricClient metricClient = null;
    logger.info("Synce predefinedMetrics for " + config.getServerURL());
    try {
        metricClient = new MetricClient(vroConf, publisher);
        metricClient.checkPredefinedMetricsandProperties();
    } catch (AuthException e) {
        logger.error("Failed to sync the metric data from VRO ", e);
        IntegrationStatus integrationStatus = config.getIntegrationStatus();
        if (integrationStatus == null) {
            integrationStatus = new IntegrationStatus();
        }
        integrationStatus.setStatus(IntegrationStatus.Status.ERROR);
        integrationStatus.setDetail(e.getMessage());
        integrationStatus.setRetryCounter(FlowgateConstant.DEFAULTNUMBEROFRETRIES);
        updateIntegrationStatus(config);
        return;
    } catch (Exception e) {
        if (e.getCause() instanceof UndeclaredThrowableException) {
            UndeclaredThrowableException undeclaredThrowableException = (UndeclaredThrowableException) e.getCause();
            if (undeclaredThrowableException.getUndeclaredThrowable().getCause() instanceof ConnectException) {
                checkAndUpdateIntegrationStatus(config, undeclaredThrowableException.getUndeclaredThrowable().getCause().getMessage());
                return;
            }
        }
        throw e;
    }
    AlertClient alertClient = new AlertClient(vroConf);
    restClient.setServiceKey(serviceKeyConfig.getServiceKey());
    alertClient.setRestClient(restClient);
    alertClient.run();
}
Also used : IntegrationStatus(com.vmware.flowgate.common.model.IntegrationStatus) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) AuthException(com.vmware.ops.api.client.exceptions.AuthException) AlertClient(com.vmware.flowgate.vroworker.vro.AlertClient) VROConfig(com.vmware.flowgate.vroworker.vro.VROConfig) MetricClient(com.vmware.flowgate.vroworker.vro.MetricClient) AuthException(com.vmware.ops.api.client.exceptions.AuthException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) ConnectException(java.net.ConnectException)

Example 12 with IntegrationStatus

use of com.vmware.flowgate.common.model.IntegrationStatus in project flowgate by vmware.

the class VROAsyncJob method syncVROMetricData.

private void syncVROMetricData(SDDCSoftwareConfig config) {
    if (!config.checkIsActive()) {
        return;
    }
    VROConfig vro = new VROConfig(config);
    long currentTime = System.currentTimeMillis();
    MetricClient metricClient = null;
    List<ResourceDto> hosts = null;
    try {
        metricClient = new MetricClient(vro, publisher);
        hosts = metricClient.getHostSystemsResources();
    } catch (AuthException authException) {
        logger.error("Failed to connect to VROps manager ", authException);
        IntegrationStatus integrationStatus = config.getIntegrationStatus();
        if (integrationStatus == null) {
            integrationStatus = new IntegrationStatus();
        }
        integrationStatus.setStatus(IntegrationStatus.Status.ERROR);
        integrationStatus.setDetail(authException.getMessage());
        integrationStatus.setRetryCounter(FlowgateConstant.DEFAULTNUMBEROFRETRIES);
        updateIntegrationStatus(config);
        return;
    } catch (Exception e) {
        if (e.getCause() instanceof UndeclaredThrowableException) {
            UndeclaredThrowableException undeclaredThrowableException = (UndeclaredThrowableException) e.getCause();
            if (undeclaredThrowableException.getUndeclaredThrowable().getCause() instanceof ConnectException) {
                checkAndUpdateIntegrationStatus(config, undeclaredThrowableException.getUndeclaredThrowable().getCause().getMessage());
                return;
            }
        }
        throw e;
    }
    // read all host/asset maaping from apiserver
    Map<String, Asset> assetDictionary = new HashMap<String, Asset>();
    try {
        restClient.setServiceKey(serviceKeyConfig.getServiceKey());
        Asset[] servers = restClient.getAssetsByVRO(vro.getId()).getBody();
        for (Asset server : servers) {
            assetDictionary.put(server.getId(), server);
        }
    } catch (HttpClientErrorException clientError) {
        if (clientError.getRawStatusCode() != HTTP_NOTFOUND) {
            throw clientError;
        }
    }
    ServerMapping[] mappings = null;
    try {
        mappings = restClient.getServerMappingsByVRO(vro.getId()).getBody();
    } catch (HttpClientErrorException clientError) {
        if (clientError.getRawStatusCode() != HTTP_NOTFOUND) {
            throw clientError;
        }
        mappings = new ServerMapping[0];
    }
    HashMap<String, ServerMapping> entityNameDictionary = new HashMap<String, ServerMapping>();
    HashMap<String, ServerMapping> objectIDDictionary = new HashMap<String, ServerMapping>();
    for (ServerMapping mapping : mappings) {
        entityNameDictionary.put(mapping.getVroVMEntityName(), mapping);
        objectIDDictionary.put(mapping.getVroVMEntityObjectID(), mapping);
    // vcIDDictionary.put(mapping.getVroVMEntityVCID(), mapping);
    }
    List<ServerMapping> validMapping = new ArrayList<ServerMapping>();
    for (ResourceDto host : hosts) {
        // There are several things that can be used as a identifier of a host.
        // the first is the Name
        // beside that there are three other identifier
        // VMEntityName -- 10.112.113.160
        // VMEntityObjectID  host-81  the mobID of the host.
        // VMEntityVCID  this is the uuid of the vc object.
        // currently we only add new servers and don't delete servers
        List<ResourceIdentifier> identifiers = host.getResourceKey().getResourceIdentifiers();
        boolean newHost = true;
        String entityName = "";
        String objectID = "";
        String vcID = "";
        ServerMapping refer = null;
        for (ResourceIdentifier identifier : identifiers) {
            if (!newHost) {
                break;
            }
            switch(identifier.getIdentifierType().getName()) {
                case EntityName:
                    entityName = identifier.getValue();
                    if (entityNameDictionary.containsKey(entityName)) {
                        newHost = false;
                        refer = entityNameDictionary.get(entityName);
                    }
                    break;
                case VMEntityObjectID:
                    objectID = identifier.getValue();
                    if (objectIDDictionary.containsKey(objectID)) {
                        newHost = false;
                        refer = objectIDDictionary.get(objectID);
                    }
                    break;
                case VMEntityVCID:
                    vcID = identifier.getValue();
                    break;
                default:
                    break;
            }
        }
        if (newHost) {
            // try to notify the other system.
            String ipaddress = IPAddressUtil.getIPAddress(entityName);
            if (null != ipaddress) {
                publisher.publish(null, ipaddress);
                ipaddress = entityName;
            }
            ServerMapping newMapping = new ServerMapping();
            newMapping.setVroID(vro.getId());
            newMapping.setVroResourceName(host.getResourceKey().getName());
            newMapping.setVroVMEntityName(entityName);
            newMapping.setVroVMEntityObjectID(objectID);
            newMapping.setVroVMEntityVCID(vcID);
            newMapping.setVroResourceID(host.getIdentifier().toString());
            AssetIPMapping[] ipMappings = restClient.getHostnameIPMappingByIP(ipaddress).getBody();
            if (null != ipMappings && ipMappings.length > 0) {
                // update the mapping
                String assetName = ipMappings[0].getAssetname();
                Asset asset = restClient.getAssetByName(assetName).getBody();
                if (asset != null) {
                    newMapping.setAsset(asset.getId());
                }
            }
            restClient.saveServerMapping(newMapping);
            validMapping.add(newMapping);
        } else {
            if (refer.getAsset() == null) {
                String ipaddress = IPAddressUtil.getIPAddress(refer.getVroVMEntityName());
                AssetIPMapping[] ipMappings = restClient.getHostnameIPMappingByIP(ipaddress).getBody();
                if (null != ipMappings && ipMappings.length > 0) {
                    // update the mapping
                    String assetName = ipMappings[0].getAssetname();
                    Asset asset = restClient.getAssetByName(assetName).getBody();
                    if (asset != null) {
                        refer.setAsset(asset.getId());
                        restClient.saveServerMapping(refer);
                        validMapping.add(refer);
                    }
                } else {
                    if (null != ipaddress) {
                        logger.info("Notify Infoblox to query the assetname");
                        publisher.publish(null, ipaddress);
                    }
                }
            } else {
                validMapping.add(refer);
            }
        }
    }
    // validMapping.stream().map(ServerMapping::getAssetID).collect(Collectors.toSet());
    if (validMapping.isEmpty()) {
        logger.info("No Mapping find.Sync nothing for this execution.");
        return;
    }
    Long latencyFactor = latencyFactorMap.get(config.getServerURL());
    if (latencyFactor == null) {
        latencyFactor = 24L;
    }
    Long lastUpdateTimeStamp = lastUpdateTimeMap.get(config.getServerURL());
    if (lastUpdateTimeStamp == null) {
        lastUpdateTimeStamp = currentTime - FIVE_MINUTES * latencyFactor;
    }
    boolean hasNewData = false;
    logger.info(String.format("Start prepare data.%s, lastUpdateTime:%s, latencyFactor:%s", executionCount, lastUpdateTimeStamp, latencyFactor));
    long newUpdateTimeStamp = lastUpdateTimeStamp;
    for (ServerMapping mapping : validMapping) {
        if (mapping.getAsset() != null) {
            MetricData[] sensorDatas = restClient.getServerRelatedSensorDataByServerID(mapping.getAsset(), lastUpdateTimeStamp, FIVE_MINUTES * latencyFactor).getBody();
            Asset server = restClient.getAssetByID(mapping.getAsset()).getBody();
            List<String> pdus = server.getPdus();
            StatContents contents = new StatContents();
            StatContent frontTemp = new StatContent();
            List<Double> frontValues = new ArrayList<Double>();
            List<Long> frontTimes = new ArrayList<Long>();
            StatContent backTemp = new StatContent();
            List<Double> backValues = new ArrayList<Double>();
            List<Long> backTimes = new ArrayList<Long>();
            StatContent pduAMPSValue = new StatContent();
            List<Double> pduAMPSValues = new ArrayList<Double>();
            List<Long> pduAMPSTimes = new ArrayList<Long>();
            StatContent pduRealtimeVoltage = new StatContent();
            List<Double> voltageValues = new ArrayList<Double>();
            List<Long> voltageTimes = new ArrayList<Long>();
            StatContent pduRealtimePower = new StatContent();
            List<Double> powerValues = new ArrayList<Double>();
            List<Long> powerTimes = new ArrayList<Long>();
            StatContent frontHumidityPercent = new StatContent();
            List<Double> frontHumidityValues = new ArrayList<Double>();
            List<Long> frontHumidityTimes = new ArrayList<Long>();
            StatContent backHumidityPercent = new StatContent();
            List<Double> backHumidityValues = new ArrayList<Double>();
            List<Long> backHumidityTimes = new ArrayList<Long>();
            StatContent currentLoad = new StatContent();
            List<Double> currentLoadValues = new ArrayList<Double>();
            List<Long> currentLoadTimes = new ArrayList<Long>();
            StatContent powerLoad = new StatContent();
            List<Double> powerLoadValues = new ArrayList<Double>();
            List<Long> powerLoadTimes = new ArrayList<Long>();
            String pduId = null;
            String currentMetricName = MetricName.SERVER_CONNECTED_PDU_CURRENT;
            String powerMetricName = MetricName.SERVER_CONNECTED_PDU_POWER;
            String voltageMetricName = MetricName.SERVER_VOLTAGE;
            String currentLoadMetricName = MetricName.PDU_CURRENT_LOAD;
            String powerLoadMetricName = MetricName.PDU_POWER_LOAD;
            if (pdus != null && !pdus.isEmpty()) {
                pduId = pdus.get(0);
                currentMetricName = String.format(MetricKeyName.SERVER_CONNECTED_PDUX_TOTAL_CURRENT, pduId);
                powerMetricName = String.format(MetricKeyName.SERVER_CONNECTED_PDUX_TOTAL_POWER, pduId);
                currentLoadMetricName = String.format(MetricKeyName.SERVER_CONNECTED_PDUX_CURRENT_LOAD, pduId);
                powerLoadMetricName = String.format(MetricKeyName.SERVER_CONNECTED_PDUX_POWER_LOAD, pduId);
            }
            for (MetricData data : sensorDatas) {
                if (data.getTimeStamp() > newUpdateTimeStamp) {
                    newUpdateTimeStamp = data.getTimeStamp();
                    hasNewData = true;
                }
                String metricName = data.getMetricName();
                if (metricName.equals(currentMetricName)) {
                    pduAMPSValues.add(data.getValueNum());
                    pduAMPSTimes.add(data.getTimeStamp());
                    continue;
                } else if (metricName.equals(powerMetricName)) {
                    powerValues.add(data.getValueNum());
                    powerTimes.add(data.getTimeStamp());
                    continue;
                } else if (metricName.equals(voltageMetricName)) {
                    voltageValues.add(data.getValueNum());
                    voltageTimes.add(data.getTimeStamp());
                    continue;
                } else if (metricName.equals(currentLoadMetricName)) {
                    currentLoadValues.add(data.getValueNum());
                    currentLoadTimes.add(data.getTimeStamp());
                    continue;
                } else if (metricName.equals(powerLoadMetricName)) {
                    powerLoadValues.add(data.getValueNum());
                    powerLoadTimes.add(data.getTimeStamp());
                    continue;
                } else if (metricName.contains(MetricName.SERVER_FRONT_HUMIDITY)) {
                    frontHumidityValues.add(data.getValueNum());
                    frontHumidityTimes.add(data.getTimeStamp());
                    continue;
                } else if (metricName.contains(MetricName.SERVER_FRONT_TEMPERATURE)) {
                    frontValues.add(data.getValueNum());
                    frontTimes.add(data.getTimeStamp());
                    continue;
                } else if (metricName.contains(MetricName.SERVER_BACK_TEMPREATURE)) {
                    backValues.add(data.getValueNum());
                    backTimes.add(data.getTimeStamp());
                    continue;
                } else if (metricName.contains(MetricName.SERVER_BACK_HUMIDITY)) {
                    backHumidityValues.add(data.getValueNum());
                    backHumidityTimes.add(data.getTimeStamp());
                    continue;
                }
            }
            if (!frontValues.isEmpty()) {
                frontTemp.setStatKey(VROConsts.ENVRIONMENT_FRONT_TEMPERATURE_METRIC);
                frontTemp.setData(frontValues.stream().mapToDouble(Double::valueOf).toArray());
                frontTemp.setTimestamps(frontTimes.stream().mapToLong(Long::valueOf).toArray());
                contents.addStatContent(frontTemp);
            }
            if (!backValues.isEmpty()) {
                backTemp.setStatKey(VROConsts.ENVRIONMENT_BACK_TEMPERATURE_METRIC);
                backTemp.setData(backValues.stream().mapToDouble(Double::valueOf).toArray());
                backTemp.setTimestamps(backTimes.stream().mapToLong(Long::valueOf).toArray());
                contents.addStatContent(backTemp);
            }
            if (!pduAMPSValues.isEmpty()) {
                pduAMPSValue.setStatKey(VROConsts.ENVRIONMENT_PDU_AMPS_METRIC);
                pduAMPSValue.setData(pduAMPSValues.stream().mapToDouble(Double::valueOf).toArray());
                pduAMPSValue.setTimestamps(pduAMPSTimes.stream().mapToLong(Long::valueOf).toArray());
                contents.addStatContent(pduAMPSValue);
            }
            if (!voltageValues.isEmpty()) {
                pduRealtimeVoltage.setStatKey(VROConsts.ENVRIONMENT_PDU_VOLTS_METRIC);
                pduRealtimeVoltage.setData(voltageValues.stream().mapToDouble(Double::valueOf).toArray());
                pduRealtimeVoltage.setTimestamps(voltageTimes.stream().mapToLong(Long::valueOf).toArray());
                contents.addStatContent(pduRealtimeVoltage);
            }
            if (!powerValues.isEmpty()) {
                pduRealtimePower.setStatKey(VROConsts.ENVRIONMENT_PDU_POWER_METRIC);
                pduRealtimePower.setData(powerValues.stream().mapToDouble(Double::valueOf).toArray());
                pduRealtimePower.setTimestamps(powerTimes.stream().mapToLong(Long::valueOf).toArray());
                contents.addStatContent(pduRealtimePower);
            }
            if (!frontHumidityValues.isEmpty()) {
                frontHumidityPercent.setStatKey(VROConsts.ENVRIONMENT_FRONT_HUMIDITY_METRIC);
                frontHumidityPercent.setData(frontHumidityValues.stream().mapToDouble(Double::valueOf).toArray());
                frontHumidityPercent.setTimestamps(frontHumidityTimes.stream().mapToLong(Long::valueOf).toArray());
                contents.addStatContent(frontHumidityPercent);
            }
            if (!backHumidityValues.isEmpty()) {
                backHumidityPercent.setStatKey(VROConsts.ENVRIONMENT_BACK_HUMIDITY_METRIC);
                backHumidityPercent.setData(backHumidityValues.stream().mapToDouble(Double::valueOf).toArray());
                backHumidityPercent.setTimestamps(backHumidityTimes.stream().mapToLong(Long::valueOf).toArray());
                contents.addStatContent(backHumidityPercent);
            }
            if (!currentLoadValues.isEmpty()) {
                currentLoad.setStatKey(VROConsts.ENVRIONMENT_PDU_AMPS_LOAD_METRIC);
                currentLoad.setData(currentLoadValues.stream().mapToDouble(Double::valueOf).toArray());
                currentLoad.setTimestamps(currentLoadTimes.stream().mapToLong(Long::valueOf).toArray());
                contents.addStatContent(currentLoad);
            }
            if (!powerLoadValues.isEmpty()) {
                powerLoad.setStatKey(VROConsts.ENVRIONMENT_PDU_POWER_LOAD_METRIC);
                powerLoad.setData(powerLoadValues.stream().mapToDouble(Double::valueOf).toArray());
                powerLoad.setTimestamps(powerLoadTimes.stream().mapToLong(Long::valueOf).toArray());
                contents.addStatContent(powerLoad);
            }
            if (!contents.getStatContents().isEmpty()) {
                logger.info("Push data to VRO: " + config.getServerURL());
                metricClient.addStats(null, UUID.fromString(mapping.getVroResourceID()), contents, false);
            }
            // UPDATE THE PROPERTIES
            if (executionCount % 1000 == 0) {
                PropertyContents propertyContents = new PropertyContents();
                packagingPropertyContent(assetDictionary.get(mapping.getAsset()), propertyContents);
                metricClient.addProperties(null, UUID.fromString(mapping.getVroResourceID()), propertyContents);
            }
        }
    }
    if (hasNewData) {
        Long factor = (currentTime - newUpdateTimeStamp) / FIVE_MINUTES + 1;
        if (factor > 24) {
            factor = 24L;
        } else if (factor < 0) {
            factor = 1L;
        }
        latencyFactorMap.put(config.getServerURL(), factor);
        if (newUpdateTimeStamp > currentTime) {
            newUpdateTimeStamp = currentTime;
        }
        lastUpdateTimeMap.put(config.getServerURL(), newUpdateTimeStamp);
    } else {
        latencyFactor = latencyFactor + 1;
        if (latencyFactor > 24) {
            latencyFactor = 24L;
        }
        latencyFactorMap.put(config.getServerURL(), latencyFactor);
    }
    executionCount++;
    logger.info("Finished Sync metric data for VRO: " + config.getServerURL());
}
Also used : HashMap(java.util.HashMap) ServerMapping(com.vmware.flowgate.common.model.ServerMapping) ArrayList(java.util.ArrayList) AuthException(com.vmware.ops.api.client.exceptions.AuthException) ResourceIdentifier(com.vmware.ops.api.model.resource.ResourceIdentifier) AssetIPMapping(com.vmware.flowgate.common.model.AssetIPMapping) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) Asset(com.vmware.flowgate.common.model.Asset) ConnectException(java.net.ConnectException) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) IntegrationStatus(com.vmware.flowgate.common.model.IntegrationStatus) AuthException(com.vmware.ops.api.client.exceptions.AuthException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) ResourceDto(com.vmware.ops.api.model.resource.ResourceDto) PropertyContents(com.vmware.ops.api.model.property.PropertyContents) StatContent(com.vmware.ops.api.model.stat.StatContent) StatContents(com.vmware.ops.api.model.stat.StatContents) VROConfig(com.vmware.flowgate.vroworker.vro.VROConfig) MetricClient(com.vmware.flowgate.vroworker.vro.MetricClient) MetricData(com.vmware.flowgate.common.model.MetricData)

Example 13 with IntegrationStatus

use of com.vmware.flowgate.common.model.IntegrationStatus in project flowgate by vmware.

the class OpenManageJobService method checkAndUpdateIntegrationStatus.

private void checkAndUpdateIntegrationStatus(FacilitySoftwareConfig integration, String message) {
    IntegrationStatus integrationStatus = integration.getIntegrationStatus();
    if (integrationStatus == null) {
        integrationStatus = new IntegrationStatus();
    }
    int timesOftry = integrationStatus.getRetryCounter();
    timesOftry++;
    if (timesOftry < FlowgateConstant.MAXNUMBEROFRETRIES) {
        integrationStatus.setRetryCounter(timesOftry);
    } else {
        integrationStatus.setStatus(IntegrationStatus.Status.ERROR);
        integrationStatus.setDetail(message);
        integrationStatus.setRetryCounter(FlowgateConstant.DEFAULTNUMBEROFRETRIES);
        logger.error("Failed to query data from integration");
    }
    integration.setIntegrationStatus(integrationStatus);
    updateIntegrationStatus(integration);
}
Also used : IntegrationStatus(com.vmware.flowgate.common.model.IntegrationStatus)

Example 14 with IntegrationStatus

use of com.vmware.flowgate.common.model.IntegrationStatus in project flowgate by vmware.

the class OpenManageJobTest method executeJobTest.

@Test
public void executeJobTest() {
    FacilitySoftwareConfig config = new FacilitySoftwareConfig();
    config.setId("executeJob");
    IntegrationStatus integrationStatus = new IntegrationStatus();
    integrationStatus.setStatus(IntegrationStatus.Status.ACTIVE);
    doNothing().when(this.openManageAPIClient).getToken();
    doNothing().when(this.wormholeAPIClient).setServiceKey(any(String.class));
    Mockito.when(this.openmanageJobService.createClient(config)).thenReturn(this.openManageAPIClient);
    Mockito.when(this.wormholeAPIClient.saveAssets(any(Asset.class))).thenReturn(saveAsset());
    Mockito.when(this.wormholeAPIClient.saveAssets(ArgumentMatchers.anyList())).thenReturn(null);
    Mockito.when(this.wormholeAPIClient.getAllAssetsBySourceAndType(config.getId(), AssetCategory.Server)).thenReturn(getAllAssetsBySourceAndType());
    Mockito.when(this.wormholeAPIClient.getAllAssetsBySourceAndType(config.getId(), AssetCategory.Chassis)).thenReturn(new ArrayList<Asset>());
    Mockito.when(this.openManageAPIClient.getDevices(any(Integer.class), any(Integer.class), ArgumentMatchers.eq(Server.class))).thenReturn(getCommonResultServer());
    Mockito.when(this.openManageAPIClient.getDevices(any(Integer.class), any(Integer.class), ArgumentMatchers.eq(Chassis.class))).thenReturn(new CommonResult<Chassis>());
    openmanageJobService.executeJob(EventMessageUtil.OpenManage_SyncAssetsMetaData, config);
}
Also used : Chassis(com.vmware.flowgate.openmanage.datamodel.Chassis) Server(com.vmware.flowgate.openmanage.datamodel.Server) IntegrationStatus(com.vmware.flowgate.common.model.IntegrationStatus) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig) Asset(com.vmware.flowgate.common.model.Asset) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 15 with IntegrationStatus

use of com.vmware.flowgate.common.model.IntegrationStatus in project flowgate by vmware.

the class AdapterJobService method checkAndUpdateIntegrationStatus.

private void checkAndUpdateIntegrationStatus(FacilitySoftwareConfig integration, String message) {
    IntegrationStatus integrationStatus = integration.getIntegrationStatus();
    if (integrationStatus == null) {
        integrationStatus = new IntegrationStatus();
    }
    int timesOftry = integrationStatus.getRetryCounter();
    timesOftry++;
    if (timesOftry < FlowgateConstant.MAXNUMBEROFRETRIES) {
        integrationStatus.setRetryCounter(timesOftry);
    } else {
        integrationStatus.setStatus(IntegrationStatus.Status.ERROR);
        integrationStatus.setDetail(message);
        integrationStatus.setRetryCounter(FlowgateConstant.DEFAULTNUMBEROFRETRIES);
        logger.error("Failed to query data from integration");
    }
    integration.setIntegrationStatus(integrationStatus);
    updateIntegrationStatus(integration);
}
Also used : IntegrationStatus(com.vmware.flowgate.common.model.IntegrationStatus)

Aggregations

IntegrationStatus (com.vmware.flowgate.common.model.IntegrationStatus)31 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)12 Asset (com.vmware.flowgate.common.model.Asset)10 ConnectException (java.net.ConnectException)10 IOException (java.io.IOException)8 FacilitySoftwareConfig (com.vmware.flowgate.common.model.FacilitySoftwareConfig)7 HashMap (java.util.HashMap)7 ResourceAccessException (org.springframework.web.client.ResourceAccessException)7 ArrayList (java.util.ArrayList)5 AssetIPMapping (com.vmware.flowgate.common.model.AssetIPMapping)3 RealTimeData (com.vmware.flowgate.common.model.RealTimeData)3 SDDCSoftwareConfig (com.vmware.flowgate.common.model.SDDCSoftwareConfig)3 NlyteAsset (com.vmware.flowgate.nlyteworker.model.NlyteAsset)3 PowerIQAPIClient (com.vmware.flowgate.poweriqworker.client.PowerIQAPIClient)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 AdvanceSettingType (com.vmware.flowgate.common.model.FacilitySoftwareConfig.AdvanceSettingType)2 ServerMapping (com.vmware.flowgate.common.model.ServerMapping)2 WormholeRequestException (com.vmware.flowgate.exception.WormholeRequestException)2 LocationGroup (com.vmware.flowgate.nlyteworker.model.LocationGroup)2 Manufacturer (com.vmware.flowgate.nlyteworker.model.Manufacturer)2