Skip to content

Commit

Permalink
[FLINK-7531] Move Flink legacy rest handler to flink-runtime
Browse files Browse the repository at this point in the history
Move metrics handlers under o.a.f.runtime.webmonitor.handlers

Move StaticFileServerHandler under o.a.f.runtime.webmonitor.files

This closes #4600.
  • Loading branch information
tillrohrmann committed Sep 19, 2017
1 parent 3277010 commit 4fc019a
Show file tree
Hide file tree
Showing 117 changed files with 363 additions and 402 deletions.
Expand Up @@ -21,9 +21,11 @@
import org.apache.flink.api.common.time.Time;
import org.apache.flink.runtime.concurrent.FutureUtils;
import org.apache.flink.runtime.jobmaster.JobManagerGateway;
import org.apache.flink.runtime.rest.NotFoundException;
import org.apache.flink.runtime.rest.handler.RedirectHandler;
import org.apache.flink.runtime.rest.handler.WebHandler;
import org.apache.flink.runtime.rest.handler.legacy.RequestHandler;
import org.apache.flink.runtime.rest.handler.util.HandlerRedirectUtils;
import org.apache.flink.runtime.webmonitor.handlers.RequestHandler;
import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever;
import org.apache.flink.util.ExceptionUtils;

Expand Down
Expand Up @@ -27,50 +27,54 @@
import org.apache.flink.runtime.jobmaster.JobManagerGateway;
import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService;
import org.apache.flink.runtime.net.SSLUtils;
import org.apache.flink.runtime.webmonitor.files.StaticFileServerHandler;
import org.apache.flink.runtime.webmonitor.handlers.ClusterOverviewHandler;
import org.apache.flink.runtime.webmonitor.handlers.ConstantTextHandler;
import org.apache.flink.runtime.webmonitor.handlers.CurrentJobIdsHandler;
import org.apache.flink.runtime.webmonitor.handlers.CurrentJobsOverviewHandler;
import org.apache.flink.runtime.webmonitor.handlers.DashboardConfigHandler;
import org.apache.flink.runtime.rest.handler.WebHandler;
import org.apache.flink.runtime.rest.handler.legacy.ClusterOverviewHandler;
import org.apache.flink.runtime.rest.handler.legacy.ConstantTextHandler;
import org.apache.flink.runtime.rest.handler.legacy.CurrentJobIdsHandler;
import org.apache.flink.runtime.rest.handler.legacy.CurrentJobsOverviewHandler;
import org.apache.flink.runtime.rest.handler.legacy.DashboardConfigHandler;
import org.apache.flink.runtime.rest.handler.legacy.ExecutionGraphHolder;
import org.apache.flink.runtime.rest.handler.legacy.JobAccumulatorsHandler;
import org.apache.flink.runtime.rest.handler.legacy.JobCancellationHandler;
import org.apache.flink.runtime.rest.handler.legacy.JobCancellationWithSavepointHandlers;
import org.apache.flink.runtime.rest.handler.legacy.JobConfigHandler;
import org.apache.flink.runtime.rest.handler.legacy.JobDetailsHandler;
import org.apache.flink.runtime.rest.handler.legacy.JobExceptionsHandler;
import org.apache.flink.runtime.rest.handler.legacy.JobManagerConfigHandler;
import org.apache.flink.runtime.rest.handler.legacy.JobPlanHandler;
import org.apache.flink.runtime.rest.handler.legacy.JobStoppingHandler;
import org.apache.flink.runtime.rest.handler.legacy.JobVertexAccumulatorsHandler;
import org.apache.flink.runtime.rest.handler.legacy.JobVertexBackPressureHandler;
import org.apache.flink.runtime.rest.handler.legacy.JobVertexDetailsHandler;
import org.apache.flink.runtime.rest.handler.legacy.JobVertexTaskManagersHandler;
import org.apache.flink.runtime.rest.handler.legacy.RequestHandler;
import org.apache.flink.runtime.rest.handler.legacy.SubtaskCurrentAttemptDetailsHandler;
import org.apache.flink.runtime.rest.handler.legacy.SubtaskExecutionAttemptAccumulatorsHandler;
import org.apache.flink.runtime.rest.handler.legacy.SubtaskExecutionAttemptDetailsHandler;
import org.apache.flink.runtime.rest.handler.legacy.SubtasksAllAccumulatorsHandler;
import org.apache.flink.runtime.rest.handler.legacy.SubtasksTimesHandler;
import org.apache.flink.runtime.rest.handler.legacy.TaskManagerLogHandler;
import org.apache.flink.runtime.rest.handler.legacy.TaskManagersHandler;
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.rest.handler.legacy.checkpoints.CheckpointConfigHandler;
import org.apache.flink.runtime.rest.handler.legacy.checkpoints.CheckpointStatsCache;
import org.apache.flink.runtime.rest.handler.legacy.checkpoints.CheckpointStatsDetailsHandler;
import org.apache.flink.runtime.rest.handler.legacy.checkpoints.CheckpointStatsDetailsSubtasksHandler;
import org.apache.flink.runtime.rest.handler.legacy.checkpoints.CheckpointStatsHandler;
import org.apache.flink.runtime.rest.handler.legacy.files.StaticFileServerHandler;
import org.apache.flink.runtime.rest.handler.legacy.metrics.JobManagerMetricsHandler;
import org.apache.flink.runtime.rest.handler.legacy.metrics.JobMetricsHandler;
import org.apache.flink.runtime.rest.handler.legacy.metrics.JobVertexMetricsHandler;
import org.apache.flink.runtime.rest.handler.legacy.metrics.MetricFetcher;
import org.apache.flink.runtime.rest.handler.legacy.metrics.TaskManagerMetricsHandler;
import org.apache.flink.runtime.webmonitor.handlers.JarAccessDeniedHandler;
import org.apache.flink.runtime.webmonitor.handlers.JarDeleteHandler;
import org.apache.flink.runtime.webmonitor.handlers.JarListHandler;
import org.apache.flink.runtime.webmonitor.handlers.JarPlanHandler;
import org.apache.flink.runtime.webmonitor.handlers.JarRunHandler;
import org.apache.flink.runtime.webmonitor.handlers.JarUploadHandler;
import org.apache.flink.runtime.webmonitor.handlers.JobAccumulatorsHandler;
import org.apache.flink.runtime.webmonitor.handlers.JobCancellationHandler;
import org.apache.flink.runtime.webmonitor.handlers.JobCancellationWithSavepointHandlers;
import org.apache.flink.runtime.webmonitor.handlers.JobConfigHandler;
import org.apache.flink.runtime.webmonitor.handlers.JobDetailsHandler;
import org.apache.flink.runtime.webmonitor.handlers.JobExceptionsHandler;
import org.apache.flink.runtime.webmonitor.handlers.JobManagerConfigHandler;
import org.apache.flink.runtime.webmonitor.handlers.JobPlanHandler;
import org.apache.flink.runtime.webmonitor.handlers.JobStoppingHandler;
import org.apache.flink.runtime.webmonitor.handlers.JobVertexAccumulatorsHandler;
import org.apache.flink.runtime.webmonitor.handlers.JobVertexBackPressureHandler;
import org.apache.flink.runtime.webmonitor.handlers.JobVertexDetailsHandler;
import org.apache.flink.runtime.webmonitor.handlers.JobVertexTaskManagersHandler;
import org.apache.flink.runtime.webmonitor.handlers.RequestHandler;
import org.apache.flink.runtime.webmonitor.handlers.SubtaskCurrentAttemptDetailsHandler;
import org.apache.flink.runtime.webmonitor.handlers.SubtaskExecutionAttemptAccumulatorsHandler;
import org.apache.flink.runtime.webmonitor.handlers.SubtaskExecutionAttemptDetailsHandler;
import org.apache.flink.runtime.webmonitor.handlers.SubtasksAllAccumulatorsHandler;
import org.apache.flink.runtime.webmonitor.handlers.SubtasksTimesHandler;
import org.apache.flink.runtime.webmonitor.handlers.TaskManagerLogHandler;
import org.apache.flink.runtime.webmonitor.handlers.TaskManagersHandler;
import org.apache.flink.runtime.webmonitor.handlers.checkpoints.CheckpointConfigHandler;
import org.apache.flink.runtime.webmonitor.handlers.checkpoints.CheckpointStatsCache;
import org.apache.flink.runtime.webmonitor.handlers.checkpoints.CheckpointStatsDetailsHandler;
import org.apache.flink.runtime.webmonitor.handlers.checkpoints.CheckpointStatsDetailsSubtasksHandler;
import org.apache.flink.runtime.webmonitor.handlers.checkpoints.CheckpointStatsHandler;
import org.apache.flink.runtime.webmonitor.history.JsonArchivist;
import org.apache.flink.runtime.webmonitor.metrics.JobManagerMetricsHandler;
import org.apache.flink.runtime.webmonitor.metrics.JobMetricsHandler;
import org.apache.flink.runtime.webmonitor.metrics.JobVertexMetricsHandler;
import org.apache.flink.runtime.webmonitor.metrics.MetricFetcher;
import org.apache.flink.runtime.webmonitor.metrics.TaskManagerMetricsHandler;
import org.apache.flink.runtime.webmonitor.retriever.LeaderGatewayRetriever;
import org.apache.flink.runtime.webmonitor.retriever.MetricQueryServiceRetriever;
import org.apache.flink.runtime.webmonitor.utils.WebFrontendBootstrap;
Expand Down Expand Up @@ -189,7 +193,7 @@ public WebRuntimeMonitor(
this.uploadDir = null;
}

ExecutionGraphHolder currentGraphs = new ExecutionGraphHolder();
ExecutionGraphHolder currentGraphs = new ExecutionGraphHolder(timeout);

// - Back pressure stats ----------------------------------------------

Expand Down Expand Up @@ -255,7 +259,7 @@ public WebRuntimeMonitor(
get(router, new SubtasksTimesHandler(currentGraphs, executor));
get(router, new JobVertexTaskManagersHandler(currentGraphs, executor, metricFetcher));
get(router, new JobVertexAccumulatorsHandler(currentGraphs, executor));
get(router, new JobVertexBackPressureHandler(currentGraphs, executor, backPressureStatsTracker, refreshInterval));
get(router, new JobVertexBackPressureHandler(currentGraphs, executor, backPressureStatsTracker, refreshInterval));
get(router, new JobVertexMetricsHandler(executor, metricFetcher));
get(router, new SubtasksAllAccumulatorsHandler(currentGraphs, executor));
get(router, new SubtaskCurrentAttemptDetailsHandler(currentGraphs, executor, metricFetcher));
Expand Down
Expand Up @@ -19,6 +19,7 @@
package org.apache.flink.runtime.webmonitor.handlers;

import org.apache.flink.runtime.jobmaster.JobManagerGateway;
import org.apache.flink.runtime.rest.handler.legacy.AbstractJsonRequestHandler;

import java.util.Map;
import java.util.concurrent.CompletableFuture;
Expand Down
Expand Up @@ -35,6 +35,8 @@
import org.apache.flink.optimizer.plantranslate.JobGraphGenerator;
import org.apache.flink.runtime.jobgraph.JobGraph;
import org.apache.flink.runtime.jobgraph.SavepointRestoreSettings;
import org.apache.flink.runtime.rest.handler.legacy.AbstractJsonRequestHandler;
import org.apache.flink.runtime.rest.handler.legacy.JsonFactory;
import org.apache.flink.util.ExceptionUtils;

import com.fasterxml.jackson.core.JsonGenerator;
Expand Down
Expand Up @@ -20,6 +20,8 @@

import org.apache.flink.runtime.concurrent.FlinkFutureException;
import org.apache.flink.runtime.jobmaster.JobManagerGateway;
import org.apache.flink.runtime.rest.handler.legacy.AbstractJsonRequestHandler;
import org.apache.flink.runtime.rest.handler.legacy.JsonFactory;

import com.fasterxml.jackson.core.JsonGenerator;

Expand Down
Expand Up @@ -21,6 +21,8 @@
import org.apache.flink.client.program.PackagedProgram;
import org.apache.flink.runtime.concurrent.FlinkFutureException;
import org.apache.flink.runtime.jobmaster.JobManagerGateway;
import org.apache.flink.runtime.rest.handler.legacy.AbstractJsonRequestHandler;
import org.apache.flink.runtime.rest.handler.legacy.JsonFactory;
import org.apache.flink.runtime.webmonitor.RuntimeMonitorHandler;

import com.fasterxml.jackson.core.JsonGenerator;
Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.apache.flink.runtime.jobgraph.JobGraph;
import org.apache.flink.runtime.jobgraph.jsonplan.JsonPlanGenerator;
import org.apache.flink.runtime.jobmaster.JobManagerGateway;
import org.apache.flink.runtime.rest.handler.legacy.JsonFactory;

import com.fasterxml.jackson.core.JsonGenerator;

Expand Down
Expand Up @@ -27,6 +27,7 @@
import org.apache.flink.runtime.concurrent.FlinkFutureException;
import org.apache.flink.runtime.jobgraph.JobGraph;
import org.apache.flink.runtime.jobmaster.JobManagerGateway;
import org.apache.flink.runtime.rest.handler.legacy.JsonFactory;
import org.apache.flink.util.Preconditions;

import com.fasterxml.jackson.core.JsonGenerator;
Expand Down
Expand Up @@ -19,6 +19,7 @@
package org.apache.flink.runtime.webmonitor.handlers;

import org.apache.flink.runtime.jobmaster.JobManagerGateway;
import org.apache.flink.runtime.rest.handler.legacy.AbstractJsonRequestHandler;

import java.io.File;
import java.util.Map;
Expand Down
Expand Up @@ -27,9 +27,9 @@
import org.apache.flink.core.fs.Path;
import org.apache.flink.runtime.history.FsJobArchivist;
import org.apache.flink.runtime.net.SSLUtils;
import org.apache.flink.runtime.rest.handler.legacy.DashboardConfigHandler;
import org.apache.flink.runtime.security.SecurityUtils;
import org.apache.flink.runtime.webmonitor.WebMonitorUtils;
import org.apache.flink.runtime.webmonitor.handlers.DashboardConfigHandler;
import org.apache.flink.runtime.webmonitor.utils.WebFrontendBootstrap;
import org.apache.flink.util.FileUtils;
import org.apache.flink.util.FlinkException;
Expand Down
Expand Up @@ -24,8 +24,8 @@
import org.apache.flink.core.fs.FileSystem;
import org.apache.flink.core.fs.Path;
import org.apache.flink.runtime.history.FsJobArchivist;
import org.apache.flink.runtime.rest.handler.legacy.CurrentJobsOverviewHandler;
import org.apache.flink.runtime.util.ExecutorThreadFactory;
import org.apache.flink.runtime.webmonitor.handlers.CurrentJobsOverviewHandler;
import org.apache.flink.util.FileUtils;

import com.fasterxml.jackson.core.JsonFactory;
Expand Down
Expand Up @@ -26,7 +26,7 @@
* https://github.com/netty/netty/blob/4.0/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java
*****************************************************************************/

import org.apache.flink.runtime.webmonitor.files.StaticFileServerHandler;
import org.apache.flink.runtime.rest.handler.legacy.files.StaticFileServerHandler;

import org.apache.flink.shaded.netty4.io.netty.channel.ChannelFuture;
import org.apache.flink.shaded.netty4.io.netty.channel.ChannelFutureListener;
Expand Down
Expand Up @@ -19,15 +19,14 @@
package org.apache.flink.runtime.webmonitor.handlers;

import org.apache.flink.runtime.jobgraph.SavepointRestoreSettings;
import org.apache.flink.runtime.webmonitor.handlers.JarActionHandler.JarActionHandlerConfig;

import org.junit.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

/**
* Tests for the JarActionHandler.
Expand All @@ -49,7 +48,7 @@ public void testSavepointRestoreSettings() throws Exception {
Map<String, String> queryParams = new HashMap<>(); // <-- everything goes here

// Nothing configured
JarActionHandlerConfig config = JarActionHandlerConfig.fromParams(pathParams, queryParams);
JarActionHandler.JarActionHandlerConfig config = JarActionHandler.JarActionHandlerConfig.fromParams(pathParams, queryParams);
assertEquals(SavepointRestoreSettings.none(), config.getSavepointRestoreSettings());

// Set path
Expand All @@ -58,14 +57,14 @@ public void testSavepointRestoreSettings() throws Exception {

SavepointRestoreSettings expected = SavepointRestoreSettings.forPath("the-savepoint-path", false);

config = JarActionHandlerConfig.fromParams(pathParams, queryParams);
config = JarActionHandler.JarActionHandlerConfig.fromParams(pathParams, queryParams);
assertEquals(expected, config.getSavepointRestoreSettings());

// Set flag
queryParams.put("allowNonRestoredState", "true");

expected = SavepointRestoreSettings.forPath("the-savepoint-path", true);
config = JarActionHandlerConfig.fromParams(pathParams, queryParams);
config = JarActionHandler.JarActionHandlerConfig.fromParams(pathParams, queryParams);
assertEquals(expected, config.getSavepointRestoreSettings());
}

Expand All @@ -85,10 +84,10 @@ public void testEmptyStringParams() throws Exception {
queryParams.put("allowNonRestoredState", "");

// Nothing configured
JarActionHandlerConfig config = JarActionHandlerConfig.fromParams(pathParams, queryParams);
JarActionHandler.JarActionHandlerConfig config = JarActionHandler.JarActionHandlerConfig.fromParams(pathParams, queryParams);

assertEquals(0, config.getProgramArgs().length);
assertNull(config.getEntryClass());
Assert.assertNull(config.getEntryClass());
assertEquals(1, config.getParallelism());
assertEquals(SavepointRestoreSettings.none(), config.getSavepointRestoreSettings());
}
Expand Down
Expand Up @@ -21,8 +21,8 @@
import org.apache.flink.core.fs.Path;
import org.apache.flink.runtime.executiongraph.AccessExecutionGraph;
import org.apache.flink.runtime.history.FsJobArchivist;
import org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedJobGenerationUtils;
import org.apache.flink.runtime.webmonitor.WebRuntimeMonitor;
import org.apache.flink.runtime.webmonitor.utils.ArchivedJobGenerationUtils;

import org.junit.Assert;
import org.junit.Rule;
Expand Down
Expand Up @@ -27,7 +27,7 @@
import org.apache.flink.runtime.jobmanager.JobManager;
import org.apache.flink.runtime.jobmanager.MemoryArchivist;
import org.apache.flink.runtime.messages.ArchiveMessages;
import org.apache.flink.runtime.webmonitor.utils.ArchivedJobGenerationUtils;
import org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedJobGenerationUtils;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
Expand Down
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.flink.runtime.webmonitor;
package org.apache.flink.runtime.rest;

/**
* A special exception that indicates that an element was not found and that the
Expand Down
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.flink.runtime.webmonitor;
package org.apache.flink.runtime.rest.handler;

/**
* Marker interface for web handlers which can describe their paths.
Expand Down
Expand Up @@ -16,15 +16,14 @@
* limitations under the License.
*/

package org.apache.flink.runtime.webmonitor.handlers;
package org.apache.flink.runtime.rest.handler.legacy;

import org.apache.flink.api.common.JobID;
import org.apache.flink.runtime.concurrent.FlinkFutureException;
import org.apache.flink.runtime.concurrent.FutureUtils;
import org.apache.flink.runtime.executiongraph.AccessExecutionGraph;
import org.apache.flink.runtime.jobmaster.JobManagerGateway;
import org.apache.flink.runtime.webmonitor.ExecutionGraphHolder;
import org.apache.flink.runtime.webmonitor.NotFoundException;
import org.apache.flink.runtime.rest.NotFoundException;
import org.apache.flink.util.FlinkException;
import org.apache.flink.util.Preconditions;

Expand Down
Expand Up @@ -16,12 +16,11 @@
* limitations under the License.
*/

package org.apache.flink.runtime.webmonitor.handlers;
package org.apache.flink.runtime.rest.handler.legacy;

import org.apache.flink.runtime.executiongraph.AccessExecutionGraph;
import org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex;
import org.apache.flink.runtime.jobgraph.JobVertexID;
import org.apache.flink.runtime.webmonitor.ExecutionGraphHolder;

import java.util.Map;
import java.util.concurrent.CompletableFuture;
Expand Down
Expand Up @@ -16,9 +16,10 @@
* limitations under the License.
*/

package org.apache.flink.runtime.webmonitor.handlers;
package org.apache.flink.runtime.rest.handler.legacy;

import org.apache.flink.runtime.jobmaster.JobManagerGateway;
import org.apache.flink.runtime.rest.NotFoundException;
import org.apache.flink.util.Preconditions;

import org.apache.flink.shaded.netty4.io.netty.buffer.Unpooled;
Expand Down Expand Up @@ -75,7 +76,7 @@ public CompletableFuture<FullHttpResponse> handleRequest(Map<String, String> pat
* @return The JSON string that is the HTTP response.
*
* @throws Exception Handlers may forward exceptions. Exceptions of type
* {@link org.apache.flink.runtime.webmonitor.NotFoundException} will cause a HTTP 404
* {@link NotFoundException} will cause a HTTP 404
* response with the exception message, other exceptions will cause a HTTP 500 response
* with the exception stack trace.
*/
Expand Down
Expand Up @@ -16,12 +16,11 @@
* limitations under the License.
*/

package org.apache.flink.runtime.webmonitor.handlers;
package org.apache.flink.runtime.rest.handler.legacy;

import org.apache.flink.runtime.concurrent.FutureUtils;
import org.apache.flink.runtime.executiongraph.AccessExecution;
import org.apache.flink.runtime.executiongraph.AccessExecutionVertex;
import org.apache.flink.runtime.webmonitor.ExecutionGraphHolder;
import org.apache.flink.util.FlinkException;

import java.util.Map;
Expand Down
Expand Up @@ -16,12 +16,11 @@
* limitations under the License.
*/

package org.apache.flink.runtime.webmonitor.handlers;
package org.apache.flink.runtime.rest.handler.legacy;

import org.apache.flink.runtime.concurrent.FutureUtils;
import org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex;
import org.apache.flink.runtime.executiongraph.AccessExecutionVertex;
import org.apache.flink.runtime.webmonitor.ExecutionGraphHolder;
import org.apache.flink.util.FlinkException;

import java.util.Map;
Expand Down
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.flink.runtime.webmonitor.handlers;
package org.apache.flink.runtime.rest.handler.legacy;

import org.apache.flink.api.common.time.Time;
import org.apache.flink.runtime.concurrent.FlinkFutureException;
Expand Down

0 comments on commit 4fc019a

Please sign in to comment.