@Test public void testGetAllEnvironments() throws SerialException, SQLException { String name = "testallenv"; EnvironmentEntity env = daoService.createEnvironment(name, 1,url); List<EnvironmentVO> result = DBQueryUtil.getAllEnvironments(); }
public static List<EnvironmentVO> getAllEnvironments() throws SQLException { ArrayList<EnvironmentVO> environmentVOs = new ArrayList<EnvironmentVO>(); Session session = HibernateConfig.getSessionFactory().getCurrentSession(); Transaction txn = session.beginTransaction(); Criteria envCriteria = session.createCriteria(EnvironmentEntity.class); envCriteria.add(Restrictions.eq("envLock", 0)); @SuppressWarnings("unchecked") List<EnvironmentEntity> environmentEntities = envCriteria.list(); for(EnvironmentEntity entity : environmentEntities) { EnvironmentVO enVo = new EnvironmentVO(); enVo.setEnvironmentId(entity.getEnvironmentId()); enVo.setEnvironmentName(entity.getEnvironmentName()); enVo.setMarathonUrl(entity.getMarathonURL()); enVo.setMarathonCred(entity.getMarathonCred()); if(entity.getMarathonJson()!=null){ byte[] data = entity.getMarathonJson().getBytes(1, (int) entity.getMarathonJson().length()); enVo.setMarathonJson(new String(data)); } enVo.setEastMarathonUrl(entity.getEastMarathonURL()); if(entity.getEastMarathonJson()!=null){ byte[] data = entity.getEastMarathonJson().getBytes(1, (int) entity.getEastMarathonJson().length()); enVo.setEastMarathonJson(new String(data)); } enVo.setK8sUrl(entity.getK8sUrl()); enVo.setK8sCred(entity.getK8sCred()); enVo.setK8sTpsQuery(entity.getK8sTpsQuery()); enVo.setK8sLatencyQuery(entity.getK8sLatencyQuery()); enVo.setMesosTpsQuery(entity.getMesosTpsQuery()); enVo.setMesosLatencyQuery(entity.getMesosLatencyQuery()); environmentVOs.add(enVo); } txn.commit(); return environmentVOs; }
DBQueryUtil { public static List<EnvironmentVO> getAllEnvironments() throws SQLException { ArrayList<EnvironmentVO> environmentVOs = new ArrayList<EnvironmentVO>(); Session session = HibernateConfig.getSessionFactory().getCurrentSession(); Transaction txn = session.beginTransaction(); Criteria envCriteria = session.createCriteria(EnvironmentEntity.class); envCriteria.add(Restrictions.eq("envLock", 0)); @SuppressWarnings("unchecked") List<EnvironmentEntity> environmentEntities = envCriteria.list(); for(EnvironmentEntity entity : environmentEntities) { EnvironmentVO enVo = new EnvironmentVO(); enVo.setEnvironmentId(entity.getEnvironmentId()); enVo.setEnvironmentName(entity.getEnvironmentName()); enVo.setMarathonUrl(entity.getMarathonURL()); enVo.setMarathonCred(entity.getMarathonCred()); if(entity.getMarathonJson()!=null){ byte[] data = entity.getMarathonJson().getBytes(1, (int) entity.getMarathonJson().length()); enVo.setMarathonJson(new String(data)); } enVo.setEastMarathonUrl(entity.getEastMarathonURL()); if(entity.getEastMarathonJson()!=null){ byte[] data = entity.getEastMarathonJson().getBytes(1, (int) entity.getEastMarathonJson().length()); enVo.setEastMarathonJson(new String(data)); } enVo.setK8sUrl(entity.getK8sUrl()); enVo.setK8sCred(entity.getK8sCred()); enVo.setK8sTpsQuery(entity.getK8sTpsQuery()); enVo.setK8sLatencyQuery(entity.getK8sLatencyQuery()); enVo.setMesosTpsQuery(entity.getMesosTpsQuery()); enVo.setMesosLatencyQuery(entity.getMesosLatencyQuery()); environmentVOs.add(enVo); } txn.commit(); return environmentVOs; } }
DBQueryUtil { public static List<EnvironmentVO> getAllEnvironments() throws SQLException { ArrayList<EnvironmentVO> environmentVOs = new ArrayList<EnvironmentVO>(); Session session = HibernateConfig.getSessionFactory().getCurrentSession(); Transaction txn = session.beginTransaction(); Criteria envCriteria = session.createCriteria(EnvironmentEntity.class); envCriteria.add(Restrictions.eq("envLock", 0)); @SuppressWarnings("unchecked") List<EnvironmentEntity> environmentEntities = envCriteria.list(); for(EnvironmentEntity entity : environmentEntities) { EnvironmentVO enVo = new EnvironmentVO(); enVo.setEnvironmentId(entity.getEnvironmentId()); enVo.setEnvironmentName(entity.getEnvironmentName()); enVo.setMarathonUrl(entity.getMarathonURL()); enVo.setMarathonCred(entity.getMarathonCred()); if(entity.getMarathonJson()!=null){ byte[] data = entity.getMarathonJson().getBytes(1, (int) entity.getMarathonJson().length()); enVo.setMarathonJson(new String(data)); } enVo.setEastMarathonUrl(entity.getEastMarathonURL()); if(entity.getEastMarathonJson()!=null){ byte[] data = entity.getEastMarathonJson().getBytes(1, (int) entity.getEastMarathonJson().length()); enVo.setEastMarathonJson(new String(data)); } enVo.setK8sUrl(entity.getK8sUrl()); enVo.setK8sCred(entity.getK8sCred()); enVo.setK8sTpsQuery(entity.getK8sTpsQuery()); enVo.setK8sLatencyQuery(entity.getK8sLatencyQuery()); enVo.setMesosTpsQuery(entity.getMesosTpsQuery()); enVo.setMesosLatencyQuery(entity.getMesosLatencyQuery()); environmentVOs.add(enVo); } txn.commit(); return environmentVOs; } private  DBQueryUtil(); }
DBQueryUtil { public static List<EnvironmentVO> getAllEnvironments() throws SQLException { ArrayList<EnvironmentVO> environmentVOs = new ArrayList<EnvironmentVO>(); Session session = HibernateConfig.getSessionFactory().getCurrentSession(); Transaction txn = session.beginTransaction(); Criteria envCriteria = session.createCriteria(EnvironmentEntity.class); envCriteria.add(Restrictions.eq("envLock", 0)); @SuppressWarnings("unchecked") List<EnvironmentEntity> environmentEntities = envCriteria.list(); for(EnvironmentEntity entity : environmentEntities) { EnvironmentVO enVo = new EnvironmentVO(); enVo.setEnvironmentId(entity.getEnvironmentId()); enVo.setEnvironmentName(entity.getEnvironmentName()); enVo.setMarathonUrl(entity.getMarathonURL()); enVo.setMarathonCred(entity.getMarathonCred()); if(entity.getMarathonJson()!=null){ byte[] data = entity.getMarathonJson().getBytes(1, (int) entity.getMarathonJson().length()); enVo.setMarathonJson(new String(data)); } enVo.setEastMarathonUrl(entity.getEastMarathonURL()); if(entity.getEastMarathonJson()!=null){ byte[] data = entity.getEastMarathonJson().getBytes(1, (int) entity.getEastMarathonJson().length()); enVo.setEastMarathonJson(new String(data)); } enVo.setK8sUrl(entity.getK8sUrl()); enVo.setK8sCred(entity.getK8sCred()); enVo.setK8sTpsQuery(entity.getK8sTpsQuery()); enVo.setK8sLatencyQuery(entity.getK8sLatencyQuery()); enVo.setMesosTpsQuery(entity.getMesosTpsQuery()); enVo.setMesosLatencyQuery(entity.getMesosLatencyQuery()); environmentVOs.add(enVo); } txn.commit(); return environmentVOs; } 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 List<EnvironmentVO> getAllEnvironments() throws SQLException { ArrayList<EnvironmentVO> environmentVOs = new ArrayList<EnvironmentVO>(); Session session = HibernateConfig.getSessionFactory().getCurrentSession(); Transaction txn = session.beginTransaction(); Criteria envCriteria = session.createCriteria(EnvironmentEntity.class); envCriteria.add(Restrictions.eq("envLock", 0)); @SuppressWarnings("unchecked") List<EnvironmentEntity> environmentEntities = envCriteria.list(); for(EnvironmentEntity entity : environmentEntities) { EnvironmentVO enVo = new EnvironmentVO(); enVo.setEnvironmentId(entity.getEnvironmentId()); enVo.setEnvironmentName(entity.getEnvironmentName()); enVo.setMarathonUrl(entity.getMarathonURL()); enVo.setMarathonCred(entity.getMarathonCred()); if(entity.getMarathonJson()!=null){ byte[] data = entity.getMarathonJson().getBytes(1, (int) entity.getMarathonJson().length()); enVo.setMarathonJson(new String(data)); } enVo.setEastMarathonUrl(entity.getEastMarathonURL()); if(entity.getEastMarathonJson()!=null){ byte[] data = entity.getEastMarathonJson().getBytes(1, (int) entity.getEastMarathonJson().length()); enVo.setEastMarathonJson(new String(data)); } enVo.setK8sUrl(entity.getK8sUrl()); enVo.setK8sCred(entity.getK8sCred()); enVo.setK8sTpsQuery(entity.getK8sTpsQuery()); enVo.setK8sLatencyQuery(entity.getK8sLatencyQuery()); enVo.setMesosTpsQuery(entity.getMesosTpsQuery()); enVo.setMesosLatencyQuery(entity.getMesosLatencyQuery()); environmentVOs.add(enVo); } txn.commit(); return environmentVOs; } 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);  }