Top Description Inners Fields Constructors Methods
io.grpc

public final Class EquivalentAddressGroup

extends Object
Class Inheritance
Annotations
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/1770
Imports
com.google.common.base.Preconditions, java.lang.annotation.Documented, .Retention, .RetentionPolicy, java.net.SocketAddress, java.util.ArrayList, .Collections, .List

A group of SocketAddresses that are considered equivalent when channel makes connections.

Usually the addresses are addresses resolved from the same host name, and connecting to any of them is equally sufficient. They do have order. An address appears earlier on the list is likely to be tried earlier.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static @interface

Field Summary

Modifier and TypeField and Description
private final List<SocketAddress>
public static final Attributes.Key<String>
ATTR_AUTHORITY_OVERRIDE

The authority to be used when constructing Subchannels for this EquivalentAddressGroup.

private final Attributes
private final int
hashCode

SocketAddress docs say that the addresses are immutable, so we cache the hashCode.

Constructor Summary

AccessConstructor and Description
public
EquivalentAddressGroup(List<SocketAddress> addrs)

List constructor without Attributes.

public
EquivalentAddressGroup(List<SocketAddress> addrs, Attributes attrs)

List constructor with Attributes.

public
EquivalentAddressGroup(SocketAddress addr)

Singleton constructor without Attributes.

public
EquivalentAddressGroup(SocketAddress addr, Attributes attrs)

Singleton constructor with Attributes.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Returns true if the given object is also an EquivalentAddressGroup with an equal address list and equal attribute values.
public List<SocketAddress>
getAddresses()

Returns an immutable list of the addresses.

public Attributes
getAttributes()

Returns the attributes.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

addrsback to summary
private final List<SocketAddress> addrs
ATTR_AUTHORITY_OVERRIDEback to summary
public static final Attributes.Key<String> ATTR_AUTHORITY_OVERRIDE

The authority to be used when constructing Subchannels for this EquivalentAddressGroup. However, if the channel has overridden authority via ManagedChannelBuilder#overrideAuthority(String), the transport will use the channel's authority override.

The authority must be from a trusted source, because if the authority is tampered with, RPCs may be sent to attackers which may leak sensitive user data. If the authority was acquired by doing I/O, the communication must be authenticated (e.g., via TLS). Recognize that the server that provided the authority can trivially impersonate the service.

Annotations
@Attr
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/6138
attrsback to summary
private final Attributes attrs
hashCodeback to summary
private final int hashCode

SocketAddress docs say that the addresses are immutable, so we cache the hashCode.

Constructor Detail

EquivalentAddressGroupback to summary
public EquivalentAddressGroup(List<SocketAddress> addrs)

List constructor without Attributes.

EquivalentAddressGroupback to summary
public EquivalentAddressGroup(List<SocketAddress> addrs, Attributes attrs)

List constructor with Attributes.

EquivalentAddressGroupback to summary
public EquivalentAddressGroup(SocketAddress addr)

Singleton constructor without Attributes.

EquivalentAddressGroupback to summary
public EquivalentAddressGroup(SocketAddress addr, Attributes attrs)

Singleton constructor with Attributes.

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Returns true if the given object is also an EquivalentAddressGroup with an equal address list and equal attribute values.

Note that if the attributes include mutable values, it is possible for two objects to be considered equal at one point in time and not equal at another (due to concurrent mutation of attribute values).

Parameters
other:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getAddressesback to summary
public List<SocketAddress> getAddresses()

Returns an immutable list of the addresses.

getAttributesback to summary
public Attributes getAttributes()

Returns the attributes.

Annotations
@Attr
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
io.grpc back to summary

public @Interface EquivalentAddressGroup.Attr

extends Annotation
Annotations
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/4972
@Retention:SOURCE
@Documented

Annotation for EquivalentAddressGroup's attributes. It follows the annotation semantics defined by Attributes.

Method Summary

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString