public class PortForwardManagerImpl extends AbstractLocation implements PortForwardManager
PortForwardManager.AssociationListener, PortForwardManager.AssociationMetadata
BrooklynObject.TagSupport
Configurable.ConfigurationSupport
BrooklynObjectInternal.ConfigurationSupportInternal
LOG, PARENT_LOCATION, TEMPORARY_LOCATION
PORT_FORWARD_MANAGER_STARTING_PORT, SCOPE
FINAL_SPEC, NAMED_SPEC_NAME, ORIGINAL_SPEC
Constructor and Description |
---|
PortForwardManagerImpl() |
Modifier and Type | Method and Description |
---|---|
int |
acquirePublicPort(java.lang.String publicIpId)
Reserves a unique public port on the given publicIpId.
|
int |
acquirePublicPort(java.lang.String publicIpId,
Location l,
int privatePort)
Deprecated.
|
PortMapping |
acquirePublicPortExplicit(java.lang.String publicIpId,
int port)
Deprecated.
|
void |
addAssociationListener(PortForwardManager.AssociationListener listener,
com.google.common.base.Predicate<? super PortForwardManager.AssociationMetadata> filter)
Registers a listener, which will be notified each time a new port mapping is associated.
|
void |
associate(java.lang.String publicIpId,
com.google.common.net.HostAndPort publicEndpoint,
int privatePort)
Records a mapping for publicIpId:privatePort to a public endpoint, such that it can
subsequently be looked up using
PortForwardManager.lookup(String, int) . |
void |
associate(java.lang.String publicIpId,
com.google.common.net.HostAndPort publicEndpoint,
Location l,
int privatePort)
Records a location and private port against a public endpoint (ip and port),
to support
PortForwardManager.lookup(Location, int) . |
void |
associate(java.lang.String publicIpId,
int publicPort,
Location l,
int privatePort)
Deprecated.
|
boolean |
forgetPortMapping(PortMapping m)
Deprecated.
|
boolean |
forgetPortMapping(java.lang.String publicIpId,
int publicPort)
Clears the given port mapping, returning true if there was a match.
|
boolean |
forgetPortMappings(Location l)
Clears the port mappings associated with the given location, returning true if there were any matches.
|
boolean |
forgetPortMappings(java.lang.String publicIpId)
Clears the port mappings associated with the given publicIpId, returning true if there were any matches.
|
boolean |
forgetPublicIpHostname(java.lang.String publicIpId)
Deprecated.
|
java.util.Collection<PortMapping> |
getLocationPublicIpIds(Location l)
returns the subset of port mappings associated with a given location
|
java.util.Map<java.lang.String,java.lang.Integer> |
getPortCounters() |
java.util.List<PortMapping> |
getPortMappings() |
PortMapping |
getPortMappingWithPrivateSide(Location l,
int privatePort)
Returns the mapping to a given private port, or null if none.
|
java.util.Collection<PortMapping> |
getPortMappingWithPublicIpId(java.lang.String publicIpId)
Returns the subset of port mappings associated with a given public IP ID.
|
PortMapping |
getPortMappingWithPublicSide(java.lang.String publicIpId,
int publicPort)
Returns the port mapping for a given publicIpId and public port.
|
com.google.common.net.HostAndPort |
getPublicHostAndPort(PortMapping m)
Returns the public host and port for use accessing the given mapping.
|
java.lang.String |
getPublicIpHostname(java.lang.String publicIpId)
Deprecated.
|
RebindSupport<LocationMemento> |
getRebindSupport()
Users are strongly discouraged from calling or overriding this method.
|
java.lang.String |
getScope() |
void |
init()
Called by framework (in new-style instances where spec was used) after configuring etc,
but before a reference to this instance is shared.
|
boolean |
isClient()
Returns true if this implementation is a client which is immutable/safe for serialization
i.e.
|
com.google.common.net.HostAndPort |
lookup(Location l,
int privatePort)
Returns the public ip hostname and public port for use contacting the given endpoint.
|
com.google.common.net.HostAndPort |
lookup(java.lang.String publicIpId,
int privatePort)
Returns the public endpoint (host and port) for use contacting the given endpoint.
|
void |
recordPublicIpHostname(java.lang.String publicIpId,
java.lang.String hostnameOrPublicIpAddress)
Deprecated.
|
void |
removeAssociationListener(PortForwardManager.AssociationListener listener) |
java.lang.String |
toVerboseString() |
addChild, addExtension, config, configure, containsLocation, equals, getAllConfig, getAllConfigBag, getChildren, getConfig, getConfig, getDisplayName, getExtension, getHostGeoInfo, getLocalConfigBag, getParent, getRawLocalConfigBag, hasConfig, hasExtension, hashCode, isManaged, onManagementStarted, onManagementStopped, removeChild, setConfig, setDisplayName, setHostGeoInfo, setManagementContext, setName, setParent, setParent, toMetadataRecord, toString
getCatalogItemId, getId, getManagementContext, getTagSupport, rebind, setCatalogItemId, tags
containsLocation, getAllConfig, getChildren, getConfig, getConfig, getDisplayName, getExtension, getId, getParent, hasConfig, hasExtension, setParent
getCatalogItemId, getTagSupport, tags
config, setConfig
getManagementContext
setCatalogItemId
public void init()
AbstractBrooklynObject
To preserve backwards compatibility for if the instance is constructed directly, one can call the code below, but that means it will be called after references to this policy have been shared with other entities.
if (isLegacyConstruction()) {
init();
}
init
in class AbstractBrooklynObject
public RebindSupport<LocationMemento> getRebindSupport()
LocationInternal
getRebindSupport
in interface BrooklynObjectInternal
getRebindSupport
in interface Rebindable
getRebindSupport
in interface LocationInternal
getRebindSupport
in class AbstractLocation
public int acquirePublicPort(java.lang.String publicIpId)
PortForwardManager
Often followed by PortForwardManager.associate(String, HostAndPort, int)
or PortForwardManager.associate(String, HostAndPort, Location, int)
to enable PortForwardManager.lookup(String, int)
or PortForwardManager.lookup(Location, int)
respectively.
acquirePublicPort
in interface PortForwardManager
public void associate(java.lang.String publicIpId, com.google.common.net.HostAndPort publicEndpoint, Location l, int privatePort)
PortForwardManager
PortForwardManager.lookup(Location, int)
.
Superfluous if PortForwardManager.acquirePublicPort(String, Location, int)
was used,
but strongly recommended if PortForwardManager.acquirePublicPortExplicit(String, int)
was used
e.g. if the location is not known ahead of time.
associate
in interface PortForwardManager
public void associate(java.lang.String publicIpId, com.google.common.net.HostAndPort publicEndpoint, int privatePort)
PortForwardManager
PortForwardManager.lookup(String, int)
.associate
in interface PortForwardManager
public com.google.common.net.HostAndPort lookup(Location l, int privatePort)
PortForwardManager
Will return null if:
lookup
in interface PortForwardManager
PortForwardManager.recordPublicIpHostname(String, String)
public com.google.common.net.HostAndPort lookup(java.lang.String publicIpId, int privatePort)
PortForwardManager
PortForwardManager.associate(String, HostAndPort, int)
, to register
the endpoint.
Will return null if there has not been a public endpoint associated with this pairing.lookup
in interface PortForwardManager
public boolean forgetPortMapping(java.lang.String publicIpId, int publicPort)
PortForwardManager
forgetPortMapping
in interface PortForwardManager
public boolean forgetPortMappings(Location l)
PortForwardManager
forgetPortMappings
in interface PortForwardManager
public boolean forgetPortMappings(java.lang.String publicIpId)
PortForwardManager
forgetPortMappings
in interface PortForwardManager
public java.lang.String toVerboseString()
toVerboseString
in interface PortForwardManager
toVerboseString
in interface Location
toVerboseString
in class AbstractLocation
public java.lang.String getScope()
getScope
in interface PortForwardManager
public boolean isClient()
PortForwardManager
isClient
in interface PortForwardManager
public void addAssociationListener(PortForwardManager.AssociationListener listener, com.google.common.base.Predicate<? super PortForwardManager.AssociationMetadata> filter)
PortForwardManager
PortForwardManager.associate(String, HostAndPort, int)
and PortForwardManager.associate(String, HostAndPort, Location, int)
.addAssociationListener
in interface PortForwardManager
public void removeAssociationListener(PortForwardManager.AssociationListener listener)
removeAssociationListener
in interface PortForwardManager
public java.util.List<PortMapping> getPortMappings()
public java.util.Map<java.lang.String,java.lang.Integer> getPortCounters()
@Deprecated public PortMapping acquirePublicPortExplicit(java.lang.String publicIpId, int port)
PortForwardManager
acquirePublicPortExplicit
in interface PortForwardManager
@Deprecated public boolean forgetPortMapping(PortMapping m)
forgetPortMapping
in interface PortForwardManager
#forgetPortMapping(String, int)} and {@link #forgetPortMappings(Location)}
@Deprecated public void recordPublicIpHostname(java.lang.String publicIpId, java.lang.String hostnameOrPublicIpAddress)
PortForwardManager
Conceivably this may have to be access-location specific.
recordPublicIpHostname
in interface PortForwardManager
@Deprecated public java.lang.String getPublicIpHostname(java.lang.String publicIpId)
PortForwardManager
getPublicIpHostname
in interface PortForwardManager
@Deprecated public boolean forgetPublicIpHostname(java.lang.String publicIpId)
PortForwardManager
PortForwardManager.recordPublicIpHostname(String, String)
.forgetPublicIpHostname
in interface PortForwardManager
@Deprecated public int acquirePublicPort(java.lang.String publicIpId, Location l, int privatePort)
PortForwardManager
If already allocated, returns the previously allocated.
acquirePublicPort
in interface PortForwardManager
@Deprecated public void associate(java.lang.String publicIpId, int publicPort, Location l, int privatePort)
PortForwardManager
PortForwardManager.lookup(Location, int)
.
Superfluous if PortForwardManager.acquirePublicPort(String, Location, int)
was used,
but strongly recommended if PortForwardManager.acquirePublicPortExplicit(String, int)
was used
e.g. if the location is not known ahead of time.
associate
in interface PortForwardManager
public com.google.common.net.HostAndPort getPublicHostAndPort(PortMapping m)
PortForwardManager
Conceivably this may have to be access-location specific.
getPublicHostAndPort
in interface PortForwardManager
public PortMapping getPortMappingWithPublicSide(java.lang.String publicIpId, int publicPort)
PortForwardManager
getPortMappingWithPublicSide
in interface PortForwardManager
public java.util.Collection<PortMapping> getPortMappingWithPublicIpId(java.lang.String publicIpId)
PortForwardManager
getPortMappingWithPublicIpId
in interface PortForwardManager
public java.util.Collection<PortMapping> getLocationPublicIpIds(Location l)
getLocationPublicIpIds
in interface PortForwardManager
public PortMapping getPortMappingWithPrivateSide(Location l, int privatePort)
PortForwardManager
getPortMappingWithPrivateSide
in interface PortForwardManager