com.netflix.eureka.resources.StatusResource Java Examples

The following examples show how to use com.netflix.eureka.resources.StatusResource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EurekaResource.java    From flair-registry with Apache License 2.0 6 votes vote down vote up
private Map<String, Object> getEurekaStatus() {

        Map<String, Object> stats = new HashMap<>();
        stats.put("time", new Date());
        stats.put("currentTime", StatusResource.getCurrentTimeAsString());
        stats.put("upTime", StatusInfo.getUpTime());
        stats.put("environment", ConfigurationManager.getDeploymentContext()
            .getDeploymentEnvironment());
        stats.put("datacenter", ConfigurationManager.getDeploymentContext()
            .getDeploymentDatacenter());

        PeerAwareInstanceRegistry registry = getRegistry();

        stats.put("isBelowRenewThreshold", registry.isBelowRenewThresold() == 1);

        populateInstanceInfo(stats);

        return stats;
    }
 
Example #2
Source File: EurekaResource.java    From flair-registry with Apache License 2.0 6 votes vote down vote up
private void populateInstanceInfo(Map<String, Object> model) {

        StatusInfo statusInfo;
        try {
            statusInfo = new StatusResource().getStatusInfo();
        } catch (Exception e) {
            log.error(e.getMessage());
            statusInfo = StatusInfo.Builder.newBuilder().isHealthy(false).build();
        }
        if (statusInfo != null && statusInfo.getGeneralStats() != null) {
            model.put("generalStats", statusInfo.getGeneralStats());
        }
        if (statusInfo != null && statusInfo.getInstanceInfo() != null) {
            InstanceInfo instanceInfo = statusInfo.getInstanceInfo();
            Map<String, String> instanceMap = new HashMap<>();
            instanceMap.put("ipAddr", instanceInfo.getIPAddr());
            instanceMap.put("status", instanceInfo.getStatus().toString());
            model.put("instanceInfo", instanceMap);
        }
    }
 
Example #3
Source File: EurekaResource.java    From jhipster-microservices-example with Apache License 2.0 6 votes vote down vote up
private Map<String, Object> getEurekaStatus() {

        Map<String, Object> stats = new HashMap<>();
        stats.put("time", new Date());
        stats.put("currentTime", StatusResource.getCurrentTimeAsString());
        stats.put("upTime", StatusInfo.getUpTime());
        stats.put("environment", ConfigurationManager.getDeploymentContext()
            .getDeploymentEnvironment());
        stats.put("datacenter", ConfigurationManager.getDeploymentContext()
            .getDeploymentDatacenter());

        PeerAwareInstanceRegistry registry = getRegistry();

        stats.put("isBelowRenewThreshold", registry.isBelowRenewThresold() == 1);

        populateInstanceInfo(stats);

        return stats;
    }
 
Example #4
Source File: EurekaResource.java    From jhipster-microservices-example with Apache License 2.0 6 votes vote down vote up
private void populateInstanceInfo(Map<String, Object> model) {

        StatusInfo statusInfo;
        try {
            statusInfo = new StatusResource().getStatusInfo();
        } catch (Exception e) {
            log.error(e.getMessage());
            statusInfo = StatusInfo.Builder.newBuilder().isHealthy(false).build();
        }
        if (statusInfo != null && statusInfo.getGeneralStats() != null) {
            model.put("generalStats", statusInfo.getGeneralStats());
        }
        if (statusInfo != null && statusInfo.getInstanceInfo() != null) {
            InstanceInfo instanceInfo = statusInfo.getInstanceInfo();
            Map<String, String> instanceMap = new HashMap<>();
            instanceMap.put("ipAddr", instanceInfo.getIPAddr());
            instanceMap.put("status", instanceInfo.getStatus().toString());
            model.put("instanceInfo", instanceMap);
        }
    }
 
Example #5
Source File: EurekaController.java    From didi-eureka-server with MIT License 6 votes vote down vote up
@RequestMapping(method = RequestMethod.GET)
public String status(HttpServletRequest request, Map<String, Object> model) {
	populateBase(request, model);
	populateApps(model);
	StatusInfo statusInfo;
	try {
		statusInfo = new StatusResource().getStatusInfo();
	}
	catch (Exception e) {
		statusInfo = StatusInfo.Builder.newBuilder().isHealthy(false).build();
	}
	model.put("statusInfo", statusInfo);
	populateInstanceInfo(model, statusInfo);
	filterReplicas(model, statusInfo);
	return "eureka/status";
}
 
Example #6
Source File: EurekaController.java    From didi-eureka-server with MIT License 6 votes vote down vote up
private void populateHeader(Map<String, Object> model) {
	model.put("currentTime", StatusResource.getCurrentTimeAsString());
	model.put("upTime", StatusInfo.getUpTime());
	model.put("environment", ConfigurationManager.getDeploymentContext()
			.getDeploymentEnvironment());
	model.put("datacenter", ConfigurationManager.getDeploymentContext()
			.getDeploymentDatacenter());
	PeerAwareInstanceRegistry registry = getRegistry();
	model.put("registry", registry);
	model.put("isBelowRenewThresold", registry.isBelowRenewThresold() == 1);
	DataCenterInfo info = applicationInfoManager.getInfo().getDataCenterInfo();
	if (info.getName() == DataCenterInfo.Name.Amazon) {
		AmazonInfo amazonInfo = (AmazonInfo) info;
		model.put("amazonInfo", amazonInfo);
		model.put("amiId", amazonInfo.get(AmazonInfo.MetaDataKey.amiId));
		model.put("availabilityZone",
				amazonInfo.get(AmazonInfo.MetaDataKey.availabilityZone));
		model.put("instanceId", amazonInfo.get(AmazonInfo.MetaDataKey.instanceId));
	}
}
 
Example #7
Source File: EurekaResource.java    From jhipster-registry with Apache License 2.0 6 votes vote down vote up
private Map<String, Object> getEurekaStatus() {

        Map<String, Object> stats = new HashMap<>();
        stats.put("time", new Date());
        stats.put("currentTime", StatusResource.getCurrentTimeAsString());
        stats.put("upTime", StatusInfo.getUpTime());
        stats.put("environment", ConfigurationManager.getDeploymentContext()
            .getDeploymentEnvironment());
        stats.put("datacenter", ConfigurationManager.getDeploymentContext()
            .getDeploymentDatacenter());

        PeerAwareInstanceRegistry registry = getRegistry();

        stats.put("isBelowRenewThreshold", registry.isBelowRenewThresold() == 1);

        populateInstanceInfo(stats);

        return stats;
    }
 
Example #8
Source File: EurekaResource.java    From jhipster-registry with Apache License 2.0 6 votes vote down vote up
private void populateInstanceInfo(Map<String, Object> model) {

        StatusInfo statusInfo;
        try {
            statusInfo = new StatusResource().getStatusInfo();
        } catch (Exception e) {
            log.error(e.getMessage());
            statusInfo = StatusInfo.Builder.newBuilder().isHealthy(false).build();
        }
        if (statusInfo != null && statusInfo.getGeneralStats() != null) {
            model.put("generalStats", statusInfo.getGeneralStats());
        }
        if (statusInfo != null && statusInfo.getInstanceInfo() != null) {
            InstanceInfo instanceInfo = statusInfo.getInstanceInfo();
            Map<String, String> instanceMap = new HashMap<>();
            instanceMap.put("ipAddr", instanceInfo.getIPAddr());
            instanceMap.put("status", instanceInfo.getStatus().toString());
            model.put("instanceInfo", instanceMap);
        }
    }
 
Example #9
Source File: EurekaController.java    From spring-cloud-netflix with Apache License 2.0 6 votes vote down vote up
@RequestMapping(method = RequestMethod.GET)
public String status(HttpServletRequest request, Map<String, Object> model) {
	populateBase(request, model);
	populateApps(model);
	StatusInfo statusInfo;
	try {
		statusInfo = new StatusResource().getStatusInfo();
	}
	catch (Exception e) {
		statusInfo = StatusInfo.Builder.newBuilder().isHealthy(false).build();
	}
	model.put("statusInfo", statusInfo);
	populateInstanceInfo(model, statusInfo);
	filterReplicas(model, statusInfo);
	return "eureka/status";
}
 
Example #10
Source File: EurekaController.java    From spring-cloud-netflix with Apache License 2.0 6 votes vote down vote up
private void populateHeader(Map<String, Object> model) {
	model.put("currentTime", StatusResource.getCurrentTimeAsString());
	model.put("upTime", StatusInfo.getUpTime());
	model.put("environment", "N/A"); // FIXME:
	model.put("datacenter", "N/A"); // FIXME:
	PeerAwareInstanceRegistry registry = getRegistry();
	model.put("registry", registry);
	model.put("isBelowRenewThresold", registry.isBelowRenewThresold() == 1);
	DataCenterInfo info = applicationInfoManager.getInfo().getDataCenterInfo();
	if (info.getName() == DataCenterInfo.Name.Amazon) {
		AmazonInfo amazonInfo = (AmazonInfo) info;
		model.put("amazonInfo", amazonInfo);
		model.put("amiId", amazonInfo.get(AmazonInfo.MetaDataKey.amiId));
		model.put("availabilityZone",
				amazonInfo.get(AmazonInfo.MetaDataKey.availabilityZone));
		model.put("instanceId", amazonInfo.get(AmazonInfo.MetaDataKey.instanceId));
	}
}