本文整理汇总了Java中org.springframework.cloud.netflix.zuul.filters.ZuulProperties类的典型用法代码示例。如果您正苦于以下问题:Java ZuulProperties类的具体用法?Java ZuulProperties怎么用?Java ZuulProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ZuulProperties类属于org.springframework.cloud.netflix.zuul.filters包,在下文中一共展示了ZuulProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: StoreProxyRouteLocator
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
/**
* Creates new instance of {@link StoreProxyRouteLocator}
*
* @param servletPath the application servlet path
* @param discovery the discovery service
* @param properties the zuul properties
* @param store the route store
*/
public StoreProxyRouteLocator(String servletPath, DiscoveryClient discovery,
ZuulProperties properties, ZuulRouteService store) {
super(servletPath, discovery, properties);
this.store = store;
refreshExecutor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
try {
refresh();
} catch (Throwable e) {
log.error(e.getMessage(), e);
}
}
}, 0, 1, TimeUnit.MINUTES);
}
示例2: routeStore
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@ConditionalOnMissingBean(RouteStore.class)
@Bean
public RouteStore routeStore() {
return new RouteStore() {
@Override
public List<ZuulProperties.ZuulRoute> getAllRoutes() {
return Collections.emptyList();
}
@Override
public void onRoutesChange(Consumer<List<ZuulProperties.ZuulRoute>> handleFunction) {
handleFunction.accept(getAllRoutes());
}
@Override
public List<ServiceRoute> getAllServiceRoutes() {
return Collections.emptyList();
}
};
}
示例3: shouldReportDownState
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Test
public void shouldReportDownState() {
// given
final ZuulProperties.ZuulRoute route = new ZuulProperties.ZuulRoute("/zuul", "proxied-service");
zuulProperties.getRoutes().put(route.getId(), route);
// when
final Health health = zuulRouteHealthIndicator.health();
// then
assertNotNull(health);
assertEquals(Status.DOWN, health.getStatus());
assertNull(health.getDetails().get("available"));
assertFalse(((Collection) health.getDetails().get("unavailable")).isEmpty());
}
开发者ID:jmnarloch,项目名称:zuul-route-health-spring-cloud-starter,代码行数:17,代码来源:ZuulRouteHealthIndicatorTest.java
示例4: shouldReportUpState
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Test
public void shouldReportUpState() {
// given
final ZuulProperties.ZuulRoute route = new ZuulProperties.ZuulRoute("/zuul", "proxied-service");
zuulProperties.getRoutes().put(route.getId(), route);
final List<ServiceInstance> services = new ArrayList<>();
services.add(mock(ServiceInstance.class));
when(discoveryClient.getInstances("proxied-service")).thenReturn(services);
// when
final Health health = zuulRouteHealthIndicator.health();
// then
assertNotNull(health);
assertEquals(Status.UP, health.getStatus());
assertFalse(((Collection) health.getDetails().get("available")).isEmpty());
assertNull(health.getDetails().get("unavailable"));
}
开发者ID:jmnarloch,项目名称:zuul-route-health-spring-cloud-starter,代码行数:21,代码来源:ZuulRouteHealthIndicatorTest.java
示例5: getRestoredPath
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
private String getRestoredPath(ZuulProperties zuulProperties, Route route,
UriComponents redirectedUriComps) {
StringBuilder path = new StringBuilder();
String redirectedPathWithoutGlobal = downstreamHasGlobalPrefix(zuulProperties)
? redirectedUriComps.getPath()
.substring(("/" + zuulProperties.getPrefix()).length())
: redirectedUriComps.getPath();
if (downstreamHasGlobalPrefix(zuulProperties)) {
path.append("/" + zuulProperties.getPrefix());
}
else {
path.append(zuulHasGlobalPrefix(zuulProperties)
? "/" + zuulProperties.getPrefix() : "");
}
path.append(downstreamHasRoutePrefix(route) ? "" : "/" + route.getPrefix())
.append(redirectedPathWithoutGlobal);
return path.toString();
}
示例6: getSetter
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
protected static Setter getSetter(final String commandKey,
ZuulProperties zuulProperties, IClientConfig config) {
// @formatter:off
Setter commandSetter = Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RibbonCommand"))
.andCommandKey(HystrixCommandKey.Factory.asKey(commandKey));
final HystrixCommandProperties.Setter setter = createSetter(config, commandKey, zuulProperties);
if (zuulProperties.getRibbonIsolationStrategy() == ExecutionIsolationStrategy.SEMAPHORE){
final String name = ZuulConstants.ZUUL_EUREKA + commandKey + ".semaphore.maxSemaphores";
// we want to default to semaphore-isolation since this wraps
// 2 others commands that are already thread isolated
final DynamicIntProperty value = DynamicPropertyFactory.getInstance()
.getIntProperty(name, zuulProperties.getSemaphore().getMaxSemaphores());
setter.withExecutionIsolationSemaphoreMaxConcurrentRequests(value.get());
} else if (zuulProperties.getThreadPool().isUseSeparateThreadPools()) {
final String threadPoolKey = zuulProperties.getThreadPool().getThreadPoolKeyPrefix() + commandKey;
commandSetter.andThreadPoolKey(HystrixThreadPoolKey.Factory.asKey(threadPoolKey));
}
return commandSetter.andCommandPropertiesDefaults(setter);
// @formatter:on
}
示例7: shouldAddBackGlobalPrefixIfPresent
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Test
public void shouldAddBackGlobalPrefixIfPresent() {
RequestContext context = RequestContext.getCurrentContext();
ZuulProperties zuulProperties = new ZuulProperties();
zuulProperties.setPrefix("global");
zuulProperties.setStripPrefix(true);
LocationRewriteFilter filter = setFilterUpWith(context, zuulProperties,
new Route("service1", "/something/redirectingUri", "service1", "prefix",
false, Collections.EMPTY_SET, true),
"/global/prefix/redirectingUri",
"/something/redirectedUri;someparam?param1=abc");
filter.run();
assertThat(getLocationHeader(context).second()).isEqualTo(String.format(
"%s/global/prefix/something/redirectedUri;someparam?param1=abc",
ZUUL_BASE_URL));
}
示例8: shouldNotAddBackGlobalPrefixIfNotStripped
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Test
public void shouldNotAddBackGlobalPrefixIfNotStripped() {
RequestContext context = RequestContext.getCurrentContext();
ZuulProperties zuulProperties = new ZuulProperties();
zuulProperties.setPrefix("global");
zuulProperties.setStripPrefix(false);
LocationRewriteFilter filter = setFilterUpWith(context, zuulProperties,
new Route("service1", "/something/redirectingUri", "service1", "prefix",
false, Collections.EMPTY_SET, true),
"/global/prefix/redirectingUri",
"/global/something/redirectedUri;someparam?param1=abc");
filter.run();
assertThat(getLocationHeader(context).second()).isEqualTo(String.format(
"%s/global/prefix/something/redirectedUri;someparam?param1=abc",
ZUUL_BASE_URL));
}
示例9: setFilterUpWith
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
private LocationRewriteFilter setFilterUpWith(RequestContext context,
ZuulProperties zuulProperties, Route route, String toZuulRequestUri,
String redirectedUri) {
MockHttpServletRequest httpServletRequest = new MockHttpServletRequest();
httpServletRequest.setRequestURI(toZuulRequestUri);
httpServletRequest.setServerName(ZUUL_HOST);
httpServletRequest.setScheme(ZUUL_SCHEME);
httpServletRequest.setServerPort(ZUUL_PORT);
context.setRequest(httpServletRequest);
MockHttpServletResponse httpServletResponse = new MockHttpServletResponse();
context.getZuulResponseHeaders().add(new Pair<>("Location",
String.format("%s%s", SERVER_BASE_URL, redirectedUri)));
context.setResponse(httpServletResponse);
RouteLocator routeLocator = mock(RouteLocator.class);
when(routeLocator.getMatchingRoute(toZuulRequestUri)).thenReturn(route);
LocationRewriteFilter filter = new LocationRewriteFilter(zuulProperties,
routeLocator);
return filter;
}
示例10: createFilter
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
private SendResponseFilter createFilter(ZuulProperties properties, String content, String characterEncoding, MockHttpServletResponse response, boolean streamContent) throws Exception {
HttpServletRequest request = new MockHttpServletRequest();
RequestContext context = new RequestContext();
context.setRequest(request);
context.setResponse(response);
if (characterEncoding != null) {
response.setCharacterEncoding(characterEncoding);
}
if (streamContent) {
context.setResponseDataStream(new ByteArrayInputStream(content.getBytes(characterEncoding)));
} else {
context.setResponseBody(content);
}
context.addZuulResponseHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(content.length()));
context.set("error.status_code", HttpStatus.NOT_FOUND.value());
RequestContext.testSetCurrentContext(context);
SendResponseFilter filter = new SendResponseFilter(properties);
return filter;
}
示例11: testHystrixTimeoutValueRibbonTimeouts
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Test
public void testHystrixTimeoutValueRibbonTimeouts() throws Exception {
SpringClientFactory springClientFactory = mock(SpringClientFactory.class);
ZuulProperties zuulProperties = new ZuulProperties();
OkHttpLoadBalancingClient loadBalancingHttpClient = mock(OkHttpLoadBalancingClient.class);
IClientConfig clientConfig = new DefaultClientConfigImpl();
clientConfig.set(IClientConfigKey.Keys.ConnectTimeout, 100);
clientConfig.set(IClientConfigKey.Keys.ReadTimeout, 500);
doReturn(loadBalancingHttpClient).when(springClientFactory).getClient(anyString(),
eq(OkHttpLoadBalancingClient.class));
doReturn(clientConfig).when(springClientFactory).getClientConfig(anyString());
OkHttpRibbonCommandFactory commandFactory = new OkHttpRibbonCommandFactory(springClientFactory, zuulProperties, new HashSet<FallbackProvider>());
RibbonCommandContext context = mock(RibbonCommandContext.class);
doReturn("service").when(context).getServiceId();
OkHttpRibbonCommand ribbonCommand = commandFactory.create(context);
assertEquals(600, ribbonCommand.getProperties().executionTimeoutInMilliseconds().get().intValue());
}
示例12: testHystrixTimeoutValueRibbonTimeouts
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Test
public void testHystrixTimeoutValueRibbonTimeouts() throws Exception {
SpringClientFactory springClientFactory = mock(SpringClientFactory.class);
ZuulProperties zuulProperties = new ZuulProperties();
RibbonLoadBalancingHttpClient loadBalancingHttpClient = mock(RibbonLoadBalancingHttpClient.class);
IClientConfig clientConfig = new DefaultClientConfigImpl();
clientConfig.set(IClientConfigKey.Keys.ConnectTimeout, 100);
clientConfig.set(IClientConfigKey.Keys.ReadTimeout, 500);
doReturn(loadBalancingHttpClient).when(springClientFactory).getClient(anyString(),
eq(RibbonLoadBalancingHttpClient.class));
doReturn(clientConfig).when(springClientFactory).getClientConfig(anyString());
HttpClientRibbonCommandFactory ribbonCommandFactory = new HttpClientRibbonCommandFactory(springClientFactory, zuulProperties, new HashSet<FallbackProvider>());
RibbonCommandContext context = mock(RibbonCommandContext.class);
doReturn("service").when(context).getServiceId();
HttpClientRibbonCommand ribbonCommand = ribbonCommandFactory.create(context);
assertEquals(600, ribbonCommand.getProperties().executionTimeoutInMilliseconds().get().intValue());
}
示例13: locateRoutes
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Override
protected LinkedHashMap<String, ZuulProperties.ZuulRoute> locateRoutes() {
LinkedHashMap<String, ZuulProperties.ZuulRoute> routeMap = super.locateRoutes();
routeStore.getAllRoutes().forEach(route -> routeMap.put(route.getPath(), route));
return routeMap;
}
示例14: locateRoutes
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
@Override
protected LinkedHashMap<String, ZuulRoute> locateRoutes() {
LinkedHashMap<String, ZuulRoute> routesMap = new LinkedHashMap<String, ZuulRoute>();
routesMap.putAll(super.locateRoutes());
for (ZuulProperties.ZuulRoute route : findAll()) {
routesMap.put(route.getPath(), route);
}
return routesMap;
}
示例15: findAll
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; //导入依赖的package包/类
private List<ZuulProperties.ZuulRoute> findAll() {
Set<ZuulRouteDto> routers = Sets.newHashSet();
if (!hasLoaded) {
routers.addAll(store.loadAllRoute());
hasLoaded = true;
} else {
routers.addAll(store.loadTop10Route());
}
routesCache.addAll(routers);
return Lists.transform(Lists.newArrayList(routesCache),
new Function<ZuulRouteDto, ZuulProperties.ZuulRoute>() {
@Override
public ZuulRoute apply(ZuulRouteDto input) {
String id = input.getRouteId();
String path = input.getRoutePath();
String service_id = input.getServiceId();
String url = input.getRouteUrl();
boolean strip_prefix = input.getStripPrefix() != null ? input.getStripPrefix() : true;
Boolean retryable = input.getRetryAble();
String sensitiveHeader = input.getSensitiveHeaders();
String[] sensitiveHeaders = null;
if (sensitiveHeader != null) {
sensitiveHeaders = StringUtils.split(sensitiveHeader, ",");
} else {
sensitiveHeaders = new String[] {};
}
return new ZuulRoute(id, path, service_id, url, strip_prefix, retryable,
new HashSet<String>(Arrays.asList(sensitiveHeaders)));
}
});
}