-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Use LinkedProjectConfig in RemoteClusterService
#133266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JeremyDahlgren
merged 32 commits into
elastic:main
from
JeremyDahlgren:es-12656-linked-proj-cfg
Aug 27, 2025
Merged
Changes from 4 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
7cd7ae3
Use LinkedProjectConfig record in RemoteClusterService
JeremyDahlgren 26c177a
[CI] Auto commit changes from spotless
76f6a09
Merge branch 'main' into es-12656-linked-proj-cfg
JeremyDahlgren 9d1e8ae
Merge branch 'main' into es-12656-linked-proj-cfg
JeremyDahlgren f720699
Fix merged settings, check linked project alias
JeremyDahlgren a38fbfe
Merge branch 'main' into es-12656-linked-proj-cfg
JeremyDahlgren 62b42a1
[CI] Auto commit changes from spotless
92adad2
Merge branch 'main' into es-12656-linked-proj-cfg
JeremyDahlgren 46caac4
Split config into sniff and proxy types
JeremyDahlgren e287fc8
Merge branch 'main' into es-12656-linked-proj-cfg
JeremyDahlgren 7c23847
Merge branch 'main' into es-12656-linked-proj-cfg
JeremyDahlgren c2d3b15
Add more validations and tests
JeremyDahlgren aa17734
Merge branch 'main' into es-12656-linked-proj-cfg
JeremyDahlgren 7db5da7
[CI] Auto commit changes from spotless
3bb6cc0
Rename buildConnectionStrategy to buildRemoteConnectionStrategy
JeremyDahlgren 607a247
LinkedProjectConfig can be sealed
JeremyDahlgren 73dda5c
Do not use builder in RemoteConnectionEnabled.isConnectionEnabled()
JeremyDahlgren 98b1fb2
Rename LinkedProjectConfig Sniff and Proxy record types
JeremyDahlgren 5666b68
Restore package-private access level for ConnectionStrategy enum
JeremyDahlgren db1a1af
Use -randomNonNegativeInt() in assertChecksGreaterThanZero()
JeremyDahlgren 9cdedbd
Reduce visibility of some methods to private
JeremyDahlgren 21a3685
add maxNumConnections and proxyAddress to LinkedProjectConfig interface
JeremyDahlgren 0725cb3
Reduce changes in RemoteConnectionStrategyTests
JeremyDahlgren fb0e431
Refactor LinkedProjectConfig.Builder into concrete subclasses
JeremyDahlgren a545f12
Refactor default values
JeremyDahlgren 7c079ad
link ticket for eliminating leniency in builders
JeremyDahlgren 18d2917
[CI] Auto commit changes from spotless
939cde6
Fix failing TimeValue equalTo()
JeremyDahlgren d1fc308
Merge branch 'main' into es-12656-linked-proj-cfg
JeremyDahlgren dd81943
Remove unnecessary builder base class param
JeremyDahlgren bbd8aef
Merge branch 'main' into es-12656-linked-proj-cfg
JeremyDahlgren c513311
Merge branch 'main' into es-12656-linked-proj-cfg
JeremyDahlgren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
165 changes: 165 additions & 0 deletions
165
server/src/main/java/org/elasticsearch/transport/LinkedProjectConfig.java
This file contains hidden or 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,165 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.transport; | ||
|
|
||
| import org.elasticsearch.cluster.metadata.ProjectId; | ||
| import org.elasticsearch.cluster.node.DiscoveryNode; | ||
| import org.elasticsearch.core.TimeValue; | ||
|
|
||
| import java.util.List; | ||
| import java.util.function.Predicate; | ||
|
|
||
| import static org.elasticsearch.transport.RemoteConnectionStrategy.ConnectionStrategy; | ||
|
|
||
| public record LinkedProjectConfig( | ||
| ProjectId originProjectId, | ||
| ProjectId linkedProjectId, | ||
| String linkedProjectAlias, | ||
| TimeValue transportConnectTimeout, | ||
| Compression.Enabled connectionCompression, | ||
| Compression.Scheme connectionCompressionScheme, | ||
| TimeValue clusterPingSchedule, | ||
| TimeValue initialConnectionTimeout, | ||
| boolean skipUnavailable, | ||
| ConnectionStrategy connectionStrategy, | ||
| int maxNumConnections, | ||
| String proxyAddress, | ||
| String proxyServerName, | ||
| Predicate<DiscoveryNode> sniffNodePredicate, | ||
| List<String> sniffSeedNodes, | ||
| int maxPendingConnectionListeners // only used in tests | ||
| ) { | ||
|
|
||
| public static Builder builder() { | ||
| return new Builder(); | ||
| } | ||
|
|
||
| public static class Builder { | ||
| private ProjectId originProjectId; | ||
| private ProjectId linkedProjectId; | ||
| private String linkedProjectAlias; | ||
| private TimeValue transportConnectTimeout; | ||
| private Compression.Enabled connectionCompression; | ||
| private Compression.Scheme connectionCompressionScheme; | ||
| private TimeValue clusterPingSchedule; | ||
| private TimeValue initialConnectionTimeout; | ||
| private boolean skipUnavailable; | ||
| private ConnectionStrategy connectionStrategy; | ||
| private int maxNumConnections; | ||
| private String proxyAddress; | ||
| private String proxyServerName; | ||
| private Predicate<DiscoveryNode> sniffNodePredicate; | ||
| private List<String> sniffSeedNodes; | ||
| private int maxPendingConnectionListeners = 1000; | ||
|
|
||
| private Builder() {} | ||
|
|
||
| public Builder originProjectId(ProjectId originProjectId) { | ||
| this.originProjectId = originProjectId; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder linkedProjectId(ProjectId linkedProjectId) { | ||
| this.linkedProjectId = linkedProjectId; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder linkedProjectAlias(String linkedProjectAlias) { | ||
| this.linkedProjectAlias = linkedProjectAlias; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder transportConnectTimeout(TimeValue transportConnectTimeout) { | ||
| this.transportConnectTimeout = transportConnectTimeout; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder connectionCompression(Compression.Enabled connectionCompression) { | ||
| this.connectionCompression = connectionCompression; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder connectionCompressionScheme(Compression.Scheme connectionCompressionScheme) { | ||
| this.connectionCompressionScheme = connectionCompressionScheme; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder clusterPingSchedule(TimeValue clusterPingSchedule) { | ||
| this.clusterPingSchedule = clusterPingSchedule; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder initialConnectionTimeout(TimeValue initialConnectionTimeout) { | ||
| this.initialConnectionTimeout = initialConnectionTimeout; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder skipUnavailable(boolean skipUnavailable) { | ||
| this.skipUnavailable = skipUnavailable; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder connectionStrategy(ConnectionStrategy connectionStrategy) { | ||
| this.connectionStrategy = connectionStrategy; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder maxNumConnections(int maxNumConnections) { | ||
| this.maxNumConnections = maxNumConnections; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder proxyAddress(String proxyAddress) { | ||
| this.proxyAddress = proxyAddress; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder proxyServerName(String proxyServerName) { | ||
| this.proxyServerName = proxyServerName; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder sniffNodePredicate(Predicate<DiscoveryNode> sniffNodePredicate) { | ||
| this.sniffNodePredicate = sniffNodePredicate; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder sniffSeedNodes(List<String> sniffSeedNodes) { | ||
| this.sniffSeedNodes = sniffSeedNodes; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder maxPendingConnectionListeners(int maxPendingConnectionListeners) { | ||
| this.maxPendingConnectionListeners = maxPendingConnectionListeners; | ||
| return this; | ||
| } | ||
|
|
||
| public LinkedProjectConfig build() { | ||
| return new LinkedProjectConfig( | ||
| originProjectId, | ||
| linkedProjectId, | ||
| linkedProjectAlias, | ||
| transportConnectTimeout, | ||
| connectionCompression, | ||
| connectionCompressionScheme, | ||
| clusterPingSchedule, | ||
| initialConnectionTimeout, | ||
| skipUnavailable, | ||
| connectionStrategy, | ||
| maxNumConnections, | ||
| proxyAddress, | ||
| proxyServerName, | ||
| sniffNodePredicate, | ||
| sniffSeedNodes, | ||
| maxPendingConnectionListeners | ||
| ); | ||
| } | ||
ywangd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.