-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Create OpenSearchClient for 6.x
Signed-off-by: Mikayla Thompson <[email protected]>
1 parent
9010fcf
commit d809f75
Showing
19 changed files
with
204 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
RFS/src/main/java/org/opensearch/migrations/bulkload/common/OpenSearchClientFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.opensearch.migrations.bulkload.common; | ||
|
||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.opensearch.migrations.Version; | ||
import org.opensearch.migrations.VersionMatchers; | ||
import org.opensearch.migrations.bulkload.common.http.ConnectionContext; | ||
import org.opensearch.migrations.bulkload.version_es_6_8.OpenSearchClient_ES_6_8; | ||
import org.opensearch.migrations.bulkload.version_os_2_11.OpenSearchClient_OS_2_11; | ||
import org.opensearch.migrations.reindexer.FailedRequestsLogger; | ||
|
||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class OpenSearchClientFactory { | ||
// Version can be null, and if so, the "default" client, for OS_2_11 will be provided (matching the pre-factory behavior) | ||
private final Version version; | ||
|
||
public OpenSearchClient get( | ||
ConnectionContext connectionContext | ||
) { | ||
if (version == null || VersionMatchers.isOS_1_X.test(version) || VersionMatchers.isOS_2_X.test(version) || VersionMatchers.isES_7_X.test(version)) { | ||
return new OpenSearchClient_OS_2_11(connectionContext); | ||
} else if (VersionMatchers.isES_6_X.test(version)) { | ||
return new OpenSearchClient_ES_6_8(connectionContext); | ||
} else { | ||
throw new IllegalArgumentException("Unsupported version: " + version); | ||
} | ||
} | ||
|
||
public OpenSearchClient get( | ||
RestClient client, | ||
FailedRequestsLogger failedRequestsLogger | ||
) { | ||
if (version == null || VersionMatchers.isOS_1_X.test(version) || VersionMatchers.isOS_2_X.test(version) || VersionMatchers.isES_7_X.test(version)) { | ||
return new OpenSearchClient_OS_2_11(client, failedRequestsLogger); | ||
} else if (VersionMatchers.isES_6_X.test(version)) { | ||
return new OpenSearchClient_ES_6_8(client, failedRequestsLogger); | ||
} else { | ||
throw new IllegalArgumentException("Unsupported version: " + version); | ||
} | ||
} | ||
|
||
|
||
} |
24 changes: 24 additions & 0 deletions
24
.../main/java/org/opensearch/migrations/bulkload/version_es_6_8/OpenSearchClient_ES_6_8.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.opensearch.migrations.bulkload.version_es_6_8; | ||
|
||
import org.opensearch.migrations.bulkload.common.OpenSearchClient; | ||
import org.opensearch.migrations.bulkload.common.RestClient; | ||
import org.opensearch.migrations.bulkload.common.http.ConnectionContext; | ||
import org.opensearch.migrations.reindexer.FailedRequestsLogger; | ||
|
||
public class OpenSearchClient_ES_6_8 extends OpenSearchClient { | ||
public OpenSearchClient_ES_6_8(ConnectionContext connectionContext) { | ||
super(connectionContext); | ||
} | ||
|
||
public OpenSearchClient_ES_6_8(RestClient client, FailedRequestsLogger failedRequestsLogger) { | ||
super(client, failedRequestsLogger); | ||
} | ||
|
||
protected String getCreateIndexPath(String indexName) { | ||
return indexName + "?include_type_name=false"; | ||
} | ||
|
||
protected String getBulkRequestPath(String indexName) { | ||
return indexName + "/_doc/_bulk"; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...ain/java/org/opensearch/migrations/bulkload/version_os_2_11/OpenSearchClient_OS_2_11.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.opensearch.migrations.bulkload.version_os_2_11; | ||
|
||
import org.opensearch.migrations.bulkload.common.OpenSearchClient; | ||
import org.opensearch.migrations.bulkload.common.RestClient; | ||
import org.opensearch.migrations.bulkload.common.http.ConnectionContext; | ||
import org.opensearch.migrations.reindexer.FailedRequestsLogger; | ||
|
||
public class OpenSearchClient_OS_2_11 extends OpenSearchClient { | ||
public OpenSearchClient_OS_2_11(ConnectionContext connectionContext) { | ||
super(connectionContext); | ||
} | ||
|
||
public OpenSearchClient_OS_2_11(RestClient client, FailedRequestsLogger failedRequestsLogger) { | ||
super(client, failedRequestsLogger); | ||
} | ||
|
||
protected String getCreateIndexPath(String indexName) { | ||
return indexName; | ||
} | ||
|
||
protected String getBulkRequestPath(String indexName) { | ||
return indexName + "/_bulk"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters