1 /* 2 * ==================================================================== 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * ==================================================================== 20 * 21 * This software consists of voluntary contributions made by many 22 * individuals on behalf of the Apache Software Foundation. For more 23 * information on the Apache Software Foundation, please see 24 * <http://www.apache.org/>. 25 * 26 */ 27 28 package org.apache.hc.client5.http.io; 29 30 import java.util.concurrent.ExecutionException; 31 import java.util.concurrent.TimeoutException; 32 33 import org.apache.hc.core5.concurrent.Cancellable; 34 import org.apache.hc.core5.util.Timeout; 35 36 /** 37 * Represents a request for a {@link ConnectionEndpoint} whose life cycle 38 * is managed by a connection manager. 39 * 40 * @since 5.0 41 */ 42 public interface LeaseRequest extends Cancellable { 43 44 /** 45 * Returns {@link ConnectionEndpoint} within a given time. 46 * This method will block until a connection becomes available, 47 * the timeout expires, or the connection manager is shut down. 48 * Timeouts are handled with millisecond precision. 49 * 50 * If {@link #cancel()} is called while this is blocking or 51 * before this began, an {@link InterruptedException} will 52 * be thrown. 53 * 54 * @param timeout the operation timeout. 55 * 56 * @return a connection that can be used to communicate 57 * along the given route 58 * 59 * @throws TimeoutException 60 * in case of a timeout 61 * @throws InterruptedException 62 * if the calling thread is interrupted while waiting 63 */ 64 ConnectionEndpoint get(Timeout timeout) 65 throws InterruptedException, ExecutionException, TimeoutException; 66 67 }