|
15 | 15 | import org.opensearch.cluster.metadata.IndexMetadata;
|
16 | 16 | import org.opensearch.cluster.service.ClusterService;
|
17 | 17 | import org.opensearch.common.Booleans;
|
| 18 | +import org.opensearch.common.settings.SecureSetting; |
18 | 19 | import org.opensearch.common.settings.Setting;
|
19 | 20 | import org.opensearch.common.settings.Settings;
|
20 | 21 | import org.opensearch.common.unit.TimeValue;
|
21 | 22 | import org.opensearch.core.action.ActionListener;
|
| 23 | +import org.opensearch.core.common.settings.SecureString; |
22 | 24 | import org.opensearch.core.common.unit.ByteSizeUnit;
|
23 | 25 | import org.opensearch.core.common.unit.ByteSizeValue;
|
24 | 26 | import org.opensearch.index.IndexModule;
|
@@ -100,6 +102,11 @@ public class KNNSettings {
|
100 | 102 | public static final String KNN_INDEX_REMOTE_VECTOR_BUILD = "index.knn.remote_index_build.enabled";
|
101 | 103 | public static final String KNN_REMOTE_VECTOR_REPO = "knn.remote_index_build.vector_repo";
|
102 | 104 | public static final String KNN_INDEX_REMOTE_VECTOR_BUILD_THRESHOLD = "index.knn.remote_index_build.size_threshold";
|
| 105 | + public static final String KNN_REMOTE_BUILD_SERVICE_ENDPOINT = "knn.remote_index_build.client.endpoint"; |
| 106 | + public static final String KNN_REMOTE_BUILD_CLIENT_POLL_INTERVAL = "knn.remote_index_build.client.poll_interval"; |
| 107 | + public static final String KNN_REMOTE_BUILD_CLIENT_TIMEOUT = "knn.remote_index_build.client.timeout"; |
| 108 | + public static final String KNN_REMOTE_BUILD_CLIENT_USERNAME = "knn.remote_index_build.client.username"; |
| 109 | + public static final String KNN_REMOTE_BUILD_CLIENT_PASSWORD = "knn.remote_index_build.client.password"; |
103 | 110 |
|
104 | 111 | /**
|
105 | 112 | * Default setting values
|
@@ -133,6 +140,10 @@ public class KNNSettings {
|
133 | 140 | // TODO: Tune this default value based on benchmarking
|
134 | 141 | public static final ByteSizeValue KNN_INDEX_REMOTE_VECTOR_BUILD_THRESHOLD_DEFAULT_VALUE = new ByteSizeValue(50, ByteSizeUnit.MB);
|
135 | 142 |
|
| 143 | + // TODO: Tune these default values based on benchmarking |
| 144 | + public static final Integer KNN_DEFAULT_REMOTE_BUILD_CLIENT_TIMEOUT_MINUTES = 60; |
| 145 | + public static final Integer KNN_DEFAULT_REMOTE_BUILD_CLIENT_POLL_INTERVAL_SECONDS = 30; |
| 146 | + |
136 | 147 | /**
|
137 | 148 | * Settings Definition
|
138 | 149 | */
|
@@ -409,6 +420,47 @@ public class KNNSettings {
|
409 | 420 | Dynamic,
|
410 | 421 | IndexScope
|
411 | 422 | );
|
| 423 | + /** |
| 424 | + * Remote build service endpoint to be used for remote index build. |
| 425 | + */ |
| 426 | + public static final Setting<String> KNN_REMOTE_BUILD_SERVICE_ENDPOINT_SETTING = Setting.simpleString( |
| 427 | + KNN_REMOTE_BUILD_SERVICE_ENDPOINT, |
| 428 | + NodeScope, |
| 429 | + Dynamic |
| 430 | + ); |
| 431 | + |
| 432 | + /** |
| 433 | + * Time the remote build service client will wait before falling back to CPU index build. |
| 434 | + */ |
| 435 | + public static final Setting<TimeValue> KNN_REMOTE_BUILD_CLIENT_TIMEOUT_SETTING = Setting.timeSetting( |
| 436 | + KNN_REMOTE_BUILD_CLIENT_TIMEOUT, |
| 437 | + TimeValue.timeValueMinutes(KNN_DEFAULT_REMOTE_BUILD_CLIENT_TIMEOUT_MINUTES), |
| 438 | + NodeScope, |
| 439 | + Dynamic |
| 440 | + ); |
| 441 | + |
| 442 | + /** |
| 443 | + * Setting to control how often the remote build service client polls the build service for the status of the job. |
| 444 | + */ |
| 445 | + public static final Setting<TimeValue> KNN_REMOTE_BUILD_CLIENT_POLL_INTERVAL_SETTING = Setting.timeSetting( |
| 446 | + KNN_REMOTE_BUILD_CLIENT_POLL_INTERVAL, |
| 447 | + TimeValue.timeValueSeconds(KNN_DEFAULT_REMOTE_BUILD_CLIENT_POLL_INTERVAL_SECONDS), |
| 448 | + NodeScope, |
| 449 | + Dynamic |
| 450 | + ); |
| 451 | + |
| 452 | + /** |
| 453 | + * Keystore settings for build service HTTP authorization |
| 454 | + */ |
| 455 | + public static final Setting<SecureString> KNN_REMOTE_BUILD_CLIENT_USERNAME_SETTING = SecureSetting.secureString( |
| 456 | + KNN_REMOTE_BUILD_CLIENT_USERNAME, |
| 457 | + null |
| 458 | + ); |
| 459 | + public static final Setting<SecureString> KNN_REMOTE_BUILD_CLIENT_PASSWORD_SETTING = SecureSetting.secureString( |
| 460 | + KNN_REMOTE_BUILD_CLIENT_PASSWORD, |
| 461 | + null |
| 462 | + ); |
| 463 | + |
412 | 464 | /**
|
413 | 465 | * Dynamic settings
|
414 | 466 | */
|
@@ -600,6 +652,26 @@ private Setting<?> getSetting(String key) {
|
600 | 652 | return KNN_INDEX_REMOTE_VECTOR_BUILD_THRESHOLD_SETTING;
|
601 | 653 | }
|
602 | 654 |
|
| 655 | + if (KNN_REMOTE_BUILD_SERVICE_ENDPOINT.equals(key)) { |
| 656 | + return KNN_REMOTE_BUILD_SERVICE_ENDPOINT_SETTING; |
| 657 | + } |
| 658 | + |
| 659 | + if (KNN_REMOTE_BUILD_CLIENT_TIMEOUT.equals(key)) { |
| 660 | + return KNN_REMOTE_BUILD_CLIENT_TIMEOUT_SETTING; |
| 661 | + } |
| 662 | + |
| 663 | + if (KNN_REMOTE_BUILD_CLIENT_POLL_INTERVAL.equals(key)) { |
| 664 | + return KNN_REMOTE_BUILD_CLIENT_POLL_INTERVAL_SETTING; |
| 665 | + } |
| 666 | + |
| 667 | + if (KNN_REMOTE_BUILD_CLIENT_USERNAME.equals(key)) { |
| 668 | + return KNN_REMOTE_BUILD_CLIENT_USERNAME_SETTING; |
| 669 | + } |
| 670 | + |
| 671 | + if (KNN_REMOTE_BUILD_CLIENT_PASSWORD.equals(key)) { |
| 672 | + return KNN_REMOTE_BUILD_CLIENT_PASSWORD_SETTING; |
| 673 | + } |
| 674 | + |
603 | 675 | throw new IllegalArgumentException("Cannot find setting by key [" + key + "]");
|
604 | 676 | }
|
605 | 677 |
|
@@ -628,7 +700,12 @@ public List<Setting<?>> getSettings() {
|
628 | 700 | KNN_DERIVED_SOURCE_ENABLED_SETTING,
|
629 | 701 | KNN_INDEX_REMOTE_VECTOR_BUILD_SETTING,
|
630 | 702 | KNN_REMOTE_VECTOR_REPO_SETTING,
|
631 |
| - KNN_INDEX_REMOTE_VECTOR_BUILD_THRESHOLD_SETTING |
| 703 | + KNN_INDEX_REMOTE_VECTOR_BUILD_THRESHOLD_SETTING, |
| 704 | + KNN_REMOTE_BUILD_SERVICE_ENDPOINT_SETTING, |
| 705 | + KNN_REMOTE_BUILD_CLIENT_TIMEOUT_SETTING, |
| 706 | + KNN_REMOTE_BUILD_CLIENT_POLL_INTERVAL_SETTING, |
| 707 | + KNN_REMOTE_BUILD_CLIENT_USERNAME_SETTING, |
| 708 | + KNN_REMOTE_BUILD_CLIENT_PASSWORD_SETTING |
632 | 709 | );
|
633 | 710 | return Stream.concat(settings.stream(), Stream.concat(getFeatureFlags().stream(), dynamicCacheSettings.values().stream()))
|
634 | 711 | .collect(Collectors.toList());
|
@@ -748,6 +825,14 @@ public static double getCircuitBreakerUnsetPercentage() {
|
748 | 825 | return KNNSettings.state().getSettingValue(KNNSettings.KNN_CIRCUIT_BREAKER_UNSET_PERCENTAGE);
|
749 | 826 | }
|
750 | 827 |
|
| 828 | + /** |
| 829 | + * Gets the remote build service endpoint. |
| 830 | + * @return String representation of the remote build service endpoint URL |
| 831 | + */ |
| 832 | + public static String getRemoteBuildServiceEndpoint() { |
| 833 | + return KNNSettings.state().getSettingValue(KNNSettings.KNN_REMOTE_BUILD_SERVICE_ENDPOINT); |
| 834 | + } |
| 835 | + |
751 | 836 | public static boolean isFaissAVX2Disabled() {
|
752 | 837 | try {
|
753 | 838 | return KNNSettings.state().getSettingValue(KNNSettings.KNN_FAISS_AVX2_DISABLED);
|
|
0 commit comments