|
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;
|
|
31 | 33 |
|
32 | 34 | import java.security.InvalidParameterException;
|
33 | 35 | import java.util.Arrays;
|
| 36 | +import java.util.Collections; |
34 | 37 | import java.util.HashMap;
|
35 | 38 | import java.util.List;
|
36 | 39 | import java.util.Map;
|
@@ -96,6 +99,11 @@ public class KNNSettings {
|
96 | 99 | public static final String KNN_DERIVED_SOURCE_ENABLED = "index.knn.derived_source.enabled";
|
97 | 100 | public static final String KNN_INDEX_REMOTE_VECTOR_BUILD = "index.knn.remote_index_build.enabled";
|
98 | 101 | public static final String KNN_REMOTE_VECTOR_REPO = "knn.remote_index_build.vector_repo";
|
| 102 | + public static final String KNN_REMOTE_BUILD_SERVICE_ENDPOINT = "knn.remote_build_service.endpoint"; |
| 103 | + public static final String KNN_REMOTE_BUILD_SERVICE_POLL_INTERVAL = "knn.remote_build_service.poll_interval"; |
| 104 | + public static final String KNN_REMOTE_BUILD_SERVICE_TIMEOUT = "knn.remote_build_service.timeout"; |
| 105 | + public static final String KNN_REMOTE_BUILD_SERVICE_USERNAME = "knn.remote_build_service.username"; |
| 106 | + public static final String KNN_REMOTE_BUILD_SERVICE_PASSWORD = "knn.remote_build_service.password"; |
99 | 107 |
|
100 | 108 | /**
|
101 | 109 | * Default setting values
|
@@ -127,6 +135,9 @@ public class KNNSettings {
|
127 | 135 | public static final Integer KNN_DEFAULT_QUANTIZATION_STATE_CACHE_EXPIRY_TIME_MINUTES = 60;
|
128 | 136 | public static final boolean KNN_DISK_VECTOR_SHARD_LEVEL_RESCORING_DISABLED_VALUE = false;
|
129 | 137 |
|
| 138 | + public static final Integer KNN_DEFAULT_REMOTE_BUILD_SERVICE_TIMEOUT_MINUTES = 60; |
| 139 | + public static final Integer KNN_DEFAULT_REMOTE_BUILD_SERVICE_POLL_INTERVAL_SECONDS = 30; |
| 140 | + |
130 | 141 | /**
|
131 | 142 | * Settings Definition
|
132 | 143 | */
|
@@ -388,6 +399,49 @@ public class KNNSettings {
|
388 | 399 | */
|
389 | 400 | public static final Setting<String> KNN_REMOTE_VECTOR_REPO_SETTING = Setting.simpleString(KNN_REMOTE_VECTOR_REPO, Dynamic, NodeScope);
|
390 | 401 |
|
| 402 | + /** |
| 403 | + * List of remote build service endpoints to be used by remote build service. If greater than one, the client uses round-robin task assignment when workers are busy. |
| 404 | + */ |
| 405 | + public static final Setting<List<String>> KNN_REMOTE_BUILD_SERVICE_ENDPOINT_SETTING = Setting.listSetting( |
| 406 | + KNN_REMOTE_BUILD_SERVICE_ENDPOINT, |
| 407 | + Collections.emptyList(), |
| 408 | + Function.identity(), |
| 409 | + NodeScope, |
| 410 | + Dynamic |
| 411 | + ); |
| 412 | + |
| 413 | + /** |
| 414 | + * Time the remote build service client will wait before falling back to CPU index build |
| 415 | + */ |
| 416 | + public static final Setting<TimeValue> KNN_REMOTE_BUILD_SERVICE_TIMEOUT_SETTING = Setting.timeSetting( |
| 417 | + KNN_REMOTE_BUILD_SERVICE_TIMEOUT, |
| 418 | + TimeValue.timeValueMinutes(KNN_DEFAULT_REMOTE_BUILD_SERVICE_TIMEOUT_MINUTES), |
| 419 | + NodeScope, |
| 420 | + Dynamic |
| 421 | + ); |
| 422 | + |
| 423 | + /** |
| 424 | + * Setting to control how often the remote build service client polls the build service for the status of the job |
| 425 | + */ |
| 426 | + public static final Setting<TimeValue> KNN_REMOTE_BUILD_SERVICE_POLL_INTERVAL_SETTING = Setting.timeSetting( |
| 427 | + KNN_REMOTE_BUILD_SERVICE_POLL_INTERVAL, |
| 428 | + TimeValue.timeValueSeconds(KNN_DEFAULT_REMOTE_BUILD_SERVICE_POLL_INTERVAL_SECONDS), |
| 429 | + NodeScope, |
| 430 | + Dynamic |
| 431 | + ); |
| 432 | + |
| 433 | + /** |
| 434 | + * Keystore settings for build service HTTP authorization |
| 435 | + */ |
| 436 | + public static final Setting<SecureString> KNN_REMOTE_BUILD_SERVICE_USERNAME_SETTING = SecureSetting.secureString( |
| 437 | + KNN_REMOTE_BUILD_SERVICE_USERNAME, |
| 438 | + null |
| 439 | + ); |
| 440 | + public static final Setting<SecureString> KNN_REMOTE_BUILD_SERVICE_PASSWORD_SETTING = SecureSetting.secureString( |
| 441 | + KNN_REMOTE_BUILD_SERVICE_PASSWORD, |
| 442 | + null |
| 443 | + ); |
| 444 | + |
391 | 445 | /**
|
392 | 446 | * Dynamic settings
|
393 | 447 | */
|
@@ -550,6 +604,26 @@ private Setting<?> getSetting(String key) {
|
550 | 604 | return KNN_REMOTE_VECTOR_REPO_SETTING;
|
551 | 605 | }
|
552 | 606 |
|
| 607 | + if (KNN_REMOTE_BUILD_SERVICE_ENDPOINT.equals(key)) { |
| 608 | + return KNN_REMOTE_BUILD_SERVICE_ENDPOINT_SETTING; |
| 609 | + } |
| 610 | + |
| 611 | + if (KNN_REMOTE_BUILD_SERVICE_TIMEOUT.equals(key)) { |
| 612 | + return KNN_REMOTE_BUILD_SERVICE_TIMEOUT_SETTING; |
| 613 | + } |
| 614 | + |
| 615 | + if (KNN_REMOTE_BUILD_SERVICE_POLL_INTERVAL.equals(key)) { |
| 616 | + return KNN_REMOTE_BUILD_SERVICE_POLL_INTERVAL_SETTING; |
| 617 | + } |
| 618 | + |
| 619 | + if (KNN_REMOTE_BUILD_SERVICE_USERNAME.equals(key)) { |
| 620 | + return KNN_REMOTE_BUILD_SERVICE_USERNAME_SETTING; |
| 621 | + } |
| 622 | + |
| 623 | + if (KNN_REMOTE_BUILD_SERVICE_PASSWORD.equals(key)) { |
| 624 | + return KNN_REMOTE_BUILD_SERVICE_PASSWORD_SETTING; |
| 625 | + } |
| 626 | + |
553 | 627 | throw new IllegalArgumentException("Cannot find setting by key [" + key + "]");
|
554 | 628 | }
|
555 | 629 |
|
@@ -577,7 +651,12 @@ public List<Setting<?>> getSettings() {
|
577 | 651 | KNN_DISK_VECTOR_SHARD_LEVEL_RESCORING_DISABLED_SETTING,
|
578 | 652 | KNN_DERIVED_SOURCE_ENABLED_SETTING,
|
579 | 653 | KNN_INDEX_REMOTE_VECTOR_BUILD_SETTING,
|
580 |
| - KNN_REMOTE_VECTOR_REPO_SETTING |
| 654 | + KNN_REMOTE_VECTOR_REPO_SETTING, |
| 655 | + KNN_REMOTE_BUILD_SERVICE_ENDPOINT_SETTING, |
| 656 | + KNN_REMOTE_BUILD_SERVICE_TIMEOUT_SETTING, |
| 657 | + KNN_REMOTE_BUILD_SERVICE_POLL_INTERVAL_SETTING, |
| 658 | + KNN_REMOTE_BUILD_SERVICE_USERNAME_SETTING, |
| 659 | + KNN_REMOTE_BUILD_SERVICE_PASSWORD_SETTING |
581 | 660 | );
|
582 | 661 | return Stream.concat(settings.stream(), Stream.concat(getFeatureFlags().stream(), dynamicCacheSettings.values().stream()))
|
583 | 662 | .collect(Collectors.toList());
|
|
0 commit comments