• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LoadBalancerCommand类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.netflix.loadbalancer.reactive.LoadBalancerCommand的典型用法代码示例。如果您正苦于以下问题:Java LoadBalancerCommand类的具体用法?Java LoadBalancerCommand怎么用?Java LoadBalancerCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LoadBalancerCommand类属于com.netflix.loadbalancer.reactive包,在下文中一共展示了LoadBalancerCommand类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sendBatches

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
@Override
public AsyncFuture<Void> sendBatches(final Collection<Batch> batches) {
    final List<Callable<AsyncFuture<Void>>> callables = new ArrayList<>();

    for (final Batch b : batches) {
        callables.add(() -> {
            final Observable<Void> observable = LoadBalancerCommand.<Void>builder()
                .withLoadBalancer(loadBalancer)
                .build()
                .submit(server -> toObservable(clientFactory.newClient(server).sendBatch(b)));

            return fromObservable(observable);
        });
    }

    return async.eventuallyCollect(callables, VOID_COLLECTOR, PARALLELISM);
}
 
开发者ID:spotify,项目名称:ffwd,代码行数:18,代码来源:HttpPluginSink.java


示例2: LoadBalancingHttpClient

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
protected LoadBalancingHttpClient(Builder<I, O> builder) {
    super(builder.lb, builder.config, new RequestSpecificRetryHandler(true, true, builder.retryHandler, null), builder.pipelineConfigurator, builder.poolCleanerScheduler);
    requestIdHeaderName = getProperty(IClientConfigKey.Keys.RequestIdHeaderName, null, null);
    requestIdProvider = (requestIdHeaderName != null) 
                      ? new HttpRequestIdProvider(requestIdHeaderName, RxContexts.DEFAULT_CORRELATOR)
                      : null;
    this.listeners = new CopyOnWriteArrayList<ExecutionListener<HttpClientRequest<I>, HttpClientResponse<O>>>(builder.listeners);
    defaultCommandBuilder = LoadBalancerCommand.<HttpClientResponse<O>>builder()
            .withLoadBalancerContext(lbContext)
            .withListeners(this.listeners)
            .withClientConfig(builder.config)
            .withRetryHandler(builder.retryHandler)
            .build();
    this.responseToErrorPolicy = builder.responseToErrorPolicy;
    this.backoffStrategy = builder.backoffStrategy;
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:17,代码来源:LoadBalancingHttpClient.java


示例3: submit

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
public Observable<DatagramPacket> submit(final String content) {
    return LoadBalancerCommand.<DatagramPacket>builder()
            .withLoadBalancerContext(lbContext)
            .build()
            .submit(new ServerOperation<DatagramPacket>() {
                @Override
                public Observable<DatagramPacket> call(Server server) {
                    RxClient<DatagramPacket, DatagramPacket> rxClient = getOrCreateRxClient(server);
                    return rxClient.connect().flatMap(new Func1<ObservableConnection<DatagramPacket, DatagramPacket>, Observable<? extends DatagramPacket>>() {
                        @Override
                        public Observable<? extends DatagramPacket> call(ObservableConnection<DatagramPacket, DatagramPacket> connection) {
                            connection.writeStringAndFlush(content);
                            return connection.getInput().timeout(10, TimeUnit.MILLISECONDS).take(1);
                        }
                    });
                }
            });
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:19,代码来源:MyUDPClient.java


示例4: call

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
public String call(final String path) throws Exception {
    return LoadBalancerCommand.<String>builder()
            .withLoadBalancer(loadBalancer)
            .build()
            .submit(new ServerOperation<String>() {
        @Override
        public Observable<String> call(Server server) {
            URL url;
            try {
                url = new URL("http://" + server.getHost() + ":" + server.getPort() + path);
                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                return Observable.just(conn.getResponseMessage());
            } catch (Exception e) {
                return Observable.error(e);
            }
        }
    }).toBlocking().first();
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:19,代码来源:URLConnectionLoadBalancer.java


示例5: loadBalanceRESTOperation

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
private <T, R> R loadBalanceRESTOperation(String endpointURI,
   		Class<T> entityClass, Function<RESTClient<T>, R> operation)
   				throws NotFoundException, LoadBalancerTimeoutException {
   	R r = null;
   	loadBalancerModificationLock.readLock().lock();
   	try {
   		if (loadBalancer == null) {
       		LOG.warn("Load Balancer was not initialized for service: " + targetService.getServiceName()
       			+ ". Is Registry up?");
       		updateLoadBalancersForServiceUsingRegistry(targetService);
       	}
       	if (loadBalancer == null || loadBalancer.getAllServers().isEmpty()) {
       		LOG.warn("No Server registered for Service: " + targetService.getServiceName());
       	} else {
       		ServiceLoadBalancerResult<R> slbr = LoadBalancerCommand.<ServiceLoadBalancerResult<R>>builder()
                       .withLoadBalancer(loadBalancer)
                       .withRetryHandler(retryHandler)
                       .build()
                       .submit(server -> Observable.just(
                       		ServiceLoadBalancerResult.fromRESTOperation(
                       				(RESTClient<T>) getEndpointClientCollection(endpointURI, entityClass)
               				.getRESTClient(server), operation)
                       		))
                       .onErrorReturn((Throwable e) -> null).toBlocking().first();
       		if (slbr == null || slbr.getStatusCode() == Status.REQUEST_TIMEOUT.getStatusCode()) {
       			throw new LoadBalancerTimeoutException("Timout at endpoint: "
       					+ endpointURI + ", with target service: " + targetService.getServiceName(),
       					targetService);
       		} else if (slbr.getStatusCode() == Status.NOT_FOUND.getStatusCode() || slbr.getEntity() == null) {
       			throw new NotFoundException();
       		}
       		r = slbr.getEntity();
       	}
   	} finally {
   		loadBalancerModificationLock.readLock().unlock();
   	}
	return r;
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:39,代码来源:ServiceLoadBalancer.java


示例6: rxFilter

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
public Observable<ResponseEntity<Message>> rxFilter(Message input) {
    return LoadBalancerCommand.<ResponseEntity<Message>>builder()
            .withLoadBalancer(loadBalancer)
            .withRetryHandler(retryHandler)
            .build()
            .submit(server -> Observable.just(callRemoteService(input, server)));
}
 
开发者ID:looztra,项目名称:my-awesome-guestbook,代码行数:8,代码来源:FilterBackend.java


示例7: rxFilterVersion

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
public Observable<ResponseEntity<Version>> rxFilterVersion() {
    return LoadBalancerCommand.<ResponseEntity<Version>>builder()
            .withLoadBalancer(loadBalancer)
            .withRetryHandler(retryHandler)
            .build()
            .submit(server -> Observable.just(getFilterServiceVersion(server)));
}
 
开发者ID:looztra,项目名称:my-awesome-guestbook,代码行数:8,代码来源:FilterBackend.java


示例8: rxStore

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
public Observable<ResponseEntity<Message>> rxStore(Message input) {
    return LoadBalancerCommand
            .<ResponseEntity<Message>>builder()
            .withLoadBalancer(loadBalancer)
            .withRetryHandler(retryHandler)
            .build()
            .submit(
                    server -> Observable.just(callRemoteStoreService(input, server))
            );
}
 
开发者ID:looztra,项目名称:my-awesome-guestbook,代码行数:11,代码来源:StorageBackend.java


示例9: rxGet

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
public Observable<ResponseEntity<List<Message>>> rxGet() {
    return LoadBalancerCommand
            .<ResponseEntity<List<Message>>>builder()
            .withLoadBalancer(loadBalancer)
            .withRetryHandler(retryHandler)
            .build()
            .submit(
                    server -> Observable.just(callRemoteGetService(server))
            );
}
 
开发者ID:looztra,项目名称:my-awesome-guestbook,代码行数:11,代码来源:StorageBackend.java


示例10: rxStorageVersion

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
public Observable<ResponseEntity<Version>> rxStorageVersion() {
    return LoadBalancerCommand.<ResponseEntity<Version>>builder()
            .withLoadBalancer(loadBalancer)
            .withRetryHandler(retryHandler)
            .build()
            .submit(server -> Observable.just(getStorageServiceVersion(server)));
}
 
开发者ID:looztra,项目名称:my-awesome-guestbook,代码行数:8,代码来源:StorageBackend.java


示例11: ProxyController

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
@Autowired
public ProxyController(HttpProxy httpProxy, SpringClientFactory springClientFactory) {
    this.httpProxy = httpProxy;

    RibbonLoadBalancerContext context = springClientFactory.getLoadBalancerContext(SERVICEID);
    IClientConfig clientConfig = springClientFactory.getClientConfig(SERVICEID);
    ILoadBalancer loadBalancer = springClientFactory.getLoadBalancer(SERVICEID);
    HttpClientLoadBalancerErrorHandler requestSpecificRetryHandler = getRequestSpecificRetryHandler(clientConfig);

    this.commandBuilder = LoadBalancerCommand.builder()
            .withRetryHandler(requestSpecificRetryHandler)
            .withLoadBalancerContext(context)
            .withClientConfig(clientConfig)
            .withLoadBalancer(loadBalancer);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:16,代码来源:ProxyController.java


示例12: buildLoadBalancerCommand

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
protected LoadBalancerCommand<T> buildLoadBalancerCommand(final S request, final IClientConfig config) {
	RequestSpecificRetryHandler handler = getRequestSpecificRetryHandler(request, config);
	LoadBalancerCommand.Builder<T> builder = LoadBalancerCommand.<T>builder()
			.withLoadBalancerContext(this)
			.withRetryHandler(handler)
			.withLoadBalancerURI(request.getUri());
	customizeLoadBalancerCommandBuilder(request, config, builder);
	return builder.build();
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:10,代码来源:AbstractLoadBalancerAwareClient.java


示例13: submit

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
/**
 * Subject an operation to run in the load balancer
 * 
 * @param request
 * @param errorHandler
 * @param requestConfig
 * @param rxClientConfig
 * @return
 */
private Observable<HttpClientResponse<O>> submit(final Server server, final HttpClientRequest<I> request, final RetryHandler errorHandler, final IClientConfig requestConfig, final ClientConfig rxClientConfig) {
    RetryHandler retryHandler = errorHandler;
    if (retryHandler == null) {
        retryHandler = getRequestRetryHandler(request, requestConfig);
    }
    
    final IClientConfig config = requestConfig == null ? DefaultClientConfigImpl.getEmptyConfig() : requestConfig;
    final ExecutionContext<HttpClientRequest<I>> context = new ExecutionContext<HttpClientRequest<I>>(request, config, this.getClientConfig(), retryHandler);
    
    Observable<HttpClientResponse<O>> result = submitToServerInURI(request, config, rxClientConfig, retryHandler, context);
    if (result == null) {
        LoadBalancerCommand<HttpClientResponse<O>> command;
        if (retryHandler != defaultRetryHandler) {
            // need to create new builder instead of the default one
            command = LoadBalancerCommand.<HttpClientResponse<O>>builder()
                    .withExecutionContext(context)
                    .withLoadBalancerContext(lbContext)
                    .withListeners(listeners)
                    .withClientConfig(this.getClientConfig())
                    .withRetryHandler(retryHandler)
                    .withServer(server)
                    .build();
        }
        else {
            command = defaultCommandBuilder;
        }
        
        result = command.submit(requestToOperation(request, getRxClientConfig(config, rxClientConfig)));
    }
    return result;
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:41,代码来源:LoadBalancingHttpClient.java


示例14: submitToServerInURI

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
/**
 * Submits the request to the server indicated in the URI
 * @param request
 * @param requestConfig
 * @param config
 * @param errorHandler
 * @param context
 * @return
 */
private Observable<HttpClientResponse<O>> submitToServerInURI(
        HttpClientRequest<I> request, IClientConfig requestConfig, ClientConfig config,
        RetryHandler errorHandler, ExecutionContext<HttpClientRequest<I>> context)  {
    // First, determine server from the URI
    URI uri;
    try {
        uri = new URI(request.getUri());
    } catch (URISyntaxException e) {
        return Observable.error(e);
    }
    String host = uri.getHost();
    if (host == null) {
        return null;
    }
    int port = uri.getPort();
    if (port < 0) {
        if (clientConfig.getPropertyAsBoolean(IClientConfigKey.Keys.IsSecure, false)) {
            port = 443;
        } else {
            port = 80;
        }
    }
    
    return LoadBalancerCommand.<HttpClientResponse<O>>builder()
            .withRetryHandler(errorHandler)
            .withLoadBalancerContext(lbContext)
            .withListeners(listeners)
            .withExecutionContext(context)
            .withServer(new Server(host, port))
            .build()
            .submit(this.requestToOperation(request, getRxClientConfig(requestConfig, config)));
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:42,代码来源:LoadBalancingHttpClient.java


示例15: connect

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
@Override
public Observable<ObservableConnection<O, I>> connect() {
    return LoadBalancerCommand.<ObservableConnection<O, I>>builder()
            .withLoadBalancerContext(lbContext)
            .build()
            .submit(new ServerOperation<ObservableConnection<O, I>>() {
                @Override
                public Observable<ObservableConnection<O, I>> call(Server server) {
                    return getOrCreateRxClient(server).connect();            
                }                    
            });
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:13,代码来源:LoadBalancingRxClient.java


示例16: buildCommand

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
protected LoadBalancerCommand<Void> buildCommand() {
    return LoadBalancerCommand.<Void>builder().withLoadBalancer(loadBalancer).build();
}
 
开发者ID:spotify,项目名称:ffwd,代码行数:4,代码来源:HttpClient.java


示例17: customizeLoadBalancerCommandBuilder

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
@Override
protected void customizeLoadBalancerCommandBuilder(S request, IClientConfig config, LoadBalancerCommand.Builder<T> builder) {
	if (request.getLoadBalancerKey() != null) {
		builder.withServerLocator(request.getLoadBalancerKey());
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:7,代码来源:AbstractLoadBalancingClient.java


示例18: customizeLoadBalancerCommandBuilder

import com.netflix.loadbalancer.reactive.LoadBalancerCommand; //导入依赖的package包/类
protected void customizeLoadBalancerCommandBuilder(final S request, final IClientConfig config,
		final LoadBalancerCommand.Builder<T> builder) {
	// do nothing by default, give a chance to its derived class to customize the builder
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:5,代码来源:AbstractLoadBalancerAwareClient.java



注:本文中的com.netflix.loadbalancer.reactive.LoadBalancerCommand类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PrimitiveConverter类代码示例发布时间:2022-05-23
下一篇:
Java LittleEndian类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap