Class MigrationUtils
java.lang.Object
org.apache.unomi.shell.migration.utils.MigrationUtils
- Author:
- dgaillard
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildIndexCreationRequest(String baseIndexSettings, String mapping, MigrationContext context, boolean isMonthlyIndex) static StringbuildIndexCreationRequestWithRollover(String baseIndexSettings, String mapping, MigrationContext context, String lifeCycleName, String rolloverAlias) static StringbuildRolloverPolicyCreationRequest(String baseRequest, MigrationContext migrationContext) static voidbulkUpdate(org.apache.http.impl.client.CloseableHttpClient httpClient, String url, String jsonData) static voidcleanAllIndexWithRollover(org.apache.http.impl.client.CloseableHttpClient httpClient, org.osgi.framework.BundleContext bundleContext, String esAddress, String prefix, String indexName) static voidconfigureAlias(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String alias, String writeIndex, Set<String> readIndices, String configureAliasBody, MigrationContext context) static org.json.JSONObjectcontinueQueryWithScroll(org.apache.http.impl.client.CloseableHttpClient httpClient, String url, String scrollId) static voiddeleteByQuery(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String indexName, String requestBody) Deletes documents from an index based on a specified query.static voiddeleteIndex(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String indexName) static StringextractMappingFromBundles(org.osgi.framework.BundleContext bundleContext, String fileName) static StringgetFileWithoutComments(org.osgi.framework.BundleContext bundleContext, String resource) getIndexesPrefixedBy(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String prefix) static booleanindexExists(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String indexName) static voidmoveToIndex(org.apache.http.impl.client.CloseableHttpClient httpClient, org.osgi.framework.BundleContext bundleContext, String esAddress, String sourceIndexName, String targetIndexName, String painlessScript) static org.json.JSONObjectqueryWithScroll(org.apache.http.impl.client.CloseableHttpClient httpClient, String url) static voidreIndex(org.apache.http.impl.client.CloseableHttpClient httpClient, org.osgi.framework.BundleContext bundleContext, String esAddress, String indexName, String newIndexSettings, String painlessScript, MigrationContext migrationContext, String migrationUniqueName) static StringresourceAsString(org.osgi.framework.BundleContext bundleContext, String resource) static voidscrollQuery(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String queryURL, String query, String scrollDuration, MigrationUtils.ScrollCallback scrollCallback) static voidupdateByQuery(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String indexName, String requestBody) Updates documents in an index based on a specified query.static voidwaitForTaskToFinish(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String taskId, MigrationContext migrationContext) static voidwaitForYellowStatus(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, MigrationContext migrationContext) Utility method that waits for the ES cluster to be in yellow status
-
Constructor Details
-
MigrationUtils
public MigrationUtils()
-
-
Method Details
-
queryWithScroll
public static org.json.JSONObject queryWithScroll(org.apache.http.impl.client.CloseableHttpClient httpClient, String url) throws IOException - Throws:
IOException
-
continueQueryWithScroll
public static org.json.JSONObject continueQueryWithScroll(org.apache.http.impl.client.CloseableHttpClient httpClient, String url, String scrollId) throws IOException - Throws:
IOException
-
bulkUpdate
public static void bulkUpdate(org.apache.http.impl.client.CloseableHttpClient httpClient, String url, String jsonData) throws IOException - Throws:
IOException
-
resourceAsString
-
getFileWithoutComments
-
indexExists
public static boolean indexExists(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String indexName) throws IOException - Throws:
IOException
-
configureAlias
public static void configureAlias(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String alias, String writeIndex, Set<String> readIndices, String configureAliasBody, MigrationContext context) throws IOException - Throws:
IOException
-
getIndexesPrefixedBy
public static Set<String> getIndexesPrefixedBy(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String prefix) throws IOException - Throws:
IOException
-
cleanAllIndexWithRollover
public static void cleanAllIndexWithRollover(org.apache.http.impl.client.CloseableHttpClient httpClient, org.osgi.framework.BundleContext bundleContext, String esAddress, String prefix, String indexName) throws IOException - Throws:
IOException
-
extractMappingFromBundles
public static String extractMappingFromBundles(org.osgi.framework.BundleContext bundleContext, String fileName) throws IOException - Throws:
IOException
-
buildIndexCreationRequest
public static String buildIndexCreationRequest(String baseIndexSettings, String mapping, MigrationContext context, boolean isMonthlyIndex) throws IOException - Throws:
IOException
-
buildIndexCreationRequestWithRollover
public static String buildIndexCreationRequestWithRollover(String baseIndexSettings, String mapping, MigrationContext context, String lifeCycleName, String rolloverAlias) throws IOException - Throws:
IOException
-
buildRolloverPolicyCreationRequest
public static String buildRolloverPolicyCreationRequest(String baseRequest, MigrationContext migrationContext) throws IOException - Throws:
IOException
-
moveToIndex
public static void moveToIndex(org.apache.http.impl.client.CloseableHttpClient httpClient, org.osgi.framework.BundleContext bundleContext, String esAddress, String sourceIndexName, String targetIndexName, String painlessScript) throws Exception - Throws:
Exception
-
deleteIndex
public static void deleteIndex(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String indexName) throws Exception - Throws:
Exception
-
reIndex
public static void reIndex(org.apache.http.impl.client.CloseableHttpClient httpClient, org.osgi.framework.BundleContext bundleContext, String esAddress, String indexName, String newIndexSettings, String painlessScript, MigrationContext migrationContext, String migrationUniqueName) throws Exception - Throws:
Exception
-
scrollQuery
public static void scrollQuery(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String queryURL, String query, String scrollDuration, MigrationUtils.ScrollCallback scrollCallback) throws IOException - Throws:
IOException
-
waitForYellowStatus
public static void waitForYellowStatus(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, MigrationContext migrationContext) throws Exception Utility method that waits for the ES cluster to be in yellow status- Throws:
Exception
-
updateByQuery
public static void updateByQuery(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String indexName, String requestBody) throws Exception Updates documents in an index based on a specified query.This method sends a request to update documents that match the provided query in the specified index. The update operation is performed asynchronously, and the method waits for the task to complete before returning.
- Parameters:
httpClient- the CloseableHttpClient used to send the request to the Elasticsearch serveresAddress- the address of the Elasticsearch serverindexName- the name of the index where documents should be updatedrequestBody- the JSON body containing the query and update instructions for the documents- Throws:
Exception- if there is an error during the HTTP request or while waiting for the task to finish
-
deleteByQuery
public static void deleteByQuery(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String indexName, String requestBody) throws Exception Deletes documents from an index based on a specified query.This method sends a request to the Elasticsearch cluster to delete documents that match the provided query in the specified index. The deletion operation is performed asynchronously, and the method waits for the task to complete before returning.
- Parameters:
httpClient- the CloseableHttpClient used to send the request to the Elasticsearch serveresAddress- the address of the Elasticsearch serverindexName- the name of the index from which documents should be deletedrequestBody- the JSON body containing the query that defines which documents to delete- Throws:
Exception- if there is an error during the HTTP request or while waiting for the task to finish
-
waitForTaskToFinish
public static void waitForTaskToFinish(org.apache.http.impl.client.CloseableHttpClient httpClient, String esAddress, String taskId, MigrationContext migrationContext) throws IOException - Throws:
IOException
-