Class MiniCluster
- All Implemented Interfaces:
AutoCloseable,org.apache.flink.util.AutoCloseableAsync
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classFactory which returns always the commonRpcService.protected classFactory which creates and registers newRpcService.static enumHA Services to use.protected static interfaceInternal factory forRpcService. -
Constructor Summary
ConstructorsConstructorDescriptionMiniCluster(MiniClusterConfiguration miniClusterConfiguration) Creates a new Flink mini cluster based on the given configuration.MiniCluster(MiniClusterConfiguration miniClusterConfiguration, Supplier<org.apache.flink.util.Reference<org.apache.flink.runtime.rpc.RpcSystem>> rpcSystemSupplier) -
Method Summary
Modifier and TypeMethodDescriptioncancelJob(org.apache.flink.api.common.JobID jobId) Shuts down the mini cluster, failing all currently executing jobs.protected Collection<? extends DispatcherResourceManagerComponent>createDispatcherResourceManagerComponents(org.apache.flink.configuration.Configuration configuration, MiniCluster.RpcServiceFactory rpcServiceFactory, BlobServer blobServer, HeartbeatServices heartbeatServices, DelegationTokenManager delegationTokenManager, MetricRegistry metricRegistry, MetricQueryServiceRetriever metricQueryServiceRetriever, org.apache.flink.runtime.rpc.FatalErrorHandler fatalErrorHandler) protected HighAvailabilityServicescreateHighAvailabilityServices(org.apache.flink.configuration.Configuration configuration, Executor executor) protected org.apache.flink.runtime.rpc.RpcServicecreateLocalRpcService(org.apache.flink.configuration.Configuration configuration, org.apache.flink.runtime.rpc.RpcSystem rpcSystem) Factory method to instantiate the local RPC service.protected MetricRegistryImplcreateMetricRegistry(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.RpcServicecreateRemoteRpcService(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.RpcServicecreateRemoteRpcService(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.deliverCoordinationRequestToCoordinator(org.apache.flink.api.common.JobID jobId, String operatorUid, org.apache.flink.util.SerializedValue<CoordinationRequest> serializedRequest) disposeSavepoint(String savepointPath) org.apache.flink.api.common.JobExecutionResultThis method runs a job in blocking mode.getArchivedExecutionGraph(org.apache.flink.api.common.JobID jobId) org.apache.flink.configuration.Configurationprotected CompletableFuture<DispatcherGateway>CompletableFuture<? extends AccessExecutionGraph>getExecutionGraph(org.apache.flink.api.common.JobID jobId) ReturnsHaLeadershipControlif enabled.protected HighAvailabilityServicesprotected ExecutorCompletableFuture<org.apache.flink.api.common.JobStatus>getJobStatus(org.apache.flink.api.common.JobID jobId) invalidateClusterDataset(org.apache.flink.util.AbstractID clusterDatasetId) booleanChecks if the mini cluster was started and is running.CompletableFuture<Set<org.apache.flink.util.AbstractID>>listJobs()voidreportHeartbeat(org.apache.flink.api.common.JobID jobId, long expiredTimestamp) requestJobResult(org.apache.flink.api.common.JobID jobId) voidrunDetached(JobGraph job) This method executes a job in detached mode.voidstart()Starts the mini cluster, based on the configured properties.voidStarts additional TaskManager process.stopWithDetachedSavepoint(org.apache.flink.api.common.JobID jobId, String targetDirectory, boolean terminate, org.apache.flink.core.execution.SavepointFormatType formatType) 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(ExecutionPlan executionPlan) terminateTaskManager(int index) Terminates a TaskManager with the given index.triggerCheckpoint(org.apache.flink.api.common.JobID jobID) triggerCheckpoint(org.apache.flink.api.common.JobID jobID, org.apache.flink.core.execution.CheckpointType checkpointType) triggerDetachedSavepoint(org.apache.flink.api.common.JobID jobId, String targetDirectory, boolean cancelJob, org.apache.flink.core.execution.SavepointFormatType formatType) triggerSavepoint(org.apache.flink.api.common.JobID jobId, String targetDirectory, boolean cancelJob, org.apache.flink.core.execution.SavepointFormatType formatType) protected booleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.flink.util.AutoCloseableAsync
close
-
Constructor Details
-
MiniCluster
Creates a new Flink mini cluster based on the given configuration.- Parameters:
miniClusterConfiguration- The configuration for the mini cluster
-
MiniCluster
public MiniCluster(MiniClusterConfiguration miniClusterConfiguration, Supplier<org.apache.flink.util.Reference<org.apache.flink.runtime.rpc.RpcSystem>> rpcSystemSupplier)
-
-
Method Details
-
getRestAddress
-
getClusterInformation
-
getIOExecutor
-
isRunning
public boolean isRunning()Checks if the mini cluster was started and is running. -
start
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.
-
createDispatcherResourceManagerComponents
@VisibleForTesting protected Collection<? extends DispatcherResourceManagerComponent> createDispatcherResourceManagerComponents(org.apache.flink.configuration.Configuration configuration, MiniCluster.RpcServiceFactory rpcServiceFactory, BlobServer blobServer, HeartbeatServices heartbeatServices, DelegationTokenManager delegationTokenManager, MetricRegistry metricRegistry, MetricQueryServiceRetriever metricQueryServiceRetriever, org.apache.flink.runtime.rpc.FatalErrorHandler fatalErrorHandler) throws Exception - Throws:
Exception
-
createDispatcherResourceManagerComponentFactory
protected DispatcherResourceManagerComponentFactory createDispatcherResourceManagerComponentFactory() -
createHighAvailabilityServices
@VisibleForTesting protected HighAvailabilityServices createHighAvailabilityServices(org.apache.flink.configuration.Configuration configuration, Executor executor) throws Exception - Throws:
Exception
-
getHaLeadershipControl
ReturnsHaLeadershipControlif enabled.HaLeadershipControlallows granting and revoking leadership of HA components, e.g. JobManager. The method returnOptional.empty()if the control is not enabled inMiniClusterConfiguration.Enabling this feature disables
HighAvailabilityOptions.HA_MODEoption. -
getHaServices
-
closeAsync
Shuts down the mini cluster, failing all currently executing jobs. The mini cluster can be started again by calling thestart()method again.This method shuts down all started services and components, even if an exception occurs in the process of shutting down some component.
- Specified by:
closeAsyncin interfaceorg.apache.flink.util.AutoCloseableAsync- Returns:
- Future which is completed once the MiniCluster has been completely shut down
-
closeAsyncWithoutCleaningHighAvailabilityData
-
startTaskManager
Starts additional TaskManager process.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 afterterminateTaskManager(int).- Throws:
Exception
-
useLocalCommunication
@VisibleForTesting protected boolean useLocalCommunication() -
getConfiguration
@VisibleForTesting public org.apache.flink.configuration.Configuration getConfiguration() -
overrideRestoreModeForChangelogStateBackend
@Internal public void overrideRestoreModeForChangelogStateBackend() -
terminateTaskManager
Terminates a TaskManager with the given 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 withstartTaskManager().- Parameters:
index- index of the TaskManager to terminate- Returns:
CompletableFutureof the given TaskManager termination
-
getArchivedExecutionGraph
public CompletableFuture<ArchivedExecutionGraph> getArchivedExecutionGraph(org.apache.flink.api.common.JobID jobId) -
listJobs
-
getJobStatus
public CompletableFuture<org.apache.flink.api.common.JobStatus> getJobStatus(org.apache.flink.api.common.JobID jobId) -
cancelJob
-
triggerSavepoint
public CompletableFuture<String> triggerSavepoint(org.apache.flink.api.common.JobID jobId, String targetDirectory, boolean cancelJob, org.apache.flink.core.execution.SavepointFormatType formatType) -
triggerDetachedSavepoint
public CompletableFuture<String> triggerDetachedSavepoint(org.apache.flink.api.common.JobID jobId, String targetDirectory, boolean cancelJob, org.apache.flink.core.execution.SavepointFormatType formatType) -
triggerCheckpoint
-
triggerCheckpoint
public CompletableFuture<Long> triggerCheckpoint(org.apache.flink.api.common.JobID jobID, org.apache.flink.core.execution.CheckpointType checkpointType) -
stopWithSavepoint
public CompletableFuture<String> stopWithSavepoint(org.apache.flink.api.common.JobID jobId, String targetDirectory, boolean terminate, org.apache.flink.core.execution.SavepointFormatType formatType) -
stopWithDetachedSavepoint
public CompletableFuture<String> stopWithDetachedSavepoint(org.apache.flink.api.common.JobID jobId, String targetDirectory, boolean terminate, org.apache.flink.core.execution.SavepointFormatType formatType) -
disposeSavepoint
-
getExecutionGraph
public CompletableFuture<? extends AccessExecutionGraph> getExecutionGraph(org.apache.flink.api.common.JobID jobId) -
deliverCoordinationRequestToCoordinator
public CompletableFuture<CoordinationResponse> deliverCoordinationRequestToCoordinator(org.apache.flink.api.common.JobID jobId, String operatorUid, org.apache.flink.util.SerializedValue<CoordinationRequest> serializedRequest) -
getResourceOverview
-
runDetached
This method executes a job in detached mode. The method returns immediately after the job has been added to the- Parameters:
job- The Flink job to execute- Throws:
JobExecutionException- Thrown if anything went amiss during initial job launch, or if the job terminally failed.InterruptedException
-
executeJobBlocking
public org.apache.flink.api.common.JobExecutionResult executeJobBlocking(JobGraph job) throws JobExecutionException, InterruptedException This method runs a job in blocking mode. The method returns only after the job completed successfully, or after it failed terminally.- Parameters:
job- The Flink job to execute- Returns:
- The result of the job execution
- Throws:
JobExecutionException- Thrown if anything went amiss during initial job launch, or if the job terminally failed.InterruptedException
-
submitJob
public CompletableFuture<org.apache.flink.api.common.JobSubmissionResult> submitJob(ExecutionPlan executionPlan) -
requestJobResult
-
requestClusterOverview
-
getDispatcherGatewayFuture
-
createMetricRegistry
protected MetricRegistryImpl createMetricRegistry(org.apache.flink.configuration.Configuration config, long maximumMessageSizeInBytes) Factory method to create the metric registry for the mini cluster.- Parameters:
config- The configuration of the mini clustermaximumMessageSizeInBytes- the maximum message size
-
createRemoteRpcService
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) throws Exception Factory method to instantiate the remote RPC service.- Parameters:
configuration- Flink configuration.bindAddress- The address to bind the RPC service to.bindPort- The port range to bind the RPC service to.rpcSystem-- Returns:
- The instantiated RPC service
- Throws:
Exception
-
createRemoteRpcService
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) throws Exception Factory method to instantiate the remote RPC service.- Parameters:
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-- Returns:
- The instantiated RPC service
- Throws:
Exception
-
createLocalRpcService
protected org.apache.flink.runtime.rpc.RpcService createLocalRpcService(org.apache.flink.configuration.Configuration configuration, org.apache.flink.runtime.rpc.RpcSystem rpcSystem) throws Exception Factory method to instantiate the local RPC service.- Parameters:
configuration- Flink configuration.rpcSystem-- Returns:
- The instantiated RPC service
- Throws:
Exception
-
invalidateClusterDataset
public CompletableFuture<Void> invalidateClusterDataset(org.apache.flink.util.AbstractID clusterDatasetId) -
listCompletedClusterDatasetIds
-
reportHeartbeat
public CompletableFuture<Void> reportHeartbeat(org.apache.flink.api.common.JobID jobId, long expiredTimestamp)
-