private Map < String , List < PortBinding > > portBindings ( ) { final Map < String , List < PortBinding > > bindings = Maps . newHashMap ( ) ; for ( final Map . Entry < String , PortMapping > e : job . getPorts ( ) . entrySet ( ) ) { final PortMapping mapping = e . getValue ( ) ; final Integer jobDefinedExtPort = mapping . getExternalPort ( ) ; // If the job didn't specify an external port, use dynamically allocated ports final String externalPort = jobDefinedExtPort == null ? ports . get ( e . getKey ( ) ) . toString ( ) : jobDefinedExtPort . toString ( ) ; final PortBinding binding = PortBinding . of ( mapping . getIp ( ) , externalPort ) ; final String entry = containerPort ( mapping . getInternalPort ( ) , mapping . getProtocol ( ) ) ; bindings . put ( entry , Collections . singletonList ( binding ) ) ; } return bindings ; }
Create a port binding configuration for the job .