public class MigrationContext extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
MigrationContext.MigrationStep
A simple migration step to be performed
|
| Modifier | Constructor and Description |
|---|---|
protected |
MigrationContext(org.apache.karaf.shell.api.console.Session session,
MigrationConfig migrationConfig) |
| Modifier and Type | Method and Description |
|---|---|
String |
askUserWithAuthorizedAnswer(String msg,
List<String> authorizedAnswer)
This method allow you to ask a question to the user.
|
String |
askUserWithDefaultAnswer(String msg,
String defaultAnswer)
This will ask a question to the user and return the default answer if the user does not answer.
|
protected void |
cleanHistory()
Clean history from FileSystem
|
boolean |
getConfigBoolean(String name)
Get config for property name, in case the property doesn't exist on file system config file
Best effort will be made to prompt question in karaf shell to get the needed information
|
String |
getConfigString(String name)
Get config for property name, in case the property doesn't exist on file system config file
Best effort will be made to prompt question in karaf shell to get the needed information
|
org.apache.http.impl.client.CloseableHttpClient |
getHttpClient()
This HTTP client is configured to be used for ElasticSearch requests to be able to perform migrations requests.
|
void |
performMigrationStep(String stepKey,
MigrationContext.MigrationStep step)
this method allow for migration step execution:
- in case the history already contains the given stepKey as COMPLETED, then the step won't be executed
- in case the history doesn't contain the given stepKey, then the step will be executed
Also this method is keeping track of the history by persisting it on the FileSystem.
|
void |
printException(String msg)
Same as above without stacktrace
|
void |
printException(String msg,
Throwable t)
Print an exception along with a message in the console.
|
void |
printMessage(String msg)
Print a message in the console.
|
String |
promptMessageToUser(String msg)
This method allow you to prompt a message to the user.
|
protected void |
setHttpClient(org.apache.http.impl.client.CloseableHttpClient httpClient) |
protected void |
tryRecoverFromHistory()
Try to recover from a previous run
I case we found an existing history we will ask if we want to recover or if we want to restart from the beginning
(it is also configurable using the conf: recoverFromHistory)
|
protected MigrationContext(org.apache.karaf.shell.api.console.Session session,
MigrationConfig migrationConfig)
protected void tryRecoverFromHistory()
throws IOException
IOExceptionpublic void performMigrationStep(String stepKey, MigrationContext.MigrationStep step) throws Exception
stepKey - the key of the given stepstep - the step to be performedIOExceptionExceptionprotected void cleanHistory()
throws IOException
IOExceptionpublic String askUserWithDefaultAnswer(String msg, String defaultAnswer) throws IOException
msg - String message to askdefaultAnswer - String default answerIOException - if there was a problem reading input from the consolepublic String askUserWithAuthorizedAnswer(String msg, List<String> authorizedAnswer) throws IOException
msg - String message to askauthorizedAnswer - Array of possible answer, all answer must be in lower caseIOException - if there was an error retrieving an answer from the user on the consolepublic String promptMessageToUser(String msg)
msg - String message to promptpublic void printMessage(String msg)
msg - the message to print out with a newlinepublic void printException(String msg, Throwable t)
msg - the message to print out with a newlinet - the exception to dump in the shell console after the messagepublic void printException(String msg)
msg - the message to print out with a newlinepublic String getConfigString(String name) throws IOException
name - the name of the propertyIOExceptionpublic boolean getConfigBoolean(String name) throws IOException
name - the name of the propertyIOExceptionpublic org.apache.http.impl.client.CloseableHttpClient getHttpClient()
protected void setHttpClient(org.apache.http.impl.client.CloseableHttpClient httpClient)
Copyright © 2014–2023 Apache Software Foundation. All rights reserved.