Skip to content
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

Cat Nodes API with Protobuf #9097

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9be33d7
Adding BaseWriteable and ProtobufWriteable
VachaShah Apr 21, 2023
0034b0a
Adding proto messages for TaskId and TaskResourceStats
VachaShah Apr 21, 2023
cdb6806
Adding Task related classes with protobuf integration
VachaShah Apr 21, 2023
c8c2f53
Adding ProtobufStreamInput and ProtobufStreamOutput for additional st…
VachaShah Apr 21, 2023
a2be2fa
Adding TransportMessage and TransportRequest classes with protobuf in…
VachaShah Apr 22, 2023
c0bbf92
Fixing build and precommit
VachaShah Apr 25, 2023
551fe82
Adding protobuf integrations for client, transport, request
VachaShah May 8, 2023
a1ab589
Fixing build and integrating protobuf for classes related to RestNode…
VachaShah May 25, 2023
8e57034
Fixing node crashes
VachaShah Jun 21, 2023
a5ce258
Fixes
VachaShah Jun 21, 2023
0d76b3b
Fixing nodes api response for protobuf
VachaShah Jun 30, 2023
e6f6190
ProtobufClusterState to ClusterState
VachaShah Jul 10, 2023
b94a49e
Fixing cluster manager x to *
VachaShah Jul 10, 2023
cb320c7
Eliminating a lot of protobuf classes to merge with original classes …
VachaShah Jul 11, 2023
13c4568
This fixes the single node calls after the refactoring in the previou…
VachaShah Jul 11, 2023
b659260
Trying serialization and deserialization across nodes
VachaShah Jul 14, 2023
e96f3e0
Debugging and fixing compile errors
VachaShah Jul 17, 2023
496cdbb
Trying proto message serde across nodes with tests and example request
VachaShah Jul 19, 2023
8aab04b
Changes for multi node - working on single and multi node
VachaShah Jul 28, 2023
b583179
Calculating time
VachaShah Jul 28, 2023
515110a
Removing sysouts
VachaShah Jul 28, 2023
f94f165
Cleaning up code
VachaShah Jul 31, 2023
35d8906
Ignoring proto generated classes
VachaShah Jul 31, 2023
d511930
Cleaning up more code
VachaShah Aug 1, 2023
562e6c3
Cleaning up CodedInputStream, CodedOutputStream and TryWriteable
VachaShah Aug 1, 2023
d5f3a0e
Performance improvements
VachaShah Aug 2, 2023
2f423b9
Fixing compile errors after merging with main
VachaShah Aug 2, 2023
eeeb40f
Renaming proto messages and related classes
VachaShah Aug 2, 2023
8f5a327
Fixing precommit failures
VachaShah Aug 2, 2023
d409e71
Cleaning up code
VachaShah Aug 3, 2023
967d26b
Improvements
VachaShah Aug 3, 2023
0e9a86e
[Refactor] Network and Transport common classes to Libraries (#9073)
nknize Aug 2, 2023
d73fd6a
[Snapshot Interop] Add Logic in Lock Manager to cleanup stale data po…
harishbhakuni Aug 3, 2023
f3a17fc
Avoid duplicate indexing in case of SegRep enabled indices' translog …
gbbafna Aug 3, 2023
64a7457
Fix flaky test testStatsOnShardUnassigned in RemoteStoreStatsIT (#9057)
ashking94 Aug 3, 2023
6030039
Fix test testDropPrimaryDuringReplication and clean up ReplicationChe…
mch2 Aug 3, 2023
46aaea2
Getting latest changes from main
VachaShah Aug 3, 2023
c05f5aa
Merge branch 'main' into poc-cat-nodes-protobuf
VachaShah Aug 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ testfixtures_shared/
.ci/jobs/

# build files generated
doc-tools/missing-doclet/bin/
doc-tools/missing-doclet/bin/
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.core.common.io.stream;

import java.io.IOException;
import java.io.OutputStream;

/**
* Implementers can be written to write to output and read from input using Protobuf.
*
* @opensearch.internal
*/
public interface ProtobufWriteable {

/**
* Write this into the stream output.
*/
public void writeTo(OutputStream out) throws IOException;

/**
* Reference to a method that can write some object to a {@link OutputStream}.
* Most classes should implement {@link ProtobufWriteable} and the {@link ProtobufWriteable#writeTo(OutputStream)} method should <em>use</em>
* {@link OutputStream} methods directly or this indirectly:
* <pre><code>
* public void writeTo(OutputStream out) throws IOException {
* out.writeVInt(someValue);
* }
* </code></pre>
*/
@FunctionalInterface
interface Writer<V> {

/**
* Write {@code V}-type {@code value} to the {@code out}put stream.
*
* @param out Output to write the {@code value} too
* @param value The value to add
*/
void write(OutputStream out, V value) throws IOException;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its strange than the writer is via an OutputStream, but the reader isn't a symetrical version that uses InputStream. Can we align the types to be consistant, be it bytes[] or *Stream?


}

/**
* Reference to a method that can read some object from a stream. By convention this is a constructor that takes
* {@linkplain byte[]} as an argument for most classes and a static method for things like enums.
* <pre><code>
* public MyClass(final byte[] in) throws IOException {
* this.someValue = in.readVInt();
* }
* </code></pre>
*/
@FunctionalInterface
interface Reader<V> {

/**
* Read {@code V}-type value from a stream.
*
* @param in Input to read the value from
*/
V read(byte[] in) throws IOException;

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.core.transport;

import org.opensearch.core.common.io.stream.ProtobufWriteable;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.Writeable;
import org.opensearch.core.common.transport.TransportAddress;
Expand All @@ -41,7 +42,7 @@
*
* @opensearch.internal
*/
public abstract class TransportMessage implements Writeable {
public abstract class TransportMessage implements Writeable, ProtobufWriteable {

private TransportAddress remoteAddress;

Expand All @@ -63,4 +64,10 @@ public TransportMessage() {}
* currently a no-op
*/
public TransportMessage(StreamInput in) {}

/**
* Constructs a new transport message with the data from the {@link byte[]}. This is
* currently a no-op
*/
public TransportMessage(byte[] in) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we avoid adding this change by reusing the existing StreamInput?

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.opensearch.core.common.io.stream.StreamOutput;

import java.io.IOException;
import java.io.OutputStream;

/**
* Response over the transport interface
Expand All @@ -58,6 +59,21 @@ public TransportResponse(StreamInput in) throws IOException {
super(in);
}

/**
* Constructs a new transport response with the data from the {@link StreamInput}. This is
* currently a no-op. However, this exists to allow extenders to call <code>super(in)</code>
* so that reading can mirror writing where we often call <code>super.writeTo(out)</code>.
*/
public TransportResponse(byte[] in) throws IOException {
super(in);
}

@Override
public void writeTo(OutputStream out) throws IOException {}

@Override
public void writeTo(StreamOutput out) throws IOException {}

/**
* Empty transport response
*
Expand All @@ -73,5 +89,8 @@ public String toString() {

@Override
public void writeTo(StreamOutput out) throws IOException {}

@Override
public void writeTo(OutputStream out) throws IOException {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ final class Netty4MessageChannelHandler extends ChannelDuplexHandler {
threadPool::relativeTimeInMillis,
transport.getInflightBreaker(),
requestHandlers::getHandler,
transport::inboundMessage
transport::inboundMessage,
transport::inboundMessageProtobuf
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void testTypeParser_parse_fromCorrelationParamsContext_InvalidVectorSimil

/**
* test parseCreateField in CorrelationVectorFieldMapper
* @throws IOException
* @throws IOException io exception
*/
public void testCorrelationVectorFieldMapper_parseCreateField() throws IOException {
String fieldName = "test-field-name";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public void testDoToQueryInvalidFieldType() {

/**
* test serialization of Correlation Query Builder
* @throws Exception
* @throws Exception exception
*/
public void testSerialization() throws Exception {
assertSerialization(Optional.empty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public TcpReadWriteHandler(NioTcpChannel channel, PageCacheRecycler recycler, Tc
threadPool::relativeTimeInMillis,
breaker,
requestHandlers::getHandler,
transport::inboundMessage
transport::inboundMessage,
transport::inboundMessageProtobuf
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public void testIndexing() throws IOException, ParseException {
* This test verifies that during rolling upgrades the segment replication does not break when replica shards can
* be running on older codec versions.
*
* @throws Exception
* @throws Exception exception
*/
@AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/8322")
public void testIndexingWithSegRep() throws Exception {
Expand Down
2 changes: 2 additions & 0 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ tasks.named("licenseHeaders").configure {
excludes << 'org/opensearch/client/documentation/placeholder.txt'
// Ignore for protobuf generated code
excludes << 'org/opensearch/extensions/proto/*'
excludes << 'org/opensearch/tasks/proto/*'
excludes << 'org/opensearch/server/proto/*'
}

tasks.test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,12 @@ public String executor() {
public TestResponse read(StreamInput in) throws IOException {
return new TestResponse(in);
}

@Override
public TestResponse read(byte[] in) throws IOException {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'read'");
}
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,10 @@ public Response read(StreamInput in) throws IOException {
public String toString() {
return super.toString() + "/" + listener;
}

@Override
public Response read(byte[] in) throws IOException {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'read'");
}
}
Loading
Loading