com.alibaba.dubbo.registry.common.route.RouteUtils Java Examples

The following examples show how to use com.alibaba.dubbo.registry.common.route.RouteUtils. 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: Routes.java    From dubbox with Apache License 2.0 6 votes vote down vote up
/**
 * 选择消费者
 * @param context
 */
public void routeselect(Map<String, Object> context){
	long rid = Long.valueOf((String)context.get("id"));
    context.put("id", rid);
    
    Route route = routeService.findRoute(rid);
    if (route == null) {
        throw new IllegalStateException("Route(id=" + rid + ") is not existed!");
    }
    
    context.put("route", route);
    // 获取数据
    List<Consumer> consumers = consumerService.findByService(route.getService());
    context.put("consumers", consumers);
    
    Map<String, Boolean> matchRoute = new HashMap<String, Boolean>();
    for(Consumer c : consumers) {
        matchRoute.put(c.getAddress(), RouteUtils.matchRoute(c.getAddress(), null, route, null));
    }
    context.put("matchRoute", matchRoute);
}
 
Example #2
Source File: Routes.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
/**
 * 选择消费者
 * @param context
 */
public void routeselect(Map<String, Object> context){
	long rid = Long.valueOf((String)context.get("id"));
    context.put("id", rid);
    
    Route route = routeService.findRoute(rid);
    if (route == null) {
        throw new IllegalStateException("Route(id=" + rid + ") is not existed!");
    }
    
    context.put("route", route);
    // 获取数据
    List<Consumer> consumers = consumerService.findByService(route.getService());
    context.put("consumers", consumers);
    
    Map<String, Boolean> matchRoute = new HashMap<String, Boolean>();
    for(Consumer c : consumers) {
        matchRoute.put(c.getAddress(), RouteUtils.matchRoute(c.getAddress(), null, route, null));
    }
    context.put("matchRoute", matchRoute);
}
 
Example #3
Source File: Routes.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
/**
 * 选择消费者
 * @param context
 */
public void routeselect(Map<String, Object> context){
	long rid = Long.valueOf((String)context.get("id"));
    context.put("id", rid);
    
    Route route = routeService.findRoute(rid);
    if (route == null) {
        throw new IllegalStateException("Route(id=" + rid + ") is not existed!");
    }
    
    context.put("route", route);
    // 获取数据
    List<Consumer> consumers = consumerService.findByService(route.getService());
    context.put("consumers", consumers);
    
    Map<String, Boolean> matchRoute = new HashMap<String, Boolean>();
    for(Consumer c : consumers) {
        matchRoute.put(c.getAddress(), RouteUtils.matchRoute(c.getAddress(), null, route, null));
    }
    context.put("matchRoute", matchRoute);
}
 
Example #4
Source File: Routes.java    From dubbox with Apache License 2.0 6 votes vote down vote up
/**
 * 选择消费者
 * @param context
 */
public void routeselect(Map<String, Object> context){
	long rid = Long.valueOf((String)context.get("id"));
    context.put("id", rid);
    
    Route route = routeService.findRoute(rid);
    if (route == null) {
        throw new IllegalStateException("Route(id=" + rid + ") is not existed!");
    }
    
    context.put("route", route);
    // 获取数据
    List<Consumer> consumers = consumerService.findByService(route.getService());
    context.put("consumers", consumers);
    
    Map<String, Boolean> matchRoute = new HashMap<String, Boolean>();
    for(Consumer c : consumers) {
        matchRoute.put(c.getAddress(), RouteUtils.matchRoute(c.getAddress(), null, route, null));
    }
    context.put("matchRoute", matchRoute);
}
 
Example #5
Source File: Routes.java    From dubbox with Apache License 2.0 6 votes vote down vote up
/**
 * 选择消费者
 * @param context
 */
public void routeselect(Map<String, Object> context){
	long rid = Long.valueOf((String)context.get("id"));
    context.put("id", rid);
    
    Route route = routeService.findRoute(rid);
    if (route == null) {
        throw new IllegalStateException("Route(id=" + rid + ") is not existed!");
    }
    
    context.put("route", route);
    // 获取数据
    List<Consumer> consumers = consumerService.findByService(route.getService());
    context.put("consumers", consumers);
    
    Map<String, Boolean> matchRoute = new HashMap<String, Boolean>();
    for(Consumer c : consumers) {
        matchRoute.put(c.getAddress(), RouteUtils.matchRoute(c.getAddress(), null, route, null));
    }
    context.put("matchRoute", matchRoute);
}
 
Example #6
Source File: Consumers.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void show(Long id, Map<String, Object> context) {
	Consumer consumer = consumerService.findConsumer(id);
	List<Provider> providers = providerService.findByService(consumer.getService());
	List<Route> routes = routeService.findByService(consumer.getService());
	List<Override> overrides = overrideService.findByService(consumer.getService());
	List<Route> routed = new ArrayList<Route>();
    consumer.setProviders(RouteUtils.route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
	consumer.setRoutes(routed);
	OverrideUtils.setConsumerOverrides(consumer, overrides);
	context.put("consumer", consumer);
	context.put("providers", consumer.getProviders());
	context.put("routes", consumer.getRoutes());
	context.put("overrides", consumer.getOverrides());
}
 
Example #7
Source File: Consumers.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public void show(Long id, Map<String, Object> context) {
	Consumer consumer = consumerService.findConsumer(id);
	List<Provider> providers = providerService.findByService(consumer.getService());
	List<Route> routes = routeService.findByService(consumer.getService());
	List<Override> overrides = overrideService.findByService(consumer.getService());
	List<Route> routed = new ArrayList<Route>();
    consumer.setProviders(RouteUtils.route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
	consumer.setRoutes(routed);
	OverrideUtils.setConsumerOverrides(consumer, overrides);
	context.put("consumer", consumer);
	context.put("providers", consumer.getProviders());
	context.put("routes", consumer.getRoutes());
	context.put("overrides", consumer.getOverrides());
}
 
Example #8
Source File: Consumers.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void show(Long id, Map<String, Object> context) {
	Consumer consumer = consumerService.findConsumer(id);
	List<Provider> providers = providerService.findByService(consumer.getService());
	List<Route> routes = routeService.findByService(consumer.getService());
	List<Override> overrides = overrideService.findByService(consumer.getService());
	List<Route> routed = new ArrayList<Route>();
    consumer.setProviders(RouteUtils.route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
	consumer.setRoutes(routed);
	OverrideUtils.setConsumerOverrides(consumer, overrides);
	context.put("consumer", consumer);
	context.put("providers", consumer.getProviders());
	context.put("routes", consumer.getRoutes());
	context.put("overrides", consumer.getOverrides());
}
 
Example #9
Source File: Consumers.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void show(Long id, Map<String, Object> context) {
	Consumer consumer = consumerService.findConsumer(id);
	List<Provider> providers = providerService.findByService(consumer.getService());
	List<Route> routes = routeService.findByService(consumer.getService());
	List<Override> overrides = overrideService.findByService(consumer.getService());
	List<Route> routed = new ArrayList<Route>();
    consumer.setProviders(RouteUtils.route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
	consumer.setRoutes(routed);
	OverrideUtils.setConsumerOverrides(consumer, overrides);
	context.put("consumer", consumer);
	context.put("providers", consumer.getProviders());
	context.put("routes", consumer.getRoutes());
	context.put("overrides", consumer.getOverrides());
}
 
Example #10
Source File: Consumers.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void show(Long id, Map<String, Object> context) {
	Consumer consumer = consumerService.findConsumer(id);
	List<Provider> providers = providerService.findByService(consumer.getService());
	List<Route> routes = routeService.findByService(consumer.getService());
	List<Override> overrides = overrideService.findByService(consumer.getService());
	List<Route> routed = new ArrayList<Route>();
    consumer.setProviders(RouteUtils.route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
	consumer.setRoutes(routed);
	OverrideUtils.setConsumerOverrides(consumer, overrides);
	context.put("consumer", consumer);
	context.put("providers", consumer.getProviders());
	context.put("routes", consumer.getRoutes());
	context.put("overrides", consumer.getOverrides());
}
 
Example #11
Source File: Consumers.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public void index(Map<String, Object> context) throws Exception {
    String service = (String) context.get("service");
    String application = (String) context.get("application");
    String address = (String) context.get("address");
    List<Consumer> consumers;
    List<Override> overrides;
    List<Provider> providers = null;
	List<Route> routes = null;
    // service
    if (service != null && service.length() > 0) {
        consumers = consumerService.findByService(service);
        overrides = overrideService.findByService(service);
        providers = providerService.findByService(service);
    	routes = routeService.findByService(service);
    }
    // address
    else if (address != null && address.length() > 0) {
        consumers = consumerService.findByAddress(address);
        overrides = overrideService.findByAddress(Tool.getIP(address));
    }
    // application
    else if (application != null && application.length() > 0) {
        consumers = consumerService.findByApplication(application);
        overrides = overrideService.findByApplication(application);
    }
    // all
    else {
        consumers = consumerService.findAll();
        overrides = overrideService.findAll();
    }
    if (consumers != null && consumers.size() > 0) {
        for (Consumer consumer : consumers) {
        	if (service == null || service.length() == 0) {
        		providers = providerService.findByService(consumer.getService());
        		routes = routeService.findByService(consumer.getService());
        	}
            List<Route> routed = new ArrayList<Route>();
            consumer.setProviders(RouteUtils.route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
        	consumer.setRoutes(routed);
        	OverrideUtils.setConsumerOverrides(consumer, overrides);
        }
    }
    context.put("consumers", consumers);
}
 
Example #12
Source File: Consumers.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public void index(Map<String, Object> context) throws Exception {
    String service = (String) context.get("service");
    String application = (String) context.get("application");
    String address = (String) context.get("address");
    List<Consumer> consumers;
    List<Override> overrides;
    List<Provider> providers = null;
	List<Route> routes = null;
    // service
    if (service != null && service.length() > 0) {
        consumers = consumerService.findByService(service);
        overrides = overrideService.findByService(service);
        providers = providerService.findByService(service);
    	routes = routeService.findByService(service);
    }
    // address
    else if (address != null && address.length() > 0) {
        consumers = consumerService.findByAddress(address);
        overrides = overrideService.findByAddress(Tool.getIP(address));
    }
    // application
    else if (application != null && application.length() > 0) {
        consumers = consumerService.findByApplication(application);
        overrides = overrideService.findByApplication(application);
    }
    // all
    else {
        consumers = consumerService.findAll();
        overrides = overrideService.findAll();
    }
    if (consumers != null && consumers.size() > 0) {
        for (Consumer consumer : consumers) {
        	if (service == null || service.length() == 0) {
        		providers = providerService.findByService(consumer.getService());
        		routes = routeService.findByService(consumer.getService());
        	}
            List<Route> routed = new ArrayList<Route>();
            consumer.setProviders(RouteUtils.route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
        	consumer.setRoutes(routed);
        	OverrideUtils.setConsumerOverrides(consumer, overrides);
        }
    }
    context.put("consumers", consumers);
}
 
Example #13
Source File: Consumers.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
public void index(Map<String, Object> context) throws Exception {
    String service = (String) context.get("service");
    String application = (String) context.get("application");
    String address = (String) context.get("address");
    List<Consumer> consumers;
    List<Override> overrides;
    List<Provider> providers = null;
	List<Route> routes = null;
    // service
    if (service != null && service.length() > 0) {
        consumers = consumerService.findByService(service);
        overrides = overrideService.findByService(service);
        providers = providerService.findByService(service);
    	routes = routeService.findByService(service);
    }
    // address
    else if (address != null && address.length() > 0) {
        consumers = consumerService.findByAddress(address);
        overrides = overrideService.findByAddress(Tool.getIP(address));
    }
    // application
    else if (application != null && application.length() > 0) {
        consumers = consumerService.findByApplication(application);
        overrides = overrideService.findByApplication(application);
    }
    // all
    else {
        consumers = consumerService.findAll();
        overrides = overrideService.findAll();
    }
    if (consumers != null && consumers.size() > 0) {
        for (Consumer consumer : consumers) {
        	if (service == null || service.length() == 0) {
        		providers = providerService.findByService(consumer.getService());
        		routes = routeService.findByService(consumer.getService());
        	}
            List<Route> routed = new ArrayList<Route>();
            consumer.setProviders(RouteUtils.route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
        	consumer.setRoutes(routed);
        	OverrideUtils.setConsumerOverrides(consumer, overrides);
        }
    }
    context.put("consumers", consumers);
}
 
Example #14
Source File: Consumers.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public void index(Map<String, Object> context) throws Exception {
    String service = (String) context.get("service");
    String application = (String) context.get("application");
    String address = (String) context.get("address");
    List<Consumer> consumers;
    List<Override> overrides;
    List<Provider> providers = null;
	List<Route> routes = null;
    // service
    if (service != null && service.length() > 0) {
        consumers = consumerService.findByService(service);
        overrides = overrideService.findByService(service);
        providers = providerService.findByService(service);
    	routes = routeService.findByService(service);
    }
    // address
    else if (address != null && address.length() > 0) {
        consumers = consumerService.findByAddress(address);
        overrides = overrideService.findByAddress(Tool.getIP(address));
    }
    // application
    else if (application != null && application.length() > 0) {
        consumers = consumerService.findByApplication(application);
        overrides = overrideService.findByApplication(application);
    }
    // all
    else {
        consumers = consumerService.findAll();
        overrides = overrideService.findAll();
    }
    if (consumers != null && consumers.size() > 0) {
        for (Consumer consumer : consumers) {
        	if (service == null || service.length() == 0) {
        		providers = providerService.findByService(consumer.getService());
        		routes = routeService.findByService(consumer.getService());
        	}
            List<Route> routed = new ArrayList<Route>();
            consumer.setProviders(RouteUtils.route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
        	consumer.setRoutes(routed);
        	OverrideUtils.setConsumerOverrides(consumer, overrides);
        }
    }
    context.put("consumers", consumers);
}
 
Example #15
Source File: Consumers.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public void index(Map<String, Object> context) throws Exception {
    String service = (String) context.get("service");
    String application = (String) context.get("application");
    String address = (String) context.get("address");
    List<Consumer> consumers;
    List<Override> overrides;
    List<Provider> providers = null;
	List<Route> routes = null;
    // service
    if (service != null && service.length() > 0) {
        consumers = consumerService.findByService(service);
        overrides = overrideService.findByService(service);
        providers = providerService.findByService(service);
    	routes = routeService.findByService(service);
    }
    // address
    else if (address != null && address.length() > 0) {
        consumers = consumerService.findByAddress(address);
        overrides = overrideService.findByAddress(Tool.getIP(address));
    }
    // application
    else if (application != null && application.length() > 0) {
        consumers = consumerService.findByApplication(application);
        overrides = overrideService.findByApplication(application);
    }
    // all
    else {
        consumers = consumerService.findAll();
        overrides = overrideService.findAll();
    }
    if (consumers != null && consumers.size() > 0) {
        for (Consumer consumer : consumers) {
        	if (service == null || service.length() == 0) {
        		providers = providerService.findByService(consumer.getService());
        		routes = routeService.findByService(consumer.getService());
        	}
            List<Route> routed = new ArrayList<Route>();
            consumer.setProviders(RouteUtils.route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
        	consumer.setRoutes(routed);
        	OverrideUtils.setConsumerOverrides(consumer, overrides);
        }
    }
    context.put("consumers", consumers);
}