public class DiscoveryConstraints extends Object
DiscoveryProtocolVersion
, MulticastMaxPacketSize
,
MulticastTimeToLive
, UnicastSocketTimeout
,
ConnectionRelativeTime
,
ConnectionAbsoluteTime
.Modifier and Type | Class and Description |
---|---|
private static class |
DiscoveryConstraints.ConnectionAbsoluteTimeReducer |
private static class |
DiscoveryConstraints.ConstraintReducer
Utility for reducing constraints of a given type into a base set of
alternatives.
|
private static class |
DiscoveryConstraints.MaxValueReducer |
private static class |
DiscoveryConstraints.MulticastMaxPacketSizeReducer |
Modifier and Type | Field and Description |
---|---|
private ConnectionAbsoluteTime |
connectionAbsoluteTime |
private int |
hashcode |
private MulticastMaxPacketSize |
maxPacketSize |
static Method |
multicastAnnouncementMethod
Method object for the multicastAnnouncement method of this class.
|
static Method |
multicastRequestMethod
Method object for the multicastRequest method of this class.
|
private int |
preferredProtocolVersion |
private Set |
protocolVersions |
private UnicastSocketTimeout |
socketTimeout |
private static Set |
supportedProtocols |
private MulticastTimeToLive |
timeToLive |
private InvocationConstraints |
unfulfilled |
static Method |
unicastDiscoveryMethod
Method object for the unicastDiscovery method of this class.
|
Modifier | Constructor and Description |
---|---|
private |
DiscoveryConstraints(InvocationConstraints constraints) |
Modifier and Type | Method and Description |
---|---|
void |
checkProtocolVersion(int version)
Checks the protocol version of an incoming multicast request,
announcement, or unicast discovery attempt, throwing an
UnsupportedConstraintException if handling of the given protocol does
not satisfy the constraints of this instance. |
int |
chooseProtocolVersion()
Returns the protocol version to use for sending multicast requests or
announcements, or initiating unicast discovery.
|
private static int |
chooseProtocolVersion(Set protocolVersions,
Set protocolVersionPrefs,
InvocationConstraints unfulfilled) |
boolean |
equals(Object o) |
long |
getConnectionDeadline(long defaultValue)
Returns the deadline by which a network connection must be established
during unicast discovery, or
defaultValue if not
constrained. |
private static Object |
getElement(Set s) |
int |
getMulticastMaxPacketSize(int defaultValue)
Returns the maximum multicast packet size to allow, or the specified
default value if not constrained.
|
int |
getMulticastTimeToLive(int defaultValue)
Returns the multicast time to live value to use, or the specified
default value if not constrained.
|
private static Set |
getUnfulfilled(Set constraints) |
InvocationConstraints |
getUnfulfilledConstraints()
Returns the constraints for this instance which are not, or do not
contain as alternatives, instances of the "fulfillable" (by this layer)
constraint types
DiscoveryProtocolVersion ,
ConnectionRelativeTime , MulticastMaxPacketSize ,
MulticastTimeToLive , and UnicastSocketTimeout . |
int |
getUnicastSocketTimeout(int defaultValue)
Returns socket read timeout to use for unicast discovery, or the
specified default value if not constrained.
|
int |
hashCode() |
private static Set |
intersect(Set s1,
Set s2) |
static void |
multicastAnnouncement()
Empty method which serves as a
MethodConstraints key for looking
up InvocationConstraints that apply to multicast announcements. |
static void |
multicastRequest()
Empty method which serves as a
MethodConstraints key for looking
up InvocationConstraints that apply to multicast requests. |
static DiscoveryConstraints |
process(InvocationConstraints constraints)
Processes the discovery-related constraints in the given set of
constraints, returning a
DiscoveryConstraints instance from
which the constraint results can be queried. |
static void |
unicastDiscovery()
Empty method which serves as a
MethodConstraints key for looking
up InvocationConstraints that apply to unicast discovery. |
public static final Method multicastRequestMethod
public static final Method multicastAnnouncementMethod
public static final Method unicastDiscoveryMethod
private static final Set supportedProtocols
private final InvocationConstraints unfulfilled
private final Set protocolVersions
private final int preferredProtocolVersion
private final ConnectionAbsoluteTime connectionAbsoluteTime
private final MulticastMaxPacketSize maxPacketSize
private final MulticastTimeToLive timeToLive
private final UnicastSocketTimeout socketTimeout
private final int hashcode
private DiscoveryConstraints(InvocationConstraints constraints) throws UnsupportedConstraintException
UnsupportedConstraintException
public static void multicastRequest()
MethodConstraints
key for looking
up InvocationConstraints
that apply to multicast requests.public static void multicastAnnouncement()
MethodConstraints
key for looking
up InvocationConstraints
that apply to multicast announcements.public static void unicastDiscovery()
MethodConstraints
key for looking
up InvocationConstraints
that apply to unicast discovery.public static DiscoveryConstraints process(InvocationConstraints constraints) throws UnsupportedConstraintException
DiscoveryConstraints
instance from
which the constraint results can be queried. Processing of timeout
constraints is time dependent, and subsequent invocations of this
method with the same InvocationConstraints
may result in
DiscoveryConstraint
instances with different constraint
results.constraints
- the constraints to processUnsupportedConstraintException
- if the discovery-related
constraints contain conflicts, or otherwise cannot be processedNullPointerException
- if constraints
is
null
public int chooseProtocolVersion()
public void checkProtocolVersion(int version) throws UnsupportedConstraintException
UnsupportedConstraintException
if handling of the given protocol does
not satisfy the constraints of this instance.version
- protocol version to checkUnsupportedConstraintException
- if handling of the given protocol
does not satisfy the constraints of this instancepublic long getConnectionDeadline(long defaultValue)
defaultValue
if not
constrained.defaultValue
- default timeout to returnpublic int getMulticastMaxPacketSize(int defaultValue)
defaultValue
- the value to return if the multicast packet size is
unconstrainedpublic int getMulticastTimeToLive(int defaultValue)
defaultValue
- the value to return if the multicast time to live
value is unconstrainedpublic int getUnicastSocketTimeout(int defaultValue)
defaultValue
- the value to return if the socket timeout is
unconstrainedpublic InvocationConstraints getUnfulfilledConstraints()
DiscoveryProtocolVersion
,
ConnectionRelativeTime
, MulticastMaxPacketSize
,
MulticastTimeToLive
, and UnicastSocketTimeout
.
Constraint alternatives containing both fulfillable and unfulfillable
constraints are treated optimistically--it is assumed that the one of the
fulfillable alternatives will be satisfied, so the unfulfillable
alternatives are not included in the returned constraints.private static int chooseProtocolVersion(Set protocolVersions, Set protocolVersionPrefs, InvocationConstraints unfulfilled)
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.