本文整理汇总了Java中org.apache.http.impl.conn.SchemeRegistryFactory类的典型用法代码示例。如果您正苦于以下问题:Java SchemeRegistryFactory类的具体用法?Java SchemeRegistryFactory怎么用?Java SchemeRegistryFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SchemeRegistryFactory类属于org.apache.http.impl.conn包,在下文中一共展示了SchemeRegistryFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: UpdateShardHandler
import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
public UpdateShardHandler(ConfigSolr cfg) {
clientConnectionManager = new PoolingClientConnectionManager(SchemeRegistryFactory.createSystemDefault());
if (cfg != null ) {
clientConnectionManager.setMaxTotal(cfg.getMaxUpdateConnections());
clientConnectionManager.setDefaultMaxPerRoute(cfg.getMaxUpdateConnectionsPerHost());
}
ModifiableSolrParams params = new ModifiableSolrParams();
if (cfg != null) {
params.set(HttpClientUtil.PROP_SO_TIMEOUT,
cfg.getDistributedSocketTimeout());
params.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT,
cfg.getDistributedConnectionTimeout());
}
// in the update case, we want to do retries, and to use
// the default Solr retry handler that createClient will
// give us
params.set(HttpClientUtil.PROP_USE_RETRY, true);
log.info("Creating UpdateShardHandler HTTP client with params: {}", params);
client = HttpClientUtil.createClient(params, clientConnectionManager);
}
示例2: createProxyClient
import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
/**
* create a proxy client
*
* @return either a client or null if none is configured
* @throws KeyManagementException
* @throws NumberFormatException
* if that port could not be parsed.
* @throws NoSuchAlgorithmException
*/
private static HttpClient createProxyClient(PlayProfile profile)
throws KeyManagementException, NoSuchAlgorithmException {
if (profile.getProxyAddress() == null) {
return null;
}
PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(
SchemeRegistryFactory.createDefault());
connManager.setMaxTotal(100);
connManager.setDefaultMaxPerRoute(30);
DefaultHttpClient client = new DefaultHttpClient(connManager);
client.getConnectionManager().getSchemeRegistry()
.register(Utils.getMockedScheme());
HttpHost proxy = new HttpHost(profile.getProxyAddress(),
profile.getProxyPort());
client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
if (profile.getProxyUser() != null && profile.getProxyPassword() != null) {
client.getCredentialsProvider().setCredentials(
new AuthScope(proxy),
new UsernamePasswordCredentials(profile.getProxyUser(), profile
.getProxyPassword()));
}
return client;
}
示例3: ClientBuilder
import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
public ClientBuilder() {
enableGZip = true;
name = "hosebird-client-" + clientNum.getAndIncrement();
ThreadFactory threadFactory = new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat("hosebird-client-io-thread-%d")
.build();
executorService = Executors.newSingleThreadExecutor(threadFactory);
ThreadFactory rateTrackerThreadFactory = new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat("hosebird-client-rateTracker-thread-%d")
.build();
ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(1, rateTrackerThreadFactory);
rateTracker = new BasicRateTracker(30000, 100, true, scheduledExecutor);
reconnectionManager = new BasicReconnectionManager(5);
socketTimeoutMillis = 60000;
connectionTimeoutMillis = 4000;
schemeRegistry = SchemeRegistryFactory.createDefault();
}
示例4: HttpStoreClientFactory
import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
public HttpStoreClientFactory(ClientConfig config) {
super(config);
ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(SchemeRegistryFactory.createDefault(),
config.getConnectionTimeout(TimeUnit.MILLISECONDS),
TimeUnit.MILLISECONDS);
mgr.setMaxTotal(config.getMaxTotalConnections());
mgr.setDefaultMaxPerRoute(config.getMaxConnectionsPerNode());
this.httpClient = new DefaultHttpClient(mgr);
HttpParams clientParams = this.httpClient.getParams();
HttpProtocolParams.setUserAgent(clientParams, VOLDEMORT_USER_AGENT);
HttpProtocolParams.setVersion(clientParams, HttpVersion.HTTP_1_1);
HttpConnectionParams.setConnectionTimeout(clientParams,
config.getConnectionTimeout(TimeUnit.MILLISECONDS));
HttpConnectionParams.setSoTimeout(clientParams,
config.getSocketTimeout(TimeUnit.MILLISECONDS));
HttpConnectionParams.setStaleCheckingEnabled(clientParams, false);
this.httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
HttpClientParams.setCookiePolicy(clientParams, CookiePolicy.IGNORE_COOKIES);
this.reroute = config.getRoutingTier().equals(RoutingTier.SERVER);
this.requestFormatFactory = new RequestFormatFactory();
}
示例5: setUp
import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
Cluster cluster = ServerTestUtils.getLocalCluster(1);
Node node = cluster.getNodes().iterator().next();
context = ServerTestUtils.getJettyServer(new ClusterMapper().writeCluster(cluster),
VoldemortTestConstants.getSimpleStoreDefinitionsXml(),
"users",
RequestFormatType.VOLDEMORT_V1,
node.getHttpPort());
server = context.getServer();
ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(SchemeRegistryFactory.createDefault(),
5000,
TimeUnit.MILLISECONDS);
httpClient = new DefaultHttpClient(connectionManager);
httpStore = ServerTestUtils.getHttpStore("users",
RequestFormatType.VOLDEMORT_V1,
node.getHttpPort(),
httpClient);
}
示例6: createClientConnectionManager
import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
@Override
protected ClientConnectionManager createClientConnectionManager() {
PoolingClientConnectionManager connmgr = new PoolingClientConnectionManager(
SchemeRegistryFactory.createSystemDefault());
String s = System.getProperty("http.keepAlive");
if ("true".equalsIgnoreCase(s)) {
s = System.getProperty("http.maxConnections", "5");
int max = Integer.parseInt(s);
connmgr.setDefaultMaxPerRoute(max);
connmgr.setMaxTotal(2 * max);
}
return connmgr;
}
示例7: getPoolingClientConnectionManager
import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
public PoolingClientConnectionManager getPoolingClientConnectionManager(
NaviHttpPoolConfig poolConfig) {
PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(
SchemeRegistryFactory.createDefault(), poolConfig.getTimeToLive(), TimeUnit.MILLISECONDS
);
// timeToLive maximum time to live. May be zero if the connection does
// not have an expiry deadline.
connectionManager.setDefaultMaxPerRoute(poolConfig.getMaxPerRoute()); // 默认每个通道最高2个链接
connectionManager.setMaxTotal(poolConfig.getMaxActive()); // 默认最大20,现改成MaxActive可配,默认是8
return connectionManager;
}
示例8: getHttpClient
import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
protected HttpClient getHttpClient() {
if (httpClient == null) {
httpClient = new DefaultHttpClient(
new PoolingClientConnectionManager(SchemeRegistryFactory.createDefault(), 3000, TimeUnit.MILLISECONDS)
);
}
return httpClient;
}
示例9: createClientConnectionManager
import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
@Override
protected ClientConnectionManager createClientConnectionManager() {
final PoolingClientConnectionManager connmgr = new PoolingClientConnectionManager(
SchemeRegistryFactory.createSystemDefault());
String s = System.getProperty("http.keepAlive", "true");
if ("true".equalsIgnoreCase(s)) {
s = System.getProperty("http.maxConnections", "5");
final int max = Integer.parseInt(s);
connmgr.setDefaultMaxPerRoute(max);
connmgr.setMaxTotal(2 * max);
}
return connmgr;
}
示例10: getConnectionManager
import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
/**
* Connection manager to allow concurrent connections.
*
* @return {@link ClientConnectionManager} instance
*/
public static ClientConnectionManager getConnectionManager() {
PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(
SchemeRegistryFactory.createDefault());
connManager.setMaxTotal(100);
connManager.setDefaultMaxPerRoute(30);
return connManager;
}
示例11: getConnectionManager
import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
/**
* Connection manager to allow concurrent connections.
*
* @return {@link ClientConnectionManager} instance
*/
public static ClientConnectionManager getConnectionManager() {
PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(
SchemeRegistryFactory.createDefault());
connManager.setMaxTotal(100);
connManager.setDefaultMaxPerRoute(30);
return connManager;
}
示例12: getHttpClient
import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
/**
*
* @param isMultiRequest
* 是否支持多线程
* @param connectionTimeout
* 建立连接超时时间(毫秒)
* @param socketTimeout
* 等待数据超时时间(毫秒)
* @return
*/
public static HttpClient getHttpClient(boolean isMultiRequest,
int connectionTimeout, int socketTimeout) {
SchemeRegistry schemeRegistry = SchemeRegistryFactory.createDefault();
ClientConnectionManager cm = isMultiRequest ? new PoolingClientConnectionManager(
schemeRegistry) : new BasicClientConnectionManager(
schemeRegistry);
HttpParams params = isMultiRequest ? new SyncBasicHttpParams()
: new BasicHttpParams();
HttpClientParams.setCookiePolicy(params,
CookiePolicy.BROWSER_COMPATIBILITY);
HttpConnectionParams.setConnectionTimeout(params, connectionTimeout);
HttpConnectionParams.setSoTimeout(params, socketTimeout);
return new DefaultHttpClient(cm, params);
}
示例13: getProxyClient
import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
/**
* Get a proxy client, if it is configured.
*
* @return either a client or null
* @throws IOException
* if reading the config file fails
* @throws KeyManagementException
* @throws NumberFormatException
* if that port could not be parsed.
* @throws NoSuchAlgorithmException
*/
public HttpClient getProxyClient() throws IOException, KeyManagementException,
NoSuchAlgorithmException, NumberFormatException {
File cfgfile = new File(root, NETCFG);
if (cfgfile.exists()) {
Properties cfg = new Properties();
cfg.load(new FileInputStream(cfgfile));
String ph = cfg.getProperty(PROXYHOST, null);
String pp = cfg.getProperty(PROXYPORT, null);
String pu = cfg.getProperty(PROXYUSER, null);
String pw = cfg.getProperty(PROXYPASS, null);
if (ph == null || pp == null) {
return null;
}
PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(
SchemeRegistryFactory.createDefault());
connManager.setMaxTotal(100);
connManager.setDefaultMaxPerRoute(30);
DefaultHttpClient client = new DefaultHttpClient(connManager);
client.getConnectionManager().getSchemeRegistry().register(Utils.getMockedScheme());
HttpHost proxy = new HttpHost(ph, Integer.parseInt(pp));
client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
if (pu != null && pw != null) {
client.getCredentialsProvider().setCredentials(new AuthScope(proxy),
new UsernamePasswordCredentials(pu, pw));
}
return client;
}
return null;
}
示例14: UpdateShardHandler
import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
public UpdateShardHandler(ConfigSolr cfg) {
clientConnectionManager = new PoolingClientConnectionManager(SchemeRegistryFactory.createSystemDefault());
clientConnectionManager.setMaxTotal(cfg.getMaxUpdateConnections());
clientConnectionManager.setDefaultMaxPerRoute(cfg.getMaxUpdateConnectionsPerHost());
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(HttpClientUtil.PROP_SO_TIMEOUT, cfg.getDistributedSocketTimeout());
params.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT, cfg.getDistributedConnectionTimeout());
params.set(HttpClientUtil.PROP_USE_RETRY, false);
client = HttpClientUtil.createClient(params, clientConnectionManager);
}
示例15: setup
import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
@Before
public void setup() throws Exception {
mockAuth = mock(Authentication.class);
mockParams = mock(HttpParams.class);
defaultSchemeRegistry = SchemeRegistryFactory.createDefault();
request = new HttpGet("http://hi");
}