@Test public void checkAndInsertComponentTest() { int i = DBQueryUtil.checkAndInsertComponent("Test1", "TestApi1", ComponentType.APP, "http: assertTrue(i!=0); }
public static int checkAndInsertComponent(final String appName, final String apiName, final ComponentType compType, final String healthCheckURL, final int environmentId, final long regionID, final HealthCheckType healthCheckType, String platform) { String appNameToInsert = appName; ComponentType compTypeToInsert = compType; AppTransformConfig config = readAppTransformConfig(); if (config != null && config.getTransformName().containsKey(appName)) { appNameToInsert = config.getTransformName().get(appName); } if (config != null && config.getConvertToInfra().contains(appName)) { compTypeToInsert = ComponentType.INFRA; } int appId = insertParentComponent(appNameToInsert, compTypeToInsert, platform); int APIId = getComponentByNameAndParent(apiName, appId, compTypeToInsert.getComponentTypeId(), platform); if (APIId == 0) { insertComponent(apiName, appId, compTypeToInsert.getComponentTypeId(), true, platform); APIId = getComponentByNameAndParent(apiName, appId, compTypeToInsert.getComponentTypeId(),platform); insertHealthCheck(APIId, regionID, environmentId, healthCheckType.getHealthCheckTypeId(), 3); if (healthCheckURL != null) { HealthCheckVO hcvo = getCurrentHealthCheckDetails(APIId, environmentId, regionID, healthCheckType); if (hcvo != null) { insertHealthCheckParam(hcvo.getHealthCheckId(), "URL", healthCheckURL); } } } else { HealthCheckVO currentDBData = getCurrentHealthCheckDetails(APIId, environmentId, regionID); if (currentDBData == null) { insertHealthCheck(APIId, regionID, environmentId, healthCheckType.getHealthCheckTypeId(), 3); if (healthCheckURL != null) { HealthCheckVO hcvo = getCurrentHealthCheckDetails(APIId, environmentId, regionID, healthCheckType); if (hcvo != null) { insertHealthCheckParam(hcvo.getHealthCheckId(), "URL", healthCheckURL); } } } else { updateHealthCheck(currentDBData.getHealthCheckId(), healthCheckType.getHealthCheckTypeId()); removeHealthCheckParams(currentDBData.getHealthCheckId()); if (healthCheckURL != null) { insertHealthCheckParam(currentDBData.getHealthCheckId(), "URL", healthCheckURL); } } APIId = getComponentByNameAndParent(apiName, appId, compTypeToInsert.getComponentTypeId(), platform); } return APIId; }
DBQueryUtil { public static int checkAndInsertComponent(final String appName, final String apiName, final ComponentType compType, final String healthCheckURL, final int environmentId, final long regionID, final HealthCheckType healthCheckType, String platform) { String appNameToInsert = appName; ComponentType compTypeToInsert = compType; AppTransformConfig config = readAppTransformConfig(); if (config != null && config.getTransformName().containsKey(appName)) { appNameToInsert = config.getTransformName().get(appName); } if (config != null && config.getConvertToInfra().contains(appName)) { compTypeToInsert = ComponentType.INFRA; } int appId = insertParentComponent(appNameToInsert, compTypeToInsert, platform); int APIId = getComponentByNameAndParent(apiName, appId, compTypeToInsert.getComponentTypeId(), platform); if (APIId == 0) { insertComponent(apiName, appId, compTypeToInsert.getComponentTypeId(), true, platform); APIId = getComponentByNameAndParent(apiName, appId, compTypeToInsert.getComponentTypeId(),platform); insertHealthCheck(APIId, regionID, environmentId, healthCheckType.getHealthCheckTypeId(), 3); if (healthCheckURL != null) { HealthCheckVO hcvo = getCurrentHealthCheckDetails(APIId, environmentId, regionID, healthCheckType); if (hcvo != null) { insertHealthCheckParam(hcvo.getHealthCheckId(), "URL", healthCheckURL); } } } else { HealthCheckVO currentDBData = getCurrentHealthCheckDetails(APIId, environmentId, regionID); if (currentDBData == null) { insertHealthCheck(APIId, regionID, environmentId, healthCheckType.getHealthCheckTypeId(), 3); if (healthCheckURL != null) { HealthCheckVO hcvo = getCurrentHealthCheckDetails(APIId, environmentId, regionID, healthCheckType); if (hcvo != null) { insertHealthCheckParam(hcvo.getHealthCheckId(), "URL", healthCheckURL); } } } else { updateHealthCheck(currentDBData.getHealthCheckId(), healthCheckType.getHealthCheckTypeId()); removeHealthCheckParams(currentDBData.getHealthCheckId()); if (healthCheckURL != null) { insertHealthCheckParam(currentDBData.getHealthCheckId(), "URL", healthCheckURL); } } APIId = getComponentByNameAndParent(apiName, appId, compTypeToInsert.getComponentTypeId(), platform); } return APIId; } }
DBQueryUtil { public static int checkAndInsertComponent(final String appName, final String apiName, final ComponentType compType, final String healthCheckURL, final int environmentId, final long regionID, final HealthCheckType healthCheckType, String platform) { String appNameToInsert = appName; ComponentType compTypeToInsert = compType; AppTransformConfig config = readAppTransformConfig(); if (config != null && config.getTransformName().containsKey(appName)) { appNameToInsert = config.getTransformName().get(appName); } if (config != null && config.getConvertToInfra().contains(appName)) { compTypeToInsert = ComponentType.INFRA; } int appId = insertParentComponent(appNameToInsert, compTypeToInsert, platform); int APIId = getComponentByNameAndParent(apiName, appId, compTypeToInsert.getComponentTypeId(), platform); if (APIId == 0) { insertComponent(apiName, appId, compTypeToInsert.getComponentTypeId(), true, platform); APIId = getComponentByNameAndParent(apiName, appId, compTypeToInsert.getComponentTypeId(),platform); insertHealthCheck(APIId, regionID, environmentId, healthCheckType.getHealthCheckTypeId(), 3); if (healthCheckURL != null) { HealthCheckVO hcvo = getCurrentHealthCheckDetails(APIId, environmentId, regionID, healthCheckType); if (hcvo != null) { insertHealthCheckParam(hcvo.getHealthCheckId(), "URL", healthCheckURL); } } } else { HealthCheckVO currentDBData = getCurrentHealthCheckDetails(APIId, environmentId, regionID); if (currentDBData == null) { insertHealthCheck(APIId, regionID, environmentId, healthCheckType.getHealthCheckTypeId(), 3); if (healthCheckURL != null) { HealthCheckVO hcvo = getCurrentHealthCheckDetails(APIId, environmentId, regionID, healthCheckType); if (hcvo != null) { insertHealthCheckParam(hcvo.getHealthCheckId(), "URL", healthCheckURL); } } } else { updateHealthCheck(currentDBData.getHealthCheckId(), healthCheckType.getHealthCheckTypeId()); removeHealthCheckParams(currentDBData.getHealthCheckId()); if (healthCheckURL != null) { insertHealthCheckParam(currentDBData.getHealthCheckId(), "URL", healthCheckURL); } } APIId = getComponentByNameAndParent(apiName, appId, compTypeToInsert.getComponentTypeId(), platform); } return APIId; } private  DBQueryUtil(); }
DBQueryUtil { public static int checkAndInsertComponent(final String appName, final String apiName, final ComponentType compType, final String healthCheckURL, final int environmentId, final long regionID, final HealthCheckType healthCheckType, String platform) { String appNameToInsert = appName; ComponentType compTypeToInsert = compType; AppTransformConfig config = readAppTransformConfig(); if (config != null && config.getTransformName().containsKey(appName)) { appNameToInsert = config.getTransformName().get(appName); } if (config != null && config.getConvertToInfra().contains(appName)) { compTypeToInsert = ComponentType.INFRA; } int appId = insertParentComponent(appNameToInsert, compTypeToInsert, platform); int APIId = getComponentByNameAndParent(apiName, appId, compTypeToInsert.getComponentTypeId(), platform); if (APIId == 0) { insertComponent(apiName, appId, compTypeToInsert.getComponentTypeId(), true, platform); APIId = getComponentByNameAndParent(apiName, appId, compTypeToInsert.getComponentTypeId(),platform); insertHealthCheck(APIId, regionID, environmentId, healthCheckType.getHealthCheckTypeId(), 3); if (healthCheckURL != null) { HealthCheckVO hcvo = getCurrentHealthCheckDetails(APIId, environmentId, regionID, healthCheckType); if (hcvo != null) { insertHealthCheckParam(hcvo.getHealthCheckId(), "URL", healthCheckURL); } } } else { HealthCheckVO currentDBData = getCurrentHealthCheckDetails(APIId, environmentId, regionID); if (currentDBData == null) { insertHealthCheck(APIId, regionID, environmentId, healthCheckType.getHealthCheckTypeId(), 3); if (healthCheckURL != null) { HealthCheckVO hcvo = getCurrentHealthCheckDetails(APIId, environmentId, regionID, healthCheckType); if (hcvo != null) { insertHealthCheckParam(hcvo.getHealthCheckId(), "URL", healthCheckURL); } } } else { updateHealthCheck(currentDBData.getHealthCheckId(), healthCheckType.getHealthCheckTypeId()); removeHealthCheckParams(currentDBData.getHealthCheckId()); if (healthCheckURL != null) { insertHealthCheckParam(currentDBData.getHealthCheckId(), "URL", healthCheckURL); } } APIId = getComponentByNameAndParent(apiName, appId, compTypeToInsert.getComponentTypeId(), platform); } return APIId; } private  DBQueryUtil(); static List<HealthCheckVO> getSurveillerDetailsOfComponent(boolean isDummyHealth); static List<EnvironmentVO> getAllEnvironments(); static List<HealthCheckVO> updateHealthCheckStatusInDB(List<HealthCheckVO> healthCheckVOs); static void updateEnvironmentDetails(
			List<EnvironmentVO> environmentVOs); static void updateWestMarathonJson(final EnvironmentVO environmentVO); static void updateEastMarathonJson(final EnvironmentVO environmentVO); static boolean checkAndUpdateMessage(final int componentId, final int environmentId,
			final long regionID,final HealthCheckType healthCheckType, final Status currentStatus,
			final String marathonMessage); static void updateMarathonHealthCheckStatus(final int componentId, final int environmentId,
			final long regionID,final HealthCheckType healthCheckType, final Status status, boolean isStatusChanged); static int checkAndInsertComponent(final String appName, final String apiName, final ComponentType compType,
	        final String healthCheckURL, final int environmentId, final long regionID,
	        final HealthCheckType healthCheckType, String platform); static AppTransformConfig readAppTransformConfig(); static int getComponentByNameAndParent(final String name, final int parentId, final int componentTypeId, String platform); static ComponentVO getComponent(final int componentId); static void insertComponent(final String name, final int parentId,
			final int componentType, boolean hasParent, String platform); static void insertHealthCheckParam(final long healthCheckId,
			final String healthCheckParamKey, final String healthCheckPramVal); static void insertHealthCheck(final int componentId,
			final Long regionId, final int environmentId,
			final int healthCheckTypeId, final int maxRetryCount); static List<ComponentVO> getAllAPIComponentDetails(final int environmentId, String platform, long regionId); static void updateDelIndForHealthCheck(final int compId,
			final int delInd, final int enviromentId, final Long regionID); static List<SubscriptionVO> getAllSubscriptions(Set<Integer> compIdSet); static List<CounterDetailVO> getCounterDetails(); static void addCounterMertic(final int environmentCounterId, final float counterMerticValue, Timestamp currDate); static void addCounterMetricHistory(final int environmentCounterId, final float counterMerticValue); static float getTotalTransaction(final int envCountId); static void executeDelete(String query); static float getCCPUpTime(final int envId, final String [] parentComponentNames); static int getNumberOfServices(CounterDetailVO counterDetails); static Map<Integer, Blob> getMarathonJson(); static void loadContainerStatus(final int envId, int compId, final int instanceNum); static int getComponentId(final String compName, final String parentCompName); static Set<Integer> getAppsLauchDateNull(int envId); static void updateAppLaunchDate(String launchDate, int compId, int envId); static void loadApiStatus(final int envId, String compName, int numOfApi); static Map<String, Integer> getCurrentApiDetails(int envId); static void updateApiDetails(final int envId, String compName, int numOfApi, String platform); static Map<String, Integer> getCurrentContainerDetails(int envId); static void updateContainerDetails(final int envId, int compId, int numOfcont); static Map<String, String> getPromLookupDetails(int envId, String platform); static int loadPromLookup(final int envId, int compId, String httpPath); static void updatePromLookup(final int envId, int compId, String httpPath); static Map<String, Integer> getPromLookupHttpPath(int envId, String platform); static List<Integer> getAllCurrentTPS(int envId, String platform); static void updateTpsService(final int envId, int componentId, float tpsVaule, float latencyValue); static void loadTpsService(final int envId, int conponentId , float tpsVaule, float latencyValue); static Map<Integer, List<Float>> getTpsLatencyHsitory(int envId, String platform); static void loadTpsLatencyHistory(final int envId, int conponentId , float tpsVaule, float latencyValue); static void loadK8sTpsLatencyHistory(final int envId, int conponentId , float tpsVaule, float latencyValue); static void updateTpsLatHistory(final int envId, int componentId, float tpsVaule, float latencyValue, String platform); static Map<String, Integer> getK8sCurrentApiDetails(int envId); static Map<String, Integer> getK8sCurrContainerDetails(int envId, String platform); static Map<String, Integer> getK8sObjPodsContDetails(int envId); static Map<String, Integer> getNumOfActiveApisOfApp(int envId, String platform); static void loadK8sApiStatus(final int envId, String compName, int numOfApi); static void updateContainerDetails(final int envId, String compName, int numOfcont, String parentCompName, String platform); static void updateObjPodss(int environmentId, String objName, ArrayList<Integer> podContList); static void loadK8sObjectPods(int environmentId, String objName, ArrayList<Integer> podContList); static void updatePodsAndContainers(final int envId, String compName, int numOfPods, String parentCompName, int numOfCont); static int loadPodsAndContainers(final int envId,final String compName,final String parentCompName, final int numPods, int numCont ); static Map<String, Integer> getAllComponentIdForEnv(int envId,String platform); static void deletePromLookup(int envId, int compId, String lookupVaule); }
DBQueryUtil { public static int checkAndInsertComponent(final String appName, final String apiName, final ComponentType compType, final String healthCheckURL, final int environmentId, final long regionID, final HealthCheckType healthCheckType, String platform) { String appNameToInsert = appName; ComponentType compTypeToInsert = compType; AppTransformConfig config = readAppTransformConfig(); if (config != null && config.getTransformName().containsKey(appName)) { appNameToInsert = config.getTransformName().get(appName); } if (config != null && config.getConvertToInfra().contains(appName)) { compTypeToInsert = ComponentType.INFRA; } int appId = insertParentComponent(appNameToInsert, compTypeToInsert, platform); int APIId = getComponentByNameAndParent(apiName, appId, compTypeToInsert.getComponentTypeId(), platform); if (APIId == 0) { insertComponent(apiName, appId, compTypeToInsert.getComponentTypeId(), true, platform); APIId = getComponentByNameAndParent(apiName, appId, compTypeToInsert.getComponentTypeId(),platform); insertHealthCheck(APIId, regionID, environmentId, healthCheckType.getHealthCheckTypeId(), 3); if (healthCheckURL != null) { HealthCheckVO hcvo = getCurrentHealthCheckDetails(APIId, environmentId, regionID, healthCheckType); if (hcvo != null) { insertHealthCheckParam(hcvo.getHealthCheckId(), "URL", healthCheckURL); } } } else { HealthCheckVO currentDBData = getCurrentHealthCheckDetails(APIId, environmentId, regionID); if (currentDBData == null) { insertHealthCheck(APIId, regionID, environmentId, healthCheckType.getHealthCheckTypeId(), 3); if (healthCheckURL != null) { HealthCheckVO hcvo = getCurrentHealthCheckDetails(APIId, environmentId, regionID, healthCheckType); if (hcvo != null) { insertHealthCheckParam(hcvo.getHealthCheckId(), "URL", healthCheckURL); } } } else { updateHealthCheck(currentDBData.getHealthCheckId(), healthCheckType.getHealthCheckTypeId()); removeHealthCheckParams(currentDBData.getHealthCheckId()); if (healthCheckURL != null) { insertHealthCheckParam(currentDBData.getHealthCheckId(), "URL", healthCheckURL); } } APIId = getComponentByNameAndParent(apiName, appId, compTypeToInsert.getComponentTypeId(), platform); } return APIId; } private  DBQueryUtil(); static List<HealthCheckVO> getSurveillerDetailsOfComponent(boolean isDummyHealth); static List<EnvironmentVO> getAllEnvironments(); static List<HealthCheckVO> updateHealthCheckStatusInDB(List<HealthCheckVO> healthCheckVOs); static void updateEnvironmentDetails(
			List<EnvironmentVO> environmentVOs); static void updateWestMarathonJson(final EnvironmentVO environmentVO); static void updateEastMarathonJson(final EnvironmentVO environmentVO); static boolean checkAndUpdateMessage(final int componentId, final int environmentId,
			final long regionID,final HealthCheckType healthCheckType, final Status currentStatus,
			final String marathonMessage); static void updateMarathonHealthCheckStatus(final int componentId, final int environmentId,
			final long regionID,final HealthCheckType healthCheckType, final Status status, boolean isStatusChanged); static int checkAndInsertComponent(final String appName, final String apiName, final ComponentType compType,
	        final String healthCheckURL, final int environmentId, final long regionID,
	        final HealthCheckType healthCheckType, String platform); static AppTransformConfig readAppTransformConfig(); static int getComponentByNameAndParent(final String name, final int parentId, final int componentTypeId, String platform); static ComponentVO getComponent(final int componentId); static void insertComponent(final String name, final int parentId,
			final int componentType, boolean hasParent, String platform); static void insertHealthCheckParam(final long healthCheckId,
			final String healthCheckParamKey, final String healthCheckPramVal); static void insertHealthCheck(final int componentId,
			final Long regionId, final int environmentId,
			final int healthCheckTypeId, final int maxRetryCount); static List<ComponentVO> getAllAPIComponentDetails(final int environmentId, String platform, long regionId); static void updateDelIndForHealthCheck(final int compId,
			final int delInd, final int enviromentId, final Long regionID); static List<SubscriptionVO> getAllSubscriptions(Set<Integer> compIdSet); static List<CounterDetailVO> getCounterDetails(); static void addCounterMertic(final int environmentCounterId, final float counterMerticValue, Timestamp currDate); static void addCounterMetricHistory(final int environmentCounterId, final float counterMerticValue); static float getTotalTransaction(final int envCountId); static void executeDelete(String query); static float getCCPUpTime(final int envId, final String [] parentComponentNames); static int getNumberOfServices(CounterDetailVO counterDetails); static Map<Integer, Blob> getMarathonJson(); static void loadContainerStatus(final int envId, int compId, final int instanceNum); static int getComponentId(final String compName, final String parentCompName); static Set<Integer> getAppsLauchDateNull(int envId); static void updateAppLaunchDate(String launchDate, int compId, int envId); static void loadApiStatus(final int envId, String compName, int numOfApi); static Map<String, Integer> getCurrentApiDetails(int envId); static void updateApiDetails(final int envId, String compName, int numOfApi, String platform); static Map<String, Integer> getCurrentContainerDetails(int envId); static void updateContainerDetails(final int envId, int compId, int numOfcont); static Map<String, String> getPromLookupDetails(int envId, String platform); static int loadPromLookup(final int envId, int compId, String httpPath); static void updatePromLookup(final int envId, int compId, String httpPath); static Map<String, Integer> getPromLookupHttpPath(int envId, String platform); static List<Integer> getAllCurrentTPS(int envId, String platform); static void updateTpsService(final int envId, int componentId, float tpsVaule, float latencyValue); static void loadTpsService(final int envId, int conponentId , float tpsVaule, float latencyValue); static Map<Integer, List<Float>> getTpsLatencyHsitory(int envId, String platform); static void loadTpsLatencyHistory(final int envId, int conponentId , float tpsVaule, float latencyValue); static void loadK8sTpsLatencyHistory(final int envId, int conponentId , float tpsVaule, float latencyValue); static void updateTpsLatHistory(final int envId, int componentId, float tpsVaule, float latencyValue, String platform); static Map<String, Integer> getK8sCurrentApiDetails(int envId); static Map<String, Integer> getK8sCurrContainerDetails(int envId, String platform); static Map<String, Integer> getK8sObjPodsContDetails(int envId); static Map<String, Integer> getNumOfActiveApisOfApp(int envId, String platform); static void loadK8sApiStatus(final int envId, String compName, int numOfApi); static void updateContainerDetails(final int envId, String compName, int numOfcont, String parentCompName, String platform); static void updateObjPodss(int environmentId, String objName, ArrayList<Integer> podContList); static void loadK8sObjectPods(int environmentId, String objName, ArrayList<Integer> podContList); static void updatePodsAndContainers(final int envId, String compName, int numOfPods, String parentCompName, int numOfCont); static int loadPodsAndContainers(final int envId,final String compName,final String parentCompName, final int numPods, int numCont ); static Map<String, Integer> getAllComponentIdForEnv(int envId,String platform); static void deletePromLookup(int envId, int compId, String lookupVaule);  }