Top Description Inners Methods
org.eclipse.jetty.util

public Interface SocketAddressResolver

Known Direct Implementers
org.eclipse.jetty.util.SocketAddressResolver.Sync, org.eclipse.jetty.util.SocketAddressResolver.Async
Imports
java.net.InetAddress, .InetSocketAddress, .SocketAddress, .UnknownHostException, java.util.ArrayList, .List, java.util.concurrent.Executor, .TimeUnit, .TimeoutException, java.util.concurrent.atomic.AtomicBoolean, org.eclipse.jetty.util.annotation.ManagedAttribute, .ManagedObject, org.eclipse.jetty.util.thread.Scheduler, org.slf4j.Logger, .LoggerFactory

Creates SocketAddress instances, returning them through a Promise.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
SocketAddressResolver.Async

Creates InetSocketAddress instances asynchronously in a different thread.

public static class
SocketAddressResolver.Sync

Creates InetSocketAddress instances synchronously in the caller thread.

Method Summary

Modifier and TypeMethod and Description
public void
resolve(String
the host to resolve
host
,
int
the port of the resulting socket address
port
,
Promise<List<InetSocketAddress>>
the callback invoked when the resolution succeeds or fails
promise
)

Resolves via DNS the given host and port, within the connect timeout, returning a list of InetSocketAddress through the given Promise.

Method Detail

resolveback to summary
public void resolve(String host, int port, Promise<List<InetSocketAddress>> promise)

Resolves via DNS the given host and port, within the connect timeout, returning a list of InetSocketAddress through the given Promise.

Parameters
host:String

the host to resolve

port:int

the port of the resulting socket address

promise:Promise<List<InetSocketAddress>>

the callback invoked when the resolution succeeds or fails

org.eclipse.jetty.util back to summary

public Class SocketAddressResolver.Async

extends Object
implements SocketAddressResolver
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.SocketAddressResolver
Annotations
@ManagedObject:The asynchronous address resolver

Creates InetSocketAddress instances asynchronously in a different thread.

InetSocketAddress#InetSocketAddress(String, int) attempts to perform a DNS resolution of the host name, and this may block for several seconds. This class creates the InetSocketAddress in a separate thread and provides the result through a Promise, with the possibility to specify a timeout for the operation.

Example usage:

SocketAddressResolver resolver = new SocketAddressResolver.Async(executor, scheduler, timeout);
resolver.resolve("www.google.com", 80, new Promise<SocketAddress>()
{
    public void succeeded(SocketAddress result)
    {
        // The address was resolved
    }

    public void failed(Throwable failure)
    {
        // The address resolution failed
    }
});

Field Summary

Modifier and TypeField and Description
private final Executor
private static final Logger
private final Scheduler
private final long

Constructor Summary

AccessConstructor and Description
public
Async(Executor
the thread pool to use to perform DNS resolution in pooled threads
executor
,
Scheduler
the scheduler to schedule tasks to cancel DNS resolution if it takes too long
scheduler
,
long
the timeout, in milliseconds, for the DNS resolution to complete
timeout
)

Creates a new instance with the given executor (to perform DNS resolution in a separate thread), the given scheduler (to cancel the operation if it takes too long) and the given timeout, in milliseconds.

Method Summary

Modifier and TypeMethod and Description
public Executor
public Scheduler
public long
public void
resolve(final String
the host to resolve
host
,
final int
the port of the resulting socket address
port
,
final Promise<List<InetSocketAddress>>
the callback invoked when the resolution succeeds or fails
promise
)

Implements org.eclipse.jetty.util.SocketAddressResolver.resolve.

Resolves via DNS the given host and port, within the connect timeout, returning a list of InetSocketAddress through the given Promise.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

executorback to summary
private final Executor executor
LOGback to summary
private static final Logger LOG
schedulerback to summary
private final Scheduler scheduler
timeoutback to summary
private final long timeout

Constructor Detail

Asyncback to summary
public Async(Executor executor, Scheduler scheduler, long timeout)

Creates a new instance with the given executor (to perform DNS resolution in a separate thread), the given scheduler (to cancel the operation if it takes too long) and the given timeout, in milliseconds.

Parameters
executor:Executor

the thread pool to use to perform DNS resolution in pooled threads

scheduler:Scheduler

the scheduler to schedule tasks to cancel DNS resolution if it takes too long

timeout:long

the timeout, in milliseconds, for the DNS resolution to complete

Method Detail

getExecutorback to summary
public Executor getExecutor()
getSchedulerback to summary
public Scheduler getScheduler()
getTimeoutback to summary
public long getTimeout()
Annotations
@ManagedAttribute:The timeout, in milliseconds, to resolve an address
readonly:true
resolveback to summary
public void resolve(final String host, final int port, final Promise<List<InetSocketAddress>> promise)

Implements org.eclipse.jetty.util.SocketAddressResolver.resolve.

Doc from org.eclipse.jetty.util.SocketAddressResolver.resolve.

Resolves via DNS the given host and port, within the connect timeout, returning a list of InetSocketAddress through the given Promise.

Parameters
host:String

the host to resolve

port:int

the port of the resulting socket address

promise:Promise<List<InetSocketAddress>>

the callback invoked when the resolution succeeds or fails

Annotations
@Override
org.eclipse.jetty.util back to summary

public Class SocketAddressResolver.Sync

extends Object
implements SocketAddressResolver
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.SocketAddressResolver
Annotations
@ManagedObject:The synchronous address resolver

Creates InetSocketAddress instances synchronously in the caller thread.

Constructor Summary

AccessConstructor and Description
public
Sync()

Method Summary

Modifier and TypeMethod and Description
public void
resolve(String
the host to resolve
host
,
int
the port of the resulting socket address
port
,
Promise<List<InetSocketAddress>>
the callback invoked when the resolution succeeds or fails
promise
)

Implements org.eclipse.jetty.util.SocketAddressResolver.resolve.

Resolves via DNS the given host and port, within the connect timeout, returning a list of InetSocketAddress through the given Promise.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Syncback to summary
public Sync()

Method Detail

resolveback to summary
public void resolve(String host, int port, Promise<List<InetSocketAddress>> promise)

Implements org.eclipse.jetty.util.SocketAddressResolver.resolve.

Doc from org.eclipse.jetty.util.SocketAddressResolver.resolve.

Resolves via DNS the given host and port, within the connect timeout, returning a list of InetSocketAddress through the given Promise.

Parameters
host:String

the host to resolve

port:int

the port of the resulting socket address

promise:Promise<List<InetSocketAddress>>

the callback invoked when the resolution succeeds or fails

Annotations
@Override