Automatically adds a mapping for TCP when running on EC2.

This commit is contained in:
boris 2015-06-02 12:22:14 +00:00
parent 4f4b5005f9
commit 471f91b364
2 changed files with 12 additions and 1 deletions

View File

@ -210,7 +210,7 @@ public class AwsCandidateHarvester
* @return <tt>true</tt> if there appear to be decent chances for this
* machine to be an AWS EC2 and <tt>false</tt> otherwise.
*/
public static boolean smellsLikeAnEC2()
public synchronized static boolean smellsLikeAnEC2()
{
if (RUNNING_ON_EC2 == null)
{

View File

@ -628,6 +628,17 @@ public class MultiplexingTcpHostHarvester
serverSocketChannels.add(channel);
}
// Automatically add a mapping if we're on EC2
TransportAddress ec2Face = AwsCandidateHarvester.getFace();
TransportAddress ec2Mask;
if (ec2Face != null &&
(ec2Mask = AwsCandidateHarvester.getMask()) != null)
{
addMappedAddress(ec2Mask.getAddress(), ec2Face.getAddress());
logger.info("Adding an EC2 mapping for TCP: "
+ ec2Face + "->" + ec2Mask);
}
acceptThread = new AcceptThread();
acceptThread.start();