flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/JobManagerStartupTest.java
/**
	 * Verifies that the JobManager fails fast (and with expressive error message)
	 * when the port to listen is already in use.
	 * @throws Throwable 
	 */
Verifies that the JobManager fails fast (and with expressive error message)
when the port to listen is already in use.
@throws Throwable
Verifies that the JobManager fails fast ( and with expressive error message ) when the port to listen is already in use . @throws Throwable
@Test( expected = BindException.class )
	public void testStartupWithPortInUse() throws BindException {
		ServerSocket portOccupier;
		final int portNum;
		try {
			portNum = NetUtils.getAvailablePort();
			portOccupier = new ServerSocket(portNum, 10, InetAddress.getByName("0.0.0.0"));
		}
		catch (Throwable t) {
			return;
		}
		try {
			JobManager.runJobManager(new Configuration(), JobManagerMode.CLUSTER, "localhost", portNum);
			fail("this should throw an exception");
		}
		catch (Exception e) {
			List<Throwable> causes = StartupUtils.getExceptionCauses(e, new ArrayList<Throwable>());
			for(Throwable cause:causes) {
				if(cause instanceof BindException) {
					throw (BindException) cause;
				}	
			}
			throw e;
		}
		finally {
			try {
				portOccupier.close();
			}
			catch (Throwable t) {
			}
		}
	}
@ Test ( expected = BindException . class ) public void testStartupWithPortInUse ( ) throws BindException { ServerSocket portOccupier ; final int portNum ; try { portNum = NetUtils . getAvailablePort ( ) ; portOccupier = new ServerSocket ( portNum , 10 , InetAddress . getByName ( "0.0.0.0" ) ) ; } catch ( Throwable t ) { return ; } try { JobManager . runJobManager ( new Configuration ( ) , JobManagerMode . CLUSTER , "localhost" , portNum ) ; fail ( "this should throw an exception" ) ; } catch ( Exception e ) { List < Throwable > causes = StartupUtils . getExceptionCauses ( e , new ArrayList < Throwable > ( ) ) ; for ( Throwable cause : causes ) { if ( cause instanceof BindException ) { throw ( BindException ) cause ; } } throw e ; } finally { try { portOccupier . close ( ) ; } catch ( Throwable t ) { } } }
Verifies that the JobManager fails fast (and with expressive error message)
 when the port to listen is already in use.
Verifies that the JobManager fails fast ( and with expressive error message ) when the port to listen is already in use .
// could not find free port, or open a connection there // expected // ignore