public class MiniCluster extends Object implements org.apache.flink.util.AutoCloseableAsync
| 限定符和类型 | 类和说明 |
|---|---|
protected static class |
MiniCluster.CommonRpcServiceFactory
Factory which returns always the common
RpcService. |
protected class |
MiniCluster.DedicatedRpcServiceFactory
Factory which creates and registers new
RpcService. |
static class |
MiniCluster.HaServices
HA Services to use.
|
protected static interface |
MiniCluster.RpcServiceFactory
Internal factory for
RpcService. |
| 构造器和说明 |
|---|
MiniCluster(MiniClusterConfiguration miniClusterConfiguration)
Creates a new Flink mini cluster based on the given configuration.
|
MiniCluster(MiniClusterConfiguration miniClusterConfiguration,
java.util.function.Supplier<org.apache.flink.util.Reference<org.apache.flink.runtime.rpc.RpcSystem>> rpcSystemSupplier) |
| 限定符和类型 | 方法和说明 |
|---|---|
CompletableFuture<Acknowledge> |
cancelJob(org.apache.flink.api.common.JobID jobId) |
CompletableFuture<Void> |
closeAsync()
Shuts down the mini cluster, failing all currently executing jobs.
|
protected DispatcherResourceManagerComponentFactory |
createDispatcherResourceManagerComponentFactory() |
protected Collection<? extends DispatcherResourceManagerComponent> |
createDispatcherResourceManagerComponents(org.apache.flink.configuration.Configuration configuration,
MiniCluster.RpcServiceFactory rpcServiceFactory,
BlobServer blobServer,
HeartbeatServices heartbeatServices,
MetricRegistry metricRegistry,
MetricQueryServiceRetriever metricQueryServiceRetriever,
org.apache.flink.runtime.rpc.FatalErrorHandler fatalErrorHandler) |
protected HighAvailabilityServices |
createHighAvailabilityServices(org.apache.flink.configuration.Configuration configuration,
Executor executor) |
protected org.apache.flink.runtime.rpc.RpcService |
createLocalRpcService(org.apache.flink.configuration.Configuration configuration,
org.apache.flink.runtime.rpc.RpcSystem rpcSystem)
Factory method to instantiate the local RPC service.
|
protected MetricRegistryImpl |
createMetricRegistry(org.apache.flink.configuration.Configuration config,
long maximumMessageSizeInBytes)
Factory method to create the metric registry for the mini cluster.
|
protected org.apache.flink.runtime.rpc.RpcService |
createRemoteRpcService(org.apache.flink.configuration.Configuration configuration,
String bindAddress,
int bindPort,
org.apache.flink.runtime.rpc.RpcSystem rpcSystem)
Factory method to instantiate the remote RPC service.
|
protected org.apache.flink.runtime.rpc.RpcService |
createRemoteRpcService(org.apache.flink.configuration.Configuration configuration,
String externalAddress,
String externalPortRange,
String bindAddress,
org.apache.flink.runtime.rpc.RpcSystem rpcSystem)
Factory method to instantiate the remote RPC service.
|
CompletableFuture<CoordinationResponse> |
deliverCoordinationRequestToCoordinator(org.apache.flink.api.common.JobID jobId,
OperatorID operatorId,
org.apache.flink.util.SerializedValue<CoordinationRequest> serializedRequest) |
CompletableFuture<Acknowledge> |
disposeSavepoint(String savepointPath) |
org.apache.flink.api.common.JobExecutionResult |
executeJobBlocking(JobGraph job)
This method runs a job in blocking mode.
|
CompletableFuture<ArchivedExecutionGraph> |
getArchivedExecutionGraph(org.apache.flink.api.common.JobID jobId) |
ClusterInformation |
getClusterInformation() |
org.apache.flink.configuration.Configuration |
getConfiguration() |
protected CompletableFuture<DispatcherGateway> |
getDispatcherGatewayFuture() |
CompletableFuture<? extends AccessExecutionGraph> |
getExecutionGraph(org.apache.flink.api.common.JobID jobId) |
Optional<HaLeadershipControl> |
getHaLeadershipControl()
Returns
HaLeadershipControl if enabled. |
protected HighAvailabilityServices |
getHaServices() |
protected Executor |
getIOExecutor() |
CompletableFuture<org.apache.flink.api.common.JobStatus> |
getJobStatus(org.apache.flink.api.common.JobID jobId) |
CompletableFuture<ResourceOverview> |
getResourceOverview() |
CompletableFuture<URI> |
getRestAddress() |
boolean |
isRunning()
Checks if the mini cluster was started and is running.
|
CompletableFuture<Collection<JobStatusMessage>> |
listJobs() |
void |
overrideRestoreModeForChangelogStateBackend() |
CompletableFuture<ClusterOverview> |
requestClusterOverview() |
CompletableFuture<JobResult> |
requestJobResult(org.apache.flink.api.common.JobID jobId) |
void |
runDetached(JobGraph job)
This method executes a job in detached mode.
|
void |
start()
Starts the mini cluster, based on the configured properties.
|
void |
startTaskManager()
Starts additional TaskManager process.
|
CompletableFuture<String> |
stopWithSavepoint(org.apache.flink.api.common.JobID jobId,
String targetDirectory,
boolean terminate,
org.apache.flink.core.execution.SavepointFormatType formatType) |
CompletableFuture<org.apache.flink.api.common.JobSubmissionResult> |
submitJob(JobGraph jobGraph) |
CompletableFuture<Void> |
terminateTaskManager(int index)
Terminates a TaskManager with the given index.
|
CompletableFuture<String> |
triggerCheckpoint(org.apache.flink.api.common.JobID jobID) |
CompletableFuture<String> |
triggerSavepoint(org.apache.flink.api.common.JobID jobId,
String targetDirectory,
boolean cancelJob,
org.apache.flink.core.execution.SavepointFormatType formatType) |
protected boolean |
useLocalCommunication() |
public MiniCluster(MiniClusterConfiguration miniClusterConfiguration)
miniClusterConfiguration - The configuration for the mini clusterpublic MiniCluster(MiniClusterConfiguration miniClusterConfiguration, java.util.function.Supplier<org.apache.flink.util.Reference<org.apache.flink.runtime.rpc.RpcSystem>> rpcSystemSupplier)
public CompletableFuture<URI> getRestAddress()
public ClusterInformation getClusterInformation()
protected Executor getIOExecutor()
public boolean isRunning()
public void start()
throws Exception
Exception - This method passes on any exception that occurs during the startup of the
mini cluster.@VisibleForTesting protected Collection<? extends DispatcherResourceManagerComponent> createDispatcherResourceManagerComponents(org.apache.flink.configuration.Configuration configuration, MiniCluster.RpcServiceFactory rpcServiceFactory, BlobServer blobServer, HeartbeatServices heartbeatServices, MetricRegistry metricRegistry, MetricQueryServiceRetriever metricQueryServiceRetriever, org.apache.flink.runtime.rpc.FatalErrorHandler fatalErrorHandler) throws Exception
Exceptionprotected DispatcherResourceManagerComponentFactory createDispatcherResourceManagerComponentFactory()
@VisibleForTesting protected HighAvailabilityServices createHighAvailabilityServices(org.apache.flink.configuration.Configuration configuration, Executor executor) throws Exception
Exceptionpublic Optional<HaLeadershipControl> getHaLeadershipControl()
HaLeadershipControl if enabled.
HaLeadershipControl allows granting and revoking leadership of HA components, e.g.
JobManager. The method return Optional.empty() if the control is not enabled in
MiniClusterConfiguration.
Enabling this feature disables HighAvailabilityOptions.HA_MODE option.
protected HighAvailabilityServices getHaServices()
public CompletableFuture<Void> closeAsync()
start() method again.
This method shuts down all started services and components, even if an exception occurs in the process of shutting down some component.
closeAsync 在接口中 org.apache.flink.util.AutoCloseableAsyncpublic void startTaskManager()
throws Exception
When the MiniCluster starts up, it always starts MiniClusterConfiguration.getNumTaskManagers() TaskManagers. All TaskManagers are indexed from
0 to the number of TaskManagers, started so far, minus one. This method starts a TaskManager
with the next index which is the number of TaskManagers, started so far. The index always
increases with each new started TaskManager. The indices of terminated TaskManagers are not
reused after terminateTaskManager(int).
Exception@VisibleForTesting protected boolean useLocalCommunication()
@VisibleForTesting public org.apache.flink.configuration.Configuration getConfiguration()
@Internal public void overrideRestoreModeForChangelogStateBackend()
public CompletableFuture<Void> terminateTaskManager(int index)
See startTaskManager() to understand how TaskManagers are indexed. This method
terminates a TaskManager with a given index but it does not clear the index. The index stays
occupied for the lifetime of the MiniCluster and its TaskManager stays terminated. The index
is not reused if more TaskManagers are started with startTaskManager().
index - index of the TaskManager to terminateCompletableFuture of the given TaskManager terminationpublic CompletableFuture<ArchivedExecutionGraph> getArchivedExecutionGraph(org.apache.flink.api.common.JobID jobId)
public CompletableFuture<Collection<JobStatusMessage>> listJobs()
public CompletableFuture<org.apache.flink.api.common.JobStatus> getJobStatus(org.apache.flink.api.common.JobID jobId)
public CompletableFuture<Acknowledge> cancelJob(org.apache.flink.api.common.JobID jobId)
public CompletableFuture<String> triggerSavepoint(org.apache.flink.api.common.JobID jobId, String targetDirectory, boolean cancelJob, org.apache.flink.core.execution.SavepointFormatType formatType)
public CompletableFuture<String> triggerCheckpoint(org.apache.flink.api.common.JobID jobID)
public CompletableFuture<String> stopWithSavepoint(org.apache.flink.api.common.JobID jobId, String targetDirectory, boolean terminate, org.apache.flink.core.execution.SavepointFormatType formatType)
public CompletableFuture<Acknowledge> disposeSavepoint(String savepointPath)
public CompletableFuture<? extends AccessExecutionGraph> getExecutionGraph(org.apache.flink.api.common.JobID jobId)
public CompletableFuture<CoordinationResponse> deliverCoordinationRequestToCoordinator(org.apache.flink.api.common.JobID jobId, OperatorID operatorId, org.apache.flink.util.SerializedValue<CoordinationRequest> serializedRequest)
public CompletableFuture<ResourceOverview> getResourceOverview()
public void runDetached(JobGraph job) throws JobExecutionException, InterruptedException
job - The Flink job to executeJobExecutionException - Thrown if anything went amiss during initial job launch, or if
the job terminally failed.InterruptedExceptionpublic org.apache.flink.api.common.JobExecutionResult executeJobBlocking(JobGraph job) throws JobExecutionException, InterruptedException
job - The Flink job to executeJobExecutionException - Thrown if anything went amiss during initial job launch, or if
the job terminally failed.InterruptedExceptionpublic CompletableFuture<org.apache.flink.api.common.JobSubmissionResult> submitJob(JobGraph jobGraph)
public CompletableFuture<JobResult> requestJobResult(org.apache.flink.api.common.JobID jobId)
public CompletableFuture<ClusterOverview> requestClusterOverview()
@VisibleForTesting protected CompletableFuture<DispatcherGateway> getDispatcherGatewayFuture()
protected MetricRegistryImpl createMetricRegistry(org.apache.flink.configuration.Configuration config, long maximumMessageSizeInBytes)
config - The configuration of the mini clustermaximumMessageSizeInBytes - the maximum message sizeprotected org.apache.flink.runtime.rpc.RpcService createRemoteRpcService(org.apache.flink.configuration.Configuration configuration,
String bindAddress,
int bindPort,
org.apache.flink.runtime.rpc.RpcSystem rpcSystem)
throws Exception
configuration - Flink configuration.bindAddress - The address to bind the RPC service to.bindPort - The port range to bind the RPC service to.rpcSystem - Exceptionprotected org.apache.flink.runtime.rpc.RpcService createRemoteRpcService(org.apache.flink.configuration.Configuration configuration,
String externalAddress,
String externalPortRange,
String bindAddress,
org.apache.flink.runtime.rpc.RpcSystem rpcSystem)
throws Exception
configuration - Flink configuration.externalAddress - The external address to access the RPC service.externalPortRange - The external port range to access the RPC service.bindAddress - The address to bind the RPC service to.rpcSystem - Exceptionprotected org.apache.flink.runtime.rpc.RpcService createLocalRpcService(org.apache.flink.configuration.Configuration configuration,
org.apache.flink.runtime.rpc.RpcSystem rpcSystem)
throws Exception
configuration - Flink configuration.rpcSystem - ExceptionCopyright © 2014–2022 The Apache Software Foundation. All rights reserved.