/** * <p>Returns the {@link Container} for which this Request was created.</p> * * @return The container instance. */ public Container container() { return parent != null ? parent.container() : container; }
/** * <p>Adds the given values to the entry of the specified key. If no entry exists for the given key, a new one is * created containing only the given values.</p> * * @param key The key with which the specified value is to be associated. * @param values The values to be added to the list associated with the specified key. */ public void add(String key, List<String> values) { h.add(key, values); }
@Override public void emitMetrics(Metric metric) { int numStaleContainers; synchronized (monitor) { numStaleContainers = this.numStaleContainers; } metric.set(TOTAL_DEACTIVATED_CONTAINERS, numStaleContainers, null); }
private void increment(String metricName, long countIncrement) { if (countIncrement > 0) { metric.add(metricName, countIncrement, null); } } }
/** * The response headers. * * @return a mutable, thread-unsafe view of the response headers */ public HeaderFields headers() { return parentResponse.headers(); }
/** * The numeric HTTP status code, e.g. 200, 404 and so on. * * @return the numeric HTTP status code */ public int getStatus() { return parentResponse.getStatus(); }
@Override protected void destroy() { for (ResourceReference resource : resources) { resource.close(); } }
/** * <p>Constructs a new instance of this class with a detail message that contains the {@link URI} of the {@link * Request} that was denied.</p> * * @param request The Request that was denied. */ public RequestDeniedException(Request request) { super("Request with URI '" + request.getUri() + "' denied."); this.request = request; }
/** * <p>Adds all the entries of the given map to this. This is the same as calling {@link #add(String, List)} for each * entry in <code>values</code>.</p> * * @param values The values to be added to this. */ public void addAll(Map<? extends String, ? extends List<String>> values) { h.addAll(values); }
/** * <p>Returns an unmodifiable list of all key-value pairs of this. This provides a flattened view on the content of * this map.</p> * * @return The collection of entries. */ public List<Entry<String, String>> entries() { return h.entries(); }
/** * <p>Convenience method for retrieving the first value of a named header field. If the header is not set, or if the * value list is empty, this method returns null.</p> * * @param key The key whose first value to return. * @return The first value of the named header, or null. */ public String getFirst(String key) { return h.getFirst(key); }
/** * <p>Convenience method for checking whether or not a named header field is <em>true</em>. To satisfy this, the * header field needs to have at least 1 entry, and Boolean.valueOf() of all its values must parse as * <em>true</em>.</p> * * @param key The key whose values to parse as a boolean. * @return The boolean value of the named header. */ public boolean isTrue(String key) { return h.isTrue(key); }
/** * <p>Mark this request as cancelled and frees any resources held by the request if possible. * All subsequent calls to {@link #isCancelled()} on this Request return <em>true</em>.</p> * * @see #isCancelled() */ public void cancel() { if (cancel) return; if (timeoutManager != null && timeout != null) timeoutManager.unscheduleTimeout(this); cancel = true; }
@Override public void handleTimeout(Request request, ResponseHandler responseHandler) { Response.dispatchTimeout(responseHandler); }
@Override protected com.yahoo.jdisc.Response newResponse() { com.yahoo.jdisc.Response response = new com.yahoo.jdisc.Response(com.yahoo.jdisc.Response.Status.OK); response.headers().add("Content-Type", Arrays.asList(new String[]{"application/json"})); return response; } }.connect(handler));
/** * <p>Adds the given value to the entry of the specified key. If no entry exists for the given key, a new one is * created containing only the given value.</p> * * @param key The key with which the specified value is to be associated. * @param value The value to be added to the list associated with the specified key. */ public void add(String key, String value) { h.add(key, value); }
/** Returns the status code. Throws an exception if handleResponse is not called prior to calling this */ public int getStatus() { return response.getStatus(); }