/** * Sets the factor to use when backing off; the new * per-host limit will be roughly the current max times * this factor. <code>Math.floor</code> is applied in the * case of non-integer outcomes to ensure we actually * decrease the pool size. Pool sizes are never decreased * below 1, however. Defaults to 0.5. * @param d must be between 0.0 and 1.0, exclusive. */ public void setBackoffFactor(final double d) { Args.check(d > 0.0 && d < 1.0, "Backoff factor must be 0.0 < f < 1.0"); backoffFactor = d; }
public AccessTokensRequestInterceptor(final String tokenId, final AccessTokens accessTokens) { Args.check(tokenId != null, "'tokenId' should never be null"); Args.check(accessTokens != null, "'accessTokens' should never be null"); Args.check(!tokenId.trim().isEmpty(), "'tokenId' should never be empty"); this.tokenId = tokenId; this.accessTokens = accessTokens; }
@Override public final HttpHost getHopTarget(final int hop) { Args.notNegative(hop, "Hop index"); final int hopcount = getHopCount(); Args.check(hop < hopcount, "Hop index exceeds tracked route length"); if (hop < hopcount - 1) { return this.proxyChain.get(hop); } else { return this.targetHost; } }
@Override public final HttpHost getHopTarget(final int hop) { Args.notNegative(hop, "Hop index"); final int hopcount = getHopCount(); Args.check(hop < hopcount, "Hop index exceeds tracked route length"); if (hop < hopcount - 1) { return this.proxyChain.get(hop); } else { return this.targetHost; } }
@Override public final HttpHost getHopTarget(final int hop) { Args.notNegative(hop, "Hop index"); final int hopcount = getHopCount(); Args.check(hop < hopcount, "Hop index exceeds tracked route length"); if (hop < hopcount - 1) { return this.proxyChain.get(hop); } else { return this.targetHost; } }
/** * Parameters needs to be add for all requests. * * @param nameValues nameValues * @return HttpRequestBuilder instance */ public HttpRequestBuilder<T> addDefaultRequestParameter(NameValuePair... nameValues) { int nameValuesLength = ArgsCheck.notNull(nameValues, "nameValues").length; Args.check(nameValuesLength != 0, "Length of parameter can't be ZERO"); return addDefaultRequestParameter(Arrays.asList(nameValues)); }
public final HttpHost getHopTarget(final int hop) { Args.notNegative(hop, "Hop index"); final int hopcount = getHopCount(); Args.check(hop < hopcount, "Hop index exceeds tracked route length"); if (hop < hopcount - 1) { return this.proxyChain.get(hop); } else { return this.targetHost; } }
@Override public final HttpHost getHopTarget(final int hop) { Args.notNegative(hop, "Hop index"); final int hopcount = getHopCount(); Args.check(hop < hopcount, "Hop index exceeds tracked route length"); if (hop < hopcount - 1) { return this.proxyChain.get(hop); } else { return this.targetHost; } }
@Override public final HttpHost getHopTarget(final int hop) { Args.notNegative(hop, "Hop index"); final int hopcount = getHopCount(); Args.check(hop < hopcount, "Hop index exceeds tracked route length"); if (hop < hopcount - 1) { return this.proxyChain.get(hop); } else { return this.targetHost; } }
/** * Indicates creation of an entry for this pool. * The entry will <i>not</i> be added to the list of free entries, * it is only recognized as belonging to this pool now. It can then * be passed to {@link #freeEntry freeEntry}. * * @param entry the entry that was created for this pool */ public void createdEntry(final BasicPoolEntry entry) { Args.check(route.equals(entry.getPlannedRoute()), "Entry not planned for this pool"); numEntries++; }
/** * Indicates creation of an entry for this pool. * The entry will <i>not</i> be added to the list of free entries, * it is only recognized as belonging to this pool now. It can then * be passed to {@link #freeEntry freeEntry}. * * @param entry the entry that was created for this pool */ public void createdEntry(final BasicPoolEntry entry) { Args.check(route.equals(entry.getPlannedRoute()), "Entry not planned for this pool"); numEntries++; }
/** * Created Builder to build BasicHttpRequest to post request * * @param uri {@link URI} instance to request * @param type Class type to resolve successful response type. Example {@code String.class} * @param <T> Type of expected successful response * @return Builder instance */ public static <T> HttpRequestBuilder<T> createPost(URI uri, Class<T> type) { Args.check(!HttpRequestUtils.isVoidType(type), TYPE_CANNOT_BE_VOID); return new HttpRequestBuilder<>(HttpPost.METHOD_NAME, uri, type); }
/** * Indicates creation of an entry for this pool. * The entry will <i>not</i> be added to the list of free entries, * it is only recognized as belonging to this pool now. It can then * be passed to {@link #freeEntry freeEntry}. * * @param entry the entry that was created for this pool */ public void createdEntry(final BasicPoolEntry entry) { Args.check(route.equals(entry.getPlannedRoute()), "Entry not planned for this pool"); numEntries++; }
public final HttpHost getHopTarget(final int hop) { Args.notNegative(hop, "Hop index"); final int hopcount = getHopCount(); Args.check(hop < hopcount, "Hop index exceeds tracked route length"); HttpHost result = null; if (hop < hopcount-1) { result = this.proxyChain[hop]; } else { result = this.targetHost; } return result; }
/** * Created Builder to build BasicHttpRequest to post request * * @param uri uri to request * @param type Class type to resolve successful response type. Example {@code String.class} * @param <T> Type of expected successful response * @return Builder instance */ public static <T> HttpRequestBuilder<T> createPost(String uri, Class<T> type) { Args.check(!HttpRequestUtils.isVoidType(type), TYPE_CANNOT_BE_VOID); return new HttpRequestBuilder<>(HttpPost.METHOD_NAME, uri, type); }
/** * Indicates creation of an entry for this pool. * The entry will <i>not</i> be added to the list of free entries, * it is only recognized as belonging to this pool now. It can then * be passed to {@link #freeEntry freeEntry}. * * @param entry the entry that was created for this pool */ public void createdEntry(final BasicPoolEntry entry) { Args.check(route.equals(entry.getPlannedRoute()), "Entry not planned for this pool"); numEntries++; }
/** * Created Builder to build BasicHttpRequest to get request * * @param uri {@link URI} instance to request * @param typeReference instance to resolve successful response type if type is Generic. Example {@code new TypeReference<java.util.List<String>>(){}} * @param <T> Type of expected successful response * @return Builder instance */ public static <T> HttpRequestBuilder<T> createGet(URI uri, TypeReference<T> typeReference) { Args.check(!HttpRequestUtils.isVoidType(typeReference.getType()), TYPE_CANNOT_BE_VOID); return new HttpRequestBuilder<>(HttpGet.METHOD_NAME, uri, typeReference); }
/** * Created Builder to build BasicHttpRequest to post request * * @param uri uri to request * @param typeReference instance to resolve successful response type if type is Generic. Example {@code new TypeReference<java.util.List<String>>(){}} * @param <T> Type of expected successful response * @return Builder instance */ public static <T> HttpRequestBuilder<T> createPost(String uri, TypeReference<T> typeReference) { Args.check(!HttpRequestUtils.isVoidType(typeReference.getType()), TYPE_CANNOT_BE_VOID); return new HttpRequestBuilder<>(HttpPost.METHOD_NAME, uri, typeReference); }
/** * Created Builder to build BasicHttpRequest to get request * * @param uri uri to request * @param typeReference instance to resolve successful response type if type is Generic. Example {@code new TypeReference<java.util.List<String>>(){}} * @param <T> Type of expected successful response * @return Builder instance */ public static <T> HttpRequestBuilder<T> createGet(String uri, TypeReference<T> typeReference) { Args.check(!HttpRequestUtils.isVoidType(typeReference.getType()), TYPE_CANNOT_BE_VOID); return new HttpRequestBuilder<>(HttpGet.METHOD_NAME, uri, typeReference); }
/** * Created Builder to build BasicHttpRequest to post request * * @param uri {@link URI} instance to request * @param typeReference instance to resolve successful response type if type is Generic. Example {@code new TypeReference<java.util.List<String>>(){}} * @param <T> Type of expected successful response * @return Builder instance */ public static <T> HttpRequestBuilder<T> createPost(URI uri, TypeReference<T> typeReference) { Args.check(!HttpRequestUtils.isVoidType(typeReference.getType()), TYPE_CANNOT_BE_VOID); return new HttpRequestBuilder<>(HttpPost.METHOD_NAME, uri, typeReference); }