public class PortForwardManagerImpl extends AbstractLocation implements PortForwardManager
AbstractLocation.BasicSubscriptionSupport
PortForwardManager.AssociationListener, PortForwardManager.AssociationMetadata
BrooklynObject.RelationSupport<T extends BrooklynObject>, BrooklynObject.SubscriptionSupport, BrooklynObject.TagSupport
Configurable.ConfigurationSupport
BrooklynObjectInternal.ConfigurationSupportInternal, BrooklynObjectInternal.RelationSupportInternal<T extends BrooklynObject>, BrooklynObjectInternal.SubscriptionSupportInternal
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.
|
void |
addAssociationListener(PortForwardManager.AssociationListener listener,
<any> filter)
Registers a listener, which will be notified each time a new port mapping is associated.
|
void |
associate(java.lang.String publicIpId,
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,
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) . |
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.
|
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.
|
HostAndPort |
getPublicHostAndPort(PortMapping m)
Returns the public host and port for use accessing the given mapping.
|
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.
|
HostAndPort |
lookup(Location l,
int privatePort)
Returns the public ip hostname and public port for use contacting the given endpoint.
|
HostAndPort |
lookup(java.lang.String publicIpId,
int privatePort)
Returns the public endpoint (host and port) for use contacting the given endpoint.
|
void |
removeAssociationListener(PortForwardManager.AssociationListener listener) |
java.lang.String |
toVerboseString() |
addChild, addExtension, config, configure, containsLocation, equals, getChildren, getConfig, getConfig, getDisplayName, getExtension, getHostGeoInfo, getLocationTypeInternal, getParent, hasExtension, hashCode, isManaged, onManagementStarted, onManagementStopped, rebind, relations, removeChild, setDisplayName, setHostGeoInfo, setManagementContext, setParent, setParent, subscriptions, toMetadataRecord, toString
addSearchPath, getCatalogItemId, getCatalogItemIdSearchPath, getId, getManagementContext, setCatalogItemId, setCatalogItemIdAndSearchPath, stackCatalogItemId, tags
containsLocation, getChildren, getConfig, getDisplayName, getExtension, getId, getParent, hasExtension, relations, setParent
getCatalogItemId, getCatalogItemIdSearchPath, subscriptions, tags
config, getConfig
getManagementContext
addSearchPath, setCatalogItemId, setCatalogItemIdAndSearchPath, stackCatalogItemId
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 AbstractLocation
public RebindSupport<LocationMemento> getRebindSupport()
LocationInternal
getRebindSupport
in interface Rebindable
getRebindSupport
in interface LocationInternal
getRebindSupport
in interface BrooklynObjectInternal
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, HostAndPort publicEndpoint, Location l, int privatePort)
PortForwardManager
PortForwardManager.lookup(Location, int)
.
Superfluous if #acquirePublicPort(String, Location, int)
was used,
but strongly recommended if #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, HostAndPort publicEndpoint, int privatePort)
PortForwardManager
PortForwardManager.lookup(String, int)
.associate
in interface PortForwardManager
public HostAndPort lookup(Location l, int privatePort)
PortForwardManager
Will return null if:
lookup
in interface PortForwardManager
#recordPublicIpHostname(String, String)
public 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 Location
toVerboseString
in interface PortForwardManager
toVerboseString
in class AbstractLocation
public java.lang.String getScope()
getScope
in interface PortForwardManager
public void addAssociationListener(PortForwardManager.AssociationListener listener, <any> 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 boolean forgetPortMapping(PortMapping m)
forgetPortMapping
in interface PortForwardManager
#forgetPortMapping(String, int)} and {@link #forgetPortMappings(Location)}
public 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