io.github.jhipster.registry.web.rest.vm.RouteVM Java Examples

The following examples show how to use io.github.jhipster.registry.web.rest.vm.RouteVM. 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: RoutesResource.java    From jhipster-microservices-example with Apache License 2.0 6 votes vote down vote up
@GetMapping("/routes")
@Timed
public ResponseEntity<List<RouteVM>> getRoutes() {

    List<Route> routes = routeLocator.getRoutes();
    Map<String, RouteVM> routeVMs = new HashMap<>();
    routeVMs.put(null, registryRoute());

    routes.forEach(route -> {
        RouteVM routeVM = new RouteVM();
        routeVM.setPath(route.getFullPath());
        routeVM.setPrefix(route.getPrefix());
        routeVM.setAppName(extractName(route.getId()));
        routeVM.setServiceId(route.getId());
        routeVM.setServiceInstances(discoveryClient.getInstances(route.getId()));
        routeVMs.put(route.getId(), routeVM);
    });

    fillStatus(routeVMs);

    return new ResponseEntity<>(new ArrayList<>(routeVMs.values()), HttpStatus.OK);
}
 
Example #2
Source File: RoutesResource.java    From jhipster-registry with Apache License 2.0 6 votes vote down vote up
@GetMapping("/routes")
public ResponseEntity<List<RouteVM>> getRoutes() {

    List<Route> routes = routeLocator.getRoutes();
    Map<String, RouteVM> routeVMs = new HashMap<>();
    routeVMs.put(null, registryRoute());

    routes.stream()
        .map(route -> {
            RouteVM routeVM = new RouteVM();
            routeVM.setPath(route.getFullPath());
            routeVM.setPrefix(route.getPrefix());
            routeVM.setAppName(extractName(route.getId()));
            routeVM.setServiceId(route.getId());
            routeVM.setServiceInstances(discoveryClient.getInstances(route.getId()));

            return routeVM;
        })
        // we don't need the service sets. They come in as of eureka.fetch-registry=true, which is needed for requests against UAA
        .filter(routeVM -> routeVM.getServiceInstances() == null || routeVM.getServiceInstances().isEmpty())
        .forEach(route -> routeVMs.put(route.getServiceId(), route));

    fillStatus(routeVMs);

    return new ResponseEntity<>(new ArrayList<>(routeVMs.values()), HttpStatus.OK);
}
 
Example #3
Source File: RoutesResource.java    From flair-registry with Apache License 2.0 5 votes vote down vote up
@GetMapping("/routes")
@Timed
public ResponseEntity<List<RouteVM>> getRoutes() {

    List<Route> routes = routeLocator.getRoutes();
    Map<String, RouteVM> routeVMs = new HashMap<>();
    routeVMs.put(null, registryRoute());

    routes.stream()
        .map(route -> {
            RouteVM routeVM = new RouteVM();
            routeVM.setPath(route.getFullPath());
            routeVM.setPrefix(route.getPrefix());
            routeVM.setAppName(extractName(route.getId()));
            routeVM.setServiceId(route.getId());
            routeVM.setServiceInstances(discoveryClient.getInstances(route.getId()));

            return routeVM;
        })
        // we don't need the service sets. They come in as of eureka.fetch-registry=true, which is needed for requests against UAA
        .filter(routeVM -> routeVM.getServiceInstances() == null || routeVM.getServiceInstances().isEmpty())
        .forEach(route -> routeVMs.put(route.getServiceId(), route));

    fillStatus(routeVMs);

    return new ResponseEntity<>(new ArrayList<>(routeVMs.values()), HttpStatus.OK);
}
 
Example #4
Source File: RoutesResource.java    From flair-registry with Apache License 2.0 5 votes vote down vote up
/**
 * Fill all Routes with each instance status.
 */
private void fillStatus(Map<String, RouteVM> routeVMs) {
    if (routeVMs != null && !routeVMs.isEmpty()) {
        zuulProperties.getRoutes().values().forEach(oneRoute -> {
            if (oneRoute instanceof ZuulRouteDTO) {
                routeVMs.get(oneRoute.getId()).setStatus(((ZuulRouteDTO) oneRoute).getStatus());
            }
        });
    }
}
 
Example #5
Source File: RoutesResource.java    From jhipster-microservices-example with Apache License 2.0 5 votes vote down vote up
/**
 * Fill all Routes with each instance status.
 */
private void fillStatus(Map<String, RouteVM> routeVMs) {
    if(routeVMs != null && !routeVMs.isEmpty()) {
        zuulProperties.getRoutes().values().forEach(oneRoute -> {
            if(oneRoute instanceof ZuulRouteDTO){
                routeVMs.get(oneRoute.getId()).setStatus(((ZuulRouteDTO) oneRoute).getStatus());
            }
        });
    }
}
 
Example #6
Source File: RoutesResource.java    From jhipster-registry with Apache License 2.0 5 votes vote down vote up
/**
 * Fill all Routes with each instance status.
 */
private void fillStatus(Map<String, RouteVM> routeVMs) {
    if (routeVMs != null && !routeVMs.isEmpty()) {
        zuulProperties.getRoutes().values().forEach(oneRoute -> {
            if (oneRoute instanceof ZuulRouteDTO) {
                routeVMs.get(oneRoute.getId()).setStatus(((ZuulRouteDTO) oneRoute).getStatus());
            }
        });
    }
}
 
Example #7
Source File: RoutesResource.java    From flair-registry with Apache License 2.0 4 votes vote down vote up
/**
 * Return the registry routeVM
 */
private RouteVM registryRoute() {
    return new RouteVM("/**", null, null, registryName, InstanceInfo.InstanceStatus.UP.toString(), null);
}
 
Example #8
Source File: RoutesResource.java    From jhipster-microservices-example with Apache License 2.0 4 votes vote down vote up
/**
 * Return the registry routeVM
 */
private RouteVM registryRoute() {
    return new RouteVM("/**", null, null, registryName, InstanceInfo.InstanceStatus.UP.toString(), null);
}
 
Example #9
Source File: RoutesResource.java    From jhipster-registry with Apache License 2.0 4 votes vote down vote up
/**
 * Return the registry routeVM
 */
private RouteVM registryRoute() {
    return new RouteVM("/**", null, null, registryName, InstanceInfo.InstanceStatus.UP.toString(), null);
}