See: Description
Class | Description |
---|---|
MonitoringContext |
Defines an abstract class for the monitoring context.
|
MonitoringKey |
Defines a wrapper class for the
PrimaryKey of monitoring records. |
MonitoringStatus |
Defines a class to include the monitoring information.
|
MonitoringTimeInformation |
Defines a class to include the monitoring time information.
|
RestartContext |
Defines a context to restart the suspended operation.
|
StartContext |
Defines a context to include the required information for registration.
|
StatusContext |
Defines a class to represent the monitoring information.
|
StopContext |
Defines a context to include required information for stopping an operation.
|
SuspendContext |
Defines a context to suspend a started operation.
|
UpdateContext |
Defines a context to include the required information for updating monitoring.
|
Provides classes to define a context for communicating with the {addon.label}.
Monitoring API can be called via MonitoringFactory
Monitoring monitoring = MonitoringFactory.getMonitoring();
To register monitoring, call the start(StartContext startContext)
method in the API with the parameter
StartContext
, which contains the required information for registration.
A MonitoringKey
is returned, which contains the newly created record's key.
ServiceContext sContext = ServiceContext.getServiceContext(request); Session userSession = sContext.getSession(); StartContext startContext = new StartContext(userSession); ParametersMap inputParams = new ParametersMap(); // The product code is stored in the 'Product' table and is mandatory. startContext.setProductCode(String productCode); // The service name is stored in the 'Operation' table and is mandatory. startContext.setServiceName(String serviceName); startContext.setDataspace(AdaptationHome dataspace); startContext.setDataset(Adaptation dataset); startContext.setTablePath(Path pathTable); startContext.setRecords(List<PrimaryKey> records); // Creates input parameters if necessary. Parameter inputParam = new Parameter(); inputParam.setName(String paramName); inputParam.setValue(String paramValue); inputParams.addParameter(inputParam); startContext.setInputParameters(inputParams); MonitoringKey monitoringKey = monitoring.start(startContext);
To get the monitoring status, call the getStatus(MonitoringKey monitoringKey)
method in the API with the parameter monitoringKey
, which is the returned value after monitor registration.
Returns a MonitoringStatus
.
The MonitoringStatus
contains information such as the state and completion percentage of the operation.
MonitoringStatus monitoringStatus = monitoring.getStatus(monitoringKey);
To update monitoring, call the update(MonitoringKey monitoringKey, UpdateContext updateContext)
method in the API.
The monitoringKey
parameter is the value returned after registering.
The updateContext
parameter is the context containing the information to be updated.
Returns the updated MonitoringStatus
.
ParametersMap workingParams = new ParametersMap(); UpdateContext updateContext = new UpdateContext(userSession); updateContext.setPercentage(double percentage); // The last modification date is fetched from monitoringStatus to verify the last user who modified monitoring. updateContext.setLastModificationDate(monitoringStatus.getLastModificationDate()); // Creates a working parameter if necessary. Parameter workingParam = new Parameter(); workingParam.setName(String paramName); workingParam.setValue(String paramValue); workingParams.addParameter(workingParam); updateContext.setWorkingParameters(workingParams); monitoringStatus = monitoring.update(monitoringKey, updateContext);
To suspend monitoring, call the suspend(MonitoringKey monitoringKey, SuspendContext suspendContext)
method in the API.
The monitoringKey
parameter is the value returned after registering.
The suspendContext
parameter is the context containing the last information modification date. This is used to verify which user updated the monitoring.
The returned value is a MonitoringStatus
.
SuspendContext suspendContext = new SuspendContext(userSession); // The last modification date is fetched from monitoringStatus to verify the last user who modified monitoring. suspendContext.setLastModificationDate(monitoringStatus.getLastModificationDate()); monitoringStatus = monitoring.suspend(monitoringKey, suspendContext);
To restart monitoring, call the restart(MonitoringKey monitoringKey, RestartContext restartContext)
method in the API.
The monitoringKey
parameter is the value returned after registering.
The restartContext
parameter is the context containing the last information modification date. This is used to verify which user updated the monitoring.
The returned value is a MonitoringStatus
.
RestartContext restartContext = new RestartContext(userSession); // The last modification date is fetched from monitoringStatus to verify the last user who modified monitoring. restartContext.setLastModificationDate(monitoringStatus.getLastModificationDate()); monitoringStatus = monitoring.restart(monitoringKey, restartContext);
To stop monitoring, call the stop(MonitoringKey monitoringKey, StopContext stopContext)
method in the API.
The monitoringKey
parameter is the value returned after registering.
The stopContext
parameter is the context containing the information to update when Monitoring is stopped.
The returned value is a MonitoringStatus
.
StopContext stopContext = new StopContext(userSession); ParametersMap outputParams = new ParametersMap(); // The last modification date is fetched from monitoringStatus to verify the last user who modified monitoring. stopContext.setLastModificationDate(monitoringStatus.getLastModificationDate()); // Sets stop cause. stopContext.setStopCause(StopCause stopCause); stopContext.setPercentage(double percentage); // Creates output parameter if necessary. Parameter outputParam = new Parameter(); outputParam.setName(String paramName); outputParam.setValue(String paramValue); outputParams.addParameter(outputParam); stopContext.setOutputParameters(outputParams); monitoringStatus = monitoring.stop(monitoringKey, stopContext);
To get the monitoring input parameters, call the getInputParameters(MonitoringKey monitoringKey)
method in the API.
The monitoringKey
parameter is the value returned after registering.
Returns the list of parameters.
List<Parameter> inputParameters = monitoring.getInputParameters(monitoringKey);
To get the monitoring working parameters, call the getWorkingParameters(MonitoringKey monitoringKey)
method in the API.
The monitoringKey
parameter is the value returned after registering.
Returns the list of parameters.
List<Parameter> workingParameters = monitoring.getWorkingParameters(monitoringKey);
To get the monitoring output parameters, call the getOutputParameters(MonitoringKey monitoringKey)
method in the API.
The monitoringKey
parameter is the value returned after registering.
Returns the list of parameters.
List<Parameter> outputParameters = monitoring.getOutputParameters(monitoringKey);