public interface ComputationManager
extends java.lang.AutoCloseable
ExecutionHandler
.
Typically, they are used to execute expensive computations through external processes.
According to the computation manager implementation, those processes may then be executed on the local host
or on a dedicated computation infrastructure which may have better performance or scaling capabilities.
Commands will be executed asynchronously and results accessible through the CompletableFuture
returned by one of the execute(com.powsybl.computation.ExecutionEnvironment, com.powsybl.computation.ExecutionHandler<R>)
method variants. If CompletableFuture.cancel(boolean)
is called,
the computation manager should try as much as possible to free computation resources used for the
underlying commands execution.
The computation manager must provide a temporary working directory for each submitted execution,
where data may be written to (in particular before the execution) and read from (in particular after the execution).
A prefix for this directory may be provided through the ExecutionEnvironment
.
Typically, the prefix will be appended with a UUID to ensure working directory uniqueness.
If ExecutionEnvironment.isDebug()
is true, that working directory will not be discarded,
otherwise it may be discarded to ensure a sustainable use of the execution environment.
Execution handlers define a list of CommandExecution
s to be executed.
Those command executions must be executed sequentially. However, when a command execution
has an execution number greater than one, the corresponding executions may be executed in parallel.
The interface extends AutoCloseable
, since it may require some resource cleanup on closing,
for instance deleting working directories or closing connections to remote infrastructure.
Modifier and Type | Method and Description |
---|---|
void |
close() |
<R> java.util.concurrent.CompletableFuture<R> |
execute(ExecutionEnvironment environment,
ExecutionHandler<R> handler)
Submits for execution commands defined by the specified
ExecutionHandler ,
using the specified ExecutionEnvironment . |
default <R> java.util.concurrent.CompletableFuture<R> |
execute(ExecutionEnvironment environment,
ExecutionHandler<R> handler,
ComputationParameters parameters)
Submits for execution commands defined by the specified
ExecutionHandler ,
using the specified ExecutionEnvironment . |
java.util.concurrent.Executor |
getExecutor()
An executor which may be used to perform expensive processing inside this JVM.
|
java.nio.file.Path |
getLocalDir() |
ComputationResourcesStatus |
getResourcesStatus() |
java.lang.String |
getVersion() |
java.io.OutputStream |
newCommonFile(java.lang.String fileName) |
java.lang.String getVersion()
java.io.OutputStream newCommonFile(java.lang.String fileName) throws java.io.IOException
java.io.IOException
<R> java.util.concurrent.CompletableFuture<R> execute(ExecutionEnvironment environment, ExecutionHandler<R> handler)
ExecutionHandler
,
using the specified ExecutionEnvironment
.
The result of type R
will be provided asynchronously through the returned CompletableFuture
.
R
- the type of the result expected from the commands execution.environment
- specifies environment details such as the working directory prefix and environment variables.handler
- defines the commands to be executed together with preprocessing and postprocessing.default <R> java.util.concurrent.CompletableFuture<R> execute(ExecutionEnvironment environment, ExecutionHandler<R> handler, ComputationParameters parameters)
ExecutionHandler
,
using the specified ExecutionEnvironment
.
The result of type R
will be provided asynchronously through the returned CompletableFuture
.
Additional technical parameters may be provided through the ComputationParameters
.
R
- the type of the result expected from the commands execution.environment
- specifies environment details such as the working directory prefix and environment variables.handler
- defines the commands to be executed together with preprocessing and postprocessing.parameters
- defines additional technical parametersComputationResourcesStatus getResourcesStatus()
java.util.concurrent.Executor getExecutor()
java.nio.file.Path getLocalDir()
void close()
close
in interface java.lang.AutoCloseable
Copyright © 2019. All rights reserved.