Skip to content

Commit b12ccca

Browse files
committed
Merge remote-tracking branch 'upstream/main' into fix_yaml_test
2 parents 0c444a5 + 9d918e6 commit b12ccca

File tree

84 files changed

+2589
-562
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2589
-562
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1212
- Add a mapper for context aware segments grouping criteria ([#19233](https://github.com/opensearch-project/OpenSearch/pull/19233))
1313
- Return full error for GRPC error response ([#19568](https://github.com/opensearch-project/OpenSearch/pull/19568))
1414
- Add pluggable gRPC interceptors with explicit ordering([#19005](https://github.com/opensearch-project/OpenSearch/pull/19005))
15+
- Add BindableServices extension point to transport-grpc-spi ([#19304](https://github.com/opensearch-project/OpenSearch/pull/19304))
1516
- Add metrics for the merged segment warmer feature ([#18929](https://github.com/opensearch-project/OpenSearch/pull/18929))
1617
- Add pointer based lag metric in pull-based ingestion ([#19635](https://github.com/opensearch-project/OpenSearch/pull/19635))
1718
- Introduced internal API for retrieving metadata about requested indices from transport actions ([#18523](https://github.com/opensearch-project/OpenSearch/pull/18523))
19+
- Add cluster defaults for merge autoThrottle, maxMergeThreads, and maxMergeCount; Add segment size filter to the merged segment warmer ([#19629](https://github.com/opensearch-project/OpenSearch/pull/19629))
1820

1921
### Changed
2022
- Faster `terms` query creation for `keyword` field with index and docValues enabled ([#19350](https://github.com/opensearch-project/OpenSearch/pull/19350))
@@ -26,15 +28,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2628
- Wrap checked exceptions in painless.DefBootstrap to support JDK-25 ([#19706](https://github.com/opensearch-project/OpenSearch/pull/19706))
2729
- Refactor the ThreadPoolStats.Stats class to use the Builder pattern instead of constructors ([#19317](https://github.com/opensearch-project/OpenSearch/pull/19317))
2830
- Refactor the IndexingStats.Stats class to use the Builder pattern instead of constructors ([#19306](https://github.com/opensearch-project/OpenSearch/pull/19306))
29-
31+
- Remove FeatureFlag.MERGED_SEGMENT_WARMER_EXPERIMENTAL_FLAG. ([#19715](https://github.com/opensearch-project/OpenSearch/pull/19715))
32+
-
3033
### Fixed
3134
- Fix Allocation and Rebalance Constraints of WeightFunction are incorrectly reset ([#19012](https://github.com/opensearch-project/OpenSearch/pull/19012))
3235
- Fix flaky test FieldDataLoadingIT.testIndicesFieldDataCacheSizeSetting ([#19571](https://github.com/opensearch-project/OpenSearch/pull/19571))
36+
- Fix case-insensitive wildcard + aggregation query crash ([#19489](https://github.com/opensearch-project/OpenSearch/pull/19489))
3337
- Avoid primary shard failure caused by merged segment warmer exceptions ([#19436](https://github.com/opensearch-project/OpenSearch/pull/19436))
3438
- Fix pull-based ingestion out-of-bounds offset scenarios and remove persisted offsets ([#19607](https://github.com/opensearch-project/OpenSearch/pull/19607))
3539
- Fix issue with updating core with a patch number other than 0 ([#19377](https://github.com/opensearch-project/OpenSearch/pull/19377))
3640
- [Java Agent] Allow JRT protocol URLs in protection domain extraction ([#19683](https://github.com/opensearch-project/OpenSearch/pull/19683))
3741
- Fix potential concurrent modification exception when updating allocation filters ([#19701])(https://github.com/opensearch-project/OpenSearch/pull/19701))
42+
- Fix file-based ingestion consumer to handle start point beyond max line number([#19757])(https://github.com/opensearch-project/OpenSearch/pull/19757))
3843

3944
### Dependencies
4045
- Update to Gradle 9.1 ([#19575](https://github.com/opensearch-project/OpenSearch/pull/19575))

modules/transport-grpc/spi/README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The `transport-grpc-spi` module enables plugin developers to:
99
- Extend gRPC protocol buffer handling
1010
- Register custom query types that can be processed via gRPC
1111
- Register gRPC interceptors with explicit ordering
12+
- Register `BindableService` implementation to the gRPC transport
1213

1314
## Key Components
1415

@@ -47,6 +48,10 @@ public interface GrpcInterceptorProvider {
4748
}
4849
```
4950

51+
### GrpcServiceFactory
52+
53+
Interface for providing a `BindableService` factory to be registered on the grpc transport.
54+
5055
## Usage for Plugin Developers
5156

5257
### 1. Add Dependency
@@ -63,7 +68,7 @@ dependencies {
6368

6469
### 2. Declare Extension in build.gradle
6570

66-
In your `build.gradle`, declare that your plugin extends `transport-grpc`. This automatically adds the `extended.plugins=transport-grpc` entry to the auto-generated `plugin-descriptor.properties` file: :
71+
In your `build.gradle`, declare that your plugin extends `transport-grpc`. This automatically adds the `extended.plugins=transport-grpc` entry to the auto-generated `plugin-descriptor.properties` file:
6772

6873
```groovy
6974
opensearchplugin {
@@ -81,20 +86,26 @@ opensearchplugin {
8186

8287
Create a service file denoting your plugin's implementation of a service interface.
8388

84-
For QueryBuilderProtoConverter implementations:
89+
For `QueryBuilderProtoConverter` implementations:
8590
`src/main/resources/META-INF/services/org.opensearch.transport.grpc.spi.QueryBuilderProtoConverter`:
8691

8792
```
8893
org.opensearch.mypackage.MyCustomQueryConverter
8994
```
9095

91-
For `GrpcInterceptorProvider` implementations: `src/main/resources/META-INF/services/org.opensearch.transport.grpc.spi.GrpcInterceptorProvider`:
96+
For `GrpcInterceptorProvider` implementations:
97+
`src/main/resources/META-INF/services/org.opensearch.transport.grpc.spi.GrpcInterceptorProvider`:
9298

9399
```
94100
org.opensearch.mypackage.SampleInterceptorProvider
95101
```
96102

103+
For `GrpcServiceFactory` implementations:
104+
`src/main/resources/META-INF/services/org.opensearch.transport.grpc.spi.GrpcServiceFactory`:
97105

106+
```
107+
org.opensearch.mypackage.MyCustomGrpcServiceFactory
108+
```
98109

99110
## QueryBuilderProtoConverter
100111
### 1. Implement Custom Query Converter
@@ -383,3 +394,25 @@ Each interceptor must have a unique order value. If duplicate order values are d
383394
IllegalArgumentException: Multiple gRPC interceptors have the same order value: 10.
384395
Each interceptor must have a unique order value.
385396
```
397+
398+
## GrpcServiceFactory
399+
400+
### 1. Implement Custom Query Converter
401+
402+
Several node resources are exposed to a `GrpcServiceFactory` for use within services such as client, settings, and thread pools.
403+
A plugin's `GrpcServiceFactory` implementation will be discovered through the SPI registration file and registered on the gRPC transport.
404+
405+
```java
406+
public static class MockServiceProvider implements GrpcServiceFactory {
407+
408+
@Override
409+
public String plugin() {
410+
return "MockExtendingPlugin";
411+
}
412+
413+
@Override
414+
public List<BindableService> build() {
415+
return List.of(new MockChannelzService());
416+
}
417+
}
418+
```

modules/transport-grpc/spi/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ dependencies {
1818
implementation project(":server")
1919
implementation "org.opensearch:protobufs:${versions.opensearchprotobufs}"
2020
implementation "io.grpc:grpc-api:${versions.grpc}"
21-
2221
testImplementation project(":test:framework")
22+
testImplementation "io.grpc:grpc-services:${versions.grpc}"
23+
testImplementation "io.grpc:grpc-stub:${versions.grpc}"
2324
}
2425

2526
thirdPartyAudit {
2627
ignoreMissingClasses(
28+
'com.google.common.collect.Maps',
29+
'com.google.common.collect.Sets',
2730
'com.google.common.base.Joiner',
2831
'com.google.common.base.MoreObjects',
2932
'com.google.common.base.MoreObjects$ToStringHelper',
@@ -33,8 +36,6 @@ thirdPartyAudit {
3336
'com.google.common.base.Throwables',
3437
'com.google.common.collect.ImmutableList',
3538
'com.google.common.collect.ImmutableMap',
36-
'com.google.common.collect.Maps',
37-
'com.google.common.collect.Sets',
3839
'com.google.common.io.BaseEncoding',
3940
'com.google.common.io.ByteStreams',
4041
'com.google.common.util.concurrent.ListenableFuture'
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.transport.grpc.spi;
10+
11+
import org.opensearch.common.settings.ClusterSettings;
12+
import org.opensearch.common.settings.Settings;
13+
import org.opensearch.threadpool.ThreadPool;
14+
import org.opensearch.transport.client.Client;
15+
16+
import java.util.List;
17+
18+
import io.grpc.BindableService;
19+
20+
/**
21+
* Extension point for plugins to add a BindableService list to the grpc-transport.
22+
* Provides init methods to allow service definitions access to OpenSearch clients, settings, ect.
23+
*/
24+
public interface GrpcServiceFactory {
25+
26+
/**
27+
* For logging.
28+
* @return owning plugin identifier for service validation.
29+
*/
30+
String plugin();
31+
32+
/**
33+
* Provide client for executing requests on the cluster.
34+
* @param client for use in services.
35+
* @return chaining.
36+
*/
37+
default GrpcServiceFactory initClient(Client client) {
38+
return this;
39+
}
40+
41+
/**
42+
* Provide visibility into node settings.
43+
* @param settings for use in services.
44+
* @return chaining.
45+
*/
46+
default GrpcServiceFactory initSettings(Settings settings) {
47+
return this;
48+
}
49+
50+
/**
51+
* Provide visibility into cluster settings.
52+
* @param clusterSettings for use in services.
53+
* @return chaining.
54+
*/
55+
default GrpcServiceFactory initClusterSettings(ClusterSettings clusterSettings) {
56+
return this;
57+
}
58+
59+
/**
60+
* Provide access to thread pool.
61+
* @param threadPool for use in services.
62+
* @return chaining.
63+
*/
64+
default GrpcServiceFactory initThreadPool(ThreadPool threadPool) {
65+
return this;
66+
}
67+
68+
/**
69+
* Build gRPC services.
70+
* @return BindableService.
71+
*/
72+
List<BindableService> build();
73+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.transport.grpc.spi;
10+
11+
import org.opensearch.test.OpenSearchTestCase;
12+
import org.opensearch.transport.client.Client;
13+
14+
import java.util.List;
15+
16+
import io.grpc.BindableService;
17+
import io.grpc.channelz.v1.ChannelzGrpc;
18+
import io.grpc.channelz.v1.GetChannelRequest;
19+
import io.grpc.channelz.v1.GetChannelResponse;
20+
import io.grpc.stub.StreamObserver;
21+
22+
import static org.mockito.Mockito.mock;
23+
24+
public class GrpcServiceFactoryTests extends OpenSearchTestCase {
25+
26+
private static class MockChannelzService extends ChannelzGrpc.ChannelzImplBase {
27+
@Override
28+
public void getChannel(GetChannelRequest request, StreamObserver<GetChannelResponse> responseObserver) {
29+
GetChannelResponse response = GetChannelResponse.newBuilder().build();
30+
responseObserver.onNext(response);
31+
responseObserver.onCompleted();
32+
}
33+
}
34+
35+
public static class MockServiceProvider implements GrpcServiceFactory {
36+
private Client client;
37+
38+
public MockServiceProvider() {}
39+
40+
@Override
41+
public String plugin() {
42+
return "MockTestPlugin";
43+
}
44+
45+
@Override
46+
public GrpcServiceFactory initClient(Client client) {
47+
this.client = client;
48+
return this;
49+
}
50+
51+
@Override
52+
public List<BindableService> build() {
53+
return List.of(new MockChannelzService());
54+
}
55+
56+
public Client getClient() {
57+
return client;
58+
}
59+
}
60+
61+
public void testGrpcServiceFactoryPlugin() {
62+
MockServiceProvider factory = new MockServiceProvider();
63+
assertEquals("MockTestPlugin", factory.plugin());
64+
}
65+
66+
public void testGrpcServiceFactoryBuild() {
67+
MockServiceProvider factory = new MockServiceProvider();
68+
List<BindableService> services = factory.build();
69+
70+
assertNotNull(services);
71+
assertEquals(1, services.size());
72+
assertTrue(services.get(0) instanceof MockChannelzService);
73+
}
74+
75+
public void testGrpcServiceFactoryInitClient() {
76+
MockServiceProvider factory = new MockServiceProvider();
77+
Client mockClient = mock(Client.class);
78+
79+
GrpcServiceFactory result = factory.initClient(mockClient);
80+
81+
assertSame(factory, result);
82+
assertSame(mockClient, factory.getClient());
83+
}
84+
}

0 commit comments

Comments
 (0)