flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestServerEndpoint.java
/**
	 * Stops this REST server endpoint.
	 */
Stops this REST server endpoint.
Stops this REST server endpoint .
public void shutdown(Time timeout) {
		synchronized (lock) {
			if (!started) {
				return;
			}
			log.info("Shutting down rest endpoint.");
			CompletableFuture<?> channelFuture = new CompletableFuture<>();
			if (this.serverChannel != null) {
				this.serverChannel.close().addListener(ignored -> channelFuture.complete(null));
				serverChannel = null;
			}
			CompletableFuture<?> groupFuture = new CompletableFuture<>();
			CompletableFuture<?> childGroupFuture = new CompletableFuture<>();
			channelFuture.thenRun(() -> {
				if (bootstrap != null) {
					if (bootstrap.group() != null) {
						bootstrap.group().shutdownGracefully(0, timeout.toMilliseconds(), TimeUnit.MILLISECONDS)
							.addListener(ignored -> groupFuture.complete(null));
					}
					if (bootstrap.childGroup() != null) {
						bootstrap.childGroup().shutdownGracefully(0, timeout.toMilliseconds(), TimeUnit.MILLISECONDS)
							.addListener(ignored -> childGroupFuture.complete(null));
					}
					bootstrap = null;
				} else {
					groupFuture.complete(null);
					childGroupFuture.complete(null);
				}
			});
			try {
				CompletableFuture.allOf(groupFuture, childGroupFuture).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
				log.info("Rest endpoint shutdown complete.");
			} catch (Exception e) {
				log.warn("Rest endpoint shutdown failed.", e);
			}
			restAddress = null;
			started = false;
		}
	}
public void shutdown ( Time timeout ) { synchronized ( lock ) { if ( ! started ) { return ; } log . info ( "Shutting down rest endpoint." ) ; CompletableFuture < ? > channelFuture = new CompletableFuture < > ( ) ; if ( this . serverChannel != null ) { this . serverChannel . close ( ) . addListener ( ignored -> channelFuture . complete ( null ) ) ; serverChannel = null ; } CompletableFuture < ? > groupFuture = new CompletableFuture < > ( ) ; CompletableFuture < ? > childGroupFuture = new CompletableFuture < > ( ) ; channelFuture . thenRun ( ( ) -> { if ( bootstrap != null ) { if ( bootstrap . group ( ) != null ) { bootstrap . group ( ) . shutdownGracefully ( 0 , timeout . toMilliseconds ( ) , TimeUnit . MILLISECONDS ) . addListener ( ignored -> groupFuture . complete ( null ) ) ; } if ( bootstrap . childGroup ( ) != null ) { bootstrap . childGroup ( ) . shutdownGracefully ( 0 , timeout . toMilliseconds ( ) , TimeUnit . MILLISECONDS ) . addListener ( ignored -> childGroupFuture . complete ( null ) ) ; } bootstrap = null ; } else { groupFuture . complete ( null ) ; childGroupFuture . complete ( null ) ; } } ) ; try { CompletableFuture . allOf ( groupFuture , childGroupFuture ) . get ( timeout . toMilliseconds ( ) , TimeUnit . MILLISECONDS ) ; log . info ( "Rest endpoint shutdown complete." ) ; } catch ( Exception e ) { log . warn ( "Rest endpoint shutdown failed." , e ) ; } restAddress = null ; started = false ; } }
Stops this REST server endpoint.
Stops this REST server endpoint .
// RestServerEndpoint has not been started // complete the group futures since there is nothing to stop