You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tr...@apache.org on 2018/02/06 16:53:16 UTC

[01/11] flink git commit: [FLINK-8501] [flip6] Use single BlobCacheService per TaskExecutor

Repository: flink
Updated Branches:
  refs/heads/master 9d0eb2299 -> 62a777bc8


http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheRetriesTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheRetriesTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheRetriesTest.java
index 80e9767..37b7009 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheRetriesTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheRetriesTest.java
@@ -117,8 +117,8 @@ public class BlobCacheRetriesTest extends TestLogger {
 
 		try (
 			BlobServer server = new TestingFailingBlobServer(config, blobStore, 2);
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -200,8 +200,8 @@ public class BlobCacheRetriesTest extends TestLogger {
 
 		try (
 			BlobServer server = new TestingFailingBlobServer(config, blobStore, 0, 10);
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheSuccessTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheSuccessTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheSuccessTest.java
index fcdc714..efafc30 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheSuccessTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheSuccessTest.java
@@ -164,8 +164,8 @@ public class BlobCacheSuccessTest extends TestLogger {
 			blobStoreService = BlobUtils.createBlobStoreFromConfig(cacheConfig);
 			try (
 				BlobServer server = new BlobServer(config, blobStoreService);
-				BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-					cacheConfig, blobStoreService)) {
+				BlobCacheService cache = new BlobCacheService(cacheConfig, blobStoreService, new InetSocketAddress("localhost", server.getPort())
+				)) {
 
 				server.start();
 

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobServerRecoveryTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobServerRecoveryTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobServerRecoveryTest.java
index 5b8d0e9..104134b 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobServerRecoveryTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobServerRecoveryTest.java
@@ -103,8 +103,8 @@ public class BlobServerRecoveryTest extends TestLogger {
 			BlobServer server1 = new BlobServer(config, blobStore);
 			// use VoidBlobStore as the HA store to force download from server[1]'s HA store
 			BlobCacheService cache1 = new BlobCacheService(
-				new InetSocketAddress("localhost", server1.getPort()), config,
-				new VoidBlobStore())) {
+				config, new VoidBlobStore(), new InetSocketAddress("localhost", server1.getPort())
+			)) {
 
 			server0.start();
 			server1.start();

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/ResourceManagerTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/ResourceManagerTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/ResourceManagerTest.java
index c238e33..096ba5e 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/ResourceManagerTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/ResourceManagerTest.java
@@ -31,6 +31,7 @@ import org.apache.flink.runtime.clusterframework.messages.ResourceRemoved;
 import org.apache.flink.runtime.clusterframework.messages.TriggerRegistrationAtJobManager;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.concurrent.ScheduledExecutor;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.heartbeat.TestingHeartbeatServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
@@ -528,6 +529,7 @@ public class ResourceManagerTest extends TestLogger {
 				slotManager,
 				metricRegistry,
 				jobLeaderIdService,
+				new ClusterInformation("localhost", 1234),
 				testingFatalErrorHandler);
 
 			resourceManager.start();
@@ -632,6 +634,7 @@ public class ResourceManagerTest extends TestLogger {
 				slotManager,
 				metricRegistry,
 				jobLeaderIdService,
+				new ClusterInformation("localhost", 1234),
 				testingFatalErrorHandler);
 
 			resourceManager.start();

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/BlobLibraryCacheManagerTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/BlobLibraryCacheManagerTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/BlobLibraryCacheManagerTest.java
index 83b6814..4b63e4b 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/BlobLibraryCacheManagerTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/BlobLibraryCacheManagerTest.java
@@ -85,7 +85,7 @@ public class BlobLibraryCacheManagerTest extends TestLogger {
 			server = new BlobServer(config, new VoidBlobStore());
 			server.start();
 			InetSocketAddress serverAddress = new InetSocketAddress("localhost", server.getPort());
-			cache = new PermanentBlobCache(serverAddress, config, new VoidBlobStore());
+			cache = new PermanentBlobCache(config, new VoidBlobStore(), serverAddress);
 
 			keys1.add(server.putPermanent(jobId1, buf));
 			buf[0] += 1;
@@ -216,7 +216,7 @@ public class BlobLibraryCacheManagerTest extends TestLogger {
 			server = new BlobServer(config, new VoidBlobStore());
 			server.start();
 			InetSocketAddress serverAddress = new InetSocketAddress("localhost", server.getPort());
-			cache = new PermanentBlobCache(serverAddress, config, new VoidBlobStore());
+			cache = new PermanentBlobCache(config, new VoidBlobStore(), serverAddress);
 
 			keys.add(server.putPermanent(jobId, buf));
 			buf[0] += 1;
@@ -328,7 +328,7 @@ public class BlobLibraryCacheManagerTest extends TestLogger {
 			server = new BlobServer(config, new VoidBlobStore());
 			server.start();
 			InetSocketAddress serverAddress = new InetSocketAddress("localhost", server.getPort());
-			cache = new PermanentBlobCache(serverAddress, config, new VoidBlobStore());
+			cache = new PermanentBlobCache(config, new VoidBlobStore(), serverAddress);
 
 			keys.add(server.putPermanent(jobId, buf));
 			buf[0] += 1;
@@ -434,7 +434,7 @@ public class BlobLibraryCacheManagerTest extends TestLogger {
 			server = new BlobServer(config, new VoidBlobStore());
 			server.start();
 			InetSocketAddress serverAddress = new InetSocketAddress("localhost", server.getPort());
-			cache = new PermanentBlobCache(serverAddress, config, new VoidBlobStore());
+			cache = new PermanentBlobCache(config, new VoidBlobStore(), serverAddress);
 
 			// upload some meaningless data to the server
 			PermanentBlobKey dataKey1 = server.putPermanent(jobId, new byte[]{1, 2, 3, 4, 5, 6, 7, 8});

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/BlobLibraryCacheRecoveryITCase.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/BlobLibraryCacheRecoveryITCase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/BlobLibraryCacheRecoveryITCase.java
index ad18ae3..a5f22cb 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/BlobLibraryCacheRecoveryITCase.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/execution/librarycache/BlobLibraryCacheRecoveryITCase.java
@@ -100,7 +100,7 @@ public class BlobLibraryCacheRecoveryITCase extends TestLogger {
 			keys.add(server[0].putPermanent(jobId, expected2)); // Request 2
 
 			// The cache
-			cache = new PermanentBlobCache(serverAddress[0], config, blobStoreService);
+			cache = new PermanentBlobCache(config, blobStoreService, serverAddress[0]);
 
 			// Register uploaded libraries
 			ExecutionAttemptID executionId = new ExecutionAttemptID();
@@ -121,7 +121,7 @@ public class BlobLibraryCacheRecoveryITCase extends TestLogger {
 			// Shutdown cache and start with other server
 			cache.close();
 
-			cache = new PermanentBlobCache(serverAddress[1], config, blobStoreService);
+			cache = new PermanentBlobCache(config, blobStoreService, serverAddress[1]);
 
 			// Verify key 1
 			f = cache.getFile(jobId, keys.get(0));

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphDeploymentWithBlobCacheTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphDeploymentWithBlobCacheTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphDeploymentWithBlobCacheTest.java
index 25d218e..61a9676 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphDeploymentWithBlobCacheTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphDeploymentWithBlobCacheTest.java
@@ -47,7 +47,7 @@ public class ExecutionGraphDeploymentWithBlobCacheTest extends ExecutionGraphDep
 		blobWriter = blobServer;
 
 		InetSocketAddress serverAddress = new InetSocketAddress("localhost", blobServer.getPort());
-		blobCache = new PermanentBlobCache(serverAddress, config, new VoidBlobStore());
+		blobCache = new PermanentBlobCache(config, new VoidBlobStore(), serverAddress);
 	}
 
 	@After

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerHATest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerHATest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerHATest.java
index 960b402..57ce349 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerHATest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerHATest.java
@@ -21,6 +21,7 @@ package org.apache.flink.runtime.resourcemanager;
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.runtime.clusterframework.FlinkResourceManager;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.highavailability.TestingHighAvailabilityServices;
 import org.apache.flink.runtime.leaderelection.TestingLeaderElectionService;
@@ -98,6 +99,7 @@ public class ResourceManagerHATest extends TestLogger {
 				resourceManagerRuntimeServices.getSlotManager(),
 				metricRegistry,
 				resourceManagerRuntimeServices.getJobLeaderIdService(),
+				new ClusterInformation("localhost", 1234),
 				testingFatalErrorHandler) {
 
 				@Override

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerJobMasterTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerJobMasterTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerJobMasterTest.java
index 6fa84bb..4440e38 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerJobMasterTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerJobMasterTest.java
@@ -22,6 +22,7 @@ import org.apache.flink.api.common.JobID;
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.runtime.clusterframework.FlinkResourceManager;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
 import org.apache.flink.runtime.highavailability.TestingHighAvailabilityServices;
@@ -295,6 +296,7 @@ public class ResourceManagerJobMasterTest extends TestLogger {
 			slotManager,
 			metricRegistry,
 			jobLeaderIdService,
+			new ClusterInformation("localhost", 1234),
 			fatalErrorHandler);
 		resourceManager.start();
 		return resourceManager;

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerTaskExecutorTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerTaskExecutorTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerTaskExecutorTest.java
index 00fbca7..2af6632 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerTaskExecutorTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerTaskExecutorTest.java
@@ -21,6 +21,7 @@ package org.apache.flink.runtime.resourcemanager;
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.runtime.clusterframework.FlinkResourceManager;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.highavailability.TestingHighAvailabilityServices;
 import org.apache.flink.runtime.instance.HardwareDescription;
@@ -218,6 +219,7 @@ public class ResourceManagerTaskExecutorTest extends TestLogger {
 				slotManager,
 				metricRegistry,
 				jobLeaderIdService,
+				new ClusterInformation("localhost", 1234),
 				fatalErrorHandler);
 
 		resourceManager.start();

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/TestingResourceManager.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/TestingResourceManager.java b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/TestingResourceManager.java
index 2af024e..3db9be0 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/TestingResourceManager.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/TestingResourceManager.java
@@ -21,6 +21,7 @@ package org.apache.flink.runtime.resourcemanager;
 import org.apache.flink.runtime.clusterframework.ApplicationStatus;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
 import org.apache.flink.runtime.metrics.MetricRegistry;
@@ -47,7 +48,18 @@ public class TestingResourceManager extends ResourceManager<ResourceID> {
 			MetricRegistry metricRegistry,
 			JobLeaderIdService jobLeaderIdService,
 			FatalErrorHandler fatalErrorHandler) {
-		super(rpcService, resourceManagerEndpointId, resourceId, resourceManagerConfiguration, highAvailabilityServices, heartbeatServices, slotManager, metricRegistry, jobLeaderIdService, fatalErrorHandler);
+		super(
+			rpcService,
+			resourceManagerEndpointId,
+			resourceId,
+			resourceManagerConfiguration,
+			highAvailabilityServices,
+			heartbeatServices,
+			slotManager,
+			metricRegistry,
+			jobLeaderIdService,
+			new ClusterInformation("localhost", 1234),
+			fatalErrorHandler);
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/utils/TestingResourceManagerGateway.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/utils/TestingResourceManagerGateway.java b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/utils/TestingResourceManagerGateway.java
index 1428e02..7325142 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/utils/TestingResourceManagerGateway.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/utils/TestingResourceManagerGateway.java
@@ -28,6 +28,7 @@ import org.apache.flink.runtime.clusterframework.types.AllocationID;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.clusterframework.types.SlotID;
 import org.apache.flink.runtime.concurrent.FutureUtils;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.instance.HardwareDescription;
 import org.apache.flink.runtime.instance.InstanceID;
 import org.apache.flink.runtime.jobmaster.JobMasterId;
@@ -178,7 +179,8 @@ public class TestingResourceManagerGateway implements ResourceManagerGateway {
 				new TaskExecutorRegistrationSuccess(
 					new InstanceID(),
 					ownResourceId,
-					heartbeatInterval));
+					heartbeatInterval,
+					new ClusterInformation("localhost", 1234)));
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorITCase.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorITCase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorITCase.java
index 69d84f4..c5d7c24 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorITCase.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorITCase.java
@@ -21,11 +21,13 @@ package org.apache.flink.runtime.taskexecutor;
 import org.apache.flink.api.common.JobID;
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.configuration.Configuration;
+import org.apache.flink.runtime.blob.BlobCacheService;
 import org.apache.flink.runtime.broadcast.BroadcastVariableManager;
 import org.apache.flink.runtime.clusterframework.FlinkResourceManager;
 import org.apache.flink.runtime.clusterframework.types.AllocationID;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.filecache.FileCache;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.highavailability.TestingHighAvailabilityServices;
@@ -153,6 +155,7 @@ public class TaskExecutorITCase extends TestLogger {
 			slotManager,
 			metricRegistry,
 			jobLeaderIdService,
+			new ClusterInformation("localhost", 1234),
 			testingFatalErrorHandler);
 
 		TaskExecutor taskExecutor = new TaskExecutor(
@@ -168,6 +171,10 @@ public class TaskExecutorITCase extends TestLogger {
 			taskManagerMetricGroup,
 			broadcastVariableManager,
 			fileCache,
+			new BlobCacheService(
+				configuration,
+				testingHAServices.createBlobStore(),
+				null),
 			taskSlotTable,
 			jobManagerTable,
 			jobLeaderService,
@@ -176,7 +183,7 @@ public class TaskExecutorITCase extends TestLogger {
 		JobMasterGateway jmGateway = mock(JobMasterGateway.class);
 
 		when(jmGateway.registerTaskManager(any(String.class), any(TaskManagerLocation.class), any(Time.class)))
-			.thenReturn(CompletableFuture.completedFuture(new JMTMRegistrationSuccess(taskManagerResourceId, 1234)));
+			.thenReturn(CompletableFuture.completedFuture(new JMTMRegistrationSuccess(taskManagerResourceId)));
 		when(jmGateway.getHostname()).thenReturn(jmAddress);
 		when(jmGateway.offerSlots(
 			eq(taskManagerResourceId),

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorTest.java
index efd27f5..0e12c54 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorTest.java
@@ -23,8 +23,7 @@ import org.apache.flink.api.common.JobID;
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.runtime.blob.BlobCacheService;
-import org.apache.flink.runtime.blob.PermanentBlobCache;
-import org.apache.flink.runtime.blob.TransientBlobCache;
+import org.apache.flink.runtime.blob.VoidBlobStore;
 import org.apache.flink.runtime.broadcast.BroadcastVariableManager;
 import org.apache.flink.runtime.clusterframework.types.AllocationID;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
@@ -34,6 +33,7 @@ import org.apache.flink.runtime.concurrent.ScheduledExecutor;
 import org.apache.flink.runtime.deployment.InputGateDeploymentDescriptor;
 import org.apache.flink.runtime.deployment.ResultPartitionDeploymentDescriptor;
 import org.apache.flink.runtime.deployment.TaskDeploymentDescriptor;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.execution.Environment;
 import org.apache.flink.runtime.execution.librarycache.LibraryCacheManager;
 import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
@@ -109,6 +109,7 @@ import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.slf4j.Logger;
 
+import java.io.IOException;
 import java.net.InetAddress;
 import java.util.Arrays;
 import java.util.Collection;
@@ -151,14 +152,20 @@ public class TaskExecutorTest extends TestLogger {
 
 	private TestingRpcService rpc;
 
+	private BlobCacheService dummyBlobCacheService;
+
 	@Before
-	public void setup() {
+	public void setup() throws IOException {
 		rpc = new TestingRpcService();
 		timerService = new TimerService<>(TestingUtils.defaultExecutor(), timeout.toMilliseconds());
+		dummyBlobCacheService = new BlobCacheService(
+			new Configuration(),
+			new VoidBlobStore(),
+			null);
 	}
 
 	@After
-	public void teardown() {
+	public void teardown() throws IOException {
 		if (rpc != null) {
 			rpc.stopService();
 			rpc = null;
@@ -168,6 +175,11 @@ public class TaskExecutorTest extends TestLogger {
 			timerService.stop();
 			timerService = null;
 		}
+
+		if (dummyBlobCacheService != null) {
+			dummyBlobCacheService.close();
+			dummyBlobCacheService = null;
+		}
 	}
 
 	@Rule
@@ -221,13 +233,12 @@ public class TaskExecutorTest extends TestLogger {
 		final UUID jmLeaderId = UUID.randomUUID();
 		final ResourceID jmResourceId = new ResourceID(jobMasterAddress);
 		final JobMasterGateway jobMasterGateway = mock(JobMasterGateway.class);
-		final int blobPort = 42;
 
 		when(jobMasterGateway.registerTaskManager(
 				any(String.class),
 				eq(taskManagerLocation),
 				any(Time.class)
-		)).thenReturn(CompletableFuture.completedFuture(new JMTMRegistrationSuccess(jmResourceId, blobPort)));
+		)).thenReturn(CompletableFuture.completedFuture(new JMTMRegistrationSuccess(jmResourceId)));
 		when(jobMasterGateway.getAddress()).thenReturn(jobMasterAddress);
 		when(jobMasterGateway.getHostname()).thenReturn("localhost");
 
@@ -241,10 +252,10 @@ public class TaskExecutorTest extends TestLogger {
 			mock(NetworkEnvironment.class),
 			haServices,
 			heartbeatServices,
-
 			mock(TaskManagerMetricGroup.class),
 			mock(BroadcastVariableManager.class),
 			mock(FileCache.class),
+			dummyBlobCacheService,
 			taskSlotTable,
 			new JobManagerTable(),
 			jobLeaderService,
@@ -295,7 +306,8 @@ public class TaskExecutorTest extends TestLogger {
 					new TaskExecutorRegistrationSuccess(
 						new InstanceID(),
 						rmResourceId,
-						10L)));
+						10L,
+						new ClusterInformation("localhost", 1234))));
 
 		rpc.registerGateway(rmAddress, rmGateway);
 
@@ -348,10 +360,10 @@ public class TaskExecutorTest extends TestLogger {
 			mock(NetworkEnvironment.class),
 			haServices,
 			heartbeatServices,
-
 			mock(TaskManagerMetricGroup.class),
 			mock(BroadcastVariableManager.class),
 			mock(FileCache.class),
+			dummyBlobCacheService,
 			taskSlotTable,
 			mock(JobManagerTable.class),
 			mock(JobLeaderService.class),
@@ -400,7 +412,8 @@ public class TaskExecutorTest extends TestLogger {
 					new TaskExecutorRegistrationSuccess(
 						new InstanceID(),
 						rmResourceId,
-						10L)));
+						10L,
+						new ClusterInformation("localhost", 1234))));
 
 		rpc.registerGateway(rmAddress, rmGateway);
 
@@ -467,10 +480,10 @@ public class TaskExecutorTest extends TestLogger {
 			mock(NetworkEnvironment.class),
 			haServices,
 			heartbeatServices,
-
 			mock(TaskManagerMetricGroup.class),
 			mock(BroadcastVariableManager.class),
 			mock(FileCache.class),
+			dummyBlobCacheService,
 			taskSlotTable,
 			mock(JobManagerTable.class),
 			mock(JobLeaderService.class),
@@ -531,7 +544,7 @@ public class TaskExecutorTest extends TestLogger {
 		when(rmGateway.registerTaskExecutor(
 					anyString(), any(ResourceID.class), any(SlotReport.class), anyInt(), any(HardwareDescription.class), any(Time.class)))
 			.thenReturn(CompletableFuture.completedFuture(new TaskExecutorRegistrationSuccess(
-				new InstanceID(), resourceManagerResourceId, 10L)));
+				new InstanceID(), resourceManagerResourceId, 10L, new ClusterInformation("localhost", 1234))));
 
 		TaskManagerConfiguration taskManagerServicesConfiguration = mock(TaskManagerConfiguration.class);
 		when(taskManagerServicesConfiguration.getNumberSlots()).thenReturn(1);
@@ -563,10 +576,10 @@ public class TaskExecutorTest extends TestLogger {
 			mock(NetworkEnvironment.class),
 			haServices,
 			mock(HeartbeatServices.class, RETURNS_MOCKS),
-
 			mock(TaskManagerMetricGroup.class),
 			mock(BroadcastVariableManager.class),
 			mock(FileCache.class),
+			dummyBlobCacheService,
 			taskSlotTable,
 			mock(JobManagerTable.class),
 			mock(JobLeaderService.class),
@@ -606,11 +619,11 @@ public class TaskExecutorTest extends TestLogger {
 		when(rmGateway1.registerTaskExecutor(
 					anyString(), any(ResourceID.class), any(SlotReport.class), anyInt(), any(HardwareDescription.class), any(Time.class)))
 			.thenReturn(CompletableFuture.completedFuture(
-				new TaskExecutorRegistrationSuccess(new InstanceID(), rmResourceId1, 10L)));
+				new TaskExecutorRegistrationSuccess(new InstanceID(), rmResourceId1, 10L, new ClusterInformation("localhost", 1234))));
 		when(rmGateway2.registerTaskExecutor(
 					anyString(), any(ResourceID.class), any(SlotReport.class), anyInt(), any(HardwareDescription.class), any(Time.class)))
 			.thenReturn(CompletableFuture.completedFuture(
-				new TaskExecutorRegistrationSuccess(new InstanceID(), rmResourceId2, 10L)));
+				new TaskExecutorRegistrationSuccess(new InstanceID(), rmResourceId2, 10L, new ClusterInformation("localhost", 1234))));
 
 		rpc.registerGateway(address1, rmGateway1);
 		rpc.registerGateway(address2, rmGateway2);
@@ -647,10 +660,10 @@ public class TaskExecutorTest extends TestLogger {
 			mock(NetworkEnvironment.class),
 			haServices,
 			mock(HeartbeatServices.class, RETURNS_MOCKS),
-
 			mock(TaskManagerMetricGroup.class),
 			mock(BroadcastVariableManager.class),
 			mock(FileCache.class),
+			dummyBlobCacheService,
 			taskSlotTable,
 			mock(JobManagerTable.class),
 			mock(JobLeaderService.class),
@@ -740,16 +753,12 @@ public class TaskExecutorTest extends TestLogger {
 		final JobMasterGateway jobMasterGateway = mock(JobMasterGateway.class);
 		when(jobMasterGateway.getFencingToken()).thenReturn(jobMasterId);
 
-		BlobCacheService blobService =
-			new BlobCacheService(mock(PermanentBlobCache.class), mock(TransientBlobCache.class));
-
 		final JobManagerConnection jobManagerConnection = new JobManagerConnection(
 			jobId,
 			ResourceID.generate(),
 			jobMasterGateway,
 			mock(TaskManagerActions.class),
 			mock(CheckpointResponder.class),
-			blobService,
 			libraryCacheManager,
 			mock(ResultPartitionConsumableNotifier.class),
 			mock(PartitionProducerStateChecker.class));
@@ -792,10 +801,10 @@ public class TaskExecutorTest extends TestLogger {
 			networkEnvironment,
 			haServices,
 			mock(HeartbeatServices.class, RETURNS_MOCKS),
-
 			taskManagerMetricGroup,
 			mock(BroadcastVariableManager.class),
 			mock(FileCache.class),
+			dummyBlobCacheService,
 			taskSlotTable,
 			jobManagerTable,
 			mock(JobLeaderService.class),
@@ -878,20 +887,18 @@ public class TaskExecutorTest extends TestLogger {
 			any(SlotReport.class),
 			anyInt(),
 			any(HardwareDescription.class),
-			any(Time.class))).thenReturn(CompletableFuture.completedFuture(new TaskExecutorRegistrationSuccess(registrationId, resourceManagerResourceId, 1000L)));
+			any(Time.class))).thenReturn(CompletableFuture.completedFuture(new TaskExecutorRegistrationSuccess(registrationId, resourceManagerResourceId, 1000L, new ClusterInformation("localhost", 1234))));
 
 		final String jobManagerAddress = "jm";
 		final UUID jobManagerLeaderId = UUID.randomUUID();
 		final ResourceID jmResourceId = new ResourceID(jobManagerAddress);
-		final int blobPort = 42;
-
 		final JobMasterGateway jobMasterGateway = mock(JobMasterGateway.class);
 
 		when(jobMasterGateway.registerTaskManager(
 				any(String.class),
 				eq(taskManagerLocation),
 				any(Time.class)
-		)).thenReturn(CompletableFuture.completedFuture(new JMTMRegistrationSuccess(jmResourceId, blobPort)));
+		)).thenReturn(CompletableFuture.completedFuture(new JMTMRegistrationSuccess(jmResourceId)));
 		when(jobMasterGateway.getHostname()).thenReturn(jobManagerAddress);
 		when(jobMasterGateway.offerSlots(
 			any(ResourceID.class),
@@ -915,10 +922,10 @@ public class TaskExecutorTest extends TestLogger {
 			mock(NetworkEnvironment.class),
 			haServices,
 			mock(HeartbeatServices.class, RETURNS_MOCKS),
-
 			mock(TaskManagerMetricGroup.class),
 			mock(BroadcastVariableManager.class),
 			mock(FileCache.class),
+			dummyBlobCacheService,
 			taskSlotTable,
 			jobManagerTable,
 			jobLeaderService,
@@ -1000,10 +1007,9 @@ public class TaskExecutorTest extends TestLogger {
 			any(SlotReport.class),
 			anyInt(),
 			any(HardwareDescription.class),
-			any(Time.class))).thenReturn(CompletableFuture.completedFuture(new TaskExecutorRegistrationSuccess(registrationId, resourceManagerResourceId, 1000L)));
+			any(Time.class))).thenReturn(CompletableFuture.completedFuture(new TaskExecutorRegistrationSuccess(registrationId, resourceManagerResourceId, 1000L, new ClusterInformation("localhost", 1234))));
 
 		final ResourceID jmResourceId = new ResourceID(jobManagerAddress);
-		final int blobPort = 42;
 
 		final AllocationID allocationId1 = new AllocationID();
 		final AllocationID allocationId2 = new AllocationID();
@@ -1016,7 +1022,7 @@ public class TaskExecutorTest extends TestLogger {
 				any(String.class),
 				eq(taskManagerLocation),
 				any(Time.class)
-		)).thenReturn(CompletableFuture.completedFuture(new JMTMRegistrationSuccess(jmResourceId, blobPort)));
+		)).thenReturn(CompletableFuture.completedFuture(new JMTMRegistrationSuccess(jmResourceId)));
 		when(jobMasterGateway.getHostname()).thenReturn(jobManagerAddress);
 
 		when(jobMasterGateway.offerSlots(
@@ -1039,6 +1045,7 @@ public class TaskExecutorTest extends TestLogger {
 			mock(TaskManagerMetricGroup.class),
 			mock(BroadcastVariableManager.class),
 			mock(FileCache.class),
+			dummyBlobCacheService,
 			taskSlotTable,
 			jobManagerTable,
 			jobLeaderService,
@@ -1119,7 +1126,7 @@ public class TaskExecutorTest extends TestLogger {
 		when(taskSlotTable.getCurrentAllocation(1)).thenReturn(new AllocationID());
 
 			when(rmGateway1.registerTaskExecutor(anyString(), eq(resourceID), any(SlotReport.class), anyInt(), any(HardwareDescription.class), any(Time.class))).thenReturn(
-			CompletableFuture.completedFuture(new TaskExecutorRegistrationSuccess(new InstanceID(), ResourceID.generate(), 1000L)));
+			CompletableFuture.completedFuture(new TaskExecutorRegistrationSuccess(new InstanceID(), ResourceID.generate(), 1000L, new ClusterInformation("localhost", 1234))));
 
 		TaskExecutor taskManager = new TaskExecutor(
 			rpc,
@@ -1131,10 +1138,10 @@ public class TaskExecutorTest extends TestLogger {
 			mock(NetworkEnvironment.class),
 			haServices,
 			mock(HeartbeatServices.class, RETURNS_MOCKS),
-
 			mock(TaskManagerMetricGroup.class),
 			mock(BroadcastVariableManager.class),
 			mock(FileCache.class),
+			dummyBlobCacheService,
 			taskSlotTable,
 			mock(JobManagerTable.class),
 			mock(JobLeaderService.class),
@@ -1246,10 +1253,9 @@ public class TaskExecutorTest extends TestLogger {
 			anyInt(),
 			any(HardwareDescription.class),
 			any(Time.class))).thenReturn(
-				CompletableFuture.completedFuture(new TaskExecutorRegistrationSuccess(registrationId, resourceManagerResourceId, 1000L)));
+				CompletableFuture.completedFuture(new TaskExecutorRegistrationSuccess(registrationId, resourceManagerResourceId, 1000L, new ClusterInformation("localhost", 1234))));
 
 		final ResourceID jmResourceId = new ResourceID(jobManagerAddress);
-		final int blobPort = 42;
 
 		final AllocationID allocationId1 = new AllocationID();
 		final AllocationID allocationId2 = new AllocationID();
@@ -1262,7 +1268,7 @@ public class TaskExecutorTest extends TestLogger {
 			any(String.class),
 			eq(taskManagerLocation),
 			any(Time.class)
-		)).thenReturn(CompletableFuture.completedFuture(new JMTMRegistrationSuccess(jmResourceId, blobPort)));
+		)).thenReturn(CompletableFuture.completedFuture(new JMTMRegistrationSuccess(jmResourceId)));
 		when(jobMasterGateway.getHostname()).thenReturn(jobManagerAddress);
 		when(jobMasterGateway.updateTaskExecutionState(any(TaskExecutionState.class))).thenReturn(CompletableFuture.completedFuture(Acknowledge.get()));
 
@@ -1273,16 +1279,12 @@ public class TaskExecutorTest extends TestLogger {
 		final LibraryCacheManager libraryCacheManager = mock(LibraryCacheManager.class);
 		when(libraryCacheManager.getClassLoader(eq(jobId))).thenReturn(getClass().getClassLoader());
 
-		BlobCacheService blobService =
-			new BlobCacheService(mock(PermanentBlobCache.class), mock(TransientBlobCache.class));
-
 		final JobManagerConnection jobManagerConnection = new JobManagerConnection(
 			jobId,
 			jmResourceId,
 			jobMasterGateway,
 			mock(TaskManagerActions.class),
 			mock(CheckpointResponder.class),
-			blobService,
 			libraryCacheManager,
 			mock(ResultPartitionConsumableNotifier.class),
 			mock(PartitionProducerStateChecker.class));
@@ -1308,10 +1310,10 @@ public class TaskExecutorTest extends TestLogger {
 			networkMock,
 			haServices,
 			mock(HeartbeatServices.class, RETURNS_MOCKS),
-
 			taskManagerMetricGroup,
 			mock(BroadcastVariableManager.class),
 			mock(FileCache.class),
+			dummyBlobCacheService,
 			taskSlotTable,
 			jobManagerTable,
 			jobLeaderService,
@@ -1419,7 +1421,7 @@ public class TaskExecutorTest extends TestLogger {
 		final JobID jobId = new JobID();
 		final JobMasterGateway jobMasterGateway = mock(JobMasterGateway.class);
 		when(jobMasterGateway.getHostname()).thenReturn("localhost");
-		final JMTMRegistrationSuccess registrationMessage = new JMTMRegistrationSuccess(ResourceID.generate(), 1);
+		final JMTMRegistrationSuccess registrationMessage = new JMTMRegistrationSuccess(ResourceID.generate());
 		final JobManagerTable jobManagerTableMock = spy(new JobManagerTable());
 
 		final TaskExecutor taskExecutor = new TaskExecutor(
@@ -1435,6 +1437,7 @@ public class TaskExecutorTest extends TestLogger {
 			mock(TaskManagerMetricGroup.class),
 			mock(BroadcastVariableManager.class),
 			mock(FileCache.class),
+			dummyBlobCacheService,
 			mock(TaskSlotTable.class),
 			jobManagerTableMock,
 			jobLeaderService,
@@ -1514,6 +1517,7 @@ public class TaskExecutorTest extends TestLogger {
 			mock(TaskManagerMetricGroup.class),
 			mock(BroadcastVariableManager.class),
 			mock(FileCache.class),
+			dummyBlobCacheService,
 			taskSlotTable,
 			mock(JobManagerTable.class),
 			mock(JobLeaderService.class),
@@ -1579,6 +1583,7 @@ public class TaskExecutorTest extends TestLogger {
 			UnregisteredMetricGroups.createUnregisteredTaskManagerMetricGroup(),
 			new BroadcastVariableManager(),
 			mock(FileCache.class),
+			dummyBlobCacheService,
 			taskSlotTable,
 			new JobManagerTable(),
 			jobLeaderService,

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-yarn/src/main/java/org/apache/flink/yarn/YarnResourceManager.java
----------------------------------------------------------------------
diff --git a/flink-yarn/src/main/java/org/apache/flink/yarn/YarnResourceManager.java b/flink-yarn/src/main/java/org/apache/flink/yarn/YarnResourceManager.java
index 4e5cfce..d72f4ac 100644
--- a/flink-yarn/src/main/java/org/apache/flink/yarn/YarnResourceManager.java
+++ b/flink-yarn/src/main/java/org/apache/flink/yarn/YarnResourceManager.java
@@ -26,6 +26,7 @@ import org.apache.flink.runtime.clusterframework.BootstrapTools;
 import org.apache.flink.runtime.clusterframework.ContaineredTaskManagerParameters;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
 import org.apache.flink.runtime.metrics.MetricRegistry;
@@ -128,6 +129,7 @@ public class YarnResourceManager extends ResourceManager<YarnWorkerNode> impleme
 			SlotManager slotManager,
 			MetricRegistry metricRegistry,
 			JobLeaderIdService jobLeaderIdService,
+			ClusterInformation clusterInformation,
 			FatalErrorHandler fatalErrorHandler,
 			@Nullable String webInterfaceUrl) {
 		super(
@@ -140,6 +142,7 @@ public class YarnResourceManager extends ResourceManager<YarnWorkerNode> impleme
 			slotManager,
 			metricRegistry,
 			jobLeaderIdService,
+			clusterInformation,
 			fatalErrorHandler);
 		this.flinkConfig  = flinkConfig;
 		this.yarnConfig = new YarnConfiguration();

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-yarn/src/main/java/org/apache/flink/yarn/entrypoint/YarnJobClusterEntrypoint.java
----------------------------------------------------------------------
diff --git a/flink-yarn/src/main/java/org/apache/flink/yarn/entrypoint/YarnJobClusterEntrypoint.java b/flink-yarn/src/main/java/org/apache/flink/yarn/entrypoint/YarnJobClusterEntrypoint.java
index d27e207..4a9442a 100644
--- a/flink-yarn/src/main/java/org/apache/flink/yarn/entrypoint/YarnJobClusterEntrypoint.java
+++ b/flink-yarn/src/main/java/org/apache/flink/yarn/entrypoint/YarnJobClusterEntrypoint.java
@@ -20,6 +20,7 @@ package org.apache.flink.yarn.entrypoint;
 
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.entrypoint.JobClusterEntrypoint;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
@@ -82,6 +83,7 @@ public class YarnJobClusterEntrypoint extends JobClusterEntrypoint {
 			HeartbeatServices heartbeatServices,
 			MetricRegistry metricRegistry,
 			FatalErrorHandler fatalErrorHandler,
+			ClusterInformation clusterInformation,
 			@Nullable String webInterfaceUrl) throws Exception {
 		final ResourceManagerConfiguration rmConfiguration = ResourceManagerConfiguration.fromConfiguration(configuration);
 		final ResourceManagerRuntimeServicesConfiguration rmServicesConfiguration = ResourceManagerRuntimeServicesConfiguration.fromConfiguration(configuration);
@@ -102,6 +104,7 @@ public class YarnJobClusterEntrypoint extends JobClusterEntrypoint {
 			rmRuntimeServices.getSlotManager(),
 			metricRegistry,
 			rmRuntimeServices.getJobLeaderIdService(),
+			clusterInformation,
 			fatalErrorHandler,
 			webInterfaceUrl);
 	}

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-yarn/src/main/java/org/apache/flink/yarn/entrypoint/YarnSessionClusterEntrypoint.java
----------------------------------------------------------------------
diff --git a/flink-yarn/src/main/java/org/apache/flink/yarn/entrypoint/YarnSessionClusterEntrypoint.java b/flink-yarn/src/main/java/org/apache/flink/yarn/entrypoint/YarnSessionClusterEntrypoint.java
index 81a9b6b..64b4aca 100644
--- a/flink-yarn/src/main/java/org/apache/flink/yarn/entrypoint/YarnSessionClusterEntrypoint.java
+++ b/flink-yarn/src/main/java/org/apache/flink/yarn/entrypoint/YarnSessionClusterEntrypoint.java
@@ -20,6 +20,7 @@ package org.apache.flink.yarn.entrypoint;
 
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.entrypoint.SessionClusterEntrypoint;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
@@ -72,6 +73,7 @@ public class YarnSessionClusterEntrypoint extends SessionClusterEntrypoint {
 			HeartbeatServices heartbeatServices,
 			MetricRegistry metricRegistry,
 			FatalErrorHandler fatalErrorHandler,
+			ClusterInformation clusterInformation,
 			@Nullable String webInterfaceUrl) throws Exception {
 		final ResourceManagerConfiguration rmConfiguration = ResourceManagerConfiguration.fromConfiguration(configuration);
 		final ResourceManagerRuntimeServicesConfiguration rmServicesConfiguration = ResourceManagerRuntimeServicesConfiguration.fromConfiguration(configuration);
@@ -92,6 +94,7 @@ public class YarnSessionClusterEntrypoint extends SessionClusterEntrypoint {
 			rmRuntimeServices.getSlotManager(),
 			metricRegistry,
 			rmRuntimeServices.getJobLeaderIdService(),
+			clusterInformation,
 			fatalErrorHandler,
 			webInterfaceUrl);
 	}

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-yarn/src/test/java/org/apache/flink/yarn/YarnResourceManagerTest.java
----------------------------------------------------------------------
diff --git a/flink-yarn/src/test/java/org/apache/flink/yarn/YarnResourceManagerTest.java b/flink-yarn/src/test/java/org/apache/flink/yarn/YarnResourceManagerTest.java
index 1e70169..8743380 100644
--- a/flink-yarn/src/test/java/org/apache/flink/yarn/YarnResourceManagerTest.java
+++ b/flink-yarn/src/test/java/org/apache/flink/yarn/YarnResourceManagerTest.java
@@ -28,6 +28,7 @@ import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
 import org.apache.flink.runtime.clusterframework.types.SlotID;
 import org.apache.flink.runtime.concurrent.ScheduledExecutor;
 import org.apache.flink.runtime.concurrent.ScheduledExecutorServiceAdapter;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.heartbeat.TestingHeartbeatServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
@@ -152,6 +153,7 @@ public class YarnResourceManagerTest extends TestLogger {
 				SlotManager slotManager,
 				MetricRegistry metricRegistry,
 				JobLeaderIdService jobLeaderIdService,
+				ClusterInformation clusterInformation,
 				FatalErrorHandler fatalErrorHandler,
 				@Nullable String webInterfaceUrl,
 				AMRMClientAsync<AMRMClient.ContainerRequest> mockResourceManagerClient,
@@ -168,6 +170,7 @@ public class YarnResourceManagerTest extends TestLogger {
 				slotManager,
 				metricRegistry,
 				jobLeaderIdService,
+				clusterInformation,
 				fatalErrorHandler,
 				webInterfaceUrl);
 			this.mockNMClient = mockNMClient;
@@ -249,6 +252,7 @@ public class YarnResourceManagerTest extends TestLogger {
 							rmServices.slotManager,
 							rmServices.metricRegistry,
 							rmServices.jobLeaderIdService,
+							new ClusterInformation("localhost", 1234),
 							fatalErrorHandler,
 							null,
 							mockResourceManagerClient,


[09/11] flink git commit: [FLINK-7856][flip6] Port JobVertexBackPressureHandler to REST endpoint

Posted by tr...@apache.org.
[FLINK-7856][flip6] Port JobVertexBackPressureHandler to REST endpoint

This closes #5397.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/c1280a50
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/c1280a50
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/c1280a50

Branch: refs/heads/master
Commit: c1280a5056196e2c20e50dc6c3631ca93c877e58
Parents: 7137d61
Author: gyao <ga...@data-artisans.com>
Authored: Tue Feb 6 13:31:02 2018 +0100
Committer: Till Rohrmann <tr...@apache.org>
Committed: Tue Feb 6 13:36:55 2018 +0100

----------------------------------------------------------------------
 .../runtime/webmonitor/WebRuntimeMonitor.java   |   6 +-
 .../flink/runtime/dispatcher/Dispatcher.java    |  14 ++
 .../dispatcher/DispatcherRestEndpoint.java      |  10 --
 .../runtime/jobmaster/JobManagerRunner.java     |   3 +-
 .../runtime/jobmaster/JobManagerServices.java   |  35 ++++-
 .../flink/runtime/jobmaster/JobMaster.java      |  26 +++-
 .../jobmaster/RpcTaskManagerGateway.java        |   8 +-
 .../job/JobVertexBackPressureHandler.java       |  60 ++++++--
 .../backpressure/BackPressureStatsTracker.java  |  50 +++++--
 .../backpressure/OperatorBackPressureStats.java |   5 +-
 .../OperatorBackPressureStatsResponse.java      |  48 ++++++
 .../EmptyJobVertexBackPressureInfo.java         |  39 -----
 .../messages/JobVertexBackPressureInfo.java     |  58 +++++++-
 .../messages/JobVertexMessageParameters.java    |   2 +-
 .../runtime/taskexecutor/TaskExecutor.java      |  83 +++++++++++
 .../taskexecutor/TaskExecutorGateway.java       |   9 ++
 .../runtime/webmonitor/RestfulGateway.java      |  17 +++
 .../runtime/webmonitor/WebMonitorEndpoint.java  |  10 ++
 .../flink/runtime/jobmaster/JobMasterTest.java  |  12 +-
 .../job/JobVertexBackPressureHandlerTest.java   | 149 +++++++++++++++++++
 .../JobVertexBackPressureHandlerTest.java       |   3 +-
 .../BackPressureStatsTrackerITCase.java         |   6 +-
 .../BackPressureStatsTrackerTest.java           |   8 +-
 .../messages/VertexBackPressureLevelTest.java   |  47 ++++++
 .../messages/VertexBackPressureStatusTest.java  |  45 ++++++
 .../TestingTaskExecutorGateway.java             |  12 ++
 .../webmonitor/TestingRestfulGateway.java       |  27 +++-
 27 files changed, 699 insertions(+), 93 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/WebRuntimeMonitor.java
----------------------------------------------------------------------
diff --git a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/WebRuntimeMonitor.java b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/WebRuntimeMonitor.java
index 1e07f8d..3583763 100644
--- a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/WebRuntimeMonitor.java
+++ b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/WebRuntimeMonitor.java
@@ -224,7 +224,11 @@ public class WebRuntimeMonitor implements WebMonitor {
 		Time delayBetweenSamples = Time.milliseconds(delay);
 
 		backPressureStatsTracker = new BackPressureStatsTracker(
-				stackTraceSamples, cleanUpInterval, numSamples, delayBetweenSamples);
+			stackTraceSamples,
+			cleanUpInterval,
+			numSamples,
+			config.getInteger(WebOptions.BACKPRESSURE_REFRESH_INTERVAL),
+			delayBetweenSamples);
 
 		// --------------------------------------------------------------------
 

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
index d13233a..da63765 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
@@ -33,6 +33,7 @@ import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
 import org.apache.flink.runtime.highavailability.RunningJobsRegistry;
 import org.apache.flink.runtime.jobgraph.JobGraph;
 import org.apache.flink.runtime.jobgraph.JobStatus;
+import org.apache.flink.runtime.jobgraph.JobVertexID;
 import org.apache.flink.runtime.jobmanager.OnCompletionActions;
 import org.apache.flink.runtime.jobmanager.SubmittedJobGraph;
 import org.apache.flink.runtime.jobmanager.SubmittedJobGraphStore;
@@ -49,6 +50,7 @@ import org.apache.flink.runtime.messages.webmonitor.MultipleJobsDetails;
 import org.apache.flink.runtime.metrics.MetricRegistry;
 import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
 import org.apache.flink.runtime.resourcemanager.ResourceOverview;
+import org.apache.flink.runtime.rest.handler.legacy.backpressure.OperatorBackPressureStatsResponse;
 import org.apache.flink.runtime.rpc.FatalErrorHandler;
 import org.apache.flink.runtime.rpc.FencedRpcEndpoint;
 import org.apache.flink.runtime.rpc.RpcService;
@@ -365,6 +367,18 @@ public abstract class Dispatcher extends FencedRpcEndpoint<DispatcherId> impleme
 	}
 
 	@Override
+	public CompletableFuture<OperatorBackPressureStatsResponse> requestOperatorBackPressureStats(
+			final JobID jobId, final JobVertexID jobVertexId) {
+			final JobManagerRunner jobManagerRunner = jobManagerRunners.get(jobId);
+		if (jobManagerRunner == null) {
+			return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId));
+		} else {
+			return jobManagerRunner.getJobManagerGateway()
+				.requestOperatorBackPressureStats(jobId, jobVertexId);
+		}
+	}
+
+	@Override
 	public CompletableFuture<ArchivedExecutionGraph> requestJob(JobID jobId, Time timeout) {
 		final JobManagerRunner jobManagerRunner = jobManagerRunners.get(jobId);
 

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DispatcherRestEndpoint.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DispatcherRestEndpoint.java b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DispatcherRestEndpoint.java
index 04175f3..f9263c9 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DispatcherRestEndpoint.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DispatcherRestEndpoint.java
@@ -30,9 +30,7 @@ import org.apache.flink.runtime.rest.handler.RestHandlerSpecification;
 import org.apache.flink.runtime.rest.handler.job.BlobServerPortHandler;
 import org.apache.flink.runtime.rest.handler.job.JobSubmitHandler;
 import org.apache.flink.runtime.rest.handler.job.JobTerminationHandler;
-import org.apache.flink.runtime.rest.handler.job.JobVertexBackPressureHandler;
 import org.apache.flink.runtime.rest.messages.JobTerminationHeaders;
-import org.apache.flink.runtime.rest.messages.JobVertexBackPressureHeaders;
 import org.apache.flink.runtime.rpc.FatalErrorHandler;
 import org.apache.flink.runtime.webmonitor.WebMonitorEndpoint;
 import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever;
@@ -102,17 +100,9 @@ public class DispatcherRestEndpoint extends WebMonitorEndpoint<DispatcherGateway
 			timeout,
 			responseHeaders);
 
-		JobVertexBackPressureHandler jobVertexBackPressureHandler = new JobVertexBackPressureHandler(
-			restAddressFuture,
-			leaderRetriever,
-			timeout,
-			responseHeaders,
-			JobVertexBackPressureHeaders.getInstance());
-
 		handlers.add(Tuple2.of(JobTerminationHeaders.getInstance(), jobTerminationHandler));
 		handlers.add(Tuple2.of(blobServerPortHandler.getMessageHeaders(), blobServerPortHandler));
 		handlers.add(Tuple2.of(jobSubmitHandler.getMessageHeaders(), jobSubmitHandler));
-		handlers.add(Tuple2.of(JobVertexBackPressureHeaders.getInstance(), jobVertexBackPressureHandler));
 
 		return handlers;
 	}

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerRunner.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerRunner.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerRunner.java
index e9d1c2d..bca135a 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerRunner.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerRunner.java
@@ -171,7 +171,8 @@ public class JobManagerRunner implements LeaderContender, OnCompletionActions, F
 				this,
 				userCodeLoader,
 				restAddress,
-				metricRegistry.getMetricQueryServicePath());
+				metricRegistry.getMetricQueryServicePath(),
+				jobManagerServices.backPressureStatsTracker);
 
 			this.timeout = jobManagerServices.rpcAskTimeout;
 		}

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerServices.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerServices.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerServices.java
index b46e0fa..e363265 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerServices.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerServices.java
@@ -22,17 +22,21 @@ import org.apache.flink.api.common.time.Time;
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.configuration.CoreOptions;
 import org.apache.flink.configuration.IllegalConfigurationException;
+import org.apache.flink.configuration.WebOptions;
 import org.apache.flink.runtime.akka.AkkaUtils;
 import org.apache.flink.runtime.blob.BlobServer;
 import org.apache.flink.runtime.execution.librarycache.BlobLibraryCacheManager;
 import org.apache.flink.runtime.execution.librarycache.FlinkUserCodeClassLoaders;
 import org.apache.flink.runtime.executiongraph.restart.RestartStrategyFactory;
+import org.apache.flink.runtime.rest.handler.legacy.backpressure.BackPressureStatsTracker;
+import org.apache.flink.runtime.rest.handler.legacy.backpressure.StackTraceSampleCoordinator;
 import org.apache.flink.runtime.util.ExecutorThreadFactory;
 import org.apache.flink.runtime.util.Hardware;
 import org.apache.flink.util.ExceptionUtils;
 
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
 
 import scala.concurrent.duration.FiniteDuration;
 
@@ -51,16 +55,29 @@ public class JobManagerServices {
 
 	public final Time rpcAskTimeout;
 
+	private final StackTraceSampleCoordinator stackTraceSampleCoordinator;
+	public final BackPressureStatsTracker backPressureStatsTracker;
+
 	public JobManagerServices(
 			ScheduledExecutorService executorService,
 			BlobLibraryCacheManager libraryCacheManager,
 			RestartStrategyFactory restartStrategyFactory,
-			Time rpcAskTimeout) {
+			Time rpcAskTimeout,
+			StackTraceSampleCoordinator stackTraceSampleCoordinator,
+			BackPressureStatsTracker backPressureStatsTracker) {
 
 		this.executorService = checkNotNull(executorService);
 		this.libraryCacheManager = checkNotNull(libraryCacheManager);
 		this.restartStrategyFactory = checkNotNull(restartStrategyFactory);
 		this.rpcAskTimeout = checkNotNull(rpcAskTimeout);
+		this.stackTraceSampleCoordinator = checkNotNull(stackTraceSampleCoordinator);
+		this.backPressureStatsTracker = checkNotNull(backPressureStatsTracker);
+
+		executorService.scheduleWithFixedDelay(
+			backPressureStatsTracker::cleanUpOperatorStatsCache,
+			backPressureStatsTracker.getCleanUpInterval(),
+			backPressureStatsTracker.getCleanUpInterval(),
+			TimeUnit.MILLISECONDS);
 	}
 
 	/**
@@ -83,6 +100,9 @@ public class JobManagerServices {
 
 		libraryCacheManager.shutdown();
 
+		stackTraceSampleCoordinator.shutDown();
+		backPressureStatsTracker.shutDown();
+
 		if (firstException != null) {
 			ExceptionUtils.rethrowException(firstException, "Error while shutting down JobManager services");
 		}
@@ -123,10 +143,21 @@ public class JobManagerServices {
 				Hardware.getNumberCPUCores(),
 				new ExecutorThreadFactory("jobmanager-future"));
 
+		final StackTraceSampleCoordinator stackTraceSampleCoordinator =
+			new StackTraceSampleCoordinator(futureExecutor, timeout.toMillis());
+		final BackPressureStatsTracker backPressureStatsTracker = new BackPressureStatsTracker(
+			stackTraceSampleCoordinator,
+			config.getInteger(WebOptions.BACKPRESSURE_CLEANUP_INTERVAL),
+			config.getInteger(WebOptions.BACKPRESSURE_NUM_SAMPLES),
+			config.getInteger(WebOptions.BACKPRESSURE_REFRESH_INTERVAL),
+			Time.milliseconds(config.getInteger(WebOptions.BACKPRESSURE_DELAY)));
+
 		return new JobManagerServices(
 			futureExecutor,
 			libraryCacheManager,
 			RestartStrategyFactory.createRestartStrategyFactory(config),
-			Time.of(timeout.length(), timeout.unit()));
+			Time.of(timeout.length(), timeout.unit()),
+			stackTraceSampleCoordinator,
+			backPressureStatsTracker);
 	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
index 7bcea19..a983c00 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
@@ -84,6 +84,9 @@ import org.apache.flink.runtime.registration.RetryingRegistration;
 import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
 import org.apache.flink.runtime.resourcemanager.ResourceManagerId;
 import org.apache.flink.runtime.resourcemanager.ResourceOverview;
+import org.apache.flink.runtime.rest.handler.legacy.backpressure.BackPressureStatsTracker;
+import org.apache.flink.runtime.rest.handler.legacy.backpressure.OperatorBackPressureStats;
+import org.apache.flink.runtime.rest.handler.legacy.backpressure.OperatorBackPressureStatsResponse;
 import org.apache.flink.runtime.rpc.FatalErrorHandler;
 import org.apache.flink.runtime.rpc.FencedRpcEndpoint;
 import org.apache.flink.runtime.rpc.RpcService;
@@ -185,6 +188,10 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 
 	private final String metricQueryServicePath;
 
+	// --------- BackPressure --------
+
+	private final BackPressureStatsTracker backPressureStatsTracker;
+
 	// --------- ResourceManager --------
 
 	/** Leader retriever service used to locate ResourceManager's address. */
@@ -215,7 +222,8 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 			FatalErrorHandler errorHandler,
 			ClassLoader userCodeLoader,
 			@Nullable String restAddress,
-			@Nullable String metricQueryServicePath) throws Exception {
+			@Nullable String metricQueryServicePath,
+			BackPressureStatsTracker backPressureStatsTracker) throws Exception {
 
 		super(rpcService, AkkaRpcServiceUtils.createRandomName(JOB_MANAGER_NAME));
 
@@ -298,6 +306,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 			.orElse(FutureUtils.completedExceptionally(new JobMasterException("The JobMaster has not been started with a REST endpoint.")));
 
 		this.metricQueryServicePath = metricQueryServicePath;
+		this.backPressureStatsTracker = checkNotNull(backPressureStatsTracker);
 	}
 
 	//----------------------------------------------------------------------------------------------
@@ -881,6 +890,21 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 		}
 	}
 
+	@Override
+	public CompletableFuture<OperatorBackPressureStatsResponse> requestOperatorBackPressureStats(
+			final JobID jobId, final JobVertexID jobVertexId) {
+		final ExecutionJobVertex jobVertex = executionGraph.getJobVertex(jobVertexId);
+		if (jobVertex == null) {
+			return FutureUtils.completedExceptionally(new FlinkException("JobVertexID not found " +
+				jobVertexId));
+		}
+
+		final Optional<OperatorBackPressureStats> operatorBackPressureStats =
+			backPressureStatsTracker.getOperatorBackPressureStats(jobVertex);
+		return CompletableFuture.completedFuture(OperatorBackPressureStatsResponse.of(
+			operatorBackPressureStats.orElse(null)));
+	}
+
 	//----------------------------------------------------------------------------------------------
 	// Internal methods
 	//----------------------------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/RpcTaskManagerGateway.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/RpcTaskManagerGateway.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/RpcTaskManagerGateway.java
index 06a5984..0648be0 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/RpcTaskManagerGateway.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/RpcTaskManagerGateway.java
@@ -84,7 +84,13 @@ public class RpcTaskManagerGateway implements TaskManagerGateway {
 			int maxStackTraceDepth,
 			Time timeout) {
 
-		throw new UnsupportedOperationException("Operation is not yet supported.");
+		return taskExecutorGateway.requestStackTraceSample(
+			executionAttemptID,
+			sampleId,
+			numSamples,
+			delayBetweenSamples,
+			maxStackTraceDepth,
+			timeout);
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/job/JobVertexBackPressureHandler.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/job/JobVertexBackPressureHandler.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/job/JobVertexBackPressureHandler.java
index 6b3bef2..01674cb 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/job/JobVertexBackPressureHandler.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/job/JobVertexBackPressureHandler.java
@@ -20,33 +20,35 @@ package org.apache.flink.runtime.rest.handler.job;
 
 import org.apache.flink.api.common.JobID;
 import org.apache.flink.api.common.time.Time;
-import org.apache.flink.runtime.dispatcher.DispatcherGateway;
 import org.apache.flink.runtime.jobgraph.JobVertexID;
 import org.apache.flink.runtime.rest.handler.AbstractRestHandler;
 import org.apache.flink.runtime.rest.handler.HandlerRequest;
 import org.apache.flink.runtime.rest.handler.RestHandlerException;
-import org.apache.flink.runtime.rest.messages.EmptyJobVertexBackPressureInfo;
+import org.apache.flink.runtime.rest.handler.legacy.backpressure.OperatorBackPressureStats;
 import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
 import org.apache.flink.runtime.rest.messages.JobIDPathParameter;
 import org.apache.flink.runtime.rest.messages.JobVertexBackPressureInfo;
 import org.apache.flink.runtime.rest.messages.JobVertexIdPathParameter;
 import org.apache.flink.runtime.rest.messages.JobVertexMessageParameters;
 import org.apache.flink.runtime.rest.messages.MessageHeaders;
+import org.apache.flink.runtime.webmonitor.RestfulGateway;
 import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever;
 
 import javax.annotation.Nonnull;
 
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 
 /**
  * Request handler for the job vertex back pressure.
  */
-public class JobVertexBackPressureHandler extends AbstractRestHandler<DispatcherGateway, EmptyRequestBody, JobVertexBackPressureInfo, JobVertexMessageParameters> {
+public class JobVertexBackPressureHandler extends AbstractRestHandler<RestfulGateway, EmptyRequestBody, JobVertexBackPressureInfo, JobVertexMessageParameters> {
 
 	public JobVertexBackPressureHandler(
 			CompletableFuture<String> localRestAddress,
-			GatewayRetriever<DispatcherGateway> leaderRetriever,
+			GatewayRetriever<? extends RestfulGateway> leaderRetriever,
 			Time timeout,
 			Map<String, String> responseHeaders,
 			MessageHeaders<EmptyRequestBody, JobVertexBackPressureInfo, JobVertexMessageParameters> messageHeaders) {
@@ -54,11 +56,51 @@ public class JobVertexBackPressureHandler extends AbstractRestHandler<Dispatcher
 	}
 
 	@Override
-	protected CompletableFuture<JobVertexBackPressureInfo> handleRequest(@Nonnull HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request, @Nonnull DispatcherGateway gateway) throws RestHandlerException {
-		JobID jobId = request.getPathParameter(JobIDPathParameter.class);
-		JobVertexID jobVertexID = request.getPathParameter(JobVertexIdPathParameter.class);
-		///TODO Get JobVertexBackPressureInfo from DispatcherGateway with JobID and JobVertexID here
+	protected CompletableFuture<JobVertexBackPressureInfo> handleRequest(
+			@Nonnull HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request,
+			@Nonnull RestfulGateway gateway) throws RestHandlerException {
+		final JobID jobId = request.getPathParameter(JobIDPathParameter.class);
+		final JobVertexID jobVertexId = request.getPathParameter(JobVertexIdPathParameter.class);
+		return gateway
+			.requestOperatorBackPressureStats(jobId, jobVertexId)
+			.thenApply(
+				operatorBackPressureStats ->
+					operatorBackPressureStats.getOperatorBackPressureStats().map(
+						JobVertexBackPressureHandler::createJobVertexBackPressureInfo).orElse(
+						JobVertexBackPressureInfo.deprecated()));
+	}
+
+	private static JobVertexBackPressureInfo createJobVertexBackPressureInfo(
+			final OperatorBackPressureStats operatorBackPressureStats) {
+		return new JobVertexBackPressureInfo(
+			JobVertexBackPressureInfo.VertexBackPressureStatus.OK,
+			getBackPressureLevel(operatorBackPressureStats.getMaxBackPressureRatio()),
+			operatorBackPressureStats.getEndTimestamp(),
+			IntStream.range(0, operatorBackPressureStats.getNumberOfSubTasks())
+				.mapToObj(subtask -> {
+					final double backPressureRatio = operatorBackPressureStats.getBackPressureRatio(subtask);
+					return new JobVertexBackPressureInfo.SubtaskBackPressureInfo(
+						subtask,
+						getBackPressureLevel(backPressureRatio),
+						backPressureRatio);
+				})
+				.collect(Collectors.toList()));
+	}
 
-		return CompletableFuture.completedFuture(EmptyJobVertexBackPressureInfo.getInstance());
+	/**
+	 * Returns the back pressure level as a String.
+	 *
+	 * @param backPressureRatio Ratio of back pressures samples to total number of samples.
+	 *
+	 * @return Back pressure level ('ok', 'low', or 'high')
+	 */
+	private static JobVertexBackPressureInfo.VertexBackPressureLevel getBackPressureLevel(double backPressureRatio) {
+		if (backPressureRatio <= 0.10) {
+			return JobVertexBackPressureInfo.VertexBackPressureLevel.OK;
+		} else if (backPressureRatio <= 0.5) {
+			return JobVertexBackPressureInfo.VertexBackPressureLevel.LOW;
+		} else {
+			return JobVertexBackPressureInfo.VertexBackPressureLevel.HIGH;
+		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/BackPressureStatsTracker.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/BackPressureStatsTracker.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/BackPressureStatsTracker.java
index 96bf7ec..b2b57e7 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/BackPressureStatsTracker.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/BackPressureStatsTracker.java
@@ -18,6 +18,7 @@
 
 package org.apache.flink.runtime.rest.handler.legacy.backpressure;
 
+import org.apache.flink.annotation.VisibleForTesting;
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
 import org.apache.flink.runtime.executiongraph.ExecutionJobVertex;
@@ -74,7 +75,7 @@ public class BackPressureStatsTracker {
 	static final String EXPECTED_CLASS_NAME = "org.apache.flink.runtime.io.network.buffer.LocalBufferPool";
 
 	/** Expected method name for back pressure indicating stack trace element. */
-	static final String EXPECTED_METHOD_NAME = "requestBufferBlocking";
+	static final String EXPECTED_METHOD_NAME = "requestBufferBuilderBlocking";
 
 	/** Lock guarding trigger operations. */
 	private final Object lock = new Object();
@@ -99,6 +100,8 @@ public class BackPressureStatsTracker {
 
 	private final int numSamples;
 
+	private final int backPressureStatsRefreshInterval;
+
 	private final Time delayBetweenSamples;
 
 	/** Flag indicating whether the stats tracker has been shut down. */
@@ -115,6 +118,7 @@ public class BackPressureStatsTracker {
 			StackTraceSampleCoordinator coordinator,
 			int cleanUpInterval,
 			int numSamples,
+			int backPressureStatsRefreshInterval,
 			Time delayBetweenSamples) {
 
 		this.coordinator = checkNotNull(coordinator, "Stack trace sample coordinator");
@@ -125,6 +129,11 @@ public class BackPressureStatsTracker {
 		checkArgument(numSamples >= 1, "Number of samples");
 		this.numSamples = numSamples;
 
+		checkArgument(
+			backPressureStatsRefreshInterval >= 0,
+			"backPressureStatsRefreshInterval must be greater than or equal to 0");
+		this.backPressureStatsRefreshInterval = backPressureStatsRefreshInterval;
+
 		this.delayBetweenSamples = checkNotNull(delayBetweenSamples, "Delay between samples");
 
 		this.operatorStatsCache = CacheBuilder.newBuilder()
@@ -139,14 +148,18 @@ public class BackPressureStatsTracker {
 	}
 
 	/**
-	 * Returns back pressure statistics for a operator.
+	 * Returns back pressure statistics for a operator. Automatically triggers stack trace sampling
+	 * if statistics are not available or outdated.
 	 *
 	 * @param vertex Operator to get the stats for.
-	 *
 	 * @return Back pressure statistics for an operator
 	 */
 	public Optional<OperatorBackPressureStats> getOperatorBackPressureStats(ExecutionJobVertex vertex) {
-		return Optional.ofNullable(operatorStatsCache.getIfPresent(vertex));
+		final OperatorBackPressureStats stats = operatorStatsCache.getIfPresent(vertex);
+		if (stats == null || backPressureStatsRefreshInterval <= System.currentTimeMillis() - stats.getEndTimestamp()) {
+			triggerStackTraceSampleInternal(vertex);
+		}
+		return Optional.ofNullable(stats);
 	}
 
 	/**
@@ -157,15 +170,15 @@ public class BackPressureStatsTracker {
 	 * @param vertex Operator to get the stats for.
 	 * @return Flag indicating whether a sample with triggered.
 	 */
-	@SuppressWarnings("unchecked")
-	public boolean triggerStackTraceSample(ExecutionJobVertex vertex) {
+	@VisibleForTesting
+	boolean triggerStackTraceSampleInternal(final ExecutionJobVertex vertex) {
 		synchronized (lock) {
 			if (shutDown) {
 				return false;
 			}
 
 			if (!pendingStats.contains(vertex) &&
-					!vertex.getGraph().getState().isGloballyTerminalState()) {
+				!vertex.getGraph().getState().isGloballyTerminalState()) {
 
 				Executor executor = vertex.getGraph().getFutureExecutor();
 
@@ -178,10 +191,10 @@ public class BackPressureStatsTracker {
 					}
 
 					CompletableFuture<StackTraceSample> sample = coordinator.triggerStackTraceSample(
-							vertex.getTaskVertices(),
-							numSamples,
-							delayBetweenSamples,
-							MAX_STACK_TRACE_DEPTH);
+						vertex.getTaskVertices(),
+						numSamples,
+						delayBetweenSamples,
+						MAX_STACK_TRACE_DEPTH);
 
 					sample.handleAsync(new StackTraceSampleCompletionCallback(vertex), executor);
 
@@ -194,6 +207,21 @@ public class BackPressureStatsTracker {
 	}
 
 	/**
+	 * Triggers a stack trace sample for a operator to gather the back pressure
+	 * statistics. If there is a sample in progress for the operator, the call
+	 * is ignored.
+	 *
+	 * @param vertex Operator to get the stats for.
+	 * @return Flag indicating whether a sample with triggered.
+	 * @deprecated {@link #getOperatorBackPressureStats(ExecutionJobVertex)} will trigger
+	 * stack trace sampling automatically.
+	 */
+	@Deprecated
+	public boolean triggerStackTraceSample(ExecutionJobVertex vertex) {
+		return triggerStackTraceSampleInternal(vertex);
+	}
+
+	/**
 	 * Cleans up the operator stats cache if it contains timed out entries.
 	 *
 	 * <p>The Guava cache only evicts as maintenance during normal operations.

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/OperatorBackPressureStats.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/OperatorBackPressureStats.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/OperatorBackPressureStats.java
index 1a78a17..49e5fce 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/OperatorBackPressureStats.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/OperatorBackPressureStats.java
@@ -18,6 +18,7 @@
 
 package org.apache.flink.runtime.rest.handler.legacy.backpressure;
 
+import java.io.Serializable;
 import java.util.Arrays;
 
 import static org.apache.flink.util.Preconditions.checkArgument;
@@ -30,7 +31,9 @@ import static org.apache.flink.util.Preconditions.checkNotNull;
  * back pressure ratio denotes the ratio of traces indicating back pressure
  * to the total number of sampled traces.
  */
-public class OperatorBackPressureStats {
+public class OperatorBackPressureStats implements Serializable {
+
+	private static final long serialVersionUID = 1L;
 
 	/** ID of the corresponding sample. */
 	private final int sampleId;

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/OperatorBackPressureStatsResponse.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/OperatorBackPressureStatsResponse.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/OperatorBackPressureStatsResponse.java
new file mode 100644
index 0000000..24c6111
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/OperatorBackPressureStatsResponse.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.handler.legacy.backpressure;
+
+import javax.annotation.Nullable;
+
+import java.io.Serializable;
+import java.util.Optional;
+
+/**
+ * Wrapper for {@link OperatorBackPressureStats}.
+ */
+public class OperatorBackPressureStatsResponse implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	@Nullable
+	private final OperatorBackPressureStats operatorBackPressureStats;
+
+	private OperatorBackPressureStatsResponse(@Nullable final OperatorBackPressureStats operatorBackPressureStats) {
+		this.operatorBackPressureStats = operatorBackPressureStats;
+	}
+
+	public static OperatorBackPressureStatsResponse of(@Nullable final OperatorBackPressureStats operatorBackPressureStats) {
+		return new OperatorBackPressureStatsResponse(operatorBackPressureStats);
+	}
+
+	public Optional<OperatorBackPressureStats> getOperatorBackPressureStats() {
+		return Optional.ofNullable(operatorBackPressureStats);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/EmptyJobVertexBackPressureInfo.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/EmptyJobVertexBackPressureInfo.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/EmptyJobVertexBackPressureInfo.java
deleted file mode 100644
index 4d021c7..0000000
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/EmptyJobVertexBackPressureInfo.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.runtime.rest.messages;
-
-import org.apache.flink.runtime.rest.handler.job.JobVertexBackPressureHandler;
-
-import java.util.ArrayList;
-
-/**
- * Empty response of the {@link JobVertexBackPressureHandler}.
- */
-public class EmptyJobVertexBackPressureInfo extends JobVertexBackPressureInfo {
-
-	private static final EmptyJobVertexBackPressureInfo INSTANCE = new EmptyJobVertexBackPressureInfo();
-
-	private EmptyJobVertexBackPressureInfo() {
-		super(null, null, System.currentTimeMillis(), new ArrayList<>());
-	}
-
-	public static EmptyJobVertexBackPressureInfo getInstance() {
-		return INSTANCE;
-	}
-}

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureInfo.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureInfo.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureInfo.java
index aae94ff..7abeb85 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureInfo.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureInfo.java
@@ -21,8 +21,13 @@ package org.apache.flink.runtime.rest.messages;
 import org.apache.flink.runtime.rest.handler.job.JobVertexBackPressureHandler;
 
 import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonInclude;
 import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonValue;
 
+import javax.annotation.Nullable;
+
+import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
 
@@ -31,6 +36,7 @@ import static org.apache.flink.util.Preconditions.checkNotNull;
 /**
  * Response type of the {@link JobVertexBackPressureHandler}.
  */
+@JsonInclude(JsonInclude.Include.NON_NULL)
 public class JobVertexBackPressureInfo implements ResponseBody {
 
 	public static final String FIELD_NAME_STATUS = "status";
@@ -38,6 +44,13 @@ public class JobVertexBackPressureInfo implements ResponseBody {
 	public static final String FIELD_NAME_END_TIMESTAMP = "end-timestamp";
 	public static final String FIELD_NAME_SUBTASKS = "subtasks";
 
+	/** Immutable singleton instance denoting that the back pressure stats are not available. */
+	private static final JobVertexBackPressureInfo DEPRECATED_JOB_VERTEX_BACK_PRESSURE_INFO = new JobVertexBackPressureInfo(
+		VertexBackPressureStatus.DEPRECATED,
+		null,
+		null,
+		null);
+
 	@JsonProperty(FIELD_NAME_STATUS)
 	private final VertexBackPressureStatus status;
 
@@ -45,21 +58,25 @@ public class JobVertexBackPressureInfo implements ResponseBody {
 	private final VertexBackPressureLevel backpressureLevel;
 
 	@JsonProperty(FIELD_NAME_END_TIMESTAMP)
-	private final long endTimestamp;
+	private final Long endTimestamp;
 
 	@JsonProperty(FIELD_NAME_SUBTASKS)
-	protected final List<SubtaskBackPressureInfo> subtasks;
+	private final List<SubtaskBackPressureInfo> subtasks;
 
 	@JsonCreator
 	public JobVertexBackPressureInfo(
 		@JsonProperty(FIELD_NAME_STATUS) VertexBackPressureStatus status,
 		@JsonProperty(FIELD_NAME_BACKPRESSURE_LEVEL) VertexBackPressureLevel backpressureLevel,
-		@JsonProperty(FIELD_NAME_END_TIMESTAMP) long endTimestamp,
+		@JsonProperty(FIELD_NAME_END_TIMESTAMP) Long endTimestamp,
 		@JsonProperty(FIELD_NAME_SUBTASKS) List<SubtaskBackPressureInfo> subtasks) {
 		this.status = status;
 		this.backpressureLevel = backpressureLevel;
 		this.endTimestamp = endTimestamp;
-		this.subtasks = checkNotNull(subtasks);
+		this.subtasks = subtasks;
+	}
+
+	public static JobVertexBackPressureInfo deprecated() {
+		return DEPRECATED_JOB_VERTEX_BACK_PRESSURE_INFO;
 	}
 
 	@Override
@@ -82,6 +99,25 @@ public class JobVertexBackPressureInfo implements ResponseBody {
 		return Objects.hash(status, backpressureLevel, endTimestamp, subtasks);
 	}
 
+	public VertexBackPressureStatus getStatus() {
+		return status;
+	}
+
+	@Nullable
+	public VertexBackPressureLevel getBackpressureLevel() {
+		return backpressureLevel;
+	}
+
+	@Nullable
+	public Long getEndTimestamp() {
+		return endTimestamp;
+	}
+
+	@Nullable
+	public List<SubtaskBackPressureInfo> getSubtasks() {
+		return subtasks == null ? null : Collections.unmodifiableList(subtasks);
+	}
+
 	//---------------------------------------------------------------------------------
 	// Static helper classes
 	//---------------------------------------------------------------------------------
@@ -131,6 +167,18 @@ public class JobVertexBackPressureInfo implements ResponseBody {
 		public int hashCode() {
 			return Objects.hash(subtask, backpressureLevel, ratio);
 		}
+
+		public int getSubtask() {
+			return subtask;
+		}
+
+		public VertexBackPressureLevel getBackpressureLevel() {
+			return backpressureLevel;
+		}
+
+		public double getRatio() {
+			return ratio;
+		}
 	}
 
 	/**
@@ -145,6 +193,7 @@ public class JobVertexBackPressureInfo implements ResponseBody {
 			this.status = status;
 		}
 
+		@JsonValue
 		@Override
 		public String toString() {
 			return status;
@@ -163,6 +212,7 @@ public class JobVertexBackPressureInfo implements ResponseBody {
 			this.level = level;
 		}
 
+		@JsonValue
 		@Override
 		public String toString() {
 			return level;

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexMessageParameters.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexMessageParameters.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexMessageParameters.java
index 042f6a0..d022443 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexMessageParameters.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexMessageParameters.java
@@ -27,7 +27,7 @@ import java.util.Collections;
  */
 public class JobVertexMessageParameters extends JobMessageParameters {
 
-	protected final JobVertexIdPathParameter jobVertexIdPathParameter = new JobVertexIdPathParameter();
+	public final JobVertexIdPathParameter jobVertexIdPathParameter = new JobVertexIdPathParameter();
 
 	@Override
 	public Collection<MessagePathParameter<?>> getPathParameters() {

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
index 518a41e..0eaf67e 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
@@ -34,6 +34,7 @@ import org.apache.flink.runtime.clusterframework.types.SlotID;
 import org.apache.flink.runtime.concurrent.FutureUtils;
 import org.apache.flink.runtime.deployment.TaskDeploymentDescriptor;
 import org.apache.flink.runtime.entrypoint.ClusterInformation;
+import org.apache.flink.runtime.execution.ExecutionState;
 import org.apache.flink.runtime.execution.librarycache.BlobLibraryCacheManager;
 import org.apache.flink.runtime.execution.librarycache.LibraryCacheManager;
 import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
@@ -60,6 +61,7 @@ import org.apache.flink.runtime.jobmaster.JobMasterId;
 import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalListener;
 import org.apache.flink.runtime.memory.MemoryManager;
 import org.apache.flink.runtime.messages.Acknowledge;
+import org.apache.flink.runtime.messages.StackTraceSampleResponse;
 import org.apache.flink.runtime.metrics.groups.TaskManagerMetricGroup;
 import org.apache.flink.runtime.metrics.groups.TaskMetricGroup;
 import org.apache.flink.runtime.query.KvStateClientProxy;
@@ -105,12 +107,16 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.UUID;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeoutException;
@@ -314,6 +320,83 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 	//  RPC methods
 	// ======================================================================
 
+	@Override
+	public CompletableFuture<StackTraceSampleResponse> requestStackTraceSample(
+			final ExecutionAttemptID executionAttemptId,
+			final int sampleId,
+			final int numSamples,
+			final Time delayBetweenSamples,
+			final int maxStackTraceDepth,
+			final Time timeout) {
+		return requestStackTraceSample(
+			executionAttemptId,
+			sampleId,
+			numSamples,
+			delayBetweenSamples,
+			maxStackTraceDepth,
+			new ArrayList<>(numSamples),
+			new CompletableFuture<>());
+	}
+
+	private CompletableFuture<StackTraceSampleResponse> requestStackTraceSample(
+			final ExecutionAttemptID executionAttemptId,
+			final int sampleId,
+			final int numSamples,
+			final Time delayBetweenSamples,
+			final int maxStackTraceDepth,
+			final List<StackTraceElement[]> currentTraces,
+			final CompletableFuture<StackTraceSampleResponse> resultFuture) {
+
+		final Optional<StackTraceElement[]> stackTrace = getStackTrace(executionAttemptId, maxStackTraceDepth);
+		if (stackTrace.isPresent()) {
+			currentTraces.add(stackTrace.get());
+		} else if (!currentTraces.isEmpty()) {
+			resultFuture.complete(new StackTraceSampleResponse(
+				sampleId,
+				executionAttemptId,
+				currentTraces));
+		} else {
+			throw new IllegalStateException(String.format("Cannot sample task %s. " +
+					"Either the task is not known to the task manager or it is not running.",
+				executionAttemptId));
+		}
+
+		if (numSamples > 1) {
+			scheduleRunAsync(() -> requestStackTraceSample(
+				executionAttemptId,
+				sampleId,
+				numSamples - 1,
+				delayBetweenSamples,
+				maxStackTraceDepth,
+				currentTraces,
+				resultFuture), delayBetweenSamples.getSize(), delayBetweenSamples.getUnit());
+			return resultFuture;
+		} else {
+			resultFuture.complete(new StackTraceSampleResponse(
+				sampleId,
+				executionAttemptId,
+				currentTraces));
+			return resultFuture;
+		}
+	}
+
+	private Optional<StackTraceElement[]> getStackTrace(
+			final ExecutionAttemptID executionAttemptId, final int maxStackTraceDepth) {
+		final Task task = taskSlotTable.getTask(executionAttemptId);
+
+		if (task != null && task.getExecutionState() == ExecutionState.RUNNING) {
+			final StackTraceElement[] stackTrace = task.getExecutingThread().getStackTrace();
+
+			if (maxStackTraceDepth > 0) {
+				return Optional.of(Arrays.copyOfRange(stackTrace, 0, Math.min(maxStackTraceDepth, stackTrace.length)));
+			} else {
+				return Optional.of(stackTrace);
+			}
+		} else {
+			return Optional.empty();
+		}
+	}
+
 	// ----------------------------------------------------------------------
 	// Task lifecycle RPCs
 	// ----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutorGateway.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutorGateway.java b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutorGateway.java
index 636be2c..4f79289 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutorGateway.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutorGateway.java
@@ -31,6 +31,7 @@ import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
 import org.apache.flink.runtime.executiongraph.PartitionInfo;
 import org.apache.flink.runtime.jobmaster.JobMasterId;
 import org.apache.flink.runtime.messages.Acknowledge;
+import org.apache.flink.runtime.messages.StackTraceSampleResponse;
 import org.apache.flink.runtime.resourcemanager.ResourceManagerId;
 import org.apache.flink.runtime.rpc.RpcGateway;
 import org.apache.flink.runtime.rpc.RpcTimeout;
@@ -62,6 +63,14 @@ public interface TaskExecutorGateway extends RpcGateway {
 		ResourceManagerId resourceManagerId,
 		@RpcTimeout Time timeout);
 
+	CompletableFuture<StackTraceSampleResponse> requestStackTraceSample(
+		ExecutionAttemptID executionAttemptId,
+		int sampleId,
+		int numSamples,
+		Time delayBetweenSamples,
+		int maxStackTraceDepth,
+		@RpcTimeout Time timeout);
+
 	/**
 	 * Submit a {@link Task} to the {@link TaskExecutor}.
 	 *

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/RestfulGateway.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/RestfulGateway.java b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/RestfulGateway.java
index 75c0546..28465a7 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/RestfulGateway.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/RestfulGateway.java
@@ -25,10 +25,12 @@ import org.apache.flink.runtime.checkpoint.CompletedCheckpoint;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.executiongraph.AccessExecutionGraph;
 import org.apache.flink.runtime.jobgraph.JobStatus;
+import org.apache.flink.runtime.jobgraph.JobVertexID;
 import org.apache.flink.runtime.messages.FlinkJobNotFoundException;
 import org.apache.flink.runtime.messages.webmonitor.ClusterOverview;
 import org.apache.flink.runtime.messages.webmonitor.MultipleJobsDetails;
 import org.apache.flink.runtime.metrics.dump.MetricQueryService;
+import org.apache.flink.runtime.rest.handler.legacy.backpressure.OperatorBackPressureStatsResponse;
 import org.apache.flink.runtime.rpc.RpcEndpoint;
 import org.apache.flink.runtime.rpc.RpcGateway;
 import org.apache.flink.runtime.rpc.RpcTimeout;
@@ -123,4 +125,19 @@ public interface RestfulGateway extends RpcGateway {
 			@RpcTimeout Time timeout) {
 		throw new UnsupportedOperationException();
 	}
+
+	/**
+	 * Requests the statistics on operator back pressure.
+	 *
+	 * @param jobId       Job for which the stats are requested.
+	 * @param jobVertexId JobVertex for which the stats are requested.
+	 * @return A Future to the {@link OperatorBackPressureStatsResponse} or {@code null} if the stats are
+	 * not available (yet).
+	 */
+	default CompletableFuture<OperatorBackPressureStatsResponse> requestOperatorBackPressureStats(
+			JobID jobId,
+			JobVertexID jobVertexId) {
+		throw new UnsupportedOperationException();
+	}
+
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitorEndpoint.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitorEndpoint.java b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitorEndpoint.java
index 083364d..021a009 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitorEndpoint.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitorEndpoint.java
@@ -41,6 +41,7 @@ import org.apache.flink.runtime.rest.handler.job.JobExecutionResultHandler;
 import org.apache.flink.runtime.rest.handler.job.JobIdsHandler;
 import org.apache.flink.runtime.rest.handler.job.JobPlanHandler;
 import org.apache.flink.runtime.rest.handler.job.JobVertexAccumulatorsHandler;
+import org.apache.flink.runtime.rest.handler.job.JobVertexBackPressureHandler;
 import org.apache.flink.runtime.rest.handler.job.JobVertexTaskManagersHandler;
 import org.apache.flink.runtime.rest.handler.job.JobsOverviewHandler;
 import org.apache.flink.runtime.rest.handler.job.SubtaskCurrentAttemptDetailsHandler;
@@ -78,6 +79,7 @@ import org.apache.flink.runtime.rest.messages.JobExceptionsHeaders;
 import org.apache.flink.runtime.rest.messages.JobIdsWithStatusesOverviewHeaders;
 import org.apache.flink.runtime.rest.messages.JobPlanHeaders;
 import org.apache.flink.runtime.rest.messages.JobVertexAccumulatorsHeaders;
+import org.apache.flink.runtime.rest.messages.JobVertexBackPressureHeaders;
 import org.apache.flink.runtime.rest.messages.JobVertexTaskManagersHeaders;
 import org.apache.flink.runtime.rest.messages.JobsOverviewHeaders;
 import org.apache.flink.runtime.rest.messages.SubtasksTimesHeaders;
@@ -440,6 +442,13 @@ public class WebMonitorEndpoint<T extends RestfulGateway> extends RestServerEndp
 			metricFetcher
 		);
 
+		JobVertexBackPressureHandler jobVertexBackPressureHandler = new JobVertexBackPressureHandler(
+			restAddressFuture,
+			leaderRetriever,
+			timeout,
+			responseHeaders,
+			JobVertexBackPressureHeaders.getInstance());
+
 		final File tmpDir = restConfiguration.getTmpDir();
 
 		Optional<StaticFileServerHandler<T>> optWebContent;
@@ -485,6 +494,7 @@ public class WebMonitorEndpoint<T extends RestfulGateway> extends RestServerEndp
 		handlers.add(Tuple2.of(SubtaskExecutionAttemptAccumulatorsHeaders.getInstance(), subtaskExecutionAttemptAccumulatorsHandler));
 		handlers.add(Tuple2.of(SubtaskCurrentAttemptDetailsHeaders.getInstance(), subtaskCurrentAttemptDetailsHandler));
 		handlers.add(Tuple2.of(JobVertexTaskManagersHeaders.getInstance(), jobVertexTaskManagersHandler));
+		handlers.add(Tuple2.of(JobVertexBackPressureHeaders.getInstance(), jobVertexBackPressureHandler));
 
 		optWebContent.ifPresent(
 			webContent -> handlers.add(Tuple2.of(WebContentHandlerSpecification.getInstance(), webContent)));

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
index 386ed95..1834d63 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
@@ -40,6 +40,8 @@ import org.apache.flink.runtime.messages.Acknowledge;
 import org.apache.flink.runtime.registration.RegistrationResponse;
 import org.apache.flink.runtime.resourcemanager.ResourceManagerId;
 import org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway;
+import org.apache.flink.runtime.rest.handler.legacy.backpressure.BackPressureStatsTracker;
+import org.apache.flink.runtime.rest.handler.legacy.backpressure.StackTraceSampleCoordinator;
 import org.apache.flink.runtime.rpc.TestingRpcService;
 import org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGateway;
 import org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation;
@@ -119,7 +121,10 @@ public class JobMasterTest extends TestLogger {
 				testingFatalErrorHandler,
 				FlinkUserCodeClassLoaders.parentFirst(new URL[0], JobMasterTest.class.getClassLoader()),
 				null,
-				null);
+				null,
+				new BackPressureStatsTracker(
+					new StackTraceSampleCoordinator(scheduledExecutor, testingTimeout.toMilliseconds()),
+					60000, 100, 60000, Time.milliseconds(50)));
 
 			CompletableFuture<Acknowledge> startFuture = jobMaster.start(jobMasterId, testingTimeout);
 
@@ -219,7 +224,10 @@ public class JobMasterTest extends TestLogger {
 				testingFatalErrorHandler,
 				FlinkUserCodeClassLoaders.parentFirst(new URL[0], JobMasterTest.class.getClassLoader()),
 				null,
-				null);
+				null,
+				new BackPressureStatsTracker(
+					new StackTraceSampleCoordinator(scheduledExecutor, testingTimeout.toMilliseconds()),
+					60000, 100, 60000, Time.milliseconds(50)));
 
 			CompletableFuture<Acknowledge> startFuture = jobMaster.start(jobMasterId, testingTimeout);
 

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/job/JobVertexBackPressureHandlerTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/job/JobVertexBackPressureHandlerTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/job/JobVertexBackPressureHandlerTest.java
new file mode 100644
index 0000000..b5a6ba6
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/job/JobVertexBackPressureHandlerTest.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.handler.job;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.runtime.jobgraph.JobVertexID;
+import org.apache.flink.runtime.rest.handler.HandlerRequest;
+import org.apache.flink.runtime.rest.handler.legacy.backpressure.OperatorBackPressureStats;
+import org.apache.flink.runtime.rest.handler.legacy.backpressure.OperatorBackPressureStatsResponse;
+import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
+import org.apache.flink.runtime.rest.messages.JobIDPathParameter;
+import org.apache.flink.runtime.rest.messages.JobVertexBackPressureHeaders;
+import org.apache.flink.runtime.rest.messages.JobVertexBackPressureInfo;
+import org.apache.flink.runtime.rest.messages.JobVertexBackPressureInfo.VertexBackPressureStatus;
+import org.apache.flink.runtime.rest.messages.JobVertexIdPathParameter;
+import org.apache.flink.runtime.rest.messages.JobVertexMessageParameters;
+import org.apache.flink.runtime.webmonitor.TestingRestfulGateway;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.runtime.rest.messages.JobVertexBackPressureInfo.VertexBackPressureLevel.HIGH;
+import static org.apache.flink.runtime.rest.messages.JobVertexBackPressureInfo.VertexBackPressureLevel.LOW;
+import static org.apache.flink.runtime.rest.messages.JobVertexBackPressureInfo.VertexBackPressureLevel.OK;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Tests for {@link JobVertexBackPressureHandler}.
+ */
+public class JobVertexBackPressureHandlerTest {
+
+	/**
+	 * Job ID for which {@link OperatorBackPressureStats} exist.
+	 */
+	private static final JobID TEST_JOB_ID_BACK_PRESSURE_STATS_AVAILABLE = new JobID();
+
+	/**
+	 * Job ID for which {@link OperatorBackPressureStats} are not available.
+	 */
+	private static final JobID TEST_JOB_ID_BACK_PRESSURE_STATS_ABSENT = new JobID();
+
+	private TestingRestfulGateway restfulGateway;
+
+	private JobVertexBackPressureHandler jobVertexBackPressureHandler;
+
+	@Before
+	public void setUp() {
+		restfulGateway = TestingRestfulGateway.newBuilder().setRequestOeratorBackPressureStatsFunction(
+			(jobId, jobVertexId) -> {
+				if (jobId.equals(TEST_JOB_ID_BACK_PRESSURE_STATS_AVAILABLE)) {
+					return CompletableFuture.completedFuture(OperatorBackPressureStatsResponse.of(new OperatorBackPressureStats(
+						4711,
+						Integer.MAX_VALUE,
+						new double[]{1.0, 0.5, 0.1}
+					)));
+				} else if (jobId.equals(TEST_JOB_ID_BACK_PRESSURE_STATS_ABSENT)) {
+					return CompletableFuture.completedFuture(OperatorBackPressureStatsResponse.of(null));
+				} else {
+					throw new AssertionError();
+				}
+			}
+		).build();
+		jobVertexBackPressureHandler = new JobVertexBackPressureHandler(
+			CompletableFuture.completedFuture("localhost:12345"),
+			() -> CompletableFuture.completedFuture(restfulGateway),
+			Time.seconds(10),
+			Collections.emptyMap(),
+			JobVertexBackPressureHeaders.getInstance()
+		);
+	}
+
+	@Test
+	public void testGetBackPressure() throws Exception {
+		final Map<String, String> pathParameters = new HashMap<>();
+		pathParameters.put(JobIDPathParameter.KEY, TEST_JOB_ID_BACK_PRESSURE_STATS_AVAILABLE.toString());
+		pathParameters.put(JobVertexIdPathParameter.KEY, new JobVertexID().toString());
+
+		final HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request =
+			new HandlerRequest<>(
+				EmptyRequestBody.getInstance(),
+				new JobVertexMessageParameters(), pathParameters, Collections.emptyMap());
+
+		final CompletableFuture<JobVertexBackPressureInfo> jobVertexBackPressureInfoCompletableFuture =
+			jobVertexBackPressureHandler.handleRequest(request, restfulGateway);
+		final JobVertexBackPressureInfo jobVertexBackPressureInfo = jobVertexBackPressureInfoCompletableFuture.get();
+
+		assertThat(jobVertexBackPressureInfo.getStatus(), equalTo(VertexBackPressureStatus.OK));
+		assertThat(jobVertexBackPressureInfo.getBackpressureLevel(), equalTo(HIGH));
+
+		assertThat(jobVertexBackPressureInfo.getSubtasks()
+			.stream()
+			.map(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getRatio)
+			.collect(Collectors.toList()), contains(1.0, 0.5, 0.1));
+
+		assertThat(jobVertexBackPressureInfo.getSubtasks()
+			.stream()
+			.map(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getBackpressureLevel)
+			.collect(Collectors.toList()), contains(HIGH, LOW, OK));
+
+		assertThat(jobVertexBackPressureInfo.getSubtasks()
+			.stream()
+			.map(JobVertexBackPressureInfo.SubtaskBackPressureInfo::getSubtask)
+			.collect(Collectors.toList()), contains(0, 1, 2));
+	}
+
+	@Test
+	public void testAbsentBackPressure() throws Exception {
+		final Map<String, String> pathParameters = new HashMap<>();
+		pathParameters.put(JobIDPathParameter.KEY, TEST_JOB_ID_BACK_PRESSURE_STATS_ABSENT.toString());
+		pathParameters.put(JobVertexIdPathParameter.KEY, new JobVertexID().toString());
+
+		final HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request =
+			new HandlerRequest<>(
+				EmptyRequestBody.getInstance(),
+				new JobVertexMessageParameters(), pathParameters, Collections.emptyMap());
+
+		final CompletableFuture<JobVertexBackPressureInfo> jobVertexBackPressureInfoCompletableFuture =
+			jobVertexBackPressureHandler.handleRequest(request, restfulGateway);
+		final JobVertexBackPressureInfo jobVertexBackPressureInfo = jobVertexBackPressureInfoCompletableFuture.get();
+
+		assertThat(jobVertexBackPressureInfo.getStatus(), equalTo(VertexBackPressureStatus.DEPRECATED));
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/JobVertexBackPressureHandlerTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/JobVertexBackPressureHandlerTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/JobVertexBackPressureHandlerTest.java
index adbc0bd..4abaef3 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/JobVertexBackPressureHandlerTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/JobVertexBackPressureHandlerTest.java
@@ -22,6 +22,7 @@ import org.apache.flink.runtime.concurrent.Executors;
 import org.apache.flink.runtime.executiongraph.ExecutionJobVertex;
 import org.apache.flink.runtime.rest.handler.legacy.backpressure.BackPressureStatsTracker;
 import org.apache.flink.runtime.rest.handler.legacy.backpressure.OperatorBackPressureStats;
+import org.apache.flink.util.TestLogger;
 
 import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode;
 import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
@@ -43,7 +44,7 @@ import static org.mockito.Mockito.when;
 /**
  * Tests for back pressure handler responses.
  */
-public class JobVertexBackPressureHandlerTest {
+public class JobVertexBackPressureHandlerTest extends TestLogger {
 	@Test
 	public void testGetPaths() {
 		JobVertexBackPressureHandler handler = new JobVertexBackPressureHandler(mock(ExecutionGraphCache.class), Executors.directExecutor(), mock(BackPressureStatsTracker.class), 0);

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/BackPressureStatsTrackerITCase.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/BackPressureStatsTrackerITCase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/BackPressureStatsTrackerITCase.java
index b1a4cd4..9a0e9b6 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/BackPressureStatsTrackerITCase.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/BackPressureStatsTrackerITCase.java
@@ -32,6 +32,7 @@ import org.apache.flink.runtime.highavailability.HighAvailabilityServicesUtils;
 import org.apache.flink.runtime.instance.ActorGateway;
 import org.apache.flink.runtime.instance.AkkaActorGateway;
 import org.apache.flink.runtime.io.network.buffer.Buffer;
+import org.apache.flink.runtime.io.network.buffer.BufferBuilder;
 import org.apache.flink.runtime.io.network.buffer.BufferPool;
 import org.apache.flink.runtime.io.network.buffer.NetworkBufferPool;
 import org.apache.flink.runtime.jobgraph.JobGraph;
@@ -182,6 +183,7 @@ public class BackPressureStatsTrackerITCase extends TestLogger {
 								coordinator,
 								100 * 1000,
 								20,
+								Integer.MAX_VALUE,
 								Time.milliseconds(10L));
 
 							int numAttempts = 10;
@@ -320,9 +322,9 @@ public class BackPressureStatsTrackerITCase extends TestLogger {
 		@Override
 		public void invoke() throws Exception {
 			while (true) {
-				Buffer buffer = testBufferPool.requestBufferBlocking();
+				final BufferBuilder bufferBuilder = testBufferPool.requestBufferBuilderBlocking();
 				// Got a buffer, yay!
-				buffer.recycleBuffer();
+				bufferBuilder.build().recycleBuffer();
 
 				new CountDownLatch(1).await();
 			}

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/BackPressureStatsTrackerTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/BackPressureStatsTrackerTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/BackPressureStatsTrackerTest.java
index 02f954a..debf71d 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/BackPressureStatsTrackerTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/backpressure/BackPressureStatsTrackerTest.java
@@ -88,10 +88,10 @@ public class BackPressureStatsTrackerTest extends TestLogger {
 		Time delayBetweenSamples = Time.milliseconds(100L);
 
 		BackPressureStatsTracker tracker = new BackPressureStatsTracker(
-				sampleCoordinator, 9999, numSamples, delayBetweenSamples);
+				sampleCoordinator, 9999, numSamples, Integer.MAX_VALUE, delayBetweenSamples);
 
-		// Trigger
-		Assert.assertTrue("Failed to trigger", tracker.triggerStackTraceSample(jobVertex));
+		// getOperatorBackPressureStats triggers stack trace sampling
+		Assert.assertFalse(tracker.getOperatorBackPressureStats(jobVertex).isPresent());
 
 		Mockito.verify(sampleCoordinator).triggerStackTraceSample(
 				Matchers.eq(taskVertices),
@@ -100,7 +100,7 @@ public class BackPressureStatsTrackerTest extends TestLogger {
 				Matchers.eq(BackPressureStatsTracker.MAX_STACK_TRACE_DEPTH));
 
 		// Trigger again for pending request, should not fire
-		Assert.assertFalse("Unexpected trigger", tracker.triggerStackTraceSample(jobVertex));
+		Assert.assertFalse("Unexpected trigger", tracker.triggerStackTraceSampleInternal(jobVertex));
 
 		Assert.assertTrue(!tracker.getOperatorBackPressureStats(jobVertex).isPresent());
 

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/test/java/org/apache/flink/runtime/rest/messages/VertexBackPressureLevelTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/messages/VertexBackPressureLevelTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/messages/VertexBackPressureLevelTest.java
new file mode 100644
index 0000000..bb1a36e
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/messages/VertexBackPressureLevelTest.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.messages;
+
+import org.apache.flink.runtime.rest.util.RestMapperUtils;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests for {@link JobVertexBackPressureInfo.VertexBackPressureLevel}.
+ */
+public class VertexBackPressureLevelTest extends TestLogger {
+
+	/**
+	 * Tests that the enum values are serialized correctly.
+	 * Clients, such as the Web UI, expect values to be lower case.
+	 */
+	@Test
+	public void testJsonValue() throws Exception {
+		assertEquals("\"ok\"", RestMapperUtils.getStrictObjectMapper()
+			.writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureLevel.OK));
+		assertEquals("\"low\"", RestMapperUtils.getStrictObjectMapper()
+			.writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureLevel.LOW));
+		assertEquals("\"high\"", RestMapperUtils.getStrictObjectMapper()
+			.writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureLevel.HIGH));
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/test/java/org/apache/flink/runtime/rest/messages/VertexBackPressureStatusTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/messages/VertexBackPressureStatusTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/messages/VertexBackPressureStatusTest.java
new file mode 100644
index 0000000..d0b8fb7
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/messages/VertexBackPressureStatusTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.messages;
+
+import org.apache.flink.runtime.rest.util.RestMapperUtils;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests for {@link JobVertexBackPressureInfo.VertexBackPressureStatus}.
+ */
+public class VertexBackPressureStatusTest extends TestLogger {
+
+	/**
+	 * Tests that the enum values are serialized correctly.
+	 * Clients, such as the Web UI, expect values to be lower case.
+	 */
+	@Test
+	public void testJsonValue() throws Exception {
+		assertEquals("\"ok\"", RestMapperUtils.getStrictObjectMapper()
+			.writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureStatus.OK));
+		assertEquals("\"deprecated\"", RestMapperUtils.getStrictObjectMapper()
+			.writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureStatus.DEPRECATED));
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TestingTaskExecutorGateway.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TestingTaskExecutorGateway.java b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TestingTaskExecutorGateway.java
index f7c90c8..a22cc6f 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TestingTaskExecutorGateway.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TestingTaskExecutorGateway.java
@@ -32,6 +32,7 @@ import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
 import org.apache.flink.runtime.executiongraph.PartitionInfo;
 import org.apache.flink.runtime.jobmaster.JobMasterId;
 import org.apache.flink.runtime.messages.Acknowledge;
+import org.apache.flink.runtime.messages.StackTraceSampleResponse;
 import org.apache.flink.runtime.resourcemanager.ResourceManagerId;
 import org.apache.flink.testutils.category.Flip6;
 import org.apache.flink.util.Preconditions;
@@ -78,6 +79,17 @@ public class TestingTaskExecutorGateway implements TaskExecutorGateway {
 	}
 
 	@Override
+	public CompletableFuture<StackTraceSampleResponse> requestStackTraceSample(
+			final ExecutionAttemptID executionAttemptId,
+			final int sampleId,
+			final int numSamples,
+			final Time delayBetweenSamples,
+			final int maxStackTraceDepth,
+			final Time timeout) {
+		throw new UnsupportedOperationException();
+	}
+
+	@Override
 	public CompletableFuture<Acknowledge> submitTask(TaskDeploymentDescriptor tdd, JobMasterId jobMasterId, Time timeout) {
 		return CompletableFuture.completedFuture(Acknowledge.get());
 	}

http://git-wip-us.apache.org/repos/asf/flink/blob/c1280a50/flink-runtime/src/test/java/org/apache/flink/runtime/webmonitor/TestingRestfulGateway.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/webmonitor/TestingRestfulGateway.java b/flink-runtime/src/test/java/org/apache/flink/runtime/webmonitor/TestingRestfulGateway.java
index 1e86051..8b9f671 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/webmonitor/TestingRestfulGateway.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/webmonitor/TestingRestfulGateway.java
@@ -25,12 +25,15 @@ import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.concurrent.FutureUtils;
 import org.apache.flink.runtime.executiongraph.AccessExecutionGraph;
 import org.apache.flink.runtime.jobgraph.JobStatus;
+import org.apache.flink.runtime.jobgraph.JobVertexID;
 import org.apache.flink.runtime.messages.webmonitor.ClusterOverview;
 import org.apache.flink.runtime.messages.webmonitor.MultipleJobsDetails;
+import org.apache.flink.runtime.rest.handler.legacy.backpressure.OperatorBackPressureStatsResponse;
 
 import java.util.Collection;
 import java.util.Collections;
 import java.util.concurrent.CompletableFuture;
+import java.util.function.BiFunction;
 import java.util.function.Function;
 import java.util.function.Supplier;
 
@@ -45,6 +48,7 @@ public class TestingRestfulGateway implements RestfulGateway {
 	static final Supplier<CompletableFuture<ClusterOverview>> DEFAULT_REQUEST_CLUSTER_OVERVIEW_SUPPLIER = () -> CompletableFuture.completedFuture(new ClusterOverview(0, 0, 0, 0, 0, 0, 0));
 	static final Supplier<CompletableFuture<Collection<String>>> DEFAULT_REQUEST_METRIC_QUERY_SERVICE_PATHS_SUPPLIER = () -> CompletableFuture.completedFuture(Collections.emptyList());
 	static final Supplier<CompletableFuture<Collection<Tuple2<ResourceID, String>>>> DEFAULT_REQUEST_TASK_MANAGER_METRIC_QUERY_SERVICE_PATHS_SUPPLIER = () -> CompletableFuture.completedFuture(Collections.emptyList());
+	static final BiFunction<JobID, JobVertexID, CompletableFuture<OperatorBackPressureStatsResponse>> DEFAULT_REQUEST_OPERATOR_BACK_PRESSURE_STATS_SUPPLIER = (jobId, jobVertexId) -> FutureUtils.completedExceptionally(new UnsupportedOperationException());
 	static final String LOCALHOST = "localhost";
 
 	protected String address;
@@ -65,6 +69,8 @@ public class TestingRestfulGateway implements RestfulGateway {
 
 	protected Supplier<CompletableFuture<Collection<Tuple2<ResourceID, String>>>> requestTaskManagerMetricQueryServicePathsSupplier;
 
+	protected BiFunction<JobID, JobVertexID, CompletableFuture<OperatorBackPressureStatsResponse>> requestOperatorBackPressureStatsFunction;
+
 	public TestingRestfulGateway() {
 		this(
 			LOCALHOST,
@@ -75,7 +81,8 @@ public class TestingRestfulGateway implements RestfulGateway {
 			DEFAULT_REQUEST_MULTIPLE_JOB_DETAILS_SUPPLIER,
 			DEFAULT_REQUEST_CLUSTER_OVERVIEW_SUPPLIER,
 			DEFAULT_REQUEST_METRIC_QUERY_SERVICE_PATHS_SUPPLIER,
-			DEFAULT_REQUEST_TASK_MANAGER_METRIC_QUERY_SERVICE_PATHS_SUPPLIER);
+			DEFAULT_REQUEST_TASK_MANAGER_METRIC_QUERY_SERVICE_PATHS_SUPPLIER,
+			DEFAULT_REQUEST_OPERATOR_BACK_PRESSURE_STATS_SUPPLIER);
 	}
 
 	public TestingRestfulGateway(
@@ -87,7 +94,8 @@ public class TestingRestfulGateway implements RestfulGateway {
 			Supplier<CompletableFuture<MultipleJobsDetails>> requestMultipleJobDetailsSupplier,
 			Supplier<CompletableFuture<ClusterOverview>> requestClusterOverviewSupplier,
 			Supplier<CompletableFuture<Collection<String>>> requestMetricQueryServicePathsSupplier,
-			Supplier<CompletableFuture<Collection<Tuple2<ResourceID, String>>>> requestTaskManagerMetricQueryServicePathsSupplier) {
+			Supplier<CompletableFuture<Collection<Tuple2<ResourceID, String>>>> requestTaskManagerMetricQueryServicePathsSupplier,
+			BiFunction<JobID, JobVertexID, CompletableFuture<OperatorBackPressureStatsResponse>> requestOperatorBackPressureStatsFunction) {
 		this.address = address;
 		this.hostname = hostname;
 		this.restAddress = restAddress;
@@ -97,6 +105,7 @@ public class TestingRestfulGateway implements RestfulGateway {
 		this.requestClusterOverviewSupplier = requestClusterOverviewSupplier;
 		this.requestMetricQueryServicePathsSupplier = requestMetricQueryServicePathsSupplier;
 		this.requestTaskManagerMetricQueryServicePathsSupplier = requestTaskManagerMetricQueryServicePathsSupplier;
+		this.requestOperatorBackPressureStatsFunction = requestOperatorBackPressureStatsFunction;
 	}
 
 	@Override
@@ -135,6 +144,11 @@ public class TestingRestfulGateway implements RestfulGateway {
 	}
 
 	@Override
+	public CompletableFuture<OperatorBackPressureStatsResponse> requestOperatorBackPressureStats(final JobID jobId, final JobVertexID jobVertexId) {
+		return requestOperatorBackPressureStatsFunction.apply(jobId, jobVertexId);
+	}
+
+	@Override
 	public String getAddress() {
 		return address;
 	}
@@ -161,6 +175,7 @@ public class TestingRestfulGateway implements RestfulGateway {
 		private Supplier<CompletableFuture<ClusterOverview>> requestClusterOverviewSupplier;
 		private Supplier<CompletableFuture<Collection<String>>> requestMetricQueryServicePathsSupplier;
 		private Supplier<CompletableFuture<Collection<Tuple2<ResourceID, String>>>> requestTaskManagerMetricQueryServicePathsSupplier;
+		private BiFunction<JobID, JobVertexID, CompletableFuture<OperatorBackPressureStatsResponse>> requestOeratorBackPressureStatsFunction;
 
 		public Builder() {
 			requestJobFunction = DEFAULT_REQUEST_JOB_FUNCTION;
@@ -169,6 +184,7 @@ public class TestingRestfulGateway implements RestfulGateway {
 			requestClusterOverviewSupplier = DEFAULT_REQUEST_CLUSTER_OVERVIEW_SUPPLIER;
 			requestMetricQueryServicePathsSupplier = DEFAULT_REQUEST_METRIC_QUERY_SERVICE_PATHS_SUPPLIER;
 			requestTaskManagerMetricQueryServicePathsSupplier = DEFAULT_REQUEST_TASK_MANAGER_METRIC_QUERY_SERVICE_PATHS_SUPPLIER;
+			requestOeratorBackPressureStatsFunction = DEFAULT_REQUEST_OPERATOR_BACK_PRESSURE_STATS_SUPPLIER;
 		}
 
 		public Builder setAddress(String address) {
@@ -216,8 +232,13 @@ public class TestingRestfulGateway implements RestfulGateway {
 			return this;
 		}
 
+		public Builder setRequestOeratorBackPressureStatsFunction(BiFunction<JobID, JobVertexID, CompletableFuture<OperatorBackPressureStatsResponse>> requestOeratorBackPressureStatsFunction) {
+			this.requestOeratorBackPressureStatsFunction = requestOeratorBackPressureStatsFunction;
+			return this;
+		}
+
 		public TestingRestfulGateway build() {
-			return new TestingRestfulGateway(address, hostname, restAddress, requestJobFunction, requestJobStatusFunction, requestMultipleJobDetailsSupplier, requestClusterOverviewSupplier, requestMetricQueryServicePathsSupplier, requestTaskManagerMetricQueryServicePathsSupplier);
+			return new TestingRestfulGateway(address, hostname, restAddress, requestJobFunction, requestJobStatusFunction, requestMultipleJobDetailsSupplier, requestClusterOverviewSupplier, requestMetricQueryServicePathsSupplier, requestTaskManagerMetricQueryServicePathsSupplier, requestOeratorBackPressureStatsFunction);
 		}
 	}
 }


[05/11] flink git commit: [FLINK-8503] [flip6] Display TaskExecutor logs and stdout files in web ui

Posted by tr...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerConfiguration.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerConfiguration.java b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerConfiguration.java
index 449f665..cbde0d5 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerConfiguration.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerConfiguration.java
@@ -20,7 +20,6 @@ package org.apache.flink.runtime.taskexecutor;
 
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.configuration.AkkaOptions;
-import org.apache.flink.configuration.BlobServerOptions;
 import org.apache.flink.configuration.ConfigConstants;
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.configuration.ConfigurationUtils;
@@ -35,6 +34,8 @@ import org.apache.flink.util.Preconditions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.annotation.Nullable;
+
 import scala.concurrent.duration.Duration;
 
 /**
@@ -63,6 +64,12 @@ public class TaskManagerConfiguration implements TaskManagerRuntimeInfo {
 
 	private final String[] alwaysParentFirstLoaderPatterns;
 
+	@Nullable
+	private final String taskManagerLogPath;
+
+	@Nullable
+	private final String taskManagerStdoutPath;
+
 	public TaskManagerConfiguration(
 		int numberSlots,
 		String[] tmpDirectories,
@@ -71,11 +78,12 @@ public class TaskManagerConfiguration implements TaskManagerRuntimeInfo {
 		Time initialRegistrationPause,
 		Time maxRegistrationPause,
 		Time refusedRegistrationPause,
-		long cleanupInterval,
 		Configuration configuration,
 		boolean exitJvmOnOutOfMemory,
 		FlinkUserCodeClassLoaders.ResolveOrder classLoaderResolveOrder,
-		String[] alwaysParentFirstLoaderPatterns) {
+		String[] alwaysParentFirstLoaderPatterns,
+		@Nullable String taskManagerLogPath,
+		@Nullable String taskManagerStdoutPath) {
 
 		this.numberSlots = numberSlots;
 		this.tmpDirectories = Preconditions.checkNotNull(tmpDirectories);
@@ -88,6 +96,8 @@ public class TaskManagerConfiguration implements TaskManagerRuntimeInfo {
 		this.exitJvmOnOutOfMemory = exitJvmOnOutOfMemory;
 		this.classLoaderResolveOrder = classLoaderResolveOrder;
 		this.alwaysParentFirstLoaderPatterns = alwaysParentFirstLoaderPatterns;
+		this.taskManagerLogPath = taskManagerLogPath;
+		this.taskManagerStdoutPath = taskManagerStdoutPath;
 	}
 
 	public int getNumberSlots() {
@@ -137,6 +147,16 @@ public class TaskManagerConfiguration implements TaskManagerRuntimeInfo {
 		return alwaysParentFirstLoaderPatterns;
 	}
 
+	@Nullable
+	public String getTaskManagerLogPath() {
+		return taskManagerLogPath;
+	}
+
+	@Nullable
+	public String getTaskManagerStdoutPath() {
+		return taskManagerStdoutPath;
+	}
+
 	// --------------------------------------------------------------------------------------------
 	//  Static factory methods
 	// --------------------------------------------------------------------------------------------
@@ -162,8 +182,6 @@ public class TaskManagerConfiguration implements TaskManagerRuntimeInfo {
 
 		LOG.info("Messages have a max timeout of " + timeout);
 
-		final long cleanupInterval = configuration.getLong(BlobServerOptions.CLEANUP_INTERVAL) * 1000;
-
 		final Time finiteRegistrationDuration;
 
 		try {
@@ -234,6 +252,21 @@ public class TaskManagerConfiguration implements TaskManagerRuntimeInfo {
 			configuration.getString(CoreOptions.ALWAYS_PARENT_FIRST_LOADER);
 		final String[] alwaysParentFirstLoaderPatterns = alwaysParentFirstLoaderString.split(";");
 
+		final String taskManagerLogPath = configuration.getString(ConfigConstants.TASK_MANAGER_LOG_PATH_KEY, System.getProperty("log.file"));
+		final String taskManagerStdoutPath;
+
+		if (taskManagerLogPath != null) {
+			final int extension = taskManagerLogPath.lastIndexOf('.');
+
+			if (extension > 0) {
+				taskManagerStdoutPath = taskManagerLogPath.substring(0, extension) + ".out";
+			} else {
+				taskManagerStdoutPath = null;
+			}
+		} else {
+			taskManagerStdoutPath = null;
+		}
+
 		return new TaskManagerConfiguration(
 			numberSlots,
 			tmpDirPaths,
@@ -242,10 +275,11 @@ public class TaskManagerConfiguration implements TaskManagerRuntimeInfo {
 			initialRegistrationPause,
 			maxRegistrationPause,
 			refusedRegistrationPause,
-			cleanupInterval,
 			configuration,
 			exitOnOom,
 			FlinkUserCodeClassLoaders.ResolveOrder.fromString(classLoaderResolveOrder),
-			alwaysParentFirstLoaderPatterns);
+			alwaysParentFirstLoaderPatterns,
+			taskManagerLogPath,
+			taskManagerStdoutPath);
 	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitorEndpoint.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitorEndpoint.java b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitorEndpoint.java
index c415cc3..083364d 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitorEndpoint.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitorEndpoint.java
@@ -22,6 +22,7 @@ import org.apache.flink.api.common.time.Time;
 import org.apache.flink.api.java.tuple.Tuple2;
 import org.apache.flink.configuration.CheckpointingOptions;
 import org.apache.flink.configuration.Configuration;
+import org.apache.flink.runtime.blob.TransientBlobService;
 import org.apache.flink.runtime.leaderelection.LeaderContender;
 import org.apache.flink.runtime.leaderelection.LeaderElectionService;
 import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
@@ -65,6 +66,8 @@ import org.apache.flink.runtime.rest.handler.legacy.files.StdoutFileHandlerSpeci
 import org.apache.flink.runtime.rest.handler.legacy.files.WebContentHandlerSpecification;
 import org.apache.flink.runtime.rest.handler.legacy.metrics.MetricFetcher;
 import org.apache.flink.runtime.rest.handler.taskmanager.TaskManagerDetailsHandler;
+import org.apache.flink.runtime.rest.handler.taskmanager.TaskManagerLogFileHandler;
+import org.apache.flink.runtime.rest.handler.taskmanager.TaskManagerStdoutFileHandler;
 import org.apache.flink.runtime.rest.handler.taskmanager.TaskManagersHandler;
 import org.apache.flink.runtime.rest.messages.ClusterConfigurationInfoHeaders;
 import org.apache.flink.runtime.rest.messages.ClusterOverviewHeaders;
@@ -95,6 +98,8 @@ import org.apache.flink.runtime.rest.messages.job.metrics.TaskManagerMetricsHead
 import org.apache.flink.runtime.rest.messages.job.savepoints.SavepointStatusHeaders;
 import org.apache.flink.runtime.rest.messages.job.savepoints.SavepointTriggerHeaders;
 import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerDetailsHeaders;
+import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerLogFileHeaders;
+import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerStdoutFileHeaders;
 import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagersHeaders;
 import org.apache.flink.runtime.rpc.FatalErrorHandler;
 import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever;
@@ -127,6 +132,7 @@ public class WebMonitorEndpoint<T extends RestfulGateway> extends RestServerEndp
 	private final Configuration clusterConfiguration;
 	protected final RestHandlerConfiguration restConfiguration;
 	private final GatewayRetriever<ResourceManagerGateway> resourceManagerRetriever;
+	private final TransientBlobService transientBlobService;
 	private final Executor executor;
 
 	private final ExecutionGraphCache executionGraphCache;
@@ -144,6 +150,7 @@ public class WebMonitorEndpoint<T extends RestfulGateway> extends RestServerEndp
 			Configuration clusterConfiguration,
 			RestHandlerConfiguration restConfiguration,
 			GatewayRetriever<ResourceManagerGateway> resourceManagerRetriever,
+			TransientBlobService transientBlobService,
 			Executor executor,
 			MetricQueryServiceRetriever metricQueryServiceRetriever,
 			LeaderElectionService leaderElectionService,
@@ -153,6 +160,7 @@ public class WebMonitorEndpoint<T extends RestfulGateway> extends RestServerEndp
 		this.clusterConfiguration = Preconditions.checkNotNull(clusterConfiguration);
 		this.restConfiguration = Preconditions.checkNotNull(restConfiguration);
 		this.resourceManagerRetriever = Preconditions.checkNotNull(resourceManagerRetriever);
+		this.transientBlobService = Preconditions.checkNotNull(transientBlobService);
 		this.executor = Preconditions.checkNotNull(executor);
 
 		this.executionGraphCache = new ExecutionGraphCache(
@@ -497,6 +505,33 @@ public class WebMonitorEndpoint<T extends RestfulGateway> extends RestServerEndp
 		handlers.add(Tuple2.of(LogFileHandlerSpecification.getInstance(), logFileHandler));
 		handlers.add(Tuple2.of(StdoutFileHandlerSpecification.getInstance(), stdoutFileHandler));
 
+		// TaskManager log and stdout file handler
+
+		final Time cacheEntryDuration = Time.milliseconds(restConfiguration.getRefreshInterval());
+
+		final TaskManagerLogFileHandler taskManagerLogFileHandler = new TaskManagerLogFileHandler(
+			restAddressFuture,
+			leaderRetriever,
+			timeout,
+			responseHeaders,
+			TaskManagerLogFileHeaders.getInstance(),
+			resourceManagerRetriever,
+			transientBlobService,
+			cacheEntryDuration);
+
+		final TaskManagerStdoutFileHandler taskManagerStdoutFileHandler = new TaskManagerStdoutFileHandler(
+			restAddressFuture,
+			leaderRetriever,
+			timeout,
+			responseHeaders,
+			TaskManagerStdoutFileHeaders.getInstance(),
+			resourceManagerRetriever,
+			transientBlobService,
+			cacheEntryDuration);
+
+		handlers.add(Tuple2.of(TaskManagerLogFileHeaders.getInstance(), taskManagerLogFileHandler));
+		handlers.add(Tuple2.of(TaskManagerStdoutFileHeaders.getInstance(), taskManagerStdoutFileHandler));
+
 		return handlers;
 	}
 

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/utils/TestingResourceManagerGateway.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/utils/TestingResourceManagerGateway.java b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/utils/TestingResourceManagerGateway.java
index 7325142..1b6fbef 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/utils/TestingResourceManagerGateway.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/utils/TestingResourceManagerGateway.java
@@ -23,6 +23,7 @@ import org.apache.flink.api.common.time.Time;
 import org.apache.flink.api.java.tuple.Tuple2;
 import org.apache.flink.api.java.tuple.Tuple4;
 import org.apache.flink.api.java.tuple.Tuple5;
+import org.apache.flink.runtime.blob.TransientBlobKey;
 import org.apache.flink.runtime.clusterframework.ApplicationStatus;
 import org.apache.flink.runtime.clusterframework.types.AllocationID;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
@@ -40,6 +41,7 @@ import org.apache.flink.runtime.resourcemanager.ResourceManagerId;
 import org.apache.flink.runtime.resourcemanager.ResourceOverview;
 import org.apache.flink.runtime.resourcemanager.SlotRequest;
 import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerInfo;
+import org.apache.flink.runtime.taskexecutor.FileType;
 import org.apache.flink.runtime.taskexecutor.SlotReport;
 import org.apache.flink.runtime.taskexecutor.TaskExecutorRegistrationSuccess;
 import org.apache.flink.util.Preconditions;
@@ -78,6 +80,8 @@ public class TestingResourceManagerGateway implements ResourceManagerGateway {
 
 	private volatile Function<Tuple5<String, ResourceID, SlotReport, Integer, HardwareDescription>, CompletableFuture<RegistrationResponse>> registerTaskExecutorFunction;
 
+	private volatile Function<Tuple2<ResourceID, FileType>, CompletableFuture<TransientBlobKey>> requestTaskManagerFileUploadFunction;
+
 	public TestingResourceManagerGateway() {
 		this(
 			ResourceManagerId.generate(),
@@ -127,6 +131,10 @@ public class TestingResourceManagerGateway implements ResourceManagerGateway {
 		this.registerTaskExecutorFunction = registerTaskExecutorFunction;
 	}
 
+	public void setRequestTaskManagerFileUploadFunction(Function<Tuple2<ResourceID, FileType>, CompletableFuture<TransientBlobKey>> requestTaskManagerFileUploadFunction) {
+		this.requestTaskManagerFileUploadFunction = requestTaskManagerFileUploadFunction;
+	}
+
 	@Override
 	public CompletableFuture<RegistrationResponse> registerJobManager(JobMasterId jobMasterId, ResourceID jobMasterResourceId, String jobMasterAddress, JobID jobId, Time timeout) {
 		final Consumer<Tuple4<JobMasterId, ResourceID, String, JobID>> currentConsumer = registerJobManagerConsumer;
@@ -254,6 +262,17 @@ public class TestingResourceManagerGateway implements ResourceManagerGateway {
 	}
 
 	@Override
+	public CompletableFuture<TransientBlobKey> requestTaskManagerFileUpload(ResourceID taskManagerId, FileType fileType, Time timeout) {
+		final Function<Tuple2<ResourceID, FileType>, CompletableFuture<TransientBlobKey>> function = requestTaskManagerFileUploadFunction;
+
+		if (function != null) {
+			return function.apply(Tuple2.of(taskManagerId, fileType));
+		} else {
+			return CompletableFuture.completedFuture(new TransientBlobKey());
+		}
+	}
+
+	@Override
 	public ResourceManagerId getFencingToken() {
 		return resourceManagerId;
 	}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/taskmanager/AbstractTaskManagerFileHandlerTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/taskmanager/AbstractTaskManagerFileHandlerTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/taskmanager/AbstractTaskManagerFileHandlerTest.java
new file mode 100644
index 0000000..a297147
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/taskmanager/AbstractTaskManagerFileHandlerTest.java
@@ -0,0 +1,556 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.handler.taskmanager;
+
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.configuration.BlobServerOptions;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.runtime.blob.BlobServer;
+import org.apache.flink.runtime.blob.TransientBlobKey;
+import org.apache.flink.runtime.blob.TransientBlobService;
+import org.apache.flink.runtime.blob.VoidBlobStore;
+import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.concurrent.FutureUtils;
+import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
+import org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway;
+import org.apache.flink.runtime.rest.HttpMethodWrapper;
+import org.apache.flink.runtime.rest.handler.HandlerRequest;
+import org.apache.flink.runtime.rest.handler.HandlerRequestException;
+import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
+import org.apache.flink.runtime.rest.messages.UntypedResponseMessageHeaders;
+import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerIdPathParameter;
+import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMessageParameters;
+import org.apache.flink.runtime.testingUtils.TestingUtils;
+import org.apache.flink.runtime.webmonitor.RestfulGateway;
+import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever;
+import org.apache.flink.util.FileUtils;
+import org.apache.flink.util.FlinkException;
+import org.apache.flink.util.Preconditions;
+import org.apache.flink.util.TestLogger;
+
+import org.apache.flink.shaded.netty4.io.netty.buffer.ByteBufAllocator;
+import org.apache.flink.shaded.netty4.io.netty.channel.Channel;
+import org.apache.flink.shaded.netty4.io.netty.channel.ChannelFuture;
+import org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler;
+import org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext;
+import org.apache.flink.shaded.netty4.io.netty.channel.ChannelPipeline;
+import org.apache.flink.shaded.netty4.io.netty.channel.ChannelProgressivePromise;
+import org.apache.flink.shaded.netty4.io.netty.channel.ChannelPromise;
+import org.apache.flink.shaded.netty4.io.netty.channel.DefaultChannelPromise;
+import org.apache.flink.shaded.netty4.io.netty.channel.DefaultFileRegion;
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.DefaultFullHttpRequest;
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpMethod;
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpVersion;
+import org.apache.flink.shaded.netty4.io.netty.util.Attribute;
+import org.apache.flink.shaded.netty4.io.netty.util.AttributeKey;
+import org.apache.flink.shaded.netty4.io.netty.util.concurrent.EventExecutor;
+import org.apache.flink.shaded.netty4.io.netty.util.concurrent.ImmediateEventExecutor;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import javax.annotation.Nonnull;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.SocketAddress;
+import java.util.ArrayDeque;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Queue;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+
+/**
+ * Tests for the {@link AbstractTaskManagerFileHandler}.
+ */
+public class AbstractTaskManagerFileHandlerTest extends TestLogger {
+
+	private static final ResourceID EXPECTED_TASK_MANAGER_ID = ResourceID.generate();
+
+	private static final DefaultFullHttpRequest HTTP_REQUEST = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, TestUntypedMessageHeaders.URL);
+
+	@ClassRule
+	public static TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+	private static BlobServer blobServer;
+
+	private static HandlerRequest<EmptyRequestBody, TaskManagerMessageParameters> handlerRequest;
+
+	private String fileContent1;
+
+	private TransientBlobKey transientBlobKey1;
+
+	private String fileContent2;
+
+	private TransientBlobKey transientBlobKey2;
+
+	@BeforeClass
+	public static void setup() throws IOException, HandlerRequestException {
+		final Configuration configuration = new Configuration();
+		configuration.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());
+
+		blobServer = new BlobServer(configuration, new VoidBlobStore());
+
+		handlerRequest = new HandlerRequest<>(
+			EmptyRequestBody.getInstance(),
+			new TaskManagerMessageParameters(),
+			Collections.singletonMap(TaskManagerIdPathParameter.KEY, EXPECTED_TASK_MANAGER_ID.getResourceIdString()),
+			Collections.emptyMap());
+	}
+
+	@Before
+	public void setupTest() throws IOException {
+		fileContent1 = UUID.randomUUID().toString();
+		final File file1 = createFileWithContent(fileContent1);
+		transientBlobKey1 = storeFileInBlobServer(file1);
+
+		fileContent2 = UUID.randomUUID().toString();
+		final File file2 = createFileWithContent(fileContent2);
+		transientBlobKey2 = storeFileInBlobServer(file2);
+	}
+
+	@AfterClass
+	public static void teardown() throws IOException {
+		if (blobServer != null) {
+			blobServer.close();
+			blobServer = null;
+		}
+	}
+
+	/**
+	 * Tests that the {@link AbstractTaskManagerFileHandler} serves the requested file.
+	 */
+	@Test
+	public void testFileServing() throws Exception {
+		final Time cacheEntryDuration = Time.milliseconds(1000L);
+
+		final Queue<CompletableFuture<TransientBlobKey>> requestFileUploads = new ArrayDeque<>(1);
+
+		requestFileUploads.add(CompletableFuture.completedFuture(transientBlobKey1));
+
+		final TestTaskManagerFileHandler testTaskManagerFileHandler = createTestTaskManagerFileHandler(cacheEntryDuration, requestFileUploads, EXPECTED_TASK_MANAGER_ID);
+
+		final File outputFile = temporaryFolder.newFile();
+		final TestingChannelHandlerContext testingContext = new TestingChannelHandlerContext(outputFile);
+
+		testTaskManagerFileHandler.respondToRequest(
+			testingContext,
+			HTTP_REQUEST,
+			handlerRequest,
+			null);
+
+		assertThat(outputFile.length(), is(greaterThan(0L)));
+		assertThat(FileUtils.readFileUtf8(outputFile), is(equalTo(fileContent1)));
+	}
+
+	/**
+	 * Tests that files are cached.
+	 */
+	@Test
+	public void testFileCaching() throws Exception {
+		final File outputFile = runFileCachingTest(
+			Time.milliseconds(5000L),
+			Time.milliseconds(0L));
+
+		assertThat(outputFile.length(), is(greaterThan(0L)));
+		assertThat(FileUtils.readFileUtf8(outputFile), is(equalTo(fileContent1)));
+	}
+
+	/**
+	 * Tests that file cache entries expire.
+	 */
+	@Test
+	public void testFileCacheExpiration() throws Exception {
+		final Time cacheEntryDuration = Time.milliseconds(5L);
+
+		final File outputFile = runFileCachingTest(cacheEntryDuration, cacheEntryDuration);
+
+		assertThat(outputFile.length(), is(greaterThan(0L)));
+		assertThat(FileUtils.readFileUtf8(outputFile), is(equalTo(fileContent2)));
+	}
+
+	private File runFileCachingTest(
+			Time cacheEntryDuration,
+			Time delayBetweenRequests) throws Exception {
+		final Queue<CompletableFuture<TransientBlobKey>> requestFileUploads = new ArrayDeque<>(2);
+		requestFileUploads.add(CompletableFuture.completedFuture(transientBlobKey1));
+		requestFileUploads.add(CompletableFuture.completedFuture(transientBlobKey2));
+
+		final TestTaskManagerFileHandler testTaskManagerFileHandler = createTestTaskManagerFileHandler(
+			cacheEntryDuration,
+			requestFileUploads,
+			EXPECTED_TASK_MANAGER_ID);
+
+		final File outputFile = temporaryFolder.newFile();
+		final TestingChannelHandlerContext testingContext = new TestingChannelHandlerContext(outputFile);
+
+		testTaskManagerFileHandler.respondToRequest(
+			testingContext,
+			HTTP_REQUEST,
+			handlerRequest,
+			null);
+
+		Thread.sleep(delayBetweenRequests.toMilliseconds());
+
+		// the handler should not trigger the file upload again because it is still cached
+		testTaskManagerFileHandler.respondToRequest(
+			testingContext,
+			HTTP_REQUEST,
+			handlerRequest,
+			null);
+		return outputFile;
+	}
+
+	private AbstractTaskManagerFileHandlerTest.TestTaskManagerFileHandler createTestTaskManagerFileHandler(
+		Time cacheEntryDuration,
+		Queue<CompletableFuture<TransientBlobKey>> requestFileUploads,
+		ResourceID expectedTaskManagerId) {
+		final ResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway();
+
+		return new TestTaskManagerFileHandler(
+			CompletableFuture.completedFuture("localhost"),
+			() -> CompletableFuture.completedFuture(null),
+			TestingUtils.infiniteTime(),
+			Collections.emptyMap(),
+			new TestUntypedMessageHeaders(),
+			() -> CompletableFuture.completedFuture(resourceManagerGateway),
+			blobServer,
+			cacheEntryDuration,
+			requestFileUploads,
+			expectedTaskManagerId);
+	}
+
+	private static File createFileWithContent(String fileContent) throws IOException {
+		final File file = temporaryFolder.newFile();
+
+		// write random content into the file
+		try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
+			fileOutputStream.write(fileContent.getBytes("UTF-8"));
+		}
+
+		return file;
+	}
+
+	private static TransientBlobKey storeFileInBlobServer(File fileToStore) throws IOException {
+		// store the requested file in the BlobServer
+		try (FileInputStream fileInputStream = new FileInputStream(fileToStore)) {
+			return blobServer.getTransientBlobService().putTransient(fileInputStream);
+		}
+	}
+
+	/**
+	 * Class under test.
+	 */
+	private static final class TestTaskManagerFileHandler extends AbstractTaskManagerFileHandler<TaskManagerMessageParameters> {
+
+		private final Queue<CompletableFuture<TransientBlobKey>> requestFileUploads;
+
+		private final ResourceID expectedTaskManagerId;
+
+		protected TestTaskManagerFileHandler(@Nonnull CompletableFuture<String> localAddressFuture, @Nonnull GatewayRetriever<? extends RestfulGateway> leaderRetriever, @Nonnull Time timeout, @Nonnull Map<String, String> responseHeaders, @Nonnull UntypedResponseMessageHeaders<EmptyRequestBody, TaskManagerMessageParameters> untypedResponseMessageHeaders, @Nonnull GatewayRetriever<ResourceManagerGateway> resourceManagerGatewayRetriever, @Nonnull TransientBlobService transientBlobService, @Nonnull Time cacheEntryDuration, Queue<CompletableFuture<TransientBlobKey>> requestFileUploads, ResourceID expectedTaskManagerId) {
+			super(localAddressFuture, leaderRetriever, timeout, responseHeaders, untypedResponseMessageHeaders, resourceManagerGatewayRetriever, transientBlobService, cacheEntryDuration);
+			this.requestFileUploads = Preconditions.checkNotNull(requestFileUploads);
+			this.expectedTaskManagerId = Preconditions.checkNotNull(expectedTaskManagerId);
+		}
+
+		@Override
+		protected CompletableFuture<TransientBlobKey> requestFileUpload(ResourceManagerGateway resourceManagerGateway, ResourceID taskManagerResourceId) {
+			assertThat(taskManagerResourceId, is(equalTo(expectedTaskManagerId)));
+			final CompletableFuture<TransientBlobKey> transientBlobKeyFuture = requestFileUploads.poll();
+
+			if (transientBlobKeyFuture != null) {
+				return transientBlobKeyFuture;
+			} else {
+				return FutureUtils.completedExceptionally(new FlinkException("Could not upload file."));
+			}
+		}
+	}
+
+	/**
+	 * Testing implementation of {@link ChannelHandlerContext}.
+	 */
+	private static final class TestingChannelHandlerContext implements ChannelHandlerContext {
+
+		final File outputFile;
+
+		private TestingChannelHandlerContext(File outputFile) {
+			this.outputFile = Preconditions.checkNotNull(outputFile);
+		}
+
+		@Override
+		public ChannelFuture write(Object msg, ChannelPromise promise) {
+			if (msg instanceof DefaultFileRegion) {
+				final DefaultFileRegion defaultFileRegion = (DefaultFileRegion) msg;
+
+				try (final FileOutputStream fileOutputStream = new FileOutputStream(outputFile)) {
+					fileOutputStream.getChannel();
+
+					defaultFileRegion.transferTo(fileOutputStream.getChannel(), 0L);
+				} catch (IOException ioe) {
+					throw new RuntimeException(ioe);
+				}
+			}
+
+			return new DefaultChannelPromise(null);
+		}
+
+		@Override
+		public EventExecutor executor() {
+			return ImmediateEventExecutor.INSTANCE;
+		}
+
+		@Override
+		public ChannelFuture write(Object msg) {
+			return write(msg, null);
+		}
+
+		@Override
+		public ChannelFuture writeAndFlush(Object msg, ChannelPromise promise) {
+			final ChannelFuture channelFuture = write(msg, promise);
+			flush();
+			return channelFuture;
+		}
+
+		@Override
+		public ChannelFuture writeAndFlush(Object msg) {
+			return writeAndFlush(msg, null);
+		}
+
+		@Override
+		public ChannelPipeline pipeline() {
+			return mock(ChannelPipeline.class);
+		}
+
+		// -----------------------------------------------------
+		// Automatically generated implementation
+		// -----------------------------------------------------
+
+		@Override
+		public Channel channel() {
+			return null;
+		}
+
+		@Override
+		public String name() {
+			return null;
+		}
+
+		@Override
+		public ChannelHandler handler() {
+			return null;
+		}
+
+		@Override
+		public boolean isRemoved() {
+			return false;
+		}
+
+		@Override
+		public ChannelHandlerContext fireChannelRegistered() {
+			return null;
+		}
+
+		@Override
+		public ChannelHandlerContext fireChannelUnregistered() {
+			return null;
+		}
+
+		@Override
+		public ChannelHandlerContext fireChannelActive() {
+			return null;
+		}
+
+		@Override
+		public ChannelHandlerContext fireChannelInactive() {
+			return null;
+		}
+
+		@Override
+		public ChannelHandlerContext fireExceptionCaught(Throwable cause) {
+			return null;
+		}
+
+		@Override
+		public ChannelHandlerContext fireUserEventTriggered(Object event) {
+			return null;
+		}
+
+		@Override
+		public ChannelHandlerContext fireChannelRead(Object msg) {
+			return null;
+		}
+
+		@Override
+		public ChannelHandlerContext fireChannelReadComplete() {
+			return null;
+		}
+
+		@Override
+		public ChannelHandlerContext fireChannelWritabilityChanged() {
+			return null;
+		}
+
+		@Override
+		public ChannelFuture bind(SocketAddress localAddress) {
+			return null;
+		}
+
+		@Override
+		public ChannelFuture connect(SocketAddress remoteAddress) {
+			return null;
+		}
+
+		@Override
+		public ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress) {
+			return null;
+		}
+
+		@Override
+		public ChannelFuture disconnect() {
+			return null;
+		}
+
+		@Override
+		public ChannelFuture close() {
+			return null;
+		}
+
+		@Override
+		public ChannelFuture deregister() {
+			return null;
+		}
+
+		@Override
+		public ChannelFuture bind(SocketAddress localAddress, ChannelPromise promise) {
+			return null;
+		}
+
+		@Override
+		public ChannelFuture connect(SocketAddress remoteAddress, ChannelPromise promise) {
+			return null;
+		}
+
+		@Override
+		public ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) {
+			return null;
+		}
+
+		@Override
+		public ChannelFuture disconnect(ChannelPromise promise) {
+			return null;
+		}
+
+		@Override
+		public ChannelFuture close(ChannelPromise promise) {
+			return null;
+		}
+
+		@Override
+		public ChannelFuture deregister(ChannelPromise promise) {
+			return null;
+		}
+
+		@Override
+		public ChannelHandlerContext read() {
+			return null;
+		}
+
+		@Override
+		public ChannelHandlerContext flush() {
+			return null;
+		}
+
+		@Override
+		public ByteBufAllocator alloc() {
+			return null;
+		}
+
+		@Override
+		public ChannelPromise newPromise() {
+			return null;
+		}
+
+		@Override
+		public ChannelProgressivePromise newProgressivePromise() {
+			return null;
+		}
+
+		@Override
+		public ChannelFuture newSucceededFuture() {
+			return null;
+		}
+
+		@Override
+		public ChannelFuture newFailedFuture(Throwable cause) {
+			return null;
+		}
+
+		@Override
+		public ChannelPromise voidPromise() {
+			return null;
+		}
+
+		@Override
+		public <T> Attribute<T> attr(AttributeKey<T> key) {
+			return null;
+		}
+	}
+
+	/**
+	 * Testing {@link UntypedResponseMessageHeaders}.
+	 */
+	private static final class TestUntypedMessageHeaders implements UntypedResponseMessageHeaders<EmptyRequestBody, TaskManagerMessageParameters> {
+
+		private static final String URL = "/foobar";
+
+		@Override
+		public Class<EmptyRequestBody> getRequestClass() {
+			return EmptyRequestBody.class;
+		}
+
+		@Override
+		public TaskManagerMessageParameters getUnresolvedMessageParameters() {
+			return new TaskManagerMessageParameters();
+		}
+
+		@Override
+		public HttpMethodWrapper getHttpMethod() {
+			return HttpMethodWrapper.GET;
+		}
+
+		@Override
+		public String getTargetRestEndpointURL() {
+			return URL;
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TestingTaskExecutorGateway.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TestingTaskExecutorGateway.java b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TestingTaskExecutorGateway.java
index 4c79ec4..f7c90c8 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TestingTaskExecutorGateway.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TestingTaskExecutorGateway.java
@@ -21,10 +21,12 @@ package org.apache.flink.runtime.taskexecutor;
 import org.apache.flink.api.common.JobID;
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.runtime.blob.TransientBlobKey;
 import org.apache.flink.runtime.checkpoint.CheckpointOptions;
 import org.apache.flink.runtime.clusterframework.types.AllocationID;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.clusterframework.types.SlotID;
+import org.apache.flink.runtime.concurrent.FutureUtils;
 import org.apache.flink.runtime.deployment.TaskDeploymentDescriptor;
 import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
 import org.apache.flink.runtime.executiongraph.PartitionInfo;
@@ -144,6 +146,11 @@ public class TestingTaskExecutorGateway implements TaskExecutorGateway {
 	}
 
 	@Override
+	public CompletableFuture<TransientBlobKey> requestFileUpload(FileType fileType, Time timeout) {
+		return FutureUtils.completedExceptionally(new UnsupportedOperationException());
+	}
+
+	@Override
 	public String getAddress() {
 		return address;
 	}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/test/java/org/apache/flink/runtime/taskmanager/TaskManagerComponentsStartupShutdownTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/taskmanager/TaskManagerComponentsStartupShutdownTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/taskmanager/TaskManagerComponentsStartupShutdownTest.java
index 5edd796..4732fc2 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/taskmanager/TaskManagerComponentsStartupShutdownTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/taskmanager/TaskManagerComponentsStartupShutdownTest.java
@@ -121,11 +121,12 @@ public class TaskManagerComponentsStartupShutdownTest extends TestLogger {
 				Time.milliseconds(500),
 				Time.seconds(30),
 				Time.seconds(10),
-				1000000, // cleanup interval
 				config,
 				false, // exit-jvm-on-fatal-error
 				FlinkUserCodeClassLoaders.ResolveOrder.CHILD_FIRST,
-				new String[0]);
+				new String[0],
+				null,
+				null);
 
 			final int networkBufNum = 32;
 			// note: the network buffer memory configured here is not actually used below but set


[03/11] flink git commit: [FLINK-8502] [flip6] Remove LibraryCacheManager from JobMaster

Posted by tr...@apache.org.
[FLINK-8502] [flip6] Remove LibraryCacheManager from JobMaster

This commit removes the LibraryCacheManager from the JobMaster since it is
no longer needed. The JobMaster is started with the correct user code class
loader and, thus, does not need the LibraryCacheManager.

This commit also corrects that the BlobServer is not closed by the
JobManagerServices#shutdown method.

This closes #5352.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/2af2b734
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/2af2b734
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/2af2b734

Branch: refs/heads/master
Commit: 2af2b7347c7036bae4b1fb5f37782eccc6749911
Parents: 0f0a637
Author: Till Rohrmann <tr...@apache.org>
Authored: Wed Jan 24 13:42:41 2018 +0100
Committer: Till Rohrmann <tr...@apache.org>
Committed: Tue Feb 6 12:15:31 2018 +0100

----------------------------------------------------------------------
 .../flink/runtime/dispatcher/Dispatcher.java    | 13 +++++---
 .../dispatcher/StandaloneDispatcher.java        |  2 ++
 .../entrypoint/JobClusterEntrypoint.java        |  3 ++
 .../runtime/jobmaster/JobManagerRunner.java     |  5 +--
 .../runtime/jobmaster/JobManagerServices.java   | 31 +++++------------
 .../flink/runtime/jobmaster/JobMaster.java      | 15 ---------
 .../minicluster/MiniClusterJobDispatcher.java   | 35 +++++++++++---------
 .../runtime/dispatcher/DispatcherTest.java      | 17 ++++++++--
 .../flink/runtime/jobmaster/JobMasterTest.java  |  9 -----
 9 files changed, 59 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/2af2b734/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
index cb2682c..d13233a 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
@@ -89,6 +89,7 @@ public abstract class Dispatcher extends FencedRpcEndpoint<DispatcherId> impleme
 	private final ResourceManagerGateway resourceManagerGateway;
 	private final JobManagerServices jobManagerServices;
 	private final HeartbeatServices heartbeatServices;
+	private final BlobServer blobServer;
 	private final MetricRegistry metricRegistry;
 
 	private final FatalErrorHandler fatalErrorHandler;
@@ -119,13 +120,15 @@ public abstract class Dispatcher extends FencedRpcEndpoint<DispatcherId> impleme
 		this.configuration = Preconditions.checkNotNull(configuration);
 		this.highAvailabilityServices = Preconditions.checkNotNull(highAvailabilityServices);
 		this.resourceManagerGateway = Preconditions.checkNotNull(resourceManagerGateway);
-		this.jobManagerServices = JobManagerServices.fromConfiguration(
-			configuration,
-			Preconditions.checkNotNull(blobServer));
 		this.heartbeatServices = Preconditions.checkNotNull(heartbeatServices);
+		this.blobServer = Preconditions.checkNotNull(blobServer);
 		this.metricRegistry = Preconditions.checkNotNull(metricRegistry);
 		this.fatalErrorHandler = Preconditions.checkNotNull(fatalErrorHandler);
 
+		this.jobManagerServices = JobManagerServices.fromConfiguration(
+			configuration,
+			this.blobServer);
+
 		this.submittedJobGraphStore = highAvailabilityServices.getSubmittedJobGraphStore();
 		this.runningJobsRegistry = highAvailabilityServices.getRunningJobsRegistry();
 
@@ -228,6 +231,7 @@ public abstract class Dispatcher extends FencedRpcEndpoint<DispatcherId> impleme
 					getRpcService(),
 					highAvailabilityServices,
 					heartbeatServices,
+					blobServer,
 					jobManagerServices,
 					metricRegistry,
 					new DispatcherOnCompleteActions(jobGraph.getJobID()),
@@ -396,7 +400,7 @@ public abstract class Dispatcher extends FencedRpcEndpoint<DispatcherId> impleme
 
 	@Override
 	public CompletableFuture<Integer> getBlobServerPort(Time timeout) {
-		return CompletableFuture.completedFuture(jobManagerServices.blobServer.getPort());
+		return CompletableFuture.completedFuture(blobServer.getPort());
 	}
 
 	@Override
@@ -526,6 +530,7 @@ public abstract class Dispatcher extends FencedRpcEndpoint<DispatcherId> impleme
 		RpcService rpcService,
 		HighAvailabilityServices highAvailabilityServices,
 		HeartbeatServices heartbeatServices,
+		BlobServer blobServer,
 		JobManagerServices jobManagerServices,
 		MetricRegistry metricRegistry,
 		OnCompletionActions onCompleteActions,

http://git-wip-us.apache.org/repos/asf/flink/blob/2af2b734/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/StandaloneDispatcher.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/StandaloneDispatcher.java b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/StandaloneDispatcher.java
index b71b6bf..5533d59 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/StandaloneDispatcher.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/StandaloneDispatcher.java
@@ -75,6 +75,7 @@ public class StandaloneDispatcher extends Dispatcher {
 			RpcService rpcService,
 			HighAvailabilityServices highAvailabilityServices,
 			HeartbeatServices heartbeatServices,
+			BlobServer blobServer,
 			JobManagerServices jobManagerServices,
 			MetricRegistry metricRegistry,
 			OnCompletionActions onCompleteActions,
@@ -87,6 +88,7 @@ public class StandaloneDispatcher extends Dispatcher {
 			rpcService,
 			highAvailabilityServices,
 			heartbeatServices,
+			blobServer,
 			jobManagerServices,
 			metricRegistry,
 			onCompleteActions,

http://git-wip-us.apache.org/repos/asf/flink/blob/2af2b734/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/JobClusterEntrypoint.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/JobClusterEntrypoint.java b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/JobClusterEntrypoint.java
index 1cf3de2..fe2636d 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/JobClusterEntrypoint.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/JobClusterEntrypoint.java
@@ -144,6 +144,7 @@ public abstract class JobClusterEntrypoint extends ClusterEntrypoint {
 			highAvailabilityServices,
 			jobManagerServices,
 			heartbeatServices,
+			blobServer,
 			metricRegistry,
 			this,
 			jobMasterRestEndpoint.getRestAddress());
@@ -191,6 +192,7 @@ public abstract class JobClusterEntrypoint extends ClusterEntrypoint {
 			HighAvailabilityServices highAvailabilityServices,
 			JobManagerServices jobManagerServices,
 			HeartbeatServices heartbeatServices,
+			BlobServer blobServer,
 			MetricRegistry metricRegistry,
 			FatalErrorHandler fatalErrorHandler,
 			@Nullable String restAddress) throws Exception {
@@ -204,6 +206,7 @@ public abstract class JobClusterEntrypoint extends ClusterEntrypoint {
 			rpcService,
 			highAvailabilityServices,
 			heartbeatServices,
+			blobServer,
 			jobManagerServices,
 			metricRegistry,
 			new TerminatingOnCompleteActions(jobGraph.getJobID()),

http://git-wip-us.apache.org/repos/asf/flink/blob/2af2b734/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerRunner.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerRunner.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerRunner.java
index 5af6c67..e9d1c2d 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerRunner.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerRunner.java
@@ -21,6 +21,7 @@ package org.apache.flink.runtime.jobmaster;
 import org.apache.flink.annotation.VisibleForTesting;
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.configuration.Configuration;
+import org.apache.flink.runtime.blob.BlobServer;
 import org.apache.flink.runtime.client.JobExecutionException;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.execution.librarycache.BlobLibraryCacheManager;
@@ -113,6 +114,7 @@ public class JobManagerRunner implements LeaderContender, OnCompletionActions, F
 			final RpcService rpcService,
 			final HighAvailabilityServices haServices,
 			final HeartbeatServices heartbeatServices,
+			final BlobServer blobServer,
 			final JobManagerServices jobManagerServices,
 			final MetricRegistry metricRegistry,
 			final OnCompletionActions toNotifyOnComplete,
@@ -161,8 +163,7 @@ public class JobManagerRunner implements LeaderContender, OnCompletionActions, F
 				haServices,
 				heartbeatServices,
 				jobManagerServices.executorService,
-				jobManagerServices.blobServer,
-				jobManagerServices.libraryCacheManager,
+				blobServer,
 				jobManagerServices.restartStrategyFactory,
 				jobManagerServices.rpcAskTimeout,
 				jobManagerMetrics,

http://git-wip-us.apache.org/repos/asf/flink/blob/2af2b734/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerServices.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerServices.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerServices.java
index 6abb1af..b46e0fa 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerServices.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerServices.java
@@ -30,13 +30,12 @@ import org.apache.flink.runtime.executiongraph.restart.RestartStrategyFactory;
 import org.apache.flink.runtime.util.ExecutorThreadFactory;
 import org.apache.flink.runtime.util.Hardware;
 import org.apache.flink.util.ExceptionUtils;
-import org.apache.flink.util.Preconditions;
-
-import scala.concurrent.duration.FiniteDuration;
 
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 
+import scala.concurrent.duration.FiniteDuration;
+
 import static org.apache.flink.util.Preconditions.checkNotNull;
 
 /**
@@ -46,7 +45,6 @@ public class JobManagerServices {
 
 	public final ScheduledExecutorService executorService;
 
-	public final BlobServer blobServer;
 	public final BlobLibraryCacheManager libraryCacheManager;
 
 	public final RestartStrategyFactory restartStrategyFactory;
@@ -55,24 +53,23 @@ public class JobManagerServices {
 
 	public JobManagerServices(
 			ScheduledExecutorService executorService,
-			BlobServer blobServer,
 			BlobLibraryCacheManager libraryCacheManager,
 			RestartStrategyFactory restartStrategyFactory,
 			Time rpcAskTimeout) {
 
 		this.executorService = checkNotNull(executorService);
-		this.blobServer = checkNotNull(blobServer);
 		this.libraryCacheManager = checkNotNull(libraryCacheManager);
 		this.restartStrategyFactory = checkNotNull(restartStrategyFactory);
 		this.rpcAskTimeout = checkNotNull(rpcAskTimeout);
 	}
 
 	/**
-	 * 
+	 * Shutdown the {@link JobMaster} services.
+	 *
 	 * <p>This method makes sure all services are closed or shut down, even when an exception occurred
 	 * in the shutdown of one component. The first encountered exception is thrown, with successive
 	 * exceptions added as suppressed exceptions.
-	 * 
+	 *
 	 * @throws Exception The first Exception encountered during shutdown.
 	 */
 	public void shutdown() throws Exception {
@@ -85,16 +82,6 @@ public class JobManagerServices {
 		}
 
 		libraryCacheManager.shutdown();
-		try {
-			blobServer.close();
-		}
-		catch (Throwable t) {
-			if (firstException == null) {
-				firstException = t;
-			} else {
-				firstException.addSuppressed(t);
-			}
-		}
 
 		if (firstException != null) {
 			ExceptionUtils.rethrowException(firstException, "Error while shutting down JobManager services");
@@ -102,16 +89,15 @@ public class JobManagerServices {
 	}
 
 	// ------------------------------------------------------------------------
-	//  Creating the components from a configuration 
+	//  Creating the components from a configuration
 	// ------------------------------------------------------------------------
-	
 
 	public static JobManagerServices fromConfiguration(
 			Configuration config,
 			BlobServer blobServer) throws Exception {
 
-		Preconditions.checkNotNull(config);
-		Preconditions.checkNotNull(blobServer);
+		checkNotNull(config);
+		checkNotNull(blobServer);
 
 		final String classLoaderResolveOrder =
 			config.getString(CoreOptions.CLASSLOADER_RESOLVE_ORDER);
@@ -139,7 +125,6 @@ public class JobManagerServices {
 
 		return new JobManagerServices(
 			futureExecutor,
-			blobServer,
 			libraryCacheManager,
 			RestartStrategyFactory.createRestartStrategyFactory(config),
 			Time.of(timeout.length(), timeout.unit()));

http://git-wip-us.apache.org/repos/asf/flink/blob/2af2b734/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
index f137f39..7bcea19 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
@@ -38,7 +38,6 @@ import org.apache.flink.runtime.clusterframework.types.AllocationID;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.concurrent.FutureUtils;
 import org.apache.flink.runtime.execution.ExecutionState;
-import org.apache.flink.runtime.execution.librarycache.BlobLibraryCacheManager;
 import org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph;
 import org.apache.flink.runtime.executiongraph.Execution;
 import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
@@ -149,9 +148,6 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 	/** Logical representation of the job. */
 	private final JobGraph jobGraph;
 
-	/** Configuration of the JobManager. */
-	private final Configuration configuration;
-
 	private final Time rpcTimeout;
 
 	/** Service to contend for and retrieve the leadership of JM and RM. */
@@ -160,12 +156,6 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 	/** Blob server used across jobs. */
 	private final BlobServer blobServer;
 
-	/** Blob library cache manager used across jobs. */
-	private final BlobLibraryCacheManager libraryCacheManager;
-
-	/** The metrics for the JobManager itself. */
-	private final MetricGroup jobManagerMetricGroup;
-
 	/** The metrics for the job. */
 	private final MetricGroup jobMetricGroup;
 
@@ -218,7 +208,6 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 			HeartbeatServices heartbeatServices,
 			ScheduledExecutorService executor,
 			BlobServer blobServer,
-			BlobLibraryCacheManager libraryCacheManager,
 			RestartStrategyFactory restartStrategyFactory,
 			Time rpcAskTimeout,
 			@Nullable JobManagerMetricGroup jobManagerMetricGroup,
@@ -234,11 +223,9 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 
 		this.resourceId = checkNotNull(resourceId);
 		this.jobGraph = checkNotNull(jobGraph);
-		this.configuration = checkNotNull(configuration);
 		this.rpcTimeout = rpcAskTimeout;
 		this.highAvailabilityServices = checkNotNull(highAvailabilityService);
 		this.blobServer = checkNotNull(blobServer);
-		this.libraryCacheManager = checkNotNull(libraryCacheManager);
 		this.executor = checkNotNull(executor);
 		this.jobCompletionActions = checkNotNull(jobCompletionActions);
 		this.errorHandler = checkNotNull(errorHandler);
@@ -260,10 +247,8 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 		final JobID jid = jobGraph.getJobID();
 
 		if (jobManagerMetricGroup != null) {
-			this.jobManagerMetricGroup = jobManagerMetricGroup;
 			this.jobMetricGroup = jobManagerMetricGroup.addJob(jobGraph);
 		} else {
-			this.jobManagerMetricGroup = UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup();
 			this.jobMetricGroup = UnregisteredMetricGroups.createUnregisteredJobManagerJobMetricGroup();
 		}
 

http://git-wip-us.apache.org/repos/asf/flink/blob/2af2b734/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniClusterJobDispatcher.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniClusterJobDispatcher.java b/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniClusterJobDispatcher.java
index 7e49cef..e5ee9d7 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniClusterJobDispatcher.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniClusterJobDispatcher.java
@@ -60,46 +60,49 @@ public class MiniClusterJobDispatcher {
 
 	// ------------------------------------------------------------------------
 
-	/** lock to ensure that this dispatcher executes only one job at a time */
+	/** lock to ensure that this dispatcher executes only one job at a time. */
 	private final Object lock = new Object();
 
-	/** the configuration with which the mini cluster was started */
+	/** the configuration with which the mini cluster was started. */
 	private final Configuration configuration;
 
-	/** the RPC services to use by the job managers */
+	/** the RPC services to use by the job managers. */
 	private final RpcService[] rpcServices;
 
-	/** services for discovery, leader election, and recovery */
+	/** services for discovery, leader election, and recovery. */
 	private final HighAvailabilityServices haServices;
 
-	/** services for heartbeating */
+	/** services for heartbeating. */
 	private final HeartbeatServices heartbeatServices;
 
-	/** all the services that the JobManager needs, such as BLOB service, factories, etc */
+	/** BlobServer for storing blobs. */
+	private final BlobServer blobServer;
+
+	/** all the services that the JobManager needs, such as BLOB service, factories, etc. */
 	private final JobManagerServices jobManagerServices;
 
-	/** Registry for all metrics in the mini cluster */
+	/** Registry for all metrics in the mini cluster. */
 	private final MetricRegistry metricRegistry;
 
-	/** The number of JobManagers to launch (more than one simulates a high-availability setup) */
+	/** The number of JobManagers to launch (more than one simulates a high-availability setup). */
 	private final int numJobManagers;
 
-	/** The runner for the job and master. non-null if a job is currently running */
+	/** The runner for the job and master. non-null if a job is currently running. */
 	private volatile JobManagerRunner[] runners;
 
-	/** flag marking the dispatcher as hut down */
+	/** flag marking the dispatcher as hut down. */
 	private volatile boolean shutdown;
 
 
 	/**
 	 * Starts a mini cluster job dispatcher.
-	 * 
+	 *
 	 * <p>The dispatcher kicks off one JobManager per job, a behavior similar to a
 	 * non-highly-available setup.
-	 * 
+	 *
 	 * @param config The configuration of the mini cluster
 	 * @param haServices Access to the discovery, leader election, and recovery services
-	 * 
+	 *
 	 * @throws Exception Thrown, if the services for the JobMaster could not be started.
 	 */
 	public MiniClusterJobDispatcher(
@@ -124,11 +127,11 @@ public class MiniClusterJobDispatcher {
 	 *
 	 * <p>The dispatcher may kick off more than one JobManager per job, thus simulating
 	 * a highly-available setup.
-	 * 
+	 *
 	 * @param config The configuration of the mini cluster
 	 * @param haServices Access to the discovery, leader election, and recovery services
 	 * @param numJobManagers The number of JobMasters to start for each job.
-	 * 
+	 *
 	 * @throws Exception Thrown, if the services for the JobMaster could not be started.
 	 */
 	public MiniClusterJobDispatcher(
@@ -147,6 +150,7 @@ public class MiniClusterJobDispatcher {
 		this.rpcServices = rpcServices;
 		this.haServices = checkNotNull(haServices);
 		this.heartbeatServices = checkNotNull(heartbeatServices);
+		this.blobServer = checkNotNull(blobServer);
 		this.metricRegistry = checkNotNull(metricRegistry);
 		this.numJobManagers = numJobManagers;
 
@@ -280,6 +284,7 @@ public class MiniClusterJobDispatcher {
 					rpcServices[i],
 					haServices,
 					heartbeatServices,
+					blobServer,
 					jobManagerServices,
 					metricRegistry,
 					onCompletion,

http://git-wip-us.apache.org/repos/asf/flink/blob/2af2b734/flink-runtime/src/test/java/org/apache/flink/runtime/dispatcher/DispatcherTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/dispatcher/DispatcherTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/dispatcher/DispatcherTest.java
index 1b399c0..0d58f62 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/dispatcher/DispatcherTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/dispatcher/DispatcherTest.java
@@ -391,15 +391,26 @@ public class DispatcherTest extends TestLogger {
 				RpcService rpcService,
 				HighAvailabilityServices highAvailabilityServices,
 				HeartbeatServices heartbeatServices,
+				BlobServer blobServer,
 				JobManagerServices jobManagerServices,
 				MetricRegistry metricRegistry,
 				OnCompletionActions onCompleteActions,
 				FatalErrorHandler fatalErrorHandler) throws Exception {
 			assertEquals(expectedJobId, jobGraph.getJobID());
 
-			return new JobManagerRunner(resourceId, jobGraph, configuration, rpcService,
-				highAvailabilityServices, heartbeatServices, jobManagerServices, metricRegistry,
-				onCompleteActions, fatalErrorHandler, null);
+			return new JobManagerRunner(
+				resourceId,
+				jobGraph,
+				configuration,
+				rpcService,
+				highAvailabilityServices,
+				heartbeatServices,
+				blobServer,
+				jobManagerServices,
+				metricRegistry,
+				onCompleteActions,
+				fatalErrorHandler,
+				null);
 		}
 
 		@Override

http://git-wip-us.apache.org/repos/asf/flink/blob/2af2b734/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
index d20e1fe..386ed95 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
@@ -27,7 +27,6 @@ import org.apache.flink.runtime.blob.VoidBlobStore;
 import org.apache.flink.runtime.checkpoint.StandaloneCheckpointRecoveryFactory;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.concurrent.ScheduledExecutor;
-import org.apache.flink.runtime.execution.librarycache.BlobLibraryCacheManager;
 import org.apache.flink.runtime.execution.librarycache.FlinkUserCodeClassLoaders;
 import org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph;
 import org.apache.flink.runtime.executiongraph.restart.NoRestartStrategy;
@@ -113,10 +112,6 @@ public class JobMasterTest extends TestLogger {
 				heartbeatServices,
 				Executors.newScheduledThreadPool(1),
 				blobServer,
-				new BlobLibraryCacheManager(
-					blobServer,
-					FlinkUserCodeClassLoaders.ResolveOrder.CHILD_FIRST,
-					new String[0]),
 				new NoRestartStrategy.NoRestartStrategyFactory(),
 				testingTimeout,
 				null,
@@ -217,10 +212,6 @@ public class JobMasterTest extends TestLogger {
 				heartbeatServices,
 				Executors.newScheduledThreadPool(1),
 				blobServer,
-				new BlobLibraryCacheManager(
-					blobServer,
-					FlinkUserCodeClassLoaders.ResolveOrder.CHILD_FIRST,
-					new String[0]),
 				new NoRestartStrategy.NoRestartStrategyFactory(),
 				testingTimeout,
 				null,


[10/11] flink git commit: [hotfix][tests] Add Javadocs to JobMasterTest

Posted by tr...@apache.org.
[hotfix][tests] Add Javadocs to JobMasterTest

Add Javadocs to JobMasterTest.
Remove debug print.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/1733e734
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/1733e734
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/1733e734

Branch: refs/heads/master
Commit: 1733e734cfcfa1c45eb3f10289a997e1c95fccb5
Parents: c1280a5
Author: gyao <ga...@data-artisans.com>
Authored: Wed Jan 31 20:01:24 2018 +0100
Committer: Till Rohrmann <tr...@apache.org>
Committed: Tue Feb 6 13:37:02 2018 +0100

----------------------------------------------------------------------
 .../java/org/apache/flink/runtime/jobmaster/JobMasterTest.java  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/1733e734/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
index 1834d63..945f05f 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
@@ -61,6 +61,9 @@ import java.util.concurrent.TimeUnit;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 
+/**
+ * Tests for {@link JobMaster}.
+ */
 @Category(Flip6.class)
 public class JobMasterTest extends TestLogger {
 
@@ -140,8 +143,6 @@ public class JobMasterTest extends TestLogger {
 			// wait for the completion of the registration
 			registrationResponse.get();
 
-			System.out.println("foobar");
-
 			final ResourceID heartbeatResourceId = heartbeatResourceIdFuture.get(testingTimeout.toMilliseconds(), TimeUnit.MILLISECONDS);
 
 			assertThat(heartbeatResourceId, Matchers.equalTo(jmResourceId));


[06/11] flink git commit: [FLINK-8503] [flip6] Display TaskExecutor logs and stdout files in web ui

Posted by tr...@apache.org.
[FLINK-8503] [flip6] Display TaskExecutor logs and stdout files in web ui

Introduce the AbstractHandler which takes a typed request and returns an untyped
response. The AbstractRestHandler extends the AbstractHandler to add typed reponses.

Introduce AbstractTaskManagerFileHandler which encapsulates the file loading logic.
Upon request of a TaskManager file, the handler will trigger the file upload via
the ResourceManager. The returned TransientBlobKey is then downloaded via the
TransientBlobService. Once downloaded, the file is served to the client. Each
transient blob key is cached for maximum duration after which it is purged and has
to be reuploaded by the TaskExecutor.

This closes #5353.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/5f573804
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/5f573804
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/5f573804

Branch: refs/heads/master
Commit: 5f573804f0f486db7cc594ae678adff5ae7f217c
Parents: 2af2b73
Author: Till Rohrmann <tr...@apache.org>
Authored: Tue Feb 6 11:05:40 2018 +0100
Committer: Till Rohrmann <tr...@apache.org>
Committed: Tue Feb 6 13:34:21 2018 +0100

----------------------------------------------------------------------
 .../docs/rest/NoOpTransientBlobService.java     |  77 +++
 .../flink/docs/rest/RestAPIDocGenerator.java    |  12 +-
 .../flink/runtime/blob/AbstractBlobCache.java   |   2 +-
 .../flink/runtime/blob/TransientBlobCache.java  |   2 +-
 .../dispatcher/DispatcherRestEndpoint.java      |  21 +-
 .../runtime/entrypoint/ClusterInformation.java  |   8 +
 .../entrypoint/JobClusterEntrypoint.java        |  24 +-
 .../entrypoint/SessionClusterEntrypoint.java    |  26 +-
 .../jobmaster/JobMasterRestEndpoint.java        |  32 +-
 .../jobmaster/RpcTaskManagerGateway.java        |   7 +-
 .../resourcemanager/ResourceManager.java        |  21 +-
 .../resourcemanager/ResourceManagerGateway.java |  17 +-
 .../UnknownTaskExecutorException.java           |  33 ++
 .../flink/runtime/rest/AbstractHandler.java     | 184 ++++++
 .../rest/handler/AbstractRestHandler.java       | 146 +----
 .../AbstractTaskManagerFileHandler.java         | 259 +++++++++
 .../taskmanager/TaskManagerLogFileHandler.java  |  60 ++
 .../TaskManagerStdoutFileHandler.java           |  60 ++
 .../runtime/rest/messages/MessageHeaders.java   |  19 +-
 .../messages/UntypedResponseMessageHeaders.java |  43 ++
 .../taskmanager/TaskManagerLogFileHeaders.java  |  60 ++
 .../TaskManagerStdoutFileHeaders.java           |  60 ++
 .../flink/runtime/taskexecutor/FileType.java    |  27 +
 .../runtime/taskexecutor/TaskExecutor.java      |  54 +-
 .../taskexecutor/TaskExecutorGateway.java       |  15 +-
 .../taskexecutor/TaskManagerConfiguration.java  |  48 +-
 .../runtime/webmonitor/WebMonitorEndpoint.java  |  35 ++
 .../utils/TestingResourceManagerGateway.java    |  19 +
 .../AbstractTaskManagerFileHandlerTest.java     | 556 +++++++++++++++++++
 .../TestingTaskExecutorGateway.java             |   7 +
 ...askManagerComponentsStartupShutdownTest.java |   5 +-
 31 files changed, 1759 insertions(+), 180 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-docs/src/main/java/org/apache/flink/docs/rest/NoOpTransientBlobService.java
----------------------------------------------------------------------
diff --git a/flink-docs/src/main/java/org/apache/flink/docs/rest/NoOpTransientBlobService.java b/flink-docs/src/main/java/org/apache/flink/docs/rest/NoOpTransientBlobService.java
new file mode 100644
index 0000000..1d307c4
--- /dev/null
+++ b/flink-docs/src/main/java/org/apache/flink/docs/rest/NoOpTransientBlobService.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.docs.rest;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.runtime.blob.TransientBlobKey;
+import org.apache.flink.runtime.blob.TransientBlobService;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * No-op implementation of {@link TransientBlobService} used by the {@link RestAPIDocGenerator}.
+ */
+enum NoOpTransientBlobService implements TransientBlobService {
+	INSTANCE;
+
+	@Override
+	public File getFile(TransientBlobKey key) throws IOException {
+		throw new UnsupportedOperationException();
+	}
+
+	@Override
+	public File getFile(JobID jobId, TransientBlobKey key) throws IOException {
+		throw new UnsupportedOperationException();
+	}
+
+	@Override
+	public TransientBlobKey putTransient(byte[] value) throws IOException {
+		throw new UnsupportedOperationException();
+	}
+
+	@Override
+	public TransientBlobKey putTransient(JobID jobId, byte[] value) throws IOException {
+		throw new UnsupportedOperationException();
+	}
+
+	@Override
+	public TransientBlobKey putTransient(InputStream inputStream) throws IOException {
+		throw new UnsupportedOperationException();
+	}
+
+	@Override
+	public TransientBlobKey putTransient(JobID jobId, InputStream inputStream) throws IOException {
+		throw new UnsupportedOperationException();
+	}
+
+	@Override
+	public boolean deleteFromCache(TransientBlobKey key) {
+		throw new UnsupportedOperationException();
+	}
+
+	@Override
+	public boolean deleteFromCache(JobID jobId, TransientBlobKey key) {
+		throw new UnsupportedOperationException();
+	}
+
+	@Override
+	public void close() throws IOException {}
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-docs/src/main/java/org/apache/flink/docs/rest/RestAPIDocGenerator.java
----------------------------------------------------------------------
diff --git a/flink-docs/src/main/java/org/apache/flink/docs/rest/RestAPIDocGenerator.java b/flink-docs/src/main/java/org/apache/flink/docs/rest/RestAPIDocGenerator.java
index b5d327f..f4e1c70 100644
--- a/flink-docs/src/main/java/org/apache/flink/docs/rest/RestAPIDocGenerator.java
+++ b/flink-docs/src/main/java/org/apache/flink/docs/rest/RestAPIDocGenerator.java
@@ -289,7 +289,17 @@ public class RestAPIDocGenerator {
 		}
 
 		private DocumentingDispatcherRestEndpoint() {
-			super(restConfig, dispatcherGatewayRetriever, config, handlerConfig, resourceManagerGatewayRetriever, executor, metricQueryServiceRetriever, NoOpElectionService.INSTANCE, NoOpFatalErrorHandler.INSTANCE);
+			super(
+				restConfig,
+				dispatcherGatewayRetriever,
+				config,
+				handlerConfig,
+				resourceManagerGatewayRetriever,
+				NoOpTransientBlobService.INSTANCE,
+				executor,
+				metricQueryServiceRetriever,
+				NoOpElectionService.INSTANCE,
+				NoOpFatalErrorHandler.INSTANCE);
 		}
 
 		@Override

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/blob/AbstractBlobCache.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/blob/AbstractBlobCache.java b/flink-runtime/src/main/java/org/apache/flink/runtime/blob/AbstractBlobCache.java
index e0d63cf..ebcb42e 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/blob/AbstractBlobCache.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/blob/AbstractBlobCache.java
@@ -210,7 +210,7 @@ public abstract class AbstractBlobCache implements Closeable {
 		final InetSocketAddress currentServerAddress = serverAddress;
 
 		if (currentServerAddress != null) {
-			return serverAddress.getPort();
+			return currentServerAddress.getPort();
 		} else {
 			return -1;
 		}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/blob/TransientBlobCache.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/blob/TransientBlobCache.java b/flink-runtime/src/main/java/org/apache/flink/runtime/blob/TransientBlobCache.java
index aab2803..9473fad 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/blob/TransientBlobCache.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/blob/TransientBlobCache.java
@@ -224,7 +224,7 @@ public class TransientBlobCache extends AbstractBlobCache implements TransientBl
 		final InetSocketAddress currentServerAddress = serverAddress;
 
 		if (currentServerAddress != null) {
-			return new BlobClient(serverAddress, blobClientConfig);
+			return new BlobClient(currentServerAddress, blobClientConfig);
 		} else {
 			throw new IOException("Could not create BlobClient because the BlobServer address is unknown.");
 		}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DispatcherRestEndpoint.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DispatcherRestEndpoint.java b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DispatcherRestEndpoint.java
index 0ac64b5..f9263c9 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DispatcherRestEndpoint.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DispatcherRestEndpoint.java
@@ -21,6 +21,7 @@ package org.apache.flink.runtime.dispatcher;
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.api.java.tuple.Tuple2;
 import org.apache.flink.configuration.Configuration;
+import org.apache.flink.runtime.blob.TransientBlobService;
 import org.apache.flink.runtime.leaderelection.LeaderElectionService;
 import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
 import org.apache.flink.runtime.rest.RestServerEndpointConfiguration;
@@ -48,21 +49,23 @@ import java.util.concurrent.Executor;
 public class DispatcherRestEndpoint extends WebMonitorEndpoint<DispatcherGateway> {
 
 	public DispatcherRestEndpoint(
-		RestServerEndpointConfiguration endpointConfiguration,
-		GatewayRetriever<DispatcherGateway> leaderRetriever,
-		Configuration clusterConfiguration,
-		RestHandlerConfiguration restConfiguration,
-		GatewayRetriever<ResourceManagerGateway> resourceManagerRetriever,
-		Executor executor,
-		MetricQueryServiceRetriever metricQueryServiceRetriever,
-		LeaderElectionService leaderElectionService,
-		FatalErrorHandler fatalErrorHandler) {
+			RestServerEndpointConfiguration endpointConfiguration,
+			GatewayRetriever<DispatcherGateway> leaderRetriever,
+			Configuration clusterConfiguration,
+			RestHandlerConfiguration restConfiguration,
+			GatewayRetriever<ResourceManagerGateway> resourceManagerRetriever,
+			TransientBlobService transientBlobService,
+			Executor executor,
+			MetricQueryServiceRetriever metricQueryServiceRetriever,
+			LeaderElectionService leaderElectionService,
+			FatalErrorHandler fatalErrorHandler) {
 		super(
 			endpointConfiguration,
 			leaderRetriever,
 			clusterConfiguration,
 			restConfiguration,
 			resourceManagerRetriever,
+			transientBlobService,
 			executor,
 			metricQueryServiceRetriever,
 			leaderElectionService,

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/ClusterInformation.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/ClusterInformation.java b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/ClusterInformation.java
index 1d9f039..50961d7 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/ClusterInformation.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/ClusterInformation.java
@@ -48,4 +48,12 @@ public class ClusterInformation implements Serializable {
 	public int getBlobServerPort() {
 		return blobServerPort;
 	}
+
+	@Override
+	public String toString() {
+		return "ClusterInformation{" +
+			"blobServerHostname='" + blobServerHostname + '\'' +
+			", blobServerPort=" + blobServerPort +
+			'}';
+	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/JobClusterEntrypoint.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/JobClusterEntrypoint.java b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/JobClusterEntrypoint.java
index fe2636d..1ff303b 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/JobClusterEntrypoint.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/JobClusterEntrypoint.java
@@ -23,6 +23,8 @@ import org.apache.flink.api.common.time.Time;
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.configuration.WebOptions;
 import org.apache.flink.runtime.blob.BlobServer;
+import org.apache.flink.runtime.blob.TransientBlobCache;
+import org.apache.flink.runtime.blob.TransientBlobService;
 import org.apache.flink.runtime.clusterframework.ApplicationStatus;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph;
@@ -61,6 +63,7 @@ import akka.actor.ActorSystem;
 
 import javax.annotation.Nullable;
 
+import java.net.InetSocketAddress;
 import java.util.concurrent.Executor;
 
 /**
@@ -78,6 +81,8 @@ public abstract class JobClusterEntrypoint extends ClusterEntrypoint {
 
 	private LeaderRetrievalService resourceManagerRetrievalService;
 
+	private TransientBlobCache transientBlobCache;
+
 	private JobManagerRunner jobManagerRunner;
 
 	public JobClusterEntrypoint(Configuration configuration) {
@@ -115,10 +120,17 @@ public abstract class JobClusterEntrypoint extends ClusterEntrypoint {
 		final ActorSystem actorSystem = ((AkkaRpcService) rpcService).getActorSystem();
 		final Time timeout = Time.milliseconds(configuration.getLong(WebOptions.TIMEOUT));
 
+		final ClusterInformation clusterInformation = new ClusterInformation(rpcService.getAddress(), blobServer.getPort());
+
+		transientBlobCache = new TransientBlobCache(
+			configuration,
+			new InetSocketAddress(clusterInformation.getBlobServerHostname(), clusterInformation.getBlobServerPort()));
+
 		jobMasterRestEndpoint = createJobMasterRestEndpoint(
 			configuration,
 			jobMasterGatewayRetriever,
 			resourceManagerGatewayRetriever,
+			transientBlobCache,
 			rpcService.getExecutor(),
 			new AkkaQueryServiceRetriever(actorSystem, timeout),
 			highAvailabilityServices.getWebMonitorLeaderElectionService());
@@ -134,7 +146,7 @@ public abstract class JobClusterEntrypoint extends ClusterEntrypoint {
 			heartbeatServices,
 			metricRegistry,
 			this,
-			new ClusterInformation(rpcService.getAddress(), blobServer.getPort()),
+			clusterInformation,
 			jobMasterRestEndpoint.getRestAddress());
 
 		jobManagerRunner = createJobManagerRunner(
@@ -166,6 +178,7 @@ public abstract class JobClusterEntrypoint extends ClusterEntrypoint {
 			Configuration configuration,
 			GatewayRetriever<JobMasterGateway> jobMasterGatewayRetriever,
 			GatewayRetriever<ResourceManagerGateway> resourceManagerGatewayRetriever,
+			TransientBlobService transientBlobService,
 			Executor executor,
 			MetricQueryServiceRetriever metricQueryServiceRetriever,
 			LeaderElectionService leaderElectionService) throws ConfigurationException {
@@ -178,6 +191,7 @@ public abstract class JobClusterEntrypoint extends ClusterEntrypoint {
 			configuration,
 			restHandlerConfiguration,
 			resourceManagerGatewayRetriever,
+			transientBlobService,
 			executor,
 			metricQueryServiceRetriever,
 			leaderElectionService,
@@ -262,6 +276,14 @@ public abstract class JobClusterEntrypoint extends ClusterEntrypoint {
 			}
 		}
 
+		if (transientBlobCache != null) {
+			try {
+				transientBlobCache.close();
+			} catch (Throwable t) {
+				exception = ExceptionUtils.firstOrSuppressed(t, exception);
+			}
+		}
+
 		if (exception != null) {
 			throw new FlinkException("Could not properly shut down the job cluster entry point.", exception);
 		}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/SessionClusterEntrypoint.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/SessionClusterEntrypoint.java b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/SessionClusterEntrypoint.java
index 86f0fe3..0f41c9a 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/SessionClusterEntrypoint.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/SessionClusterEntrypoint.java
@@ -24,6 +24,8 @@ import org.apache.flink.configuration.ConfigurationUtils;
 import org.apache.flink.configuration.JobManagerOptions;
 import org.apache.flink.configuration.WebOptions;
 import org.apache.flink.runtime.blob.BlobServer;
+import org.apache.flink.runtime.blob.TransientBlobCache;
+import org.apache.flink.runtime.blob.TransientBlobService;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.concurrent.ScheduledExecutor;
 import org.apache.flink.runtime.dispatcher.ArchivedExecutionGraphStore;
@@ -61,6 +63,7 @@ import javax.annotation.Nullable;
 
 import java.io.File;
 import java.io.IOException;
+import java.net.InetSocketAddress;
 import java.util.concurrent.Executor;
 
 /**
@@ -80,6 +83,8 @@ public abstract class SessionClusterEntrypoint extends ClusterEntrypoint {
 
 	private ArchivedExecutionGraphStore archivedExecutionGraphStore;
 
+	private TransientBlobCache transientBlobCache;
+
 	public SessionClusterEntrypoint(Configuration configuration) {
 		super(configuration);
 	}
@@ -117,10 +122,19 @@ public abstract class SessionClusterEntrypoint extends ClusterEntrypoint {
 		final ActorSystem actorSystem = ((AkkaRpcService) rpcService).getActorSystem();
 		final Time timeout = Time.milliseconds(configuration.getLong(WebOptions.TIMEOUT));
 
+		final ClusterInformation clusterInformation = new ClusterInformation(
+			rpcService.getAddress(),
+			blobServer.getPort());
+
+		transientBlobCache = new TransientBlobCache(
+			configuration,
+			new InetSocketAddress(clusterInformation.getBlobServerHostname(), clusterInformation.getBlobServerPort()));
+
 		dispatcherRestEndpoint = createDispatcherRestEndpoint(
 			configuration,
 			dispatcherGatewayRetriever,
 			resourceManagerGatewayRetriever,
+			transientBlobCache,
 			rpcService.getExecutor(),
 			new AkkaQueryServiceRetriever(actorSystem, timeout),
 			highAvailabilityServices.getWebMonitorLeaderElectionService());
@@ -136,7 +150,7 @@ public abstract class SessionClusterEntrypoint extends ClusterEntrypoint {
 			heartbeatServices,
 			metricRegistry,
 			this,
-			new ClusterInformation(rpcService.getAddress(), blobServer.getPort()),
+			clusterInformation,
 			dispatcherRestEndpoint.getRestAddress());
 
 		dispatcher = createDispatcher(
@@ -224,6 +238,14 @@ public abstract class SessionClusterEntrypoint extends ClusterEntrypoint {
 			}
 		}
 
+		if (transientBlobCache != null) {
+			try {
+				transientBlobCache.close();
+			} catch (Throwable t) {
+				exception = ExceptionUtils.firstOrSuppressed(t, exception);
+			}
+		}
+
 		if (exception != null) {
 			throw new FlinkException("Could not properly shut down the session cluster entry point.", exception);
 		}
@@ -233,6 +255,7 @@ public abstract class SessionClusterEntrypoint extends ClusterEntrypoint {
 		Configuration configuration,
 		LeaderGatewayRetriever<DispatcherGateway> dispatcherGatewayRetriever,
 		LeaderGatewayRetriever<ResourceManagerGateway> resourceManagerGatewayRetriever,
+			TransientBlobService transientBlobService,
 		Executor executor,
 		MetricQueryServiceRetriever metricQueryServiceRetriever,
 		LeaderElectionService leaderElectionService) throws Exception {
@@ -245,6 +268,7 @@ public abstract class SessionClusterEntrypoint extends ClusterEntrypoint {
 			configuration,
 			restHandlerConfiguration,
 			resourceManagerGatewayRetriever,
+			transientBlobService,
 			executor,
 			metricQueryServiceRetriever,
 			leaderElectionService,

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMasterRestEndpoint.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMasterRestEndpoint.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMasterRestEndpoint.java
index 1ed191f..b0fa46d 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMasterRestEndpoint.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMasterRestEndpoint.java
@@ -19,6 +19,7 @@
 package org.apache.flink.runtime.jobmaster;
 
 import org.apache.flink.configuration.Configuration;
+import org.apache.flink.runtime.blob.TransientBlobService;
 import org.apache.flink.runtime.leaderelection.LeaderElectionService;
 import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
 import org.apache.flink.runtime.rest.RestServerEndpointConfiguration;
@@ -36,15 +37,26 @@ import java.util.concurrent.Executor;
 public class JobMasterRestEndpoint extends WebMonitorEndpoint<JobMasterGateway> {
 
 	public JobMasterRestEndpoint(
-		RestServerEndpointConfiguration endpointConfiguration,
-		GatewayRetriever<JobMasterGateway> leaderRetriever,
-		Configuration clusterConfiguration,
-		RestHandlerConfiguration restConfiguration,
-		GatewayRetriever<ResourceManagerGateway> resourceManagerRetriever,
-		Executor executor,
-		MetricQueryServiceRetriever metricQueryServiceRetriever,
-		LeaderElectionService leaderElectionService,
-		FatalErrorHandler fatalErrorHandler) {
-		super(endpointConfiguration, leaderRetriever, clusterConfiguration, restConfiguration, resourceManagerRetriever, executor, metricQueryServiceRetriever, leaderElectionService, fatalErrorHandler);
+			RestServerEndpointConfiguration endpointConfiguration,
+			GatewayRetriever<JobMasterGateway> leaderRetriever,
+			Configuration clusterConfiguration,
+			RestHandlerConfiguration restConfiguration,
+			GatewayRetriever<ResourceManagerGateway> resourceManagerRetriever,
+			TransientBlobService transientBlobService,
+			Executor executor,
+			MetricQueryServiceRetriever metricQueryServiceRetriever,
+			LeaderElectionService leaderElectionService,
+			FatalErrorHandler fatalErrorHandler) {
+		super(
+			endpointConfiguration,
+			leaderRetriever,
+			clusterConfiguration,
+			restConfiguration,
+			resourceManagerRetriever,
+			transientBlobService,
+			executor,
+			metricQueryServiceRetriever,
+			leaderElectionService,
+			fatalErrorHandler);
 	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/RpcTaskManagerGateway.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/RpcTaskManagerGateway.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/RpcTaskManagerGateway.java
index f1d991d..06a5984 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/RpcTaskManagerGateway.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/RpcTaskManagerGateway.java
@@ -32,6 +32,7 @@ import org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway;
 import org.apache.flink.runtime.messages.Acknowledge;
 import org.apache.flink.runtime.messages.StackTrace;
 import org.apache.flink.runtime.messages.StackTraceSampleResponse;
+import org.apache.flink.runtime.taskexecutor.FileType;
 import org.apache.flink.runtime.taskexecutor.TaskExecutorGateway;
 import org.apache.flink.util.Preconditions;
 
@@ -127,14 +128,12 @@ public class RpcTaskManagerGateway implements TaskManagerGateway {
 
 	@Override
 	public CompletableFuture<TransientBlobKey> requestTaskManagerLog(Time timeout) {
-//		return taskExecutorGateway.requestTaskManagerLog(timeout);
-		throw new UnsupportedOperationException("Operation is not yet supported.");
+		return taskExecutorGateway.requestFileUpload(FileType.LOG, timeout);
 	}
 
 	@Override
 	public CompletableFuture<TransientBlobKey> requestTaskManagerStdout(Time timeout) {
-//		return taskExecutorGateway.requestTaskManagerStdout(timeout);
-		throw new UnsupportedOperationException("Operation is not yet supported.");
+		return taskExecutorGateway.requestFileUpload(FileType.STDOUT, timeout);
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java
index 7db127d..2d633f1 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java
@@ -22,6 +22,7 @@ import org.apache.flink.annotation.VisibleForTesting;
 import org.apache.flink.api.common.JobID;
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.runtime.blob.TransientBlobKey;
 import org.apache.flink.runtime.clusterframework.ApplicationStatus;
 import org.apache.flink.runtime.clusterframework.messages.InfoMessage;
 import org.apache.flink.runtime.clusterframework.types.AllocationID;
@@ -49,6 +50,7 @@ import org.apache.flink.runtime.metrics.MetricRegistry;
 import org.apache.flink.runtime.metrics.dump.MetricQueryService;
 import org.apache.flink.runtime.registration.RegistrationResponse;
 import org.apache.flink.runtime.resourcemanager.exceptions.ResourceManagerException;
+import org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException;
 import org.apache.flink.runtime.resourcemanager.registration.JobManagerRegistration;
 import org.apache.flink.runtime.resourcemanager.registration.WorkerRegistration;
 import org.apache.flink.runtime.resourcemanager.slotmanager.ResourceActions;
@@ -58,6 +60,7 @@ import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerInfo;
 import org.apache.flink.runtime.rpc.FatalErrorHandler;
 import org.apache.flink.runtime.rpc.FencedRpcEndpoint;
 import org.apache.flink.runtime.rpc.RpcService;
+import org.apache.flink.runtime.taskexecutor.FileType;
 import org.apache.flink.runtime.taskexecutor.SlotReport;
 import org.apache.flink.runtime.taskexecutor.TaskExecutorGateway;
 import org.apache.flink.runtime.taskexecutor.TaskExecutorRegistrationSuccess;
@@ -532,10 +535,10 @@ public abstract class ResourceManager<WorkerType extends ResourceIDRetrievable>
 	@Override
 	public CompletableFuture<TaskManagerInfo> requestTaskManagerInfo(ResourceID resourceId, Time timeout) {
 
-		WorkerRegistration<WorkerType> taskExecutor = taskExecutors.get(resourceId);
+		final WorkerRegistration<WorkerType> taskExecutor = taskExecutors.get(resourceId);
 
 		if (taskExecutor == null) {
-			return FutureUtils.completedExceptionally(new FlinkException("Requested TaskManager " + resourceId + " is not registered."));
+			return FutureUtils.completedExceptionally(new UnknownTaskExecutorException(resourceId));
 		} else {
 			final InstanceID instanceId = taskExecutor.getInstanceID();
 			final TaskManagerInfo taskManagerInfo = new TaskManagerInfo(
@@ -580,6 +583,20 @@ public abstract class ResourceManager<WorkerType extends ResourceIDRetrievable>
 		return CompletableFuture.completedFuture(metricQueryServicePaths);
 	}
 
+	@Override
+	public CompletableFuture<TransientBlobKey> requestTaskManagerFileUpload(ResourceID taskManagerId, FileType fileType, Time timeout) {
+		log.debug("Request file {} upload from TaskExecutor {}.", fileType, taskManagerId);
+
+		final WorkerRegistration<WorkerType> taskExecutor = taskExecutors.get(taskManagerId);
+
+		if (taskExecutor == null) {
+			log.debug("Requested file {} upload from unregistered TaskExecutor {}.", fileType, taskManagerId);
+			return FutureUtils.completedExceptionally(new UnknownTaskExecutorException(taskManagerId));
+		} else {
+			return taskExecutor.getTaskExecutorGateway().requestFileUpload(fileType, timeout);
+		}
+	}
+
 	// ------------------------------------------------------------------------
 	//  Internal methods
 	// ------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManagerGateway.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManagerGateway.java b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManagerGateway.java
index 41a0794..836bc0b 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManagerGateway.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManagerGateway.java
@@ -21,6 +21,8 @@ package org.apache.flink.runtime.resourcemanager;
 import org.apache.flink.api.common.JobID;
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.runtime.blob.BlobServer;
+import org.apache.flink.runtime.blob.TransientBlobKey;
 import org.apache.flink.runtime.clusterframework.ApplicationStatus;
 import org.apache.flink.runtime.clusterframework.types.AllocationID;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
@@ -30,11 +32,12 @@ import org.apache.flink.runtime.instance.InstanceID;
 import org.apache.flink.runtime.jobmaster.JobMaster;
 import org.apache.flink.runtime.jobmaster.JobMasterId;
 import org.apache.flink.runtime.messages.Acknowledge;
-import org.apache.flink.runtime.registration.RegistrationResponse;
 import org.apache.flink.runtime.metrics.dump.MetricQueryService;
+import org.apache.flink.runtime.registration.RegistrationResponse;
 import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerInfo;
 import org.apache.flink.runtime.rpc.FencedRpcGateway;
 import org.apache.flink.runtime.rpc.RpcTimeout;
+import org.apache.flink.runtime.taskexecutor.FileType;
 import org.apache.flink.runtime.taskexecutor.SlotReport;
 import org.apache.flink.runtime.taskexecutor.TaskExecutor;
 
@@ -207,4 +210,16 @@ public interface ResourceManagerGateway extends FencedRpcGateway<ResourceManager
 	 * @return Future containing the collection of resource ids and the corresponding metric query service path
 	 */
 	CompletableFuture<Collection<Tuple2<ResourceID, String>>> requestTaskManagerMetricQueryServicePaths(@RpcTimeout Time timeout);
+
+	/**
+	 * Request the file upload from the given {@link TaskExecutor} to the cluster's {@link BlobServer}. The
+	 * corresponding {@link TransientBlobKey} is returned.
+	 *
+	 * @param taskManagerId identifying the {@link TaskExecutor} to upload the specified file
+	 * @param fileType type of the file to upload
+	 * @param timeout for the asynchronous operation
+	 * @return Future which is completed with the {@link TransientBlobKey} after uploading the file to the
+	 * {@link BlobServer}.
+	 */
+	CompletableFuture<TransientBlobKey> requestTaskManagerFileUpload(ResourceID taskManagerId, FileType fileType, @RpcTimeout Time timeout);
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/exceptions/UnknownTaskExecutorException.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/exceptions/UnknownTaskExecutorException.java b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/exceptions/UnknownTaskExecutorException.java
new file mode 100644
index 0000000..ed34d42
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/exceptions/UnknownTaskExecutorException.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.resourcemanager.exceptions;
+
+import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.taskexecutor.TaskExecutor;
+
+/**
+ * Exception denoting that a requested {@link TaskExecutor} could not be found.
+ */
+public class UnknownTaskExecutorException extends ResourceManagerException {
+	private static final long serialVersionUID = -950571714195353733L;
+
+	public UnknownTaskExecutorException(ResourceID taskExecutorId) {
+		super("No TaskExecutor registered under " + taskExecutorId + '.');
+	}
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/rest/AbstractHandler.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/AbstractHandler.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/AbstractHandler.java
new file mode 100644
index 0000000..2510429
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/AbstractHandler.java
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest;
+
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.runtime.rest.handler.HandlerRequest;
+import org.apache.flink.runtime.rest.handler.HandlerRequestException;
+import org.apache.flink.runtime.rest.handler.RedirectHandler;
+import org.apache.flink.runtime.rest.handler.RestHandlerException;
+import org.apache.flink.runtime.rest.handler.util.HandlerUtils;
+import org.apache.flink.runtime.rest.messages.ErrorResponseBody;
+import org.apache.flink.runtime.rest.messages.MessageParameters;
+import org.apache.flink.runtime.rest.messages.RequestBody;
+import org.apache.flink.runtime.rest.messages.UntypedResponseMessageHeaders;
+import org.apache.flink.runtime.rest.util.RestMapperUtils;
+import org.apache.flink.runtime.webmonitor.RestfulGateway;
+import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever;
+import org.apache.flink.util.Preconditions;
+
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParseException;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf;
+import org.apache.flink.shaded.netty4.io.netty.buffer.ByteBufInputStream;
+import org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext;
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest;
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest;
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus;
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.router.Routed;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nonnull;
+
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Super class for netty-based handlers that work with {@link RequestBody}.
+ *
+ * <p>Subclasses must be thread-safe
+ *
+ * @param <T> type of the leader gateway
+ * @param <R> type of the incoming request
+ * @param <M> type of the message parameters
+ */
+public abstract class AbstractHandler<T extends RestfulGateway, R extends RequestBody, M extends MessageParameters> extends RedirectHandler<T> {
+
+	protected final Logger log = LoggerFactory.getLogger(getClass());
+
+	protected static final ObjectMapper MAPPER = RestMapperUtils.getStrictObjectMapper();
+
+	private final UntypedResponseMessageHeaders<R, M> untypedResponseMessageHeaders;
+
+	protected AbstractHandler(
+			@Nonnull CompletableFuture<String> localAddressFuture,
+			@Nonnull GatewayRetriever<? extends T> leaderRetriever,
+			@Nonnull Time timeout,
+			@Nonnull Map<String, String> responseHeaders,
+			@Nonnull UntypedResponseMessageHeaders<R, M> untypedResponseMessageHeaders) {
+		super(localAddressFuture, leaderRetriever, timeout, responseHeaders);
+
+		this.untypedResponseMessageHeaders = Preconditions.checkNotNull(untypedResponseMessageHeaders);
+	}
+
+	@Override
+	protected void respondAsLeader(ChannelHandlerContext ctx, Routed routed, T gateway) throws Exception {
+		if (log.isDebugEnabled()) {
+			log.debug("Received request " + routed.request().getUri() + '.');
+		}
+
+		final HttpRequest httpRequest = routed.request();
+
+		try {
+			if (!(httpRequest instanceof FullHttpRequest)) {
+				// The RestServerEndpoint defines a HttpObjectAggregator in the pipeline that always returns
+				// FullHttpRequests.
+				log.error("Implementation error: Received a request that wasn't a FullHttpRequest.");
+				HandlerUtils.sendErrorResponse(
+					ctx,
+					httpRequest,
+					new ErrorResponseBody("Bad request received."),
+					HttpResponseStatus.BAD_REQUEST,
+					responseHeaders);
+				return;
+			}
+
+			ByteBuf msgContent = ((FullHttpRequest) httpRequest).content();
+
+			R request;
+			if (msgContent.capacity() == 0) {
+				try {
+					request = MAPPER.readValue("{}", untypedResponseMessageHeaders.getRequestClass());
+				} catch (JsonParseException | JsonMappingException je) {
+					log.error("Request did not conform to expected format.", je);
+					HandlerUtils.sendErrorResponse(
+						ctx,
+						httpRequest,
+						new ErrorResponseBody("Bad request received."),
+						HttpResponseStatus.BAD_REQUEST,
+						responseHeaders);
+					return;
+				}
+			} else {
+				try {
+					ByteBufInputStream in = new ByteBufInputStream(msgContent);
+					request = MAPPER.readValue(in, untypedResponseMessageHeaders.getRequestClass());
+				} catch (JsonParseException | JsonMappingException je) {
+					log.error("Failed to read request.", je);
+					HandlerUtils.sendErrorResponse(
+						ctx,
+						httpRequest,
+						new ErrorResponseBody(String.format("Request did not match expected format %s.", untypedResponseMessageHeaders.getRequestClass().getSimpleName())),
+						HttpResponseStatus.BAD_REQUEST,
+						responseHeaders);
+					return;
+				}
+			}
+
+			final HandlerRequest<R, M> handlerRequest;
+
+			try {
+				handlerRequest = new HandlerRequest<>(request, untypedResponseMessageHeaders.getUnresolvedMessageParameters(), routed.pathParams(), routed.queryParams());
+			} catch (HandlerRequestException hre) {
+				log.error("Could not create the handler request.", hre);
+
+				HandlerUtils.sendErrorResponse(
+					ctx,
+					httpRequest,
+					new ErrorResponseBody(String.format("Bad request, could not parse parameters: %s", hre.getMessage())),
+					HttpResponseStatus.BAD_REQUEST,
+					responseHeaders);
+				return;
+			}
+
+			respondToRequest(
+				ctx,
+				httpRequest,
+				handlerRequest,
+				gateway);
+
+		} catch (Throwable e) {
+			log.error("Request processing failed.", e);
+			HandlerUtils.sendErrorResponse(
+				ctx,
+				httpRequest,
+				new ErrorResponseBody("Internal server error."),
+				HttpResponseStatus.INTERNAL_SERVER_ERROR,
+				responseHeaders);
+		}
+	}
+
+	/**
+	 * Respond to the given {@link HandlerRequest}.
+	 *
+	 * @param ctx channel handler context to write the response
+	 * @param httpRequest original http request
+	 * @param handlerRequest typed handler request
+	 * @param gateway leader gateway
+	 * @throws RestHandlerException if an exception occurred while responding
+	 */
+	protected abstract void respondToRequest(
+		ChannelHandlerContext ctx,
+		HttpRequest httpRequest,
+		HandlerRequest<R, M> handlerRequest,
+		T gateway) throws RestHandlerException;
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/AbstractRestHandler.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/AbstractRestHandler.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/AbstractRestHandler.java
index 408c40a..f5a74c3 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/AbstractRestHandler.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/AbstractRestHandler.java
@@ -20,32 +20,22 @@ package org.apache.flink.runtime.rest.handler;
 
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.runtime.concurrent.FutureUtils;
+import org.apache.flink.runtime.rest.AbstractHandler;
 import org.apache.flink.runtime.rest.handler.util.HandlerUtils;
 import org.apache.flink.runtime.rest.messages.ErrorResponseBody;
 import org.apache.flink.runtime.rest.messages.MessageHeaders;
 import org.apache.flink.runtime.rest.messages.MessageParameters;
 import org.apache.flink.runtime.rest.messages.RequestBody;
 import org.apache.flink.runtime.rest.messages.ResponseBody;
-import org.apache.flink.runtime.rest.util.RestMapperUtils;
 import org.apache.flink.runtime.webmonitor.RestfulGateway;
 import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever;
 import org.apache.flink.util.ExceptionUtils;
 import org.apache.flink.util.Preconditions;
 
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParseException;
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException;
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf;
-import org.apache.flink.shaded.netty4.io.netty.buffer.ByteBufInputStream;
 import org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler;
 import org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext;
-import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest;
 import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest;
 import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus;
-import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.router.Routed;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.annotation.Nonnull;
 
@@ -61,10 +51,7 @@ import java.util.concurrent.CompletableFuture;
  * @param <P> type of outgoing responses
  */
 @ChannelHandler.Sharable
-public abstract class AbstractRestHandler<T extends RestfulGateway, R extends RequestBody, P extends ResponseBody, M extends MessageParameters> extends RedirectHandler<T> {
-	protected final Logger log = LoggerFactory.getLogger(getClass());
-
-	private static final ObjectMapper mapper = RestMapperUtils.getStrictObjectMapper();
+public abstract class AbstractRestHandler<T extends RestfulGateway, R extends RequestBody, P extends ResponseBody, M extends MessageParameters> extends AbstractHandler<T, R, M> {
 
 	private final MessageHeaders<R, P, M> messageHeaders;
 
@@ -74,7 +61,7 @@ public abstract class AbstractRestHandler<T extends RestfulGateway, R extends Re
 			Time timeout,
 			Map<String, String> responseHeaders,
 			MessageHeaders<R, P, M> messageHeaders) {
-		super(localRestAddress, leaderRetriever, timeout, responseHeaders);
+		super(localRestAddress, leaderRetriever, timeout, responseHeaders, messageHeaders);
 		this.messageHeaders = Preconditions.checkNotNull(messageHeaders);
 	}
 
@@ -83,126 +70,49 @@ public abstract class AbstractRestHandler<T extends RestfulGateway, R extends Re
 	}
 
 	@Override
-	protected void respondAsLeader(final ChannelHandlerContext ctx, Routed routed, T gateway) throws Exception {
-		if (log.isDebugEnabled()) {
-			log.debug("Received request " + routed.request().getUri() + '.');
+	protected void respondToRequest(ChannelHandlerContext ctx, HttpRequest httpRequest, HandlerRequest<R, M> handlerRequest, T gateway) throws RestHandlerException {
+		CompletableFuture<P> response;
+
+		try {
+			response = handleRequest(handlerRequest, gateway);
+		} catch (RestHandlerException e) {
+			response = FutureUtils.completedExceptionally(e);
 		}
 
-		final HttpRequest httpRequest = routed.request();
+		response.whenComplete((P resp, Throwable throwable) -> {
+			if (throwable != null) {
 
-		try {
-			if (!(httpRequest instanceof FullHttpRequest)) {
-				// The RestServerEndpoint defines a HttpObjectAggregator in the pipeline that always returns
-				// FullHttpRequests.
-				log.error("Implementation error: Received a request that wasn't a FullHttpRequest.");
-				HandlerUtils.sendErrorResponse(
-					ctx,
-					httpRequest,
-					new ErrorResponseBody("Bad request received."),
-					HttpResponseStatus.BAD_REQUEST,
-					responseHeaders);
-				return;
-			}
+				Throwable error = ExceptionUtils.stripCompletionException(throwable);
 
-			ByteBuf msgContent = ((FullHttpRequest) httpRequest).content();
+				if (error instanceof RestHandlerException) {
+					final RestHandlerException rhe = (RestHandlerException) error;
+
+					log.error("Exception occurred in REST handler.", error);
 
-			R request;
-			if (msgContent.capacity() == 0) {
-				try {
-					request = mapper.readValue("{}", messageHeaders.getRequestClass());
-				} catch (JsonParseException | JsonMappingException je) {
-					log.error("Request did not conform to expected format.", je);
 					HandlerUtils.sendErrorResponse(
 						ctx,
 						httpRequest,
-						new ErrorResponseBody("Bad request received."),
-						HttpResponseStatus.BAD_REQUEST,
+						new ErrorResponseBody(rhe.getMessage()),
+						rhe.getHttpResponseStatus(),
 						responseHeaders);
-					return;
-				}
-			} else {
-				try {
-					ByteBufInputStream in = new ByteBufInputStream(msgContent);
-					request = mapper.readValue(in, messageHeaders.getRequestClass());
-				} catch (JsonParseException | JsonMappingException je) {
-					log.error("Failed to read request.", je);
+				} else {
+					log.error("Implementation error: Unhandled exception.", error);
 					HandlerUtils.sendErrorResponse(
 						ctx,
 						httpRequest,
-						new ErrorResponseBody(String.format("Request did not match expected format %s.", messageHeaders.getRequestClass().getSimpleName())),
-						HttpResponseStatus.BAD_REQUEST,
+						new ErrorResponseBody("Internal server error."),
+						HttpResponseStatus.INTERNAL_SERVER_ERROR,
 						responseHeaders);
-					return;
 				}
-			}
-
-			final HandlerRequest<R, M> handlerRequest;
-
-			try {
-				handlerRequest = new HandlerRequest<>(request, messageHeaders.getUnresolvedMessageParameters(), routed.pathParams(), routed.queryParams());
-			} catch (HandlerRequestException hre) {
-				log.error("Could not create the handler request.", hre);
-
-				HandlerUtils.sendErrorResponse(
+			} else {
+				HandlerUtils.sendResponse(
 					ctx,
 					httpRequest,
-					new ErrorResponseBody(String.format("Bad request, could not parse parameters: %s", hre.getMessage())),
-					HttpResponseStatus.BAD_REQUEST,
+					resp,
+					messageHeaders.getResponseStatusCode(),
 					responseHeaders);
-				return;
-			}
-
-			CompletableFuture<P> response;
-
-			try {
-				response = handleRequest(handlerRequest, gateway);
-			} catch (RestHandlerException e) {
-				response = FutureUtils.completedExceptionally(e);
 			}
-
-			response.whenComplete((P resp, Throwable throwable) -> {
-				if (throwable != null) {
-
-					Throwable error = ExceptionUtils.stripCompletionException(throwable);
-
-					if (error instanceof RestHandlerException) {
-						final RestHandlerException rhe = (RestHandlerException) error;
-
-						log.error("Exception occurred in REST handler.", error);
-
-						HandlerUtils.sendErrorResponse(
-							ctx,
-							httpRequest,
-							new ErrorResponseBody(rhe.getMessage()),
-							rhe.getHttpResponseStatus(),
-							responseHeaders);
-					} else {
-						log.error("Implementation error: Unhandled exception.", error);
-						HandlerUtils.sendErrorResponse(
-							ctx,
-							httpRequest,
-							new ErrorResponseBody("Internal server error."),
-							HttpResponseStatus.INTERNAL_SERVER_ERROR,
-							responseHeaders);
-					}
-				} else {
-					HandlerUtils.sendResponse(
-						ctx,
-						httpRequest,
-						resp,
-						messageHeaders.getResponseStatusCode(),
-						responseHeaders);
-				}
-			});
-		} catch (Throwable e) {
-			log.error("Request processing failed.", e);
-			HandlerUtils.sendErrorResponse(
-				ctx,
-				httpRequest,
-				new ErrorResponseBody("Internal server error."),
-				HttpResponseStatus.INTERNAL_SERVER_ERROR,
-				responseHeaders);
-		}
+		});
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/AbstractTaskManagerFileHandler.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/AbstractTaskManagerFileHandler.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/AbstractTaskManagerFileHandler.java
new file mode 100644
index 0000000..5b5d97d
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/AbstractTaskManagerFileHandler.java
@@ -0,0 +1,259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.handler.taskmanager;
+
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.runtime.blob.TransientBlobKey;
+import org.apache.flink.runtime.blob.TransientBlobService;
+import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
+import org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException;
+import org.apache.flink.runtime.rest.AbstractHandler;
+import org.apache.flink.runtime.rest.handler.HandlerRequest;
+import org.apache.flink.runtime.rest.handler.RestHandlerException;
+import org.apache.flink.runtime.rest.handler.util.HandlerUtils;
+import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
+import org.apache.flink.runtime.rest.messages.ErrorResponseBody;
+import org.apache.flink.runtime.rest.messages.UntypedResponseMessageHeaders;
+import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerIdPathParameter;
+import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMessageParameters;
+import org.apache.flink.runtime.taskexecutor.TaskExecutor;
+import org.apache.flink.runtime.webmonitor.RestfulGateway;
+import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever;
+import org.apache.flink.util.ExceptionUtils;
+import org.apache.flink.util.FlinkException;
+import org.apache.flink.util.Preconditions;
+
+import org.apache.flink.shaded.guava18.com.google.common.cache.CacheBuilder;
+import org.apache.flink.shaded.guava18.com.google.common.cache.CacheLoader;
+import org.apache.flink.shaded.guava18.com.google.common.cache.LoadingCache;
+import org.apache.flink.shaded.guava18.com.google.common.cache.RemovalNotification;
+import org.apache.flink.shaded.netty4.io.netty.channel.ChannelFuture;
+import org.apache.flink.shaded.netty4.io.netty.channel.ChannelFutureListener;
+import org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext;
+import org.apache.flink.shaded.netty4.io.netty.channel.DefaultFileRegion;
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.DefaultHttpResponse;
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpChunkedInput;
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpHeaders;
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest;
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponse;
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus;
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.LastHttpContent;
+import org.apache.flink.shaded.netty4.io.netty.handler.ssl.SslHandler;
+import org.apache.flink.shaded.netty4.io.netty.handler.stream.ChunkedFile;
+import org.apache.flink.shaded.netty4.io.netty.util.concurrent.Future;
+import org.apache.flink.shaded.netty4.io.netty.util.concurrent.GenericFutureListener;
+
+import javax.annotation.Nonnull;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.channels.FileChannel;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+
+import static org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpHeaders.Names.CONNECTION;
+import static org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpHeaders.Names.CONTENT_TYPE;
+import static org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus.INTERNAL_SERVER_ERROR;
+import static org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus.OK;
+import static org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
+
+/**
+ * Base class for serving files from the {@link TaskExecutor}.
+ */
+public abstract class AbstractTaskManagerFileHandler<M extends TaskManagerMessageParameters> extends AbstractHandler<RestfulGateway, EmptyRequestBody, M> {
+
+	private final GatewayRetriever<ResourceManagerGateway> resourceManagerGatewayRetriever;
+	private final TransientBlobService transientBlobService;
+
+	private final LoadingCache<ResourceID, CompletableFuture<TransientBlobKey>> fileBlobKeys;
+
+	protected AbstractTaskManagerFileHandler(
+			@Nonnull CompletableFuture<String> localAddressFuture,
+			@Nonnull GatewayRetriever<? extends RestfulGateway> leaderRetriever,
+			@Nonnull Time timeout,
+			@Nonnull Map<String, String> responseHeaders,
+			@Nonnull UntypedResponseMessageHeaders<EmptyRequestBody, M> untypedResponseMessageHeaders,
+			@Nonnull GatewayRetriever<ResourceManagerGateway> resourceManagerGatewayRetriever,
+			@Nonnull TransientBlobService transientBlobService,
+			@Nonnull Time cacheEntryDuration) {
+		super(localAddressFuture, leaderRetriever, timeout, responseHeaders, untypedResponseMessageHeaders);
+
+		this.resourceManagerGatewayRetriever = Preconditions.checkNotNull(resourceManagerGatewayRetriever);
+
+		this.transientBlobService = Preconditions.checkNotNull(transientBlobService);
+
+		this.fileBlobKeys = CacheBuilder
+			.newBuilder()
+			.expireAfterWrite(cacheEntryDuration.toMilliseconds(), TimeUnit.MILLISECONDS)
+			.removalListener(this::removeBlob)
+			.build(
+				new CacheLoader<ResourceID, CompletableFuture<TransientBlobKey>>() {
+					@Override
+					public CompletableFuture<TransientBlobKey> load(ResourceID resourceId) throws Exception {
+						return loadTaskManagerFile(resourceId);
+					}
+			});
+	}
+
+	@Override
+	protected void respondToRequest(ChannelHandlerContext ctx, HttpRequest httpRequest, HandlerRequest<EmptyRequestBody, M> handlerRequest, RestfulGateway gateway) throws RestHandlerException {
+		final ResourceID taskManagerId = handlerRequest.getPathParameter(TaskManagerIdPathParameter.class);
+
+		final CompletableFuture<TransientBlobKey> blobKeyFuture;
+		try {
+			blobKeyFuture = fileBlobKeys.get(taskManagerId);
+		} catch (ExecutionException e) {
+			final Throwable cause = ExceptionUtils.stripExecutionException(e);
+			if (cause instanceof RestHandlerException) {
+				throw (RestHandlerException) cause;
+			} else {
+				throw new RestHandlerException("Could not retrieve file blob key future.", HttpResponseStatus.INTERNAL_SERVER_ERROR, e);
+			}
+		}
+
+		final CompletableFuture<Void> resultFuture = blobKeyFuture.thenAcceptAsync(
+			(TransientBlobKey blobKey) -> {
+				final File file;
+				try {
+					file = transientBlobService.getFile(blobKey);
+				} catch (IOException e) {
+					throw new CompletionException(new FlinkException("Could not retrieve file from transient blob store.", e));
+				}
+
+				try {
+					transferFile(
+						ctx,
+						file,
+						httpRequest);
+				} catch (FlinkException e) {
+					throw new CompletionException(new FlinkException("Could not transfer file to client.", e));
+				}
+			},
+			ctx.executor());
+
+		resultFuture.whenComplete(
+			(Void ignored, Throwable throwable) -> {
+				if (throwable != null) {
+					log.debug("Failed to transfer file from TaskExecutor {}.", taskManagerId, throwable);
+					fileBlobKeys.invalidate(taskManagerId);
+
+					final Throwable strippedThrowable = ExceptionUtils.stripCompletionException(throwable);
+					final ErrorResponseBody errorResponseBody;
+					final HttpResponseStatus httpResponseStatus;
+
+					if (strippedThrowable instanceof UnknownTaskExecutorException) {
+						errorResponseBody = new ErrorResponseBody("Unknown TaskExecutor " + taskManagerId + '.');
+						httpResponseStatus = HttpResponseStatus.NOT_FOUND;
+					} else {
+						errorResponseBody = new ErrorResponseBody("Internal server error: " + throwable.getMessage() + '.');
+						httpResponseStatus = INTERNAL_SERVER_ERROR;
+					}
+
+					HandlerUtils.sendErrorResponse(
+						ctx,
+						httpRequest,
+						errorResponseBody,
+						httpResponseStatus,
+						responseHeaders);
+				}
+			});
+	}
+
+	protected abstract CompletableFuture<TransientBlobKey> requestFileUpload(ResourceManagerGateway resourceManagerGateway, ResourceID taskManagerResourceId);
+
+	private CompletableFuture<TransientBlobKey> loadTaskManagerFile(ResourceID taskManagerResourceId) throws RestHandlerException {
+		log.debug("Load file from TaskManager {}.", taskManagerResourceId);
+
+		final ResourceManagerGateway resourceManagerGateway = resourceManagerGatewayRetriever
+			.getNow()
+			.orElseThrow(() -> {
+				log.debug("Could not connect to ResourceManager right now.");
+				return new RestHandlerException(
+					"Cannot connect to ResourceManager right now. Please try to refresh.",
+					HttpResponseStatus.NOT_FOUND);
+			});
+
+		return requestFileUpload(resourceManagerGateway, taskManagerResourceId);
+	}
+
+	private void removeBlob(RemovalNotification<ResourceID, CompletableFuture<TransientBlobKey>> removalNotification) {
+		log.debug("Remove cached file for TaskExecutor {}.", removalNotification.getKey());
+
+		final CompletableFuture<TransientBlobKey> value = removalNotification.getValue();
+
+		if (value != null) {
+			value.thenAccept(transientBlobService::deleteFromCache);
+		}
+	}
+
+	private void transferFile(ChannelHandlerContext ctx, File file, HttpRequest httpRequest) throws FlinkException {
+		try (final RandomAccessFile randomAccessFile = new RandomAccessFile(file, "r")) {
+			final long fileLength = randomAccessFile.length();
+
+			try (final FileChannel fileChannel = randomAccessFile.getChannel()) {
+
+				HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);
+				response.headers().set(CONTENT_TYPE, "text/plain");
+
+				if (HttpHeaders.isKeepAlive(httpRequest)) {
+					response.headers().set(CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
+				}
+				HttpHeaders.setContentLength(response, fileLength);
+
+				// write the initial line and the header.
+				ctx.write(response);
+
+				// write the content.
+				final ChannelFuture lastContentFuture;
+				final GenericFutureListener<Future<? super Void>> completionListener = future -> {
+					fileChannel.close();
+					randomAccessFile.close();
+				};
+
+				if (ctx.pipeline().get(SslHandler.class) == null) {
+					ctx.write(
+						new DefaultFileRegion(fileChannel, 0, fileLength), ctx.newProgressivePromise())
+						.addListener(completionListener);
+					lastContentFuture = ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
+
+				} else {
+					lastContentFuture = ctx
+						.writeAndFlush(
+							new HttpChunkedInput(new ChunkedFile(randomAccessFile, 0, fileLength, 8192)),
+							ctx.newProgressivePromise())
+						.addListener(completionListener);
+
+					// HttpChunkedInput will write the end marker (LastHttpContent) for us.
+				}
+
+				// close the connection, if no keep-alive is needed
+				if (!HttpHeaders.isKeepAlive(httpRequest)) {
+					lastContentFuture.addListener(ChannelFutureListener.CLOSE);
+				}
+			}
+		} catch (IOException ioe) {
+			throw new FlinkException("Could not transfer file " + file + " to the client.", ioe);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerLogFileHandler.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerLogFileHandler.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerLogFileHandler.java
new file mode 100644
index 0000000..fab6059
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerLogFileHandler.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.handler.taskmanager;
+
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.runtime.blob.TransientBlobKey;
+import org.apache.flink.runtime.blob.TransientBlobService;
+import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
+import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
+import org.apache.flink.runtime.rest.messages.UntypedResponseMessageHeaders;
+import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMessageParameters;
+import org.apache.flink.runtime.taskexecutor.FileType;
+import org.apache.flink.runtime.taskexecutor.TaskExecutor;
+import org.apache.flink.runtime.webmonitor.RestfulGateway;
+import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever;
+
+import javax.annotation.Nonnull;
+
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Rest handler which serves the log files from {@link TaskExecutor}.
+ */
+public class TaskManagerLogFileHandler extends AbstractTaskManagerFileHandler<TaskManagerMessageParameters> {
+
+	public TaskManagerLogFileHandler(
+			@Nonnull CompletableFuture<String> localAddressFuture,
+			@Nonnull GatewayRetriever<? extends RestfulGateway> leaderRetriever,
+			@Nonnull Time timeout,
+			@Nonnull Map<String, String> responseHeaders,
+			@Nonnull UntypedResponseMessageHeaders<EmptyRequestBody, TaskManagerMessageParameters> untypedResponseMessageHeaders,
+			@Nonnull GatewayRetriever<ResourceManagerGateway> resourceManagerGatewayRetriever,
+			@Nonnull TransientBlobService transientBlobService,
+			@Nonnull Time cacheEntryDuration) {
+		super(localAddressFuture, leaderRetriever, timeout, responseHeaders, untypedResponseMessageHeaders, resourceManagerGatewayRetriever, transientBlobService, cacheEntryDuration);
+	}
+
+	@Override
+	protected CompletableFuture<TransientBlobKey> requestFileUpload(ResourceManagerGateway resourceManagerGateway, ResourceID taskManagerResourceId) {
+		return resourceManagerGateway.requestTaskManagerFileUpload(taskManagerResourceId, FileType.LOG, timeout);
+	}
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerStdoutFileHandler.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerStdoutFileHandler.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerStdoutFileHandler.java
new file mode 100644
index 0000000..6f86abb
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerStdoutFileHandler.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.handler.taskmanager;
+
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.runtime.blob.TransientBlobKey;
+import org.apache.flink.runtime.blob.TransientBlobService;
+import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
+import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
+import org.apache.flink.runtime.rest.messages.UntypedResponseMessageHeaders;
+import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMessageParameters;
+import org.apache.flink.runtime.taskexecutor.FileType;
+import org.apache.flink.runtime.taskexecutor.TaskExecutor;
+import org.apache.flink.runtime.webmonitor.RestfulGateway;
+import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever;
+
+import javax.annotation.Nonnull;
+
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Rest handler which serves the stdout file of the {@link TaskExecutor}.
+ */
+public class TaskManagerStdoutFileHandler extends AbstractTaskManagerFileHandler<TaskManagerMessageParameters> {
+
+	public TaskManagerStdoutFileHandler(
+			@Nonnull CompletableFuture<String> localAddressFuture,
+			@Nonnull GatewayRetriever<? extends RestfulGateway> leaderRetriever,
+			@Nonnull Time timeout,
+			@Nonnull Map<String, String> responseHeaders,
+			@Nonnull UntypedResponseMessageHeaders<EmptyRequestBody, TaskManagerMessageParameters> untypedResponseMessageHeaders,
+			@Nonnull GatewayRetriever<ResourceManagerGateway> resourceManagerGatewayRetriever,
+			@Nonnull TransientBlobService transientBlobService,
+			@Nonnull Time cacheEntryDuration) {
+		super(localAddressFuture, leaderRetriever, timeout, responseHeaders, untypedResponseMessageHeaders, resourceManagerGatewayRetriever, transientBlobService, cacheEntryDuration);
+	}
+
+	@Override
+	protected CompletableFuture<TransientBlobKey> requestFileUpload(ResourceManagerGateway resourceManagerGateway, ResourceID taskManagerResourceId) {
+		return resourceManagerGateway.requestTaskManagerFileUpload(taskManagerResourceId, FileType.STDOUT, timeout);
+	}
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/MessageHeaders.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/MessageHeaders.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/MessageHeaders.java
index e5ec794..85555f8 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/MessageHeaders.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/MessageHeaders.java
@@ -18,8 +18,6 @@
 
 package org.apache.flink.runtime.rest.messages;
 
-import org.apache.flink.runtime.rest.handler.RestHandlerSpecification;
-
 import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus;
 
 /**
@@ -31,14 +29,7 @@ import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseSt
  * @param <P> response message type
  * @param <M> message parameters type
  */
-public interface MessageHeaders<R extends RequestBody, P extends ResponseBody, M extends MessageParameters> extends RestHandlerSpecification {
-
-	/**
-	 * Returns the class of the request message.
-	 *
-	 * @return class of the request message
-	 */
-	Class<R> getRequestClass();
+public interface MessageHeaders<R extends RequestBody, P extends ResponseBody, M extends MessageParameters> extends UntypedResponseMessageHeaders<R, M> {
 
 	/**
 	 * Returns the class of the response message.
@@ -53,12 +44,4 @@ public interface MessageHeaders<R extends RequestBody, P extends ResponseBody, M
 	 * @return http status code of the response
 	 */
 	HttpResponseStatus getResponseStatusCode();
-
-	/**
-	 * Returns a new {@link MessageParameters} object.
-	 *
-	 * @return new message parameters object
-	 */
-	M getUnresolvedMessageParameters();
-
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/UntypedResponseMessageHeaders.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/UntypedResponseMessageHeaders.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/UntypedResponseMessageHeaders.java
new file mode 100644
index 0000000..1556b90
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/UntypedResponseMessageHeaders.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.messages;
+
+import org.apache.flink.runtime.rest.handler.RestHandlerSpecification;
+
+/**
+ * Message headers for a web handler request.
+ *
+ * @param <R> type of the request
+ * @param <M> type of the message message parameters
+ */
+public interface UntypedResponseMessageHeaders<R extends RequestBody, M extends MessageParameters> extends RestHandlerSpecification {
+	/**
+	 * Returns the class of the request message.
+	 *
+	 * @return class of the request message
+	 */
+	Class<R> getRequestClass();
+
+	/**
+	 * Returns a new {@link MessageParameters} object.
+	 *
+	 * @return new message parameters object
+	 */
+	M getUnresolvedMessageParameters();
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/taskmanager/TaskManagerLogFileHeaders.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/taskmanager/TaskManagerLogFileHeaders.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/taskmanager/TaskManagerLogFileHeaders.java
new file mode 100644
index 0000000..0eea50b
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/taskmanager/TaskManagerLogFileHeaders.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.messages.taskmanager;
+
+import org.apache.flink.runtime.rest.HttpMethodWrapper;
+import org.apache.flink.runtime.rest.handler.taskmanager.TaskManagerLogFileHandler;
+import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
+import org.apache.flink.runtime.rest.messages.UntypedResponseMessageHeaders;
+
+/**
+ * Headers for the {@link TaskManagerLogFileHandler}.
+ */
+public class TaskManagerLogFileHeaders implements UntypedResponseMessageHeaders<EmptyRequestBody, TaskManagerMessageParameters> {
+
+	private static final TaskManagerLogFileHeaders INSTANCE = new TaskManagerLogFileHeaders();
+
+	private static final String URL = String.format("/taskmanagers/:%s/log", TaskManagerIdPathParameter.KEY);
+
+	private TaskManagerLogFileHeaders() {}
+
+	@Override
+	public Class<EmptyRequestBody> getRequestClass() {
+		return EmptyRequestBody.class;
+	}
+
+	@Override
+	public TaskManagerMessageParameters getUnresolvedMessageParameters() {
+		return new TaskManagerMessageParameters();
+	}
+
+	@Override
+	public HttpMethodWrapper getHttpMethod() {
+		return HttpMethodWrapper.GET;
+	}
+
+	@Override
+	public String getTargetRestEndpointURL() {
+		return URL;
+	}
+
+	public static TaskManagerLogFileHeaders getInstance() {
+		return INSTANCE;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/taskmanager/TaskManagerStdoutFileHeaders.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/taskmanager/TaskManagerStdoutFileHeaders.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/taskmanager/TaskManagerStdoutFileHeaders.java
new file mode 100644
index 0000000..860d2e4
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/taskmanager/TaskManagerStdoutFileHeaders.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.messages.taskmanager;
+
+import org.apache.flink.runtime.rest.HttpMethodWrapper;
+import org.apache.flink.runtime.rest.handler.taskmanager.TaskManagerStdoutFileHandler;
+import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
+import org.apache.flink.runtime.rest.messages.UntypedResponseMessageHeaders;
+
+/**
+ * Headers for the {@link TaskManagerStdoutFileHandler}.
+ */
+public class TaskManagerStdoutFileHeaders implements UntypedResponseMessageHeaders<EmptyRequestBody, TaskManagerMessageParameters> {
+
+	private static final TaskManagerStdoutFileHeaders INSTANCE = new TaskManagerStdoutFileHeaders();
+
+	private static final String URL = String.format("/taskmanagers/:%s/stdout", TaskManagerIdPathParameter.KEY);
+
+	private TaskManagerStdoutFileHeaders() {}
+
+	@Override
+	public Class<EmptyRequestBody> getRequestClass() {
+		return EmptyRequestBody.class;
+	}
+
+	@Override
+	public TaskManagerMessageParameters getUnresolvedMessageParameters() {
+		return new TaskManagerMessageParameters();
+	}
+
+	@Override
+	public HttpMethodWrapper getHttpMethod() {
+		return HttpMethodWrapper.GET;
+	}
+
+	@Override
+	public String getTargetRestEndpointURL() {
+		return URL;
+	}
+
+	public static TaskManagerStdoutFileHeaders getInstance() {
+		return INSTANCE;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/FileType.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/FileType.java b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/FileType.java
new file mode 100644
index 0000000..bb6923c
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/FileType.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.taskexecutor;
+
+/**
+ * Different file types to request from the {@link TaskExecutor}.
+ */
+public enum FileType {
+	LOG,
+	STDOUT
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
index 0e35f1e..518a41e 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
@@ -23,6 +23,8 @@ import org.apache.flink.api.common.JobID;
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.runtime.accumulators.AccumulatorSnapshot;
 import org.apache.flink.runtime.blob.BlobCacheService;
+import org.apache.flink.runtime.blob.TransientBlobCache;
+import org.apache.flink.runtime.blob.TransientBlobKey;
 import org.apache.flink.runtime.broadcast.BroadcastVariableManager;
 import org.apache.flink.runtime.checkpoint.CheckpointOptions;
 import org.apache.flink.runtime.checkpoint.JobManagerTaskRestore;
@@ -99,6 +101,8 @@ import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
 import org.apache.flink.util.ExceptionUtils;
 import org.apache.flink.util.FlinkException;
 
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.Collection;
@@ -707,6 +711,47 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 		return CompletableFuture.completedFuture(Acknowledge.get());
 	}
 
+	@Override
+	public CompletableFuture<TransientBlobKey> requestFileUpload(FileType fileType, Time timeout) {
+		log.debug("Request file {} upload.", fileType);
+
+		final String filePath;
+
+		switch (fileType) {
+			case LOG:
+				filePath = taskManagerConfiguration.getTaskManagerLogPath();
+				break;
+			case STDOUT:
+				filePath = taskManagerConfiguration.getTaskManagerStdoutPath();
+				break;
+			default:
+				filePath = null;
+		}
+
+		if (filePath != null && !filePath.isEmpty()) {
+			final File file = new File(filePath);
+
+			if (file.exists()) {
+				final TransientBlobCache transientBlobService = blobCacheService.getTransientBlobService();
+				final TransientBlobKey transientBlobKey;
+				try (FileInputStream fileInputStream = new FileInputStream(file)) {
+					transientBlobKey = transientBlobService.putTransient(fileInputStream);
+				} catch (IOException e) {
+					log.debug("Could not upload file {}.", fileType, e);
+					return FutureUtils.completedExceptionally(new FlinkException("Could not upload file " + fileType + '.', e));
+				}
+
+				return CompletableFuture.completedFuture(transientBlobKey);
+			} else {
+				log.debug("The file {} does not exist on the TaskExecutor {}.", fileType, getResourceID());
+				return FutureUtils.completedExceptionally(new FlinkException("The file " + fileType + " does not exist on the TaskExecutor."));
+			}
+		} else {
+			log.debug("The file {} is unavailable on the TaskExecutor {}.", fileType, getResourceID());
+			return FutureUtils.completedExceptionally(new FlinkException("The file " + fileType + " is not available on the TaskExecutor."));
+		}
+	}
+
 	// ----------------------------------------------------------------------
 	// Disconnection RPCs
 	// ----------------------------------------------------------------------
@@ -939,7 +984,11 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 	}
 
 	private void closeJobManagerConnection(JobID jobId, Exception cause) {
-		log.info("Close JobManager connection for job {}.", jobId);
+		if (log.isDebugEnabled()) {
+			log.debug("Close JobManager connection for job {}.", jobId, cause);
+		} else {
+			log.info("Close JobManager connection for job {}.", jobId);
+		}
 
 		// 1. fail tasks running under this JobID
 		Iterator<Task> tasks = taskSlotTable.getTasks(jobId);
@@ -1293,9 +1342,10 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 		@Override
 		public void onRegistrationSuccess(TaskExecutorRegistrationSuccess success) {
 			final ResourceID resourceManagerId = success.getResourceManagerId();
+			final ClusterInformation clusterInformation = success.getClusterInformation();
 
 			runAsync(
-				() -> establishResourceManagerConnection(resourceManagerId, success.getClusterInformation())
+				() -> establishResourceManagerConnection(resourceManagerId, clusterInformation)
 			);
 		}
 

http://git-wip-us.apache.org/repos/asf/flink/blob/5f573804/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutorGateway.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutorGateway.java b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutorGateway.java
index 482d6fc..636be2c 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutorGateway.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutorGateway.java
@@ -20,6 +20,8 @@ package org.apache.flink.runtime.taskexecutor;
 
 import org.apache.flink.api.common.JobID;
 import org.apache.flink.api.common.time.Time;
+import org.apache.flink.runtime.blob.BlobServer;
+import org.apache.flink.runtime.blob.TransientBlobKey;
 import org.apache.flink.runtime.checkpoint.CheckpointOptions;
 import org.apache.flink.runtime.clusterframework.types.AllocationID;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
@@ -135,14 +137,14 @@ public interface TaskExecutorGateway extends RpcGateway {
 	CompletableFuture<Acknowledge> cancelTask(ExecutionAttemptID executionAttemptID, @RpcTimeout Time timeout);
 
 	/**
-	 * Heartbeat request from the job manager
+	 * Heartbeat request from the job manager.
 	 *
 	 * @param heartbeatOrigin unique id of the job manager
 	 */
 	void heartbeatFromJobManager(ResourceID heartbeatOrigin);
 
 	/**
-	 * Heartbeat request from the resource manager
+	 * Heartbeat request from the resource manager.
 	 *
 	 * @param heartbeatOrigin unique id of the resource manager
 	 */
@@ -175,4 +177,13 @@ public interface TaskExecutorGateway extends RpcGateway {
 		final AllocationID allocationId,
 		final Throwable cause,
 		@RpcTimeout final Time timeout);
+
+	/**
+	 * Requests the file upload of the specified type to the cluster's {@link BlobServer}.
+	 *
+	 * @param fileType to upload
+	 * @param timeout for the asynchronous operation
+	 * @return Future which is completed with the {@link TransientBlobKey} of the uploaded file.
+	 */
+	CompletableFuture<TransientBlobKey> requestFileUpload(FileType fileType, @RpcTimeout Time timeout);
 }


[11/11] flink git commit: [hotfix] Log swallowed exception in JobMaster

Posted by tr...@apache.org.
[hotfix] Log swallowed exception in JobMaster


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/62a777bc
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/62a777bc
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/62a777bc

Branch: refs/heads/master
Commit: 62a777bc8ddfb4e34d7beaf7091a90b0bcc70c51
Parents: 1733e73
Author: gyao <ga...@data-artisans.com>
Authored: Wed Jan 31 20:06:09 2018 +0100
Committer: Till Rohrmann <tr...@apache.org>
Committed: Tue Feb 6 13:37:03 2018 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/flink/runtime/jobmaster/JobMaster.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/62a777bc/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
index a983c00..7d845aa 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
@@ -682,7 +682,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 
 				return CompletableFuture.completedFuture(Acknowledge.get());
 			} catch (Exception e) {
-				log.error("Failed to notify KvStateRegistry about registration {}.", registrationName);
+				log.error("Failed to notify KvStateRegistry about registration {}.", registrationName, e);
 				return FutureUtils.completedExceptionally(e);
 			}
 		} else {


[04/11] flink git commit: [hotfix] [tests] Remove JobManagerRunnerMockTest

Posted by tr...@apache.org.
[hotfix] [tests] Remove JobManagerRunnerMockTest

The JobManagerRunnerMockTest is completely ignored. Moreover, it tests things with
heavy usage of Mockito which is hard to maintain.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/0f0a637d
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/0f0a637d
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/0f0a637d

Branch: refs/heads/master
Commit: 0f0a637d4c2ec6e9080a90c747cb9acdbcbb175e
Parents: 22bf386
Author: Till Rohrmann <tr...@apache.org>
Authored: Wed Jan 24 13:41:53 2018 +0100
Committer: Till Rohrmann <tr...@apache.org>
Committed: Tue Feb 6 12:15:31 2018 +0100

----------------------------------------------------------------------
 .../jobmaster/JobManagerRunnerMockTest.java     | 297 -------------------
 1 file changed, 297 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/0f0a637d/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobManagerRunnerMockTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobManagerRunnerMockTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobManagerRunnerMockTest.java
deleted file mode 100644
index a69235a..0000000
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobManagerRunnerMockTest.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.runtime.jobmaster;
-
-import org.apache.flink.api.common.JobID;
-import org.apache.flink.api.common.time.Time;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.runtime.blob.BlobServer;
-import org.apache.flink.runtime.blob.BlobStore;
-import org.apache.flink.runtime.clusterframework.types.ResourceID;
-import org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph;
-import org.apache.flink.runtime.executiongraph.ErrorInfo;
-import org.apache.flink.runtime.heartbeat.HeartbeatServices;
-import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
-import org.apache.flink.runtime.highavailability.RunningJobsRegistry;
-import org.apache.flink.runtime.jobgraph.JobGraph;
-import org.apache.flink.runtime.jobgraph.JobStatus;
-import org.apache.flink.runtime.jobgraph.JobVertex;
-import org.apache.flink.runtime.jobmanager.OnCompletionActions;
-import org.apache.flink.runtime.jobmanager.SubmittedJobGraphStore;
-import org.apache.flink.runtime.leaderelection.LeaderElectionService;
-import org.apache.flink.runtime.metrics.MetricRegistryConfiguration;
-import org.apache.flink.runtime.metrics.MetricRegistryImpl;
-import org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder;
-import org.apache.flink.runtime.rpc.FatalErrorHandler;
-import org.apache.flink.runtime.rpc.RpcService;
-import org.apache.flink.testutils.category.Flip6;
-import org.apache.flink.util.TestLogger;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import java.util.UUID;
-
-import static org.apache.flink.util.Preconditions.checkArgument;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(JobManagerRunner.class)
-@Category(Flip6.class)
-public class JobManagerRunnerMockTest extends TestLogger {
-
-	private JobManagerRunner runner;
-
-	private JobMaster jobManager;
-
-	private JobMasterGateway jobManagerGateway;
-
-	private LeaderElectionService leaderElectionService;
-
-	private SubmittedJobGraphStore submittedJobGraphStore;
-
-	private TestingOnCompletionActions jobCompletion;
-
-	private BlobStore blobStore;
-
-	private RunningJobsRegistry runningJobsRegistry;
-
-	@Before
-	public void setUp() throws Exception {
-		RpcService mockRpc = mock(RpcService.class);
-		when(mockRpc.getAddress()).thenReturn("localhost");
-
-		jobManager = mock(JobMaster.class);
-		jobManagerGateway = mock(JobMasterGateway.class);
-		when(jobManager.getSelfGateway(eq(JobMasterGateway.class))).thenReturn(jobManagerGateway);
-		when(jobManager.getRpcService()).thenReturn(mockRpc);
-
-		PowerMockito.whenNew(JobMaster.class).withAnyArguments().thenReturn(jobManager);
-
-		jobCompletion = new TestingOnCompletionActions();
-
-		leaderElectionService = mock(LeaderElectionService.class);
-		when(leaderElectionService.hasLeadership()).thenReturn(true);
-
-		SubmittedJobGraphStore submittedJobGraphStore = mock(SubmittedJobGraphStore.class);
-
-		blobStore = mock(BlobStore.class);
-
-		HighAvailabilityServices haServices = mock(HighAvailabilityServices.class);
-		when(haServices.getJobManagerLeaderElectionService(any(JobID.class))).thenReturn(leaderElectionService);
-		when(haServices.getSubmittedJobGraphStore()).thenReturn(submittedJobGraphStore);
-		when(haServices.createBlobStore()).thenReturn(blobStore);
-		when(haServices.getRunningJobsRegistry()).thenReturn(runningJobsRegistry);
-
-		HeartbeatServices heartbeatServices = mock(HeartbeatServices.class);
-
-		runner = PowerMockito.spy(new JobManagerRunner(
-			ResourceID.generate(),
-			new JobGraph("test", new JobVertex("vertex")),
-			mock(Configuration.class),
-			mockRpc,
-			haServices,
-			heartbeatServices,
-			JobManagerServices.fromConfiguration(new Configuration(), mock(BlobServer.class)),
-			new MetricRegistryImpl(MetricRegistryConfiguration.defaultMetricRegistryConfiguration()),
-			jobCompletion,
-			jobCompletion,
-			null));
-	}
-
-	@After
-	public void tearDown() throws Exception {
-	}
-
-	@Ignore
-	@Test
-	public void testStartAndShutdown() throws Exception {
-		runner.start();
-		verify(leaderElectionService).start(runner);
-
-		assertTrue(!jobCompletion.isJobFinished());
-		assertTrue(!jobCompletion.isJobFailed());
-
-		verify(jobManager).start(any(JobMasterId.class), any(Time.class));
-
-		runner.shutdown();
-		verify(leaderElectionService).stop();
-		verify(jobManager).shutDown();
-	}
-
-	@Ignore
-	@Test
-	public void testShutdownBeforeGrantLeadership() throws Exception {
-		runner.start();
-		verify(jobManager).start();
-		verify(leaderElectionService).start(runner);
-
-		runner.shutdown();
-		verify(leaderElectionService).stop();
-		verify(jobManager).shutDown();
-
-		assertTrue(!jobCompletion.isJobFinished());
-		assertTrue(!jobCompletion.isJobFailed());
-
-		runner.grantLeadership(UUID.randomUUID());
-		assertTrue(!jobCompletion.isJobFinished());
-		assertTrue(!jobCompletion.isJobFailed());
-
-	}
-
-	@Ignore
-	@Test
-	public void testJobFinished() throws Exception {
-		runner.start();
-
-		JobMasterId jobMasterId = JobMasterId.generate();
-		runner.grantLeadership(jobMasterId.toUUID());
-		verify(jobManager).start(eq(jobMasterId), any(Time.class));
-		assertTrue(!jobCompletion.isJobFinished());
-
-		// runner been told by JobManager that job is finished
-		runner.jobReachedGloballyTerminalState(mock(ArchivedExecutionGraph.class));
-
-		assertTrue(jobCompletion.isJobFinished());
-		assertFalse(jobCompletion.isJobFinishedByOther());
-		verify(leaderElectionService).stop();
-		verify(jobManager).shutDown();
-		assertTrue(runner.isShutdown());
-	}
-
-	@Ignore
-	@Test
-	public void testJobFailed() throws Exception {
-		runner.start();
-
-		JobMasterId jobMasterId = JobMasterId.generate();
-		runner.grantLeadership(jobMasterId.toUUID());
-		verify(jobManager).start(eq(jobMasterId), any(Time.class));
-		assertTrue(!jobCompletion.isJobFinished());
-
-		final ArchivedExecutionGraph failedExecutionGraph = new ArchivedExecutionGraphBuilder()
-			.setFailureCause(new ErrorInfo(new Exception("failed manually"), 1L))
-			.setState(JobStatus.FAILED)
-			.build();
-
-		// runner been told by JobManager that job is failed
-		runner.jobReachedGloballyTerminalState(failedExecutionGraph);
-
-		assertTrue(jobCompletion.isJobFailed());
-		verify(leaderElectionService).stop();
-		verify(jobManager).shutDown();
-		assertTrue(runner.isShutdown());
-	}
-
-	@Ignore
-	@Test
-	public void testLeadershipRevoked() throws Exception {
-		runner.start();
-
-		JobMasterId jobMasterId = JobMasterId.generate();
-		runner.grantLeadership(jobMasterId.toUUID());
-		verify(jobManager).start(eq(jobMasterId), any(Time.class));
-		assertTrue(!jobCompletion.isJobFinished());
-
-		runner.revokeLeadership();
-		verify(jobManager).suspend(any(Throwable.class), any(Time.class));
-		assertFalse(runner.isShutdown());
-	}
-
-	@Ignore
-	@Test
-	public void testRegainLeadership() throws Exception {
-		runner.start();
-
-		JobMasterId jobMasterId = JobMasterId.generate();
-		runner.grantLeadership(jobMasterId.toUUID());
-		verify(jobManager).start(eq(jobMasterId), any(Time.class));
-		assertTrue(!jobCompletion.isJobFinished());
-
-		runner.revokeLeadership();
-		verify(jobManager).suspend(any(Throwable.class), any(Time.class));
-		assertFalse(runner.isShutdown());
-
-		JobMasterId jobMasterId2 = JobMasterId.generate();
-		runner.grantLeadership(jobMasterId2.toUUID());
-		verify(jobManager).start(eq(jobMasterId2), any(Time.class));
-	}
-
-	private static class TestingOnCompletionActions implements OnCompletionActions, FatalErrorHandler {
-
-		private volatile JobResult result;
-
-		private volatile Throwable failedCause;
-
-		private volatile boolean finishedByOther;
-
-		@Override
-		public void jobReachedGloballyTerminalState(ArchivedExecutionGraph executionGraph) {
-			checkArgument(!isJobFinished(), "job finished already");
-			checkArgument(!isJobFailed(), "job failed already");
-
-			this.result = JobResult.createFrom(executionGraph);
-
-			if (!result.isSuccess()) {
-				failedCause = result.getSerializedThrowable().get();
-			}
-		}
-
-		@Override
-		public void jobFinishedByOther() {
-			checkArgument(!isJobFinished(), "job finished already");
-			checkArgument(!isJobFailed(), "job failed already");
-
-			this.finishedByOther = true;
-		}
-
-		@Override
-		public void onFatalError(Throwable exception) {
-			checkArgument(!isJobFinished(), "job finished already");
-			checkArgument(!isJobFailed(), "job failed already");
-
-			this.failedCause = exception;
-		}
-
-		boolean isJobFinished() {
-			return result != null || finishedByOther;
-		}
-
-		boolean isJobFinishedByOther() {
-			return finishedByOther;
-		}
-
-		boolean isJobFailed() {
-			return failedCause != null;
-		}
-	}
-}


[08/11] flink git commit: [FLINK-7856][flip6] Port JobVertexBackPressureHandler to REST endpoint

Posted by tr...@apache.org.
[FLINK-7856][flip6] Port JobVertexBackPressureHandler to REST endpoint


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/7137d619
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/7137d619
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/7137d619

Branch: refs/heads/master
Commit: 7137d619456be401cb8a7b867daa98eb80f3838c
Parents: d306cc7
Author: zjureel <zj...@gmail.com>
Authored: Wed Nov 15 13:55:28 2017 +0800
Committer: Till Rohrmann <tr...@apache.org>
Committed: Tue Feb 6 13:34:23 2018 +0100

----------------------------------------------------------------------
 .../dispatcher/DispatcherRestEndpoint.java      |  10 ++
 .../job/JobVertexBackPressureHandler.java       |  64 +++++++
 .../EmptyJobVertexBackPressureInfo.java         |  39 +++++
 .../messages/JobVertexBackPressureHeaders.java  |  68 ++++++++
 .../messages/JobVertexBackPressureInfo.java     | 171 +++++++++++++++++++
 .../messages/JobVertexBackPressureInfoTest.java |  45 +++++
 6 files changed, 397 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/7137d619/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DispatcherRestEndpoint.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DispatcherRestEndpoint.java b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DispatcherRestEndpoint.java
index f9263c9..04175f3 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DispatcherRestEndpoint.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DispatcherRestEndpoint.java
@@ -30,7 +30,9 @@ import org.apache.flink.runtime.rest.handler.RestHandlerSpecification;
 import org.apache.flink.runtime.rest.handler.job.BlobServerPortHandler;
 import org.apache.flink.runtime.rest.handler.job.JobSubmitHandler;
 import org.apache.flink.runtime.rest.handler.job.JobTerminationHandler;
+import org.apache.flink.runtime.rest.handler.job.JobVertexBackPressureHandler;
 import org.apache.flink.runtime.rest.messages.JobTerminationHeaders;
+import org.apache.flink.runtime.rest.messages.JobVertexBackPressureHeaders;
 import org.apache.flink.runtime.rpc.FatalErrorHandler;
 import org.apache.flink.runtime.webmonitor.WebMonitorEndpoint;
 import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever;
@@ -100,9 +102,17 @@ public class DispatcherRestEndpoint extends WebMonitorEndpoint<DispatcherGateway
 			timeout,
 			responseHeaders);
 
+		JobVertexBackPressureHandler jobVertexBackPressureHandler = new JobVertexBackPressureHandler(
+			restAddressFuture,
+			leaderRetriever,
+			timeout,
+			responseHeaders,
+			JobVertexBackPressureHeaders.getInstance());
+
 		handlers.add(Tuple2.of(JobTerminationHeaders.getInstance(), jobTerminationHandler));
 		handlers.add(Tuple2.of(blobServerPortHandler.getMessageHeaders(), blobServerPortHandler));
 		handlers.add(Tuple2.of(jobSubmitHandler.getMessageHeaders(), jobSubmitHandler));
+		handlers.add(Tuple2.of(JobVertexBackPressureHeaders.getInstance(), jobVertexBackPressureHandler));
 
 		return handlers;
 	}

http://git-wip-us.apache.org/repos/asf/flink/blob/7137d619/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/job/JobVertexBackPressureHandler.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/job/JobVertexBackPressureHandler.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/job/JobVertexBackPressureHandler.java
new file mode 100644
index 0000000..6b3bef2
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/job/JobVertexBackPressureHandler.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.handler.job;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.runtime.dispatcher.DispatcherGateway;
+import org.apache.flink.runtime.jobgraph.JobVertexID;
+import org.apache.flink.runtime.rest.handler.AbstractRestHandler;
+import org.apache.flink.runtime.rest.handler.HandlerRequest;
+import org.apache.flink.runtime.rest.handler.RestHandlerException;
+import org.apache.flink.runtime.rest.messages.EmptyJobVertexBackPressureInfo;
+import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
+import org.apache.flink.runtime.rest.messages.JobIDPathParameter;
+import org.apache.flink.runtime.rest.messages.JobVertexBackPressureInfo;
+import org.apache.flink.runtime.rest.messages.JobVertexIdPathParameter;
+import org.apache.flink.runtime.rest.messages.JobVertexMessageParameters;
+import org.apache.flink.runtime.rest.messages.MessageHeaders;
+import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever;
+
+import javax.annotation.Nonnull;
+
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Request handler for the job vertex back pressure.
+ */
+public class JobVertexBackPressureHandler extends AbstractRestHandler<DispatcherGateway, EmptyRequestBody, JobVertexBackPressureInfo, JobVertexMessageParameters> {
+
+	public JobVertexBackPressureHandler(
+			CompletableFuture<String> localRestAddress,
+			GatewayRetriever<DispatcherGateway> leaderRetriever,
+			Time timeout,
+			Map<String, String> responseHeaders,
+			MessageHeaders<EmptyRequestBody, JobVertexBackPressureInfo, JobVertexMessageParameters> messageHeaders) {
+		super(localRestAddress, leaderRetriever, timeout, responseHeaders, messageHeaders);
+	}
+
+	@Override
+	protected CompletableFuture<JobVertexBackPressureInfo> handleRequest(@Nonnull HandlerRequest<EmptyRequestBody, JobVertexMessageParameters> request, @Nonnull DispatcherGateway gateway) throws RestHandlerException {
+		JobID jobId = request.getPathParameter(JobIDPathParameter.class);
+		JobVertexID jobVertexID = request.getPathParameter(JobVertexIdPathParameter.class);
+		///TODO Get JobVertexBackPressureInfo from DispatcherGateway with JobID and JobVertexID here
+
+		return CompletableFuture.completedFuture(EmptyJobVertexBackPressureInfo.getInstance());
+	}
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/7137d619/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/EmptyJobVertexBackPressureInfo.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/EmptyJobVertexBackPressureInfo.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/EmptyJobVertexBackPressureInfo.java
new file mode 100644
index 0000000..4d021c7
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/EmptyJobVertexBackPressureInfo.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.messages;
+
+import org.apache.flink.runtime.rest.handler.job.JobVertexBackPressureHandler;
+
+import java.util.ArrayList;
+
+/**
+ * Empty response of the {@link JobVertexBackPressureHandler}.
+ */
+public class EmptyJobVertexBackPressureInfo extends JobVertexBackPressureInfo {
+
+	private static final EmptyJobVertexBackPressureInfo INSTANCE = new EmptyJobVertexBackPressureInfo();
+
+	private EmptyJobVertexBackPressureInfo() {
+		super(null, null, System.currentTimeMillis(), new ArrayList<>());
+	}
+
+	public static EmptyJobVertexBackPressureInfo getInstance() {
+		return INSTANCE;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/7137d619/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureHeaders.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureHeaders.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureHeaders.java
new file mode 100644
index 0000000..6ce4bd1
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureHeaders.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.messages;
+
+import org.apache.flink.runtime.rest.HttpMethodWrapper;
+import org.apache.flink.runtime.rest.handler.job.JobVertexBackPressureHandler;
+
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus;
+
+/**
+ * Message headers for the {@link JobVertexBackPressureHandler}.
+ */
+public class JobVertexBackPressureHeaders implements MessageHeaders<EmptyRequestBody, JobVertexBackPressureInfo, JobVertexMessageParameters> {
+
+	private static final JobVertexBackPressureHeaders INSTANCE = new JobVertexBackPressureHeaders();
+
+	private static final String URL = "/jobs/:" + JobIDPathParameter.KEY + "/vertices/:" + JobVertexIdPathParameter.KEY + "/backpressure";
+
+	@Override
+	public Class<EmptyRequestBody> getRequestClass() {
+		return EmptyRequestBody.class;
+	}
+
+	@Override
+	public Class<JobVertexBackPressureInfo> getResponseClass() {
+		return JobVertexBackPressureInfo.class;
+	}
+
+	@Override
+	public HttpResponseStatus getResponseStatusCode() {
+		return HttpResponseStatus.OK;
+	}
+
+	@Override
+	public JobVertexMessageParameters getUnresolvedMessageParameters() {
+		return new JobVertexMessageParameters();
+	}
+
+	@Override
+	public HttpMethodWrapper getHttpMethod() {
+		return HttpMethodWrapper.GET;
+	}
+
+	@Override
+	public String getTargetRestEndpointURL() {
+		return URL;
+	}
+
+	public static JobVertexBackPressureHeaders getInstance() {
+		return INSTANCE;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/7137d619/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureInfo.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureInfo.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureInfo.java
new file mode 100644
index 0000000..aae94ff
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureInfo.java
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.messages;
+
+import org.apache.flink.runtime.rest.handler.job.JobVertexBackPressureHandler;
+
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+import java.util.Objects;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * Response type of the {@link JobVertexBackPressureHandler}.
+ */
+public class JobVertexBackPressureInfo implements ResponseBody {
+
+	public static final String FIELD_NAME_STATUS = "status";
+	public static final String FIELD_NAME_BACKPRESSURE_LEVEL = "backpressure-level";
+	public static final String FIELD_NAME_END_TIMESTAMP = "end-timestamp";
+	public static final String FIELD_NAME_SUBTASKS = "subtasks";
+
+	@JsonProperty(FIELD_NAME_STATUS)
+	private final VertexBackPressureStatus status;
+
+	@JsonProperty(FIELD_NAME_BACKPRESSURE_LEVEL)
+	private final VertexBackPressureLevel backpressureLevel;
+
+	@JsonProperty(FIELD_NAME_END_TIMESTAMP)
+	private final long endTimestamp;
+
+	@JsonProperty(FIELD_NAME_SUBTASKS)
+	protected final List<SubtaskBackPressureInfo> subtasks;
+
+	@JsonCreator
+	public JobVertexBackPressureInfo(
+		@JsonProperty(FIELD_NAME_STATUS) VertexBackPressureStatus status,
+		@JsonProperty(FIELD_NAME_BACKPRESSURE_LEVEL) VertexBackPressureLevel backpressureLevel,
+		@JsonProperty(FIELD_NAME_END_TIMESTAMP) long endTimestamp,
+		@JsonProperty(FIELD_NAME_SUBTASKS) List<SubtaskBackPressureInfo> subtasks) {
+		this.status = status;
+		this.backpressureLevel = backpressureLevel;
+		this.endTimestamp = endTimestamp;
+		this.subtasks = checkNotNull(subtasks);
+	}
+
+	@Override
+	public boolean equals(Object o) {
+		if (this == o) {
+			return true;
+		}
+		if (o == null || getClass() != o.getClass()) {
+			return false;
+		}
+		JobVertexBackPressureInfo that = (JobVertexBackPressureInfo) o;
+		return Objects.equals(status, that.status) &&
+			Objects.equals(backpressureLevel, that.backpressureLevel) &&
+			Objects.equals(endTimestamp, that.endTimestamp) &&
+			Objects.equals(subtasks, that.subtasks);
+	}
+
+	@Override
+	public int hashCode() {
+		return Objects.hash(status, backpressureLevel, endTimestamp, subtasks);
+	}
+
+	//---------------------------------------------------------------------------------
+	// Static helper classes
+	//---------------------------------------------------------------------------------
+
+	/**
+	 * Nested class to encapsulate the sub tasks back pressure.
+	 */
+	public static final class SubtaskBackPressureInfo {
+
+		public static final String FIELD_NAME_SUBTASK = "subtask";
+		public static final String FIELD_NAME_BACKPRESSURE_LEVEL = "backpressure-level";
+		public static final String FIELD_NAME_RATIO = "ratio";
+
+		@JsonProperty(FIELD_NAME_SUBTASK)
+		private final int subtask;
+
+		@JsonProperty(FIELD_NAME_BACKPRESSURE_LEVEL)
+		private final VertexBackPressureLevel backpressureLevel;
+
+		@JsonProperty(FIELD_NAME_RATIO)
+		private final double ratio;
+
+		public SubtaskBackPressureInfo(
+			@JsonProperty(FIELD_NAME_SUBTASK) int subtask,
+			@JsonProperty(FIELD_NAME_BACKPRESSURE_LEVEL) VertexBackPressureLevel backpressureLevel,
+			@JsonProperty(FIELD_NAME_RATIO) double ratio) {
+			this.subtask = subtask;
+			this.backpressureLevel = checkNotNull(backpressureLevel);
+			this.ratio = ratio;
+		}
+
+		@Override
+		public boolean equals(Object o) {
+			if (this == o) {
+				return true;
+			}
+			if (o == null || getClass() != o.getClass()) {
+				return false;
+			}
+			SubtaskBackPressureInfo that = (SubtaskBackPressureInfo) o;
+			return subtask == that.subtask &&
+				ratio == that.ratio &&
+				Objects.equals(backpressureLevel, that.backpressureLevel);
+		}
+
+		@Override
+		public int hashCode() {
+			return Objects.hash(subtask, backpressureLevel, ratio);
+		}
+	}
+
+	/**
+	 * Status of vertex back-pressure.
+	 */
+	public enum VertexBackPressureStatus {
+		DEPRECATED("deprecated"), OK("ok");
+
+		private String status;
+
+		VertexBackPressureStatus(String status) {
+			this.status = status;
+		}
+
+		@Override
+		public String toString() {
+			return status;
+		}
+	}
+
+	/**
+	 * Level of vertex back-pressure.
+	 */
+	public enum VertexBackPressureLevel {
+		OK("ok"), LOW("low"), HIGH("high");
+
+		private String level;
+
+		VertexBackPressureLevel(String level) {
+			this.level = level;
+		}
+
+		@Override
+		public String toString() {
+			return level;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/7137d619/flink-runtime/src/test/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureInfoTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureInfoTest.java
new file mode 100644
index 0000000..751d05a
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/messages/JobVertexBackPressureInfoTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.messages;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Tests that the {@link JobVertexBackPressureInfo} can be marshalled and unmarshalled.
+ */
+public class JobVertexBackPressureInfoTest extends RestResponseMarshallingTestBase<JobVertexBackPressureInfo> {
+	@Override
+	protected Class<JobVertexBackPressureInfo> getTestResponseClass() {
+		return JobVertexBackPressureInfo.class;
+	}
+
+	@Override
+	protected JobVertexBackPressureInfo getTestResponseInstance() throws Exception {
+		List<JobVertexBackPressureInfo.SubtaskBackPressureInfo> subtaskList = new ArrayList<>();
+		subtaskList.add(new JobVertexBackPressureInfo.SubtaskBackPressureInfo(0, JobVertexBackPressureInfo.VertexBackPressureLevel.LOW, 0.1));
+		subtaskList.add(new JobVertexBackPressureInfo.SubtaskBackPressureInfo(1, JobVertexBackPressureInfo.VertexBackPressureLevel.OK, 0.4));
+		subtaskList.add(new JobVertexBackPressureInfo.SubtaskBackPressureInfo(2, JobVertexBackPressureInfo.VertexBackPressureLevel.HIGH, 0.9));
+		return new JobVertexBackPressureInfo(
+					JobVertexBackPressureInfo.VertexBackPressureStatus.OK,
+					JobVertexBackPressureInfo.VertexBackPressureLevel.LOW,
+					System.currentTimeMillis(),
+					subtaskList);
+	}
+}


[02/11] flink git commit: [FLINK-8501] [flip6] Use single BlobCacheService per TaskExecutor

Posted by tr...@apache.org.
[FLINK-8501] [flip6] Use single BlobCacheService per TaskExecutor

Instead of creating for each new JobManagerConnection a dedicated BlobCacheService
the TaskExecutor uses a single BlobCacheService which it shares between the
different JobManagerConnections. The initial BlobServer address is passed by the
ResourceManager when the TaskExecutor registers at it. In order to avoid the re-
creation of BlobCacheServices, this commit changes the behaviour such that one can
update the BlobServer address.

This closes #5350.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/22bf3861
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/22bf3861
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/22bf3861

Branch: refs/heads/master
Commit: 22bf3861c95ed93b2eb5f8d0661d282ef6cdbbc8
Parents: 9d0eb22
Author: Till Rohrmann <tr...@apache.org>
Authored: Tue Feb 6 11:01:36 2018 +0100
Committer: Till Rohrmann <tr...@apache.org>
Committed: Tue Feb 6 12:15:30 2018 +0100

----------------------------------------------------------------------
 .../entrypoint/MesosJobClusterEntrypoint.java   |  3 +
 .../MesosSessionClusterEntrypoint.java          |  3 +
 .../clusterframework/MesosResourceManager.java  |  3 +
 .../MesosResourceManagerTest.java               | 22 ++++-
 .../flink/runtime/blob/AbstractBlobCache.java   | 56 +++++++++----
 .../flink/runtime/blob/BlobCacheService.java    | 25 ++++--
 .../flink/runtime/blob/PermanentBlobCache.java  | 15 ++--
 .../flink/runtime/blob/TransientBlobCache.java  | 29 ++++---
 .../apache/flink/runtime/client/JobClient.java  |  2 +-
 .../runtime/entrypoint/ClusterInformation.java  | 51 ++++++++++++
 .../entrypoint/JobClusterEntrypoint.java        |  2 +
 .../entrypoint/SessionClusterEntrypoint.java    |  2 +
 .../StandaloneSessionClusterEntrypoint.java     |  2 +
 .../jobmaster/JMTMRegistrationSuccess.java      | 14 ++--
 .../flink/runtime/jobmaster/JobMaster.java      |  5 +-
 .../flink/runtime/minicluster/MiniCluster.java  | 86 ++++++++++++++------
 .../resourcemanager/ResourceManager.java        |  8 +-
 .../resourcemanager/ResourceManagerRunner.java  |  5 +-
 .../StandaloneResourceManager.java              |  3 +
 .../handler/legacy/TaskManagerLogHandler.java   |  2 +-
 .../taskexecutor/JobManagerConnection.java      | 16 +---
 .../runtime/taskexecutor/TaskExecutor.java      | 61 ++++++--------
 .../TaskExecutorRegistrationSuccess.java        | 27 ++++--
 .../runtime/taskexecutor/TaskManagerRunner.java | 18 +++-
 .../flink/runtime/taskmanager/TaskManager.scala |  4 +-
 .../runtime/blob/BlobCacheCleanupTest.java      | 10 +--
 .../runtime/blob/BlobCacheCorruptionTest.java   |  4 +-
 .../flink/runtime/blob/BlobCacheDeleteTest.java | 16 ++--
 .../flink/runtime/blob/BlobCacheGetTest.java    | 24 +++---
 .../flink/runtime/blob/BlobCachePutTest.java    | 34 ++++----
 .../runtime/blob/BlobCacheRecoveryTest.java     |  8 +-
 .../runtime/blob/BlobCacheRetriesTest.java      |  8 +-
 .../runtime/blob/BlobCacheSuccessTest.java      |  4 +-
 .../runtime/blob/BlobServerRecoveryTest.java    |  4 +-
 .../clusterframework/ResourceManagerTest.java   |  3 +
 .../BlobLibraryCacheManagerTest.java            |  8 +-
 .../BlobLibraryCacheRecoveryITCase.java         |  4 +-
 ...ecutionGraphDeploymentWithBlobCacheTest.java |  2 +-
 .../resourcemanager/ResourceManagerHATest.java  |  2 +
 .../ResourceManagerJobMasterTest.java           |  2 +
 .../ResourceManagerTaskExecutorTest.java        |  2 +
 .../resourcemanager/TestingResourceManager.java | 14 +++-
 .../utils/TestingResourceManagerGateway.java    |  4 +-
 .../taskexecutor/TaskExecutorITCase.java        |  9 +-
 .../runtime/taskexecutor/TaskExecutorTest.java  | 85 ++++++++++---------
 .../apache/flink/yarn/YarnResourceManager.java  |  3 +
 .../entrypoint/YarnJobClusterEntrypoint.java    |  3 +
 .../YarnSessionClusterEntrypoint.java           |  3 +
 .../flink/yarn/YarnResourceManagerTest.java     |  4 +
 49 files changed, 471 insertions(+), 253 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-mesos/src/main/java/org/apache/flink/mesos/entrypoint/MesosJobClusterEntrypoint.java
----------------------------------------------------------------------
diff --git a/flink-mesos/src/main/java/org/apache/flink/mesos/entrypoint/MesosJobClusterEntrypoint.java b/flink-mesos/src/main/java/org/apache/flink/mesos/entrypoint/MesosJobClusterEntrypoint.java
index d38e734..21864dc 100755
--- a/flink-mesos/src/main/java/org/apache/flink/mesos/entrypoint/MesosJobClusterEntrypoint.java
+++ b/flink-mesos/src/main/java/org/apache/flink/mesos/entrypoint/MesosJobClusterEntrypoint.java
@@ -29,6 +29,7 @@ import org.apache.flink.runtime.blob.BlobServer;
 import org.apache.flink.runtime.clusterframework.BootstrapTools;
 import org.apache.flink.runtime.clusterframework.ContainerSpecification;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.entrypoint.JobClusterEntrypoint;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
@@ -132,6 +133,7 @@ public class MesosJobClusterEntrypoint extends JobClusterEntrypoint {
 			HeartbeatServices heartbeatServices,
 			MetricRegistry metricRegistry,
 			FatalErrorHandler fatalErrorHandler,
+			ClusterInformation clusterInformation,
 			@Nullable String webInterfaceUrl) throws Exception {
 		final ResourceManagerConfiguration rmConfiguration = ResourceManagerConfiguration.fromConfiguration(configuration);
 		final ResourceManagerRuntimeServicesConfiguration rmServicesConfiguration = ResourceManagerRuntimeServicesConfiguration.fromConfiguration(configuration);
@@ -150,6 +152,7 @@ public class MesosJobClusterEntrypoint extends JobClusterEntrypoint {
 			rmRuntimeServices.getSlotManager(),
 			metricRegistry,
 			rmRuntimeServices.getJobLeaderIdService(),
+			clusterInformation,
 			fatalErrorHandler,
 			configuration,
 			mesosServices,

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-mesos/src/main/java/org/apache/flink/mesos/entrypoint/MesosSessionClusterEntrypoint.java
----------------------------------------------------------------------
diff --git a/flink-mesos/src/main/java/org/apache/flink/mesos/entrypoint/MesosSessionClusterEntrypoint.java b/flink-mesos/src/main/java/org/apache/flink/mesos/entrypoint/MesosSessionClusterEntrypoint.java
index f52532a..68cf7c6 100755
--- a/flink-mesos/src/main/java/org/apache/flink/mesos/entrypoint/MesosSessionClusterEntrypoint.java
+++ b/flink-mesos/src/main/java/org/apache/flink/mesos/entrypoint/MesosSessionClusterEntrypoint.java
@@ -29,6 +29,7 @@ import org.apache.flink.runtime.blob.BlobServer;
 import org.apache.flink.runtime.clusterframework.BootstrapTools;
 import org.apache.flink.runtime.clusterframework.ContainerSpecification;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.entrypoint.SessionClusterEntrypoint;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
@@ -122,6 +123,7 @@ public class MesosSessionClusterEntrypoint extends SessionClusterEntrypoint {
 			HeartbeatServices heartbeatServices,
 			MetricRegistry metricRegistry,
 			FatalErrorHandler fatalErrorHandler,
+			ClusterInformation clusterInformation,
 			@Nullable String webInterfaceUrl) throws Exception {
 		final ResourceManagerConfiguration rmConfiguration = ResourceManagerConfiguration.fromConfiguration(configuration);
 		final ResourceManagerRuntimeServicesConfiguration rmServicesConfiguration = ResourceManagerRuntimeServicesConfiguration.fromConfiguration(configuration);
@@ -140,6 +142,7 @@ public class MesosSessionClusterEntrypoint extends SessionClusterEntrypoint {
 			rmRuntimeServices.getSlotManager(),
 			metricRegistry,
 			rmRuntimeServices.getJobLeaderIdService(),
+			clusterInformation,
 			fatalErrorHandler,
 			configuration,
 			mesosServices,

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-mesos/src/main/java/org/apache/flink/mesos/runtime/clusterframework/MesosResourceManager.java
----------------------------------------------------------------------
diff --git a/flink-mesos/src/main/java/org/apache/flink/mesos/runtime/clusterframework/MesosResourceManager.java b/flink-mesos/src/main/java/org/apache/flink/mesos/runtime/clusterframework/MesosResourceManager.java
index bb60465..d42d8d1 100644
--- a/flink-mesos/src/main/java/org/apache/flink/mesos/runtime/clusterframework/MesosResourceManager.java
+++ b/flink-mesos/src/main/java/org/apache/flink/mesos/runtime/clusterframework/MesosResourceManager.java
@@ -47,6 +47,7 @@ import org.apache.flink.runtime.clusterframework.ContaineredTaskManagerParameter
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
 import org.apache.flink.runtime.concurrent.FutureUtils;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
 import org.apache.flink.runtime.metrics.MetricRegistry;
@@ -149,6 +150,7 @@ public class MesosResourceManager extends ResourceManager<RegisteredMesosWorkerN
 			SlotManager slotManager,
 			MetricRegistry metricRegistry,
 			JobLeaderIdService jobLeaderIdService,
+			ClusterInformation clusterInformation,
 			FatalErrorHandler fatalErrorHandler,
 			// Mesos specifics
 			Configuration flinkConfig,
@@ -166,6 +168,7 @@ public class MesosResourceManager extends ResourceManager<RegisteredMesosWorkerN
 			slotManager,
 			metricRegistry,
 			jobLeaderIdService,
+			clusterInformation,
 			fatalErrorHandler);
 
 		this.mesosServices = Preconditions.checkNotNull(mesosServices);

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-mesos/src/test/java/org/apache/flink/mesos/runtime/clusterframework/MesosResourceManagerTest.java
----------------------------------------------------------------------
diff --git a/flink-mesos/src/test/java/org/apache/flink/mesos/runtime/clusterframework/MesosResourceManagerTest.java b/flink-mesos/src/test/java/org/apache/flink/mesos/runtime/clusterframework/MesosResourceManagerTest.java
index 57fb2df..e23e0cb 100644
--- a/flink-mesos/src/test/java/org/apache/flink/mesos/runtime/clusterframework/MesosResourceManagerTest.java
+++ b/flink-mesos/src/test/java/org/apache/flink/mesos/runtime/clusterframework/MesosResourceManagerTest.java
@@ -43,6 +43,7 @@ import org.apache.flink.runtime.clusterframework.ContaineredTaskManagerParameter
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
 import org.apache.flink.runtime.concurrent.ScheduledExecutor;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.heartbeat.TestingHeartbeatServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
@@ -172,10 +173,23 @@ public class MesosResourceManagerTest extends TestLogger {
 			MesosConfiguration mesosConfig,
 			MesosTaskManagerParameters taskManagerParameters,
 			ContainerSpecification taskManagerContainerSpec) {
-			super(rpcService, resourceManagerEndpointId, resourceId, resourceManagerConfiguration,
-				highAvailabilityServices, heartbeatServices, slotManager, metricRegistry,
-				jobLeaderIdService, fatalErrorHandler, flinkConfig, mesosServices, mesosConfig,
-				taskManagerParameters, taskManagerContainerSpec);
+			super(
+				rpcService,
+				resourceManagerEndpointId,
+				resourceId,
+				resourceManagerConfiguration,
+				highAvailabilityServices,
+				heartbeatServices,
+				slotManager,
+				metricRegistry,
+				jobLeaderIdService,
+				new ClusterInformation("localhost", 1234),
+				fatalErrorHandler,
+				flinkConfig,
+				mesosServices,
+				mesosConfig,
+				taskManagerParameters,
+				taskManagerContainerSpec);
 		}
 
 		@Override

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/blob/AbstractBlobCache.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/blob/AbstractBlobCache.java b/flink-runtime/src/main/java/org/apache/flink/runtime/blob/AbstractBlobCache.java
index efb9ded..e0d63cf 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/blob/AbstractBlobCache.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/blob/AbstractBlobCache.java
@@ -54,8 +54,6 @@ public abstract class AbstractBlobCache implements Closeable {
 	 */
 	protected final AtomicLong tempFileCounter = new AtomicLong(0);
 
-	protected final InetSocketAddress serverAddress;
-
 	/**
 	 * Root directory for local file storage.
 	 */
@@ -89,15 +87,16 @@ public abstract class AbstractBlobCache implements Closeable {
 	 */
 	protected final ReadWriteLock readWriteLock;
 
+	@Nullable
+	protected volatile InetSocketAddress serverAddress;
+
 	public AbstractBlobCache(
-			final InetSocketAddress serverAddress,
 			final Configuration blobClientConfig,
 			final BlobView blobView,
-			final Logger logger) throws IOException {
+			final Logger logger,
+			@Nullable final InetSocketAddress serverAddress) throws IOException {
 
 		this.log = checkNotNull(logger);
-
-		this.serverAddress = checkNotNull(serverAddress);
 		this.blobClientConfig = checkNotNull(blobClientConfig);
 		this.blobView = checkNotNull(blobView);
 		this.readWriteLock = new ReentrantReadWriteLock();
@@ -118,6 +117,8 @@ public abstract class AbstractBlobCache implements Closeable {
 
 		// Add shutdown hook to delete storage directory
 		shutdownHook = BlobUtils.addShutdownHook(this, log);
+
+		this.serverAddress = serverAddress;
 	}
 
 	/**
@@ -172,16 +173,22 @@ public abstract class AbstractBlobCache implements Closeable {
 				log.info("Failed to copy from blob store. Downloading from BLOB server instead.", e);
 			}
 
-			// fallback: download from the BlobServer
-			BlobClient.downloadFromBlobServer(
-				jobId, blobKey, incomingFile, serverAddress, blobClientConfig, numFetchRetries);
+			final InetSocketAddress currentServerAddress = serverAddress;
 
-			readWriteLock.writeLock().lock();
-			try {
-				BlobUtils.moveTempFileToStore(
-					incomingFile, jobId, blobKey, localFile, log, null);
-			} finally {
-				readWriteLock.writeLock().unlock();
+			if (currentServerAddress != null) {
+				// fallback: download from the BlobServer
+				BlobClient.downloadFromBlobServer(
+					jobId, blobKey, incomingFile, currentServerAddress, blobClientConfig, numFetchRetries);
+
+				readWriteLock.writeLock().lock();
+				try {
+					BlobUtils.moveTempFileToStore(
+						incomingFile, jobId, blobKey, localFile, log, null);
+				} finally {
+					readWriteLock.writeLock().unlock();
+				}
+			} else {
+				throw new IOException("Cannot download from BlobServer, because the server address is unknown.");
 			}
 
 			return localFile;
@@ -197,10 +204,25 @@ public abstract class AbstractBlobCache implements Closeable {
 	/**
 	 * Returns the port the BLOB server is listening on.
 	 *
-	 * @return BLOB server port
+	 * @return BLOB server port or {@code -1} if no server address
 	 */
 	public int getPort() {
-		return serverAddress.getPort();
+		final InetSocketAddress currentServerAddress = serverAddress;
+
+		if (currentServerAddress != null) {
+			return serverAddress.getPort();
+		} else {
+			return -1;
+		}
+	}
+
+	/**
+	 * Sets the address of the {@link BlobServer}.
+	 *
+	 * @param blobServerAddress address of the {@link BlobServer}.
+	 */
+	public void setBlobServerAddress(InetSocketAddress blobServerAddress) {
+		serverAddress = checkNotNull(blobServerAddress);
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/blob/BlobCacheService.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/blob/BlobCacheService.java b/flink-runtime/src/main/java/org/apache/flink/runtime/blob/BlobCacheService.java
index 89ce2c4..b2ee100 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/blob/BlobCacheService.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/blob/BlobCacheService.java
@@ -20,6 +20,8 @@ package org.apache.flink.runtime.blob;
 
 import org.apache.flink.configuration.Configuration;
 
+import javax.annotation.Nullable;
+
 import java.io.IOException;
 import java.net.InetSocketAddress;
 
@@ -39,23 +41,22 @@ public class BlobCacheService implements BlobService {
 	/**
 	 * Instantiates a new BLOB cache.
 	 *
-	 * @param serverAddress
-	 * 		address of the {@link BlobServer} to use for fetching files from
 	 * @param blobClientConfig
 	 * 		global configuration
 	 * @param blobView
 	 * 		(distributed) blob store file system to retrieve files from first
-	 *
+	 * @param serverAddress
+	 * 		address of the {@link BlobServer} to use for fetching files from or {@code null} if none yet
 	 * @throws IOException
 	 * 		thrown if the (local or distributed) file storage cannot be created or is not usable
 	 */
 	public BlobCacheService(
-			final InetSocketAddress serverAddress,
 			final Configuration blobClientConfig,
-			final BlobView blobView) throws IOException {
+			final BlobView blobView,
+			@Nullable final InetSocketAddress serverAddress) throws IOException {
 
-		this(new PermanentBlobCache(serverAddress, blobClientConfig, blobView),
-			new TransientBlobCache(serverAddress, blobClientConfig));
+		this(new PermanentBlobCache(blobClientConfig, blobView, serverAddress),
+			new TransientBlobCache(blobClientConfig, serverAddress));
 	}
 
 	/**
@@ -82,6 +83,16 @@ public class BlobCacheService implements BlobService {
 		return transientBlobCache;
 	}
 
+	/**
+	 * Sets the address of the {@link BlobServer}.
+	 *
+	 * @param blobServerAddress address of the {@link BlobServer}.
+	 */
+	public void setBlobServerAddress(InetSocketAddress blobServerAddress) {
+		permanentBlobCache.setBlobServerAddress(blobServerAddress);
+		transientBlobCache.setBlobServerAddress(blobServerAddress);
+	}
+
 	@Override
 	public void close() throws IOException {
 		permanentBlobCache.close();

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/blob/PermanentBlobCache.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/blob/PermanentBlobCache.java b/flink-runtime/src/main/java/org/apache/flink/runtime/blob/PermanentBlobCache.java
index 83cb18e..88ea74a 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/blob/PermanentBlobCache.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/blob/PermanentBlobCache.java
@@ -26,6 +26,8 @@ import org.apache.flink.util.FileUtils;
 
 import org.slf4j.LoggerFactory;
 
+import javax.annotation.Nullable;
+
 import java.io.File;
 import java.io.IOException;
 import java.net.InetSocketAddress;
@@ -85,23 +87,22 @@ public class PermanentBlobCache extends AbstractBlobCache implements PermanentBl
 	/**
 	 * Instantiates a new cache for permanent BLOBs which are also available in an HA store.
 	 *
-	 * @param serverAddress
-	 * 		address of the {@link BlobServer} to use for fetching files from
 	 * @param blobClientConfig
 	 * 		global configuration
 	 * @param blobView
 	 * 		(distributed) HA blob store file system to retrieve files from first
-	 *
+	 * @param serverAddress
+	 * 		address of the {@link BlobServer} to use for fetching files from or {@code null} if none yet
 	 * @throws IOException
 	 * 		thrown if the (local or distributed) file storage cannot be created or is not usable
 	 */
 	public PermanentBlobCache(
-			final InetSocketAddress serverAddress,
 			final Configuration blobClientConfig,
-			final BlobView blobView) throws IOException {
+			final BlobView blobView,
+			@Nullable final InetSocketAddress serverAddress) throws IOException {
 
-		super(serverAddress, blobClientConfig, blobView,
-			LoggerFactory.getLogger(PermanentBlobCache.class));
+		super(blobClientConfig, blobView, LoggerFactory.getLogger(PermanentBlobCache.class), serverAddress
+		);
 
 		// Initializing the clean up task
 		this.cleanupTimer = new Timer(true);

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/blob/TransientBlobCache.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/blob/TransientBlobCache.java b/flink-runtime/src/main/java/org/apache/flink/runtime/blob/TransientBlobCache.java
index bbd008a..aab2803 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/blob/TransientBlobCache.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/blob/TransientBlobCache.java
@@ -67,20 +67,19 @@ public class TransientBlobCache extends AbstractBlobCache implements TransientBl
 	/**
 	 * Instantiates a new BLOB cache.
 	 *
-	 * @param serverAddress
-	 * 		address of the {@link BlobServer} to use for fetching files from
 	 * @param blobClientConfig
 	 * 		global configuration
-	 *
+	 * @param serverAddress
+	 * 		address of the {@link BlobServer} to use for fetching files from or {@code null} if none yet
 	 * @throws IOException
 	 * 		thrown if the (local or distributed) file storage cannot be created or is not usable
 	 */
 	public TransientBlobCache(
-			final InetSocketAddress serverAddress,
-			final Configuration blobClientConfig) throws IOException {
+			final Configuration blobClientConfig,
+			@Nullable final InetSocketAddress serverAddress) throws IOException {
 
-		super(serverAddress, blobClientConfig, new VoidBlobStore(),
-			LoggerFactory.getLogger(TransientBlobCache.class));
+		super(blobClientConfig, new VoidBlobStore(), LoggerFactory.getLogger(TransientBlobCache.class), serverAddress
+		);
 
 		// Initializing the clean up task
 		this.cleanupTimer = new Timer(true);
@@ -122,7 +121,7 @@ public class TransientBlobCache extends AbstractBlobCache implements TransientBl
 
 	@Override
 	public TransientBlobKey putTransient(byte[] value) throws IOException {
-		try (BlobClient bc = new BlobClient(serverAddress, blobClientConfig)) {
+		try (BlobClient bc = createClient()) {
 			return (TransientBlobKey) bc.putBuffer(null, value, 0, value.length, TRANSIENT_BLOB);
 		}
 	}
@@ -130,14 +129,14 @@ public class TransientBlobCache extends AbstractBlobCache implements TransientBl
 	@Override
 	public TransientBlobKey putTransient(JobID jobId, byte[] value) throws IOException {
 		checkNotNull(jobId);
-		try (BlobClient bc = new BlobClient(serverAddress, blobClientConfig)) {
+		try (BlobClient bc = createClient()) {
 			return (TransientBlobKey) bc.putBuffer(jobId, value, 0, value.length, TRANSIENT_BLOB);
 		}
 	}
 
 	@Override
 	public TransientBlobKey putTransient(InputStream inputStream) throws IOException {
-		try (BlobClient bc = new BlobClient(serverAddress, blobClientConfig)) {
+		try (BlobClient bc = createClient()) {
 			return (TransientBlobKey) bc.putInputStream(null, inputStream, TRANSIENT_BLOB);
 		}
 	}
@@ -145,7 +144,7 @@ public class TransientBlobCache extends AbstractBlobCache implements TransientBl
 	@Override
 	public TransientBlobKey putTransient(JobID jobId, InputStream inputStream) throws IOException {
 		checkNotNull(jobId);
-		try (BlobClient bc = new BlobClient(serverAddress, blobClientConfig)) {
+		try (BlobClient bc = createClient()) {
 			return (TransientBlobKey) bc.putInputStream(jobId, inputStream, TRANSIENT_BLOB);
 		}
 	}
@@ -222,7 +221,13 @@ public class TransientBlobCache extends AbstractBlobCache implements TransientBl
 	}
 
 	private BlobClient createClient() throws IOException {
-		return new BlobClient(serverAddress, blobClientConfig);
+		final InetSocketAddress currentServerAddress = serverAddress;
+
+		if (currentServerAddress != null) {
+			return new BlobClient(serverAddress, blobClientConfig);
+		} else {
+			throw new IOException("Could not create BlobClient because the BlobServer address is unknown.");
+		}
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/client/JobClient.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/client/JobClient.java b/flink-runtime/src/main/java/org/apache/flink/runtime/client/JobClient.java
index 82c40e0..4b84857 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/client/JobClient.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/client/JobClient.java
@@ -206,7 +206,7 @@ public class JobClient {
 			final PermanentBlobCache permanentBlobCache;
 			try {
 				// TODO: Fix lifecycle of PermanentBlobCache to properly close it upon usage
-				permanentBlobCache = new PermanentBlobCache(serverAddress, config, highAvailabilityServices.createBlobStore());
+				permanentBlobCache = new PermanentBlobCache(config, highAvailabilityServices.createBlobStore(), serverAddress);
 			} catch (IOException e) {
 				throw new JobRetrievalException(
 					jobID,

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/ClusterInformation.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/ClusterInformation.java b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/ClusterInformation.java
new file mode 100644
index 0000000..1d9f039
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/ClusterInformation.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.entrypoint;
+
+import org.apache.flink.util.Preconditions;
+
+import java.io.Serializable;
+
+/**
+ * Information about the cluster which is shared with the cluster components.
+ */
+public class ClusterInformation implements Serializable {
+
+	private static final long serialVersionUID = 316958921518479205L;
+
+	private final String blobServerHostname;
+
+	private final int blobServerPort;
+
+	public ClusterInformation(String blobServerHostname, int blobServerPort) {
+		this.blobServerHostname = Preconditions.checkNotNull(blobServerHostname);
+		Preconditions.checkArgument(
+			0 < blobServerPort && blobServerPort < 65_536,
+			"The blob port must between 0 and 65_536. However, it was " + blobServerPort + '.');
+		this.blobServerPort = blobServerPort;
+	}
+
+	public String getBlobServerHostname() {
+		return blobServerHostname;
+	}
+
+	public int getBlobServerPort() {
+		return blobServerPort;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/JobClusterEntrypoint.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/JobClusterEntrypoint.java b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/JobClusterEntrypoint.java
index e52f113..1cf3de2 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/JobClusterEntrypoint.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/JobClusterEntrypoint.java
@@ -134,6 +134,7 @@ public abstract class JobClusterEntrypoint extends ClusterEntrypoint {
 			heartbeatServices,
 			metricRegistry,
 			this,
+			new ClusterInformation(rpcService.getAddress(), blobServer.getPort()),
 			jobMasterRestEndpoint.getRestAddress());
 
 		jobManagerRunner = createJobManagerRunner(
@@ -288,6 +289,7 @@ public abstract class JobClusterEntrypoint extends ClusterEntrypoint {
 		HeartbeatServices heartbeatServices,
 		MetricRegistry metricRegistry,
 		FatalErrorHandler fatalErrorHandler,
+		ClusterInformation clusterInformation,
 		@Nullable String webInterfaceUrl) throws Exception;
 
 	protected abstract JobGraph retrieveJobGraph(Configuration configuration) throws FlinkException;

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/SessionClusterEntrypoint.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/SessionClusterEntrypoint.java b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/SessionClusterEntrypoint.java
index fe9bd92..86f0fe3 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/SessionClusterEntrypoint.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/SessionClusterEntrypoint.java
@@ -136,6 +136,7 @@ public abstract class SessionClusterEntrypoint extends ClusterEntrypoint {
 			heartbeatServices,
 			metricRegistry,
 			this,
+			new ClusterInformation(rpcService.getAddress(), blobServer.getPort()),
 			dispatcherRestEndpoint.getRestAddress());
 
 		dispatcher = createDispatcher(
@@ -285,5 +286,6 @@ public abstract class SessionClusterEntrypoint extends ClusterEntrypoint {
 		HeartbeatServices heartbeatServices,
 		MetricRegistry metricRegistry,
 		FatalErrorHandler fatalErrorHandler,
+		ClusterInformation clusterInformation,
 		@Nullable String webInterfaceUrl) throws Exception;
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/StandaloneSessionClusterEntrypoint.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/StandaloneSessionClusterEntrypoint.java b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/StandaloneSessionClusterEntrypoint.java
index 8d01196..0f205f1 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/StandaloneSessionClusterEntrypoint.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/StandaloneSessionClusterEntrypoint.java
@@ -55,6 +55,7 @@ public class StandaloneSessionClusterEntrypoint extends SessionClusterEntrypoint
 			HeartbeatServices heartbeatServices,
 			MetricRegistry metricRegistry,
 			FatalErrorHandler fatalErrorHandler,
+			ClusterInformation clusterInformation,
 			@Nullable String webInterfaceUrl) throws Exception {
 		final ResourceManagerConfiguration resourceManagerConfiguration = ResourceManagerConfiguration.fromConfiguration(configuration);
 		final ResourceManagerRuntimeServicesConfiguration resourceManagerRuntimeServicesConfiguration = ResourceManagerRuntimeServicesConfiguration.fromConfiguration(configuration);
@@ -73,6 +74,7 @@ public class StandaloneSessionClusterEntrypoint extends SessionClusterEntrypoint
 			resourceManagerRuntimeServices.getSlotManager(),
 			metricRegistry,
 			resourceManagerRuntimeServices.getJobLeaderIdService(),
+			clusterInformation,
 			fatalErrorHandler);
 	}
 

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JMTMRegistrationSuccess.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JMTMRegistrationSuccess.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JMTMRegistrationSuccess.java
index 7272cd4..34e38ac 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JMTMRegistrationSuccess.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JMTMRegistrationSuccess.java
@@ -20,26 +20,22 @@ package org.apache.flink.runtime.jobmaster;
 
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.registration.RegistrationResponse;
+import org.apache.flink.runtime.taskexecutor.TaskExecutor;
 import org.apache.flink.util.Preconditions;
 
+/**
+ * Message indicating a successful {@link JobMaster} and {@link TaskExecutor} registration.
+ */
 public class JMTMRegistrationSuccess extends RegistrationResponse.Success {
 	private static final long serialVersionUID = -3528383155961318929L;
 
 	private final ResourceID resourceID;
-	private final int blobPort;
-
-	public JMTMRegistrationSuccess(ResourceID resourceID, int blobPort) {
-		Preconditions.checkArgument(0 < blobPort && 65536 > blobPort, "The blob port has to be 0 < blobPort < 65536.");
 
+	public JMTMRegistrationSuccess(ResourceID resourceID) {
 		this.resourceID = Preconditions.checkNotNull(resourceID);
-		this.blobPort = blobPort;
 	}
 
 	public ResourceID getResourceID() {
 		return resourceID;
 	}
-
-	public int getBlobPort() {
-		return blobPort;
-	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
index 8d47655..f137f39 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
@@ -753,8 +753,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 		final ResourceID taskManagerId = taskManagerLocation.getResourceID();
 
 		if (registeredTaskManagers.containsKey(taskManagerId)) {
-			final RegistrationResponse response = new JMTMRegistrationSuccess(
-				resourceId, blobServer.getPort());
+			final RegistrationResponse response = new JMTMRegistrationSuccess(resourceId);
 			return CompletableFuture.completedFuture(response);
 		} else {
 			return getRpcService()
@@ -781,7 +780,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 							}
 						});
 
-						return new JMTMRegistrationSuccess(resourceId, blobServer.getPort());
+						return new JMTMRegistrationSuccess(resourceId);
 					},
 					getMainThreadExecutor());
 		}

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniCluster.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniCluster.java b/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniCluster.java
index 531c1a1..c54bf54 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniCluster.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniCluster.java
@@ -22,11 +22,13 @@ import org.apache.flink.api.common.JobExecutionResult;
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.runtime.akka.AkkaUtils;
+import org.apache.flink.runtime.blob.BlobCacheService;
 import org.apache.flink.runtime.blob.BlobServer;
 import org.apache.flink.runtime.client.JobExecutionException;
 import org.apache.flink.runtime.clusterframework.FlinkResourceManager;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.concurrent.FutureUtils;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServicesUtils;
@@ -52,6 +54,8 @@ import org.slf4j.LoggerFactory;
 
 import javax.annotation.concurrent.GuardedBy;
 
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
 import java.util.UUID;
 import java.util.concurrent.CompletableFuture;
 
@@ -59,17 +63,20 @@ import static org.apache.flink.util.ExceptionUtils.firstOrSuppressed;
 import static org.apache.flink.util.Preconditions.checkNotNull;
 import static org.apache.flink.util.Preconditions.checkState;
 
+/**
+ * Flip-6 based MiniCluster.
+ */
 public class MiniCluster implements JobExecutorService {
 
 	private static final Logger LOG = LoggerFactory.getLogger(MiniCluster.class);
 
-	/** The lock to guard startup / shutdown / manipulation methods */
+	/** The lock to guard startup / shutdown / manipulation methods. */
 	private final Object lock = new Object();
 
-	/** The configuration for this mini cluster */
+	/** The configuration for this mini cluster. */
 	private final MiniClusterConfiguration miniClusterConfiguration;
 
-	@GuardedBy("lock") 
+	@GuardedBy("lock")
 	private MetricRegistryImpl metricRegistry;
 
 	@GuardedBy("lock")
@@ -94,6 +101,9 @@ public class MiniCluster implements JobExecutorService {
 	private HeartbeatServices heartbeatServices;
 
 	@GuardedBy("lock")
+	private BlobCacheService blobCacheService;
+
+	@GuardedBy("lock")
 	private ResourceManagerRunner[] resourceManagerRunners;
 
 	private volatile TaskExecutor[] taskManagers;
@@ -101,14 +111,14 @@ public class MiniCluster implements JobExecutorService {
 	@GuardedBy("lock")
 	private MiniClusterJobDispatcher jobDispatcher;
 
-	/** Flag marking the mini cluster as started/running */
+	/** Flag marking the mini cluster as started/running. */
 	private volatile boolean running;
 
 	// ------------------------------------------------------------------------
 
 	/**
 	 * Creates a new Flink mini cluster based on the given configuration.
-	 * 
+	 *
 	 * @param miniClusterConfiguration The configuration for the mini cluster
 	 */
 	public MiniCluster(MiniClusterConfiguration miniClusterConfiguration) {
@@ -130,7 +140,7 @@ public class MiniCluster implements JobExecutorService {
 
 	/**
 	 * Starts the mini cluster, based on the configured properties.
-	 * 
+	 *
 	 * @throws Exception This method passes on any exception that occurs during the startup of
 	 *                   the mini cluster.
 	 */
@@ -227,12 +237,23 @@ public class MiniCluster implements JobExecutorService {
 					heartbeatServices,
 					metricRegistry,
 					numResourceManagers,
-					resourceManagerRpcServices);
+					resourceManagerRpcServices,
+					new ClusterInformation("localhost", blobServer.getPort()));
+
+				blobCacheService = new BlobCacheService(
+					configuration, haServices.createBlobStore(), new InetSocketAddress(InetAddress.getLocalHost(), blobServer.getPort())
+				);
 
 				// bring up the TaskManager(s) for the mini cluster
 				LOG.info("Starting {} TaskManger(s)", numTaskManagers);
 				taskManagers = startTaskManagers(
-						configuration, haServices, metricRegistry, numTaskManagers, taskManagerRpcServices);
+					configuration,
+					haServices,
+					heartbeatServices,
+					metricRegistry,
+					blobCacheService,
+					numTaskManagers,
+					taskManagerRpcServices);
 
 				// bring up the dispatcher that launches JobManagers when jobs submitted
 				LOG.info("Starting job dispatcher(s) for {} JobManger(s)", numJobManagers);
@@ -265,10 +286,10 @@ public class MiniCluster implements JobExecutorService {
 	/**
 	 * Shuts down the mini cluster, failing all currently executing jobs.
 	 * The mini cluster can be started again by calling the {@link #start()} method again.
-	 * 
+	 *
 	 * <p>This method shuts down all started services and components,
-	 * even if an exception occurs in the process of shutting down some component. 
-	 * 
+	 * even if an exception occurs in the process of shutting down some component.
+	 *
 	 * @throws Exception Thrown, if the shutdown did not complete cleanly.
 	 */
 	public void shutdown() throws Exception {
@@ -331,7 +352,6 @@ public class MiniCluster implements JobExecutorService {
 			}
 			taskManagers = null;
 		}
-
 		// metrics shutdown
 		if (metricRegistry != null) {
 			metricRegistry.shutdown();
@@ -348,6 +368,16 @@ public class MiniCluster implements JobExecutorService {
 		taskManagerRpcServices = null;
 		resourceManagerRpcServices = null;
 
+		if (blobCacheService != null) {
+			try {
+				blobCacheService.close();
+			} catch (Exception e) {
+				exception = firstOrSuppressed(e, exception);
+			}
+			blobCacheService = null;
+		}
+
+
 		// shut down the blob server
 		if (blobServer != null) {
 			try {
@@ -385,20 +415,23 @@ public class MiniCluster implements JobExecutorService {
 				OneTimeLeaderListenerFuture listenerFuture = new OneTimeLeaderListenerFuture();
 				rmMasterListener = haServices.getResourceManagerLeaderRetriever();
 				rmMasterListener.start(listenerFuture);
-				addressAndIdFuture = listenerFuture.future(); 
+				addressAndIdFuture = listenerFuture.future();
 			}
 
 			final LeaderAddressAndId addressAndId = addressAndIdFuture.get();
 
-			final ResourceManagerGateway resourceManager = 
-					commonRpcService.connect(addressAndId.leaderAddress(), new ResourceManagerId(addressAndId.leaderId()), ResourceManagerGateway.class).get();
+			final ResourceManagerGateway resourceManager = commonRpcService
+				.connect(
+					addressAndId.leaderAddress(),
+					new ResourceManagerId(addressAndId.leaderId()),
+					ResourceManagerGateway.class)
+				.get();
 
 			final int numTaskManagersToWaitFor = taskManagers.length;
 
 			// poll and wait until enough TaskManagers are available
 			while (true) {
-				int numTaskManagersAvailable = 
-						resourceManager.getNumberOfRegisteredTaskManagers().get();
+				int numTaskManagersAvailable = resourceManager.getNumberOfRegisteredTaskManagers().get();
 
 				if (numTaskManagersAvailable >= numTaskManagersToWaitFor) {
 					break;
@@ -443,7 +476,7 @@ public class MiniCluster implements JobExecutorService {
 	 * This method runs a job in blocking mode. The method returns only after the job
 	 * completed successfully, or after it failed terminally.
 	 *
-	 * @param job  The Flink job to execute 
+	 * @param job  The Flink job to execute
 	 * @return The result of the job execution
 	 *
 	 * @throws JobExecutionException Thrown if anything went amiss during initial job launch,
@@ -471,8 +504,8 @@ public class MiniCluster implements JobExecutorService {
 	// ------------------------------------------------------------------------
 
 	/**
-	 * Factory method to create the metric registry for the mini cluster
-	 * 
+	 * Factory method to create the metric registry for the mini cluster.
+	 *
 	 * @param config The configuration of the mini cluster
 	 */
 	protected MetricRegistryImpl createMetricRegistry(Configuration config) {
@@ -481,7 +514,7 @@ public class MiniCluster implements JobExecutorService {
 
 	/**
 	 * Factory method to instantiate the RPC service.
-	 * 
+	 *
 	 * @param configuration
 	 *            The configuration of the mini cluster
 	 * @param askTimeout
@@ -490,7 +523,7 @@ public class MiniCluster implements JobExecutorService {
 	 *            True, if the RPC service should be reachable from other (remote) RPC services.
 	 * @param bindAddress
 	 *            The address to bind the RPC service to. Only relevant when "remoteEnabled" is true.
-	 * 
+	 *
 	 * @return The instantiated RPC service
 	 */
 	protected RpcService createRpcService(
@@ -515,7 +548,8 @@ public class MiniCluster implements JobExecutorService {
 			HeartbeatServices heartbeatServices,
 			MetricRegistry metricRegistry,
 			int numResourceManagers,
-			RpcService[] resourceManagerRpcServices) throws Exception {
+			RpcService[] resourceManagerRpcServices,
+			ClusterInformation clusterInformation) throws Exception {
 
 		final ResourceManagerRunner[] resourceManagerRunners = new ResourceManagerRunner[numResourceManagers];
 
@@ -528,7 +562,8 @@ public class MiniCluster implements JobExecutorService {
 				resourceManagerRpcServices[i],
 				haServices,
 				heartbeatServices,
-				metricRegistry);
+				metricRegistry,
+				clusterInformation);
 
 			resourceManagerRunners[i].start();
 		}
@@ -539,7 +574,9 @@ public class MiniCluster implements JobExecutorService {
 	protected TaskExecutor[] startTaskManagers(
 			Configuration configuration,
 			HighAvailabilityServices haServices,
+			HeartbeatServices heartbeatServices,
 			MetricRegistry metricRegistry,
+			BlobCacheService blobCacheService,
 			int numTaskManagers,
 			RpcService[] taskManagerRpcServices) throws Exception {
 
@@ -554,6 +591,7 @@ public class MiniCluster implements JobExecutorService {
 				haServices,
 				heartbeatServices,
 				metricRegistry,
+				blobCacheService,
 				localCommunication,
 				new TerminatingFatalErrorHandler(i));
 

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java
index e5fef14..7db127d 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java
@@ -30,6 +30,7 @@ import org.apache.flink.runtime.clusterframework.types.ResourceIDRetrievable;
 import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
 import org.apache.flink.runtime.clusterframework.types.SlotID;
 import org.apache.flink.runtime.concurrent.FutureUtils;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.heartbeat.HeartbeatListener;
 import org.apache.flink.runtime.heartbeat.HeartbeatManager;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
@@ -130,6 +131,8 @@ public abstract class ResourceManager<WorkerType extends ResourceIDRetrievable>
 	/** The slot manager maintains the available slots. */
 	private final SlotManager slotManager;
 
+	private final ClusterInformation clusterInformation;
+
 	/** The service to elect a ResourceManager leader. */
 	private LeaderElectionService leaderElectionService;
 
@@ -146,6 +149,7 @@ public abstract class ResourceManager<WorkerType extends ResourceIDRetrievable>
 			SlotManager slotManager,
 			MetricRegistry metricRegistry,
 			JobLeaderIdService jobLeaderIdService,
+			ClusterInformation clusterInformation,
 			FatalErrorHandler fatalErrorHandler) {
 
 		super(rpcService, resourceManagerEndpointId);
@@ -156,6 +160,7 @@ public abstract class ResourceManager<WorkerType extends ResourceIDRetrievable>
 		this.slotManager = checkNotNull(slotManager);
 		this.metricRegistry = checkNotNull(metricRegistry);
 		this.jobLeaderIdService = checkNotNull(jobLeaderIdService);
+		this.clusterInformation = checkNotNull(clusterInformation);
 		this.fatalErrorHandler = checkNotNull(fatalErrorHandler);
 
 		this.taskManagerHeartbeatManager = heartbeatServices.createHeartbeatManagerSender(
@@ -699,7 +704,8 @@ public abstract class ResourceManager<WorkerType extends ResourceIDRetrievable>
 			return new TaskExecutorRegistrationSuccess(
 				registration.getInstanceID(),
 				resourceId,
-				resourceManagerConfiguration.getHeartbeatInterval().toMilliseconds());
+				resourceManagerConfiguration.getHeartbeatInterval().toMilliseconds(),
+				clusterInformation);
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManagerRunner.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManagerRunner.java b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManagerRunner.java
index caa3ba0..58a2789 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManagerRunner.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManagerRunner.java
@@ -20,6 +20,7 @@ package org.apache.flink.runtime.resourcemanager;
 
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
 import org.apache.flink.runtime.metrics.MetricRegistry;
@@ -55,7 +56,8 @@ public class ResourceManagerRunner implements FatalErrorHandler {
 			final RpcService rpcService,
 			final HighAvailabilityServices highAvailabilityServices,
 			final HeartbeatServices heartbeatServices,
-			final MetricRegistry metricRegistry) throws Exception {
+			final MetricRegistry metricRegistry,
+			final ClusterInformation clusterInformation) throws Exception {
 
 		Preconditions.checkNotNull(resourceId);
 		Preconditions.checkNotNull(configuration);
@@ -83,6 +85,7 @@ public class ResourceManagerRunner implements FatalErrorHandler {
 			resourceManagerRuntimeServices.getSlotManager(),
 			metricRegistry,
 			resourceManagerRuntimeServices.getJobLeaderIdService(),
+			clusterInformation,
 			this);
 	}
 

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/StandaloneResourceManager.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/StandaloneResourceManager.java b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/StandaloneResourceManager.java
index 886a046..7226d29 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/StandaloneResourceManager.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/StandaloneResourceManager.java
@@ -21,6 +21,7 @@ package org.apache.flink.runtime.resourcemanager;
 import org.apache.flink.runtime.clusterframework.ApplicationStatus;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
 import org.apache.flink.runtime.metrics.MetricRegistry;
@@ -49,6 +50,7 @@ public class StandaloneResourceManager extends ResourceManager<ResourceID> {
 			SlotManager slotManager,
 			MetricRegistry metricRegistry,
 			JobLeaderIdService jobLeaderIdService,
+			ClusterInformation clusterInformation,
 			FatalErrorHandler fatalErrorHandler) {
 		super(
 			rpcService,
@@ -60,6 +62,7 @@ public class StandaloneResourceManager extends ResourceManager<ResourceID> {
 			slotManager,
 			metricRegistry,
 			jobLeaderIdService,
+			clusterInformation,
 			fatalErrorHandler);
 	}
 

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/TaskManagerLogHandler.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/TaskManagerLogHandler.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/TaskManagerLogHandler.java
index e4ad461..ed06d3d 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/TaskManagerLogHandler.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/TaskManagerLogHandler.java
@@ -154,7 +154,7 @@ public class TaskManagerLogHandler extends RedirectHandler<JobManagerGateway> im
 			cache = blobPortFuture.thenApplyAsync(
 				(Integer port) -> {
 					try {
-						return new TransientBlobCache(new InetSocketAddress(jobManagerGateway.getHostname(), port), config);
+						return new TransientBlobCache(config, new InetSocketAddress(jobManagerGateway.getHostname(), port));
 					} catch (IOException e) {
 						throw new CompletionException(new FlinkException("Could not create TransientBlobCache.", e));
 					}

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/JobManagerConnection.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/JobManagerConnection.java b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/JobManagerConnection.java
index 7e92285..943901f 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/JobManagerConnection.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/JobManagerConnection.java
@@ -19,7 +19,6 @@
 package org.apache.flink.runtime.taskexecutor;
 
 import org.apache.flink.api.common.JobID;
-import org.apache.flink.runtime.blob.BlobCacheService;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.execution.librarycache.LibraryCacheManager;
 import org.apache.flink.runtime.io.network.netty.PartitionProducerStateChecker;
@@ -50,9 +49,6 @@ public class JobManagerConnection {
 	// Checkpoint responder for the specific job manager
 	private final CheckpointResponder checkpointResponder;
 
-	// BLOB cache connected to the BLOB server at the specific job manager
-	private final BlobCacheService blobService;
-
 	// Library cache manager connected to the specific job manager
 	private final LibraryCacheManager libraryCacheManager;
 
@@ -68,7 +64,7 @@ public class JobManagerConnection {
 				JobMasterGateway jobMasterGateway,
 				TaskManagerActions taskManagerActions,
 				CheckpointResponder checkpointResponder,
-				BlobCacheService blobService, LibraryCacheManager libraryCacheManager,
+				LibraryCacheManager libraryCacheManager,
 				ResultPartitionConsumableNotifier resultPartitionConsumableNotifier,
 				PartitionProducerStateChecker partitionStateChecker) {
 		this.jobID = Preconditions.checkNotNull(jobID);
@@ -76,7 +72,6 @@ public class JobManagerConnection {
 		this.jobMasterGateway = Preconditions.checkNotNull(jobMasterGateway);
 		this.taskManagerActions = Preconditions.checkNotNull(taskManagerActions);
 		this.checkpointResponder = Preconditions.checkNotNull(checkpointResponder);
-		this.blobService = Preconditions.checkNotNull(blobService);
 		this.libraryCacheManager = Preconditions.checkNotNull(libraryCacheManager);
 		this.resultPartitionConsumableNotifier = Preconditions.checkNotNull(resultPartitionConsumableNotifier);
 		this.partitionStateChecker = Preconditions.checkNotNull(partitionStateChecker);
@@ -110,15 +105,6 @@ public class JobManagerConnection {
 		return libraryCacheManager;
 	}
 
-	/**
-	 * Gets the BLOB cache connected to the respective BLOB server instance at the job manager.
-	 *
-	 * @return BLOB cache
-	 */
-	public BlobCacheService getBlobService() {
-		return blobService;
-	}
-
 	public ResultPartitionConsumableNotifier getResultPartitionConsumableNotifier() {
 		return resultPartitionConsumableNotifier;
 	}

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
index 6534c11..0e35f1e 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
@@ -31,6 +31,7 @@ import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.clusterframework.types.SlotID;
 import org.apache.flink.runtime.concurrent.FutureUtils;
 import org.apache.flink.runtime.deployment.TaskDeploymentDescriptor;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.execution.librarycache.BlobLibraryCacheManager;
 import org.apache.flink.runtime.execution.librarycache.LibraryCacheManager;
 import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
@@ -124,9 +125,6 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 	/** The connection information of this task manager. */
 	private final TaskManagerLocation taskManagerLocation;
 
-	/** Max blob port which is accepted. */
-	public static final int MAX_BLOB_PORT = 65536;
-
 	/** The access to the leader election and retrieval services. */
 	private final HighAvailabilityServices haServices;
 
@@ -160,6 +158,8 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 
 	private final FileCache fileCache;
 
+	private final BlobCacheService blobCacheService;
+
 	// --------- resource manager --------
 
 	private TaskExecutorToResourceManagerConnection resourceManagerConnection;
@@ -193,6 +193,7 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 			TaskManagerMetricGroup taskManagerMetricGroup,
 			BroadcastVariableManager broadcastVariableManager,
 			FileCache fileCache,
+			BlobCacheService blobCacheService,
 			TaskSlotTable taskSlotTable,
 			JobManagerTable jobManagerTable,
 			JobLeaderService jobLeaderService,
@@ -214,6 +215,7 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 		this.taskManagerMetricGroup = checkNotNull(taskManagerMetricGroup);
 		this.broadcastVariableManager = checkNotNull(broadcastVariableManager);
 		this.fileCache = checkNotNull(fileCache);
+		this.blobCacheService = checkNotNull(blobCacheService);
 		this.jobManagerTable = checkNotNull(jobManagerTable);
 		this.jobLeaderService = checkNotNull(jobLeaderService);
 
@@ -347,9 +349,8 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 			}
 
 			// re-integrate offloaded data:
-			BlobCacheService blobCache = jobManagerConnection.getBlobService();
 			try {
-				tdd.loadBigData(blobCache.getPermanentBlobService());
+				tdd.loadBigData(blobCacheService.getPermanentBlobService());
 			} catch (IOException | ClassNotFoundException e) {
 				throw new TaskSubmissionException("Could not re-integrate offloaded TaskDeploymentDescriptor data.", e);
 			}
@@ -388,7 +389,6 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 			TaskManagerActions taskManagerActions = jobManagerConnection.getTaskManagerActions();
 			CheckpointResponder checkpointResponder = jobManagerConnection.getCheckpointResponder();
 
-			BlobCacheService blobService = jobManagerConnection.getBlobService();
 			LibraryCacheManager libraryCache = jobManagerConnection.getLibraryCacheManager();
 			ResultPartitionConsumableNotifier resultPartitionConsumableNotifier = jobManagerConnection.getResultPartitionConsumableNotifier();
 			PartitionProducerStateChecker partitionStateChecker = jobManagerConnection.getPartitionStateChecker();
@@ -425,7 +425,7 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 				taskManagerActions,
 				inputSplitProvider,
 				checkpointResponder,
-				blobService,
+				blobCacheService,
 				libraryCache,
 				fileCache,
 				taskManagerConfiguration,
@@ -769,7 +769,9 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 		}
 	}
 
-	private void establishResourceManagerConnection(ResourceID resourceManagerResourceId) {
+	private void establishResourceManagerConnection(
+			ResourceID resourceManagerResourceId,
+			ClusterInformation clusterInformation) {
 		// monitor the resource manager as heartbeat target
 		resourceManagerHeartbeatManager.monitorTarget(resourceManagerResourceId, new HeartbeatTarget<SlotReport>() {
 			@Override
@@ -783,6 +785,13 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 				// the TaskManager won't send heartbeat requests to the ResourceManager
 			}
 		});
+
+		// set the propagated blob server address
+		final InetSocketAddress blobServerAddress = new InetSocketAddress(
+			clusterInformation.getBlobServerHostname(),
+			clusterInformation.getBlobServerPort());
+
+		blobCacheService.setBlobServerAddress(blobServerAddress);
 	}
 
 	private void closeResourceManagerConnection(Exception cause) {
@@ -909,8 +918,7 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 		JobManagerConnection newJobManagerConnection = associateWithJobManager(
 				jobId,
 				jobManagerResourceID,
-				jobMasterGateway,
-				registrationSuccess.getBlobPort());
+				jobMasterGateway);
 		jobManagerConnections.put(jobManagerResourceID, newJobManagerConnection);
 		jobManagerTable.put(jobId, newJobManagerConnection);
 
@@ -979,38 +987,19 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 	private JobManagerConnection associateWithJobManager(
 			JobID jobID,
 			ResourceID resourceID,
-			JobMasterGateway jobMasterGateway,
-			int blobPort) {
+			JobMasterGateway jobMasterGateway) {
 		checkNotNull(jobID);
 		checkNotNull(resourceID);
 		checkNotNull(jobMasterGateway);
-		checkArgument(blobPort > 0 && blobPort < MAX_BLOB_PORT, "Blob server port is out of range.");
 
 		TaskManagerActions taskManagerActions = new TaskManagerActionsImpl(jobMasterGateway);
 
 		CheckpointResponder checkpointResponder = new RpcCheckpointResponder(jobMasterGateway);
 
-		InetSocketAddress blobServerAddress = new InetSocketAddress(jobMasterGateway.getHostname(), blobPort);
-
-		final LibraryCacheManager libraryCacheManager;
-		final BlobCacheService blobService;
-		try {
-			blobService = new BlobCacheService(
-				blobServerAddress,
-				taskManagerConfiguration.getConfiguration(),
-				haServices.createBlobStore());
-			libraryCacheManager = new BlobLibraryCacheManager(
-				blobService.getPermanentBlobService(),
-				taskManagerConfiguration.getClassLoaderResolveOrder(),
-				taskManagerConfiguration.getAlwaysParentFirstLoaderPatterns());
-		} catch (IOException e) {
-			// Can't pass the IOException up - we need a RuntimeException anyway
-			// two levels up where this is run asynchronously. Also, we don't
-			// know whether this is caught in the thread running this method.
-			final String message = "Could not create BLOB cache or library cache.";
-			log.error(message, e);
-			throw new RuntimeException(message, e);
-		}
+		final LibraryCacheManager libraryCacheManager = new BlobLibraryCacheManager(
+			blobCacheService.getPermanentBlobService(),
+			taskManagerConfiguration.getClassLoaderResolveOrder(),
+			taskManagerConfiguration.getAlwaysParentFirstLoaderPatterns());
 
 		ResultPartitionConsumableNotifier resultPartitionConsumableNotifier = new RpcResultPartitionConsumableNotifier(
 			jobMasterGateway,
@@ -1027,7 +1016,6 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 			jobMasterGateway,
 			taskManagerActions,
 			checkpointResponder,
-			blobService,
 			libraryCacheManager,
 			resultPartitionConsumableNotifier,
 			partitionStateChecker);
@@ -1051,7 +1039,6 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 		JobMasterGateway jobManagerGateway = jobManagerConnection.getJobManagerGateway();
 		jobManagerGateway.disconnectTaskManager(getResourceID(), cause);
 		jobManagerConnection.getLibraryCacheManager().shutdown();
-		jobManagerConnection.getBlobService().close();
 	}
 
 	private void registerQueryableState(JobID jobId, JobMasterGateway jobMasterGateway) {
@@ -1308,7 +1295,7 @@ public class TaskExecutor extends RpcEndpoint implements TaskExecutorGateway {
 			final ResourceID resourceManagerId = success.getResourceManagerId();
 
 			runAsync(
-				() -> establishResourceManagerConnection(resourceManagerId)
+				() -> establishResourceManagerConnection(resourceManagerId, success.getClusterInformation())
 			);
 		}
 

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutorRegistrationSuccess.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutorRegistrationSuccess.java b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutorRegistrationSuccess.java
index 4b61f68..dc8d599 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutorRegistrationSuccess.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutorRegistrationSuccess.java
@@ -19,8 +19,10 @@
 package org.apache.flink.runtime.taskexecutor;
 
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.entrypoint.ClusterInformation;
 import org.apache.flink.runtime.instance.InstanceID;
 import org.apache.flink.runtime.registration.RegistrationResponse;
+import org.apache.flink.util.Preconditions;
 
 import java.io.Serializable;
 
@@ -38,17 +40,25 @@ public final class TaskExecutorRegistrationSuccess extends RegistrationResponse.
 
 	private final long heartbeatInterval;
 
+	private final ClusterInformation clusterInformation;
+
 	/**
 	 * Create a new {@code TaskExecutorRegistrationSuccess} message.
 	 * 
-	 * @param registrationId     The ID that the ResourceManager assigned the registration.
+	 * @param registrationId The ID that the ResourceManager assigned the registration.
 	 * @param resourceManagerResourceId The unique ID that identifies the ResourceManager.
-	 * @param heartbeatInterval  The interval in which the ResourceManager will heartbeat the TaskExecutor.
+	 * @param heartbeatInterval The interval in which the ResourceManager will heartbeat the TaskExecutor.
+	 * @param clusterInformation information about the cluster
 	 */
-	public TaskExecutorRegistrationSuccess(InstanceID registrationId, ResourceID resourceManagerResourceId, long heartbeatInterval) {
-		this.registrationId = registrationId;
-		this.resourceManagerResourceId = resourceManagerResourceId;
+	public TaskExecutorRegistrationSuccess(
+			InstanceID registrationId,
+			ResourceID resourceManagerResourceId,
+			long heartbeatInterval,
+			ClusterInformation clusterInformation) {
+		this.registrationId = Preconditions.checkNotNull(registrationId);
+		this.resourceManagerResourceId = Preconditions.checkNotNull(resourceManagerResourceId);
 		this.heartbeatInterval = heartbeatInterval;
+		this.clusterInformation = Preconditions.checkNotNull(clusterInformation);
 	}
 
 	/**
@@ -72,6 +82,13 @@ public final class TaskExecutorRegistrationSuccess extends RegistrationResponse.
 		return heartbeatInterval;
 	}
 
+	/**
+	 * Gets the cluster information.
+	 */
+	public ClusterInformation getClusterInformation() {
+		return clusterInformation;
+	}
+
 	@Override
 	public String toString() {
 		return "TaskExecutorRegistrationSuccess (" + registrationId + " / " + resourceManagerResourceId + " / " + heartbeatInterval + ')';

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java
index d089107..333ce12 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java
@@ -24,6 +24,7 @@ import org.apache.flink.configuration.ConfigConstants;
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.configuration.GlobalConfiguration;
 import org.apache.flink.runtime.akka.AkkaUtils;
+import org.apache.flink.runtime.blob.BlobCacheService;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.heartbeat.HeartbeatServices;
 import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
@@ -88,6 +89,8 @@ public class TaskManagerRunner implements FatalErrorHandler {
 
 	private final MetricRegistryImpl metricRegistry;
 
+	private final BlobCacheService blobCacheService;
+
 	/** Executor used to run future callbacks. */
 	private final ExecutorService executor;
 
@@ -118,6 +121,10 @@ public class TaskManagerRunner implements FatalErrorHandler {
 		final ActorSystem actorSystem = ((AkkaRpcService) rpcService).getActorSystem();
 		metricRegistry.startQueryService(actorSystem, resourceId);
 
+		blobCacheService = new BlobCacheService(
+			configuration, highAvailabilityServices.createBlobStore(), null
+		);
+
 		taskManager = startTaskManager(
 			this.configuration,
 			this.resourceId,
@@ -125,6 +132,7 @@ public class TaskManagerRunner implements FatalErrorHandler {
 			highAvailabilityServices,
 			heartbeatServices,
 			metricRegistry,
+			blobCacheService,
 			false,
 			this);
 	}
@@ -144,7 +152,7 @@ public class TaskManagerRunner implements FatalErrorHandler {
 	protected void shutDownInternally() throws Exception {
 		Exception exception = null;
 
-		synchronized(lock) {
+		synchronized (lock) {
 			try {
 				taskManager.shutDown();
 			} catch (Exception e) {
@@ -152,6 +160,12 @@ public class TaskManagerRunner implements FatalErrorHandler {
 			}
 
 			try {
+				blobCacheService.close();
+			} catch (Exception e) {
+				exception = ExceptionUtils.firstOrSuppressed(e, exception);
+			}
+
+			try {
 				metricRegistry.shutdown();
 			} catch (Exception e) {
 				exception = ExceptionUtils.firstOrSuppressed(e, exception);
@@ -252,6 +266,7 @@ public class TaskManagerRunner implements FatalErrorHandler {
 			HighAvailabilityServices highAvailabilityServices,
 			HeartbeatServices heartbeatServices,
 			MetricRegistry metricRegistry,
+			BlobCacheService blobCacheService,
 			boolean localCommunicationOnly,
 			FatalErrorHandler fatalErrorHandler) throws Exception {
 
@@ -292,6 +307,7 @@ public class TaskManagerRunner implements FatalErrorHandler {
 			taskManagerMetricGroup,
 			taskManagerServices.getBroadcastVariableManager(),
 			taskManagerServices.getFileCache(),
+			blobCacheService,
 			taskManagerServices.getTaskSlotTable(),
 			taskManagerServices.getJobManagerTable(),
 			taskManagerServices.getJobLeaderService(),

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/main/scala/org/apache/flink/runtime/taskmanager/TaskManager.scala
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/scala/org/apache/flink/runtime/taskmanager/TaskManager.scala b/flink-runtime/src/main/scala/org/apache/flink/runtime/taskmanager/TaskManager.scala
index 93d432d..e8b043e 100644
--- a/flink-runtime/src/main/scala/org/apache/flink/runtime/taskmanager/TaskManager.scala
+++ b/flink-runtime/src/main/scala/org/apache/flink/runtime/taskmanager/TaskManager.scala
@@ -968,9 +968,9 @@ class TaskManager(
 
     try {
       val blobcache = new BlobCacheService(
-        address,
         config.getConfiguration(),
-        highAvailabilityServices.createBlobStore())
+        highAvailabilityServices.createBlobStore(),
+        address)
       blobCache = Option(blobcache)
       libraryCacheManager = Some(
         new BlobLibraryCacheManager(

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheCleanupTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheCleanupTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheCleanupTest.java
index 5ec9b89..93371f7 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheCleanupTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheCleanupTest.java
@@ -91,7 +91,7 @@ public class BlobCacheCleanupTest extends TestLogger {
 			server = new BlobServer(config, new VoidBlobStore());
 			server.start();
 			InetSocketAddress serverAddress = new InetSocketAddress("localhost", server.getPort());
-			cache = new PermanentBlobCache(serverAddress, config, new VoidBlobStore());
+			cache = new PermanentBlobCache(config, new VoidBlobStore(), serverAddress);
 
 			// upload blobs
 			keys.add(server.putPermanent(jobId, buf));
@@ -164,7 +164,7 @@ public class BlobCacheCleanupTest extends TestLogger {
 		// NOTE: use fake address - we will not connect to it here
 		InetSocketAddress serverAddress = new InetSocketAddress("localhost", 12345);
 
-		try (PermanentBlobCache cache = new PermanentBlobCache(serverAddress, config, new VoidBlobStore())) {
+		try (PermanentBlobCache cache = new PermanentBlobCache(config, new VoidBlobStore(), serverAddress)) {
 
 			// register once
 			cache.registerJob(jobId);
@@ -231,7 +231,7 @@ public class BlobCacheCleanupTest extends TestLogger {
 			server = new BlobServer(config, new VoidBlobStore());
 			server.start();
 			InetSocketAddress serverAddress = new InetSocketAddress("localhost", server.getPort());
-			cache = new PermanentBlobCache(serverAddress, config, new VoidBlobStore());
+			cache = new PermanentBlobCache(config, new VoidBlobStore(), serverAddress);
 
 			// upload blobs
 			keys.add(server.putPermanent(jobId, buf));
@@ -339,8 +339,8 @@ public class BlobCacheCleanupTest extends TestLogger {
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
 			final BlobCacheService cache = new BlobCacheService(
-				new InetSocketAddress("localhost", server.getPort()), config,
-				new VoidBlobStore())) {
+				config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 			ConcurrentMap<Tuple2<JobID, TransientBlobKey>, Long> transientBlobExpiryTimes =
 				cache.getTransientBlobService().getBlobExpiryTimes();
 

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheCorruptionTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheCorruptionTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheCorruptionTest.java
index a0e46ba..4d8727c 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheCorruptionTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheCorruptionTest.java
@@ -173,8 +173,8 @@ public class BlobCacheCorruptionTest extends TestLogger {
 
 		try (
 			BlobServer server = new BlobServer(config, blobStore);
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, corruptOnHAStore ? blobStore : new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, corruptOnHAStore ? blobStore : new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheDeleteTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheDeleteTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheDeleteTest.java
index 16ba020..42f88fb 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheDeleteTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheDeleteTest.java
@@ -109,8 +109,8 @@ public class BlobCacheDeleteTest extends TestLogger {
 
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -187,8 +187,8 @@ public class BlobCacheDeleteTest extends TestLogger {
 
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -241,8 +241,8 @@ public class BlobCacheDeleteTest extends TestLogger {
 		File directory = null;
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -319,8 +319,8 @@ public class BlobCacheDeleteTest extends TestLogger {
 
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheGetTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheGetTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheGetTest.java
index 6e05aa0..cb493d7 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheGetTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheGetTest.java
@@ -130,8 +130,8 @@ public class BlobCacheGetTest extends TestLogger {
 
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -221,8 +221,8 @@ public class BlobCacheGetTest extends TestLogger {
 		File tempFileDir = null;
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -323,8 +323,8 @@ public class BlobCacheGetTest extends TestLogger {
 		File jobStoreDir = null;
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -391,8 +391,8 @@ public class BlobCacheGetTest extends TestLogger {
 
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -457,8 +457,8 @@ public class BlobCacheGetTest extends TestLogger {
 
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -552,8 +552,8 @@ public class BlobCacheGetTest extends TestLogger {
 
 		try (
 			final BlobServer server = new BlobServer(config, blobStoreServer);
-			final BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, cacheAccessesHAStore ? blobStoreServer : blobStoreCache)) {
+			final BlobCacheService cache = new BlobCacheService(config, cacheAccessesHAStore ? blobStoreServer : blobStoreCache, new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCachePutTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCachePutTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCachePutTest.java
index 264c7cb..c9bd442 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCachePutTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCachePutTest.java
@@ -156,7 +156,7 @@ public class BlobCachePutTest extends TestLogger {
 
 		try (BlobServer server = new BlobServer(config, new VoidBlobStore());
 			final TransientBlobCache cache = new TransientBlobCache(
-				new InetSocketAddress("localhost", server.getPort()), config)) {
+				config, new InetSocketAddress("localhost", server.getPort()))) {
 
 			server.start();
 
@@ -181,8 +181,8 @@ public class BlobCachePutTest extends TestLogger {
 
 		try (BlobServer server = new BlobServer(config, new VoidBlobStore());
 			final PermanentBlobCache cache = new PermanentBlobCache(
-				new InetSocketAddress("localhost", server.getPort()), config,
-				new VoidBlobStore())) {
+				config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -263,8 +263,8 @@ public class BlobCachePutTest extends TestLogger {
 
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -379,8 +379,8 @@ public class BlobCachePutTest extends TestLogger {
 
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -489,8 +489,8 @@ public class BlobCachePutTest extends TestLogger {
 
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -590,8 +590,8 @@ public class BlobCachePutTest extends TestLogger {
 		File tempFileDir = null;
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -653,8 +653,8 @@ public class BlobCachePutTest extends TestLogger {
 		File tempFileDir = null;
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -721,8 +721,8 @@ public class BlobCachePutTest extends TestLogger {
 		File jobStoreDir = null;
 		try (
 			BlobServer server = new BlobServer(config, new VoidBlobStore());
-			BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, new VoidBlobStore())) {
+			BlobCacheService cache = new BlobCacheService(config, new VoidBlobStore(), new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 
@@ -815,8 +815,8 @@ public class BlobCachePutTest extends TestLogger {
 
 		try (
 			final BlobServer server = new BlobServer(config, blobStoreServer);
-			final BlobCacheService cache = new BlobCacheService(new InetSocketAddress("localhost", server.getPort()),
-				config, blobStoreCache)) {
+			final BlobCacheService cache = new BlobCacheService(config, blobStoreCache, new InetSocketAddress("localhost", server.getPort())
+			)) {
 
 			server.start();
 

http://git-wip-us.apache.org/repos/asf/flink/blob/22bf3861/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheRecoveryTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheRecoveryTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheRecoveryTest.java
index e275949..13f94d8 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheRecoveryTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/BlobCacheRecoveryTest.java
@@ -105,11 +105,11 @@ public class BlobCacheRecoveryTest extends TestLogger {
 			BlobServer server1 = new BlobServer(config, blobStore);
 			// use VoidBlobStore as the HA store to force download from each server's HA store
 			BlobCacheService cache0 = new BlobCacheService(
-				new InetSocketAddress("localhost", server0.getPort()), config,
-				new VoidBlobStore());
+				config, new VoidBlobStore(), new InetSocketAddress("localhost", server0.getPort())
+			);
 			BlobCacheService cache1 = new BlobCacheService(
-				new InetSocketAddress("localhost", server1.getPort()), config,
-				new VoidBlobStore())) {
+				config, new VoidBlobStore(), new InetSocketAddress("localhost", server1.getPort())
+			)) {
 
 			server0.start();
 			server1.start();


[07/11] flink git commit: [hotfix] Return NOT_FOUND in TaskManagerDetailsHandler if TaskExecutor unknown

Posted by tr...@apache.org.
[hotfix] Return NOT_FOUND in TaskManagerDetailsHandler  if TaskExecutor unknown


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/d306cc7b
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/d306cc7b
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/d306cc7b

Branch: refs/heads/master
Commit: d306cc7b3a970f3db82f562a2287f1358f73b703
Parents: 5f57380
Author: Till Rohrmann <tr...@apache.org>
Authored: Tue Feb 6 10:52:40 2018 +0100
Committer: Till Rohrmann <tr...@apache.org>
Committed: Tue Feb 6 13:34:22 2018 +0100

----------------------------------------------------------------------
 .../taskmanager/TaskManagerDetailsHandler.java  | 22 +++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/d306cc7b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerDetailsHandler.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerDetailsHandler.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerDetailsHandler.java
index 9429a65..f2ded8e 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerDetailsHandler.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerDetailsHandler.java
@@ -21,6 +21,7 @@ package org.apache.flink.runtime.rest.handler.taskmanager;
 import org.apache.flink.api.common.time.Time;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
+import org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException;
 import org.apache.flink.runtime.rest.handler.HandlerRequest;
 import org.apache.flink.runtime.rest.handler.RestHandlerException;
 import org.apache.flink.runtime.rest.handler.legacy.metrics.MetricFetcher;
@@ -34,14 +35,18 @@ import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMessagePara
 import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMetricsInfo;
 import org.apache.flink.runtime.webmonitor.RestfulGateway;
 import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever;
+import org.apache.flink.util.ExceptionUtils;
 import org.apache.flink.util.Preconditions;
 
+import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus;
+
 import javax.annotation.Nonnull;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
 
 /**
  * Handler which serves detailed TaskManager information.
@@ -94,7 +99,22 @@ public class TaskManagerDetailsHandler extends AbstractTaskManagerHandler<Restfu
 				return new TaskManagerDetailsInfo(
 					taskManagerInfo,
 					taskManagerMetricsInfo);
-			});
+			})
+			.exceptionally(
+				(Throwable throwable) -> {
+					final Throwable strippedThrowable = ExceptionUtils.stripExecutionException(throwable);
+
+					if (strippedThrowable instanceof UnknownTaskExecutorException) {
+						throw new CompletionException(
+							new RestHandlerException(
+								"Could not find TaskExecutor " + taskManagerResourceId + '.',
+								HttpResponseStatus.NOT_FOUND,
+								strippedThrowable));
+					} else {
+						throw new CompletionException(strippedThrowable);
+					}
+				}
+			);
 	}
 
 	private static TaskManagerMetricsInfo createTaskManagerMetricsInfo(MetricStore.TaskManagerMetricStore tmMetrics) {