-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enh 37496193 - [37496162->24.09.2] General refactoring and hardening …
…of the gRPC APIs (merge ce/main -> ce/24.09 113641) [git-p4: depot-paths = "//dev/coherence-ce/release/coherence-ce-v24.09/": change = 113642]
- Loading branch information
1 parent
e856cf5
commit e15767a
Showing
69 changed files
with
2,802 additions
and
365 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
39 changes: 39 additions & 0 deletions
39
...src/main/java/com/tangosol/coherence/component/net/extend/message/GrpcMessageWrapper.java
This file contains 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,39 @@ | ||
/* | ||
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. | ||
* | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* https://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
package com.tangosol.coherence.component.net.extend.message; | ||
|
||
import com.google.protobuf.Any; | ||
|
||
import com.tangosol.coherence.component.net.extend.message.response.GrpcResponse; | ||
import com.tangosol.io.Serializer; | ||
|
||
import com.tangosol.net.messaging.Message; | ||
|
||
/** | ||
* A {@link Message} implementation that wraps a protobuf message. | ||
* | ||
* @author Jonathan Knight 2025.01.25 | ||
*/ | ||
public interface GrpcMessageWrapper | ||
extends Message | ||
{ | ||
/** | ||
* Set the wrapped protobuf message. | ||
* | ||
* @param any the wrapped protobuf message | ||
* @param serializer the serializer to deserialize binary payloads | ||
*/ | ||
void setProtoMessage(Any any, Serializer serializer); | ||
|
||
/** | ||
* Return the message response. | ||
* | ||
* @return the message response | ||
*/ | ||
GrpcResponse getResponse(); | ||
} |
129 changes: 129 additions & 0 deletions
129
.../main/java/com/tangosol/coherence/component/net/extend/message/response/GrpcResponse.java
This file contains 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,129 @@ | ||
/* | ||
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. | ||
* | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* https://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
package com.tangosol.coherence.component.net.extend.message.response; | ||
|
||
import com.google.protobuf.Message; | ||
|
||
import com.tangosol.coherence.component.net.extend.message.Response; | ||
|
||
import com.tangosol.io.Serializer; | ||
|
||
import io.grpc.stub.StreamObserver; | ||
|
||
/** | ||
* A gRPC response message. | ||
* | ||
* @author Jonathan Knight 2025.01.25 | ||
*/ | ||
public abstract class GrpcResponse | ||
extends Response | ||
{ | ||
/** | ||
* Default constructor. | ||
*/ | ||
protected GrpcResponse() | ||
{ | ||
super(null, null, true); | ||
} | ||
|
||
/** | ||
* Set the proxy identifier for this message. | ||
* | ||
* @param proxyId the proxy identifier for this message | ||
*/ | ||
public void setProxyId(int proxyId) | ||
{ | ||
m_nProxyId = proxyId; | ||
} | ||
|
||
/** | ||
* Return the proxy identifier for this message. | ||
* | ||
* @return the proxy identifier for this message | ||
*/ | ||
public int getProxyId() | ||
{ | ||
return m_nProxyId; | ||
} | ||
|
||
/** | ||
* Set the {@link StreamObserver} to send responses to. | ||
* | ||
* @param observer the {@link StreamObserver} to send responses to | ||
*/ | ||
public void setStreamObserver(StreamObserver<? extends Message> observer) | ||
{ | ||
m_observer = observer; | ||
} | ||
|
||
/** | ||
* Return the {@link StreamObserver} to send responses to. | ||
* | ||
* @return the {@link StreamObserver} to send responses to | ||
*/ | ||
public StreamObserver<? extends Message> getStreamObserver() | ||
{ | ||
return m_observer; | ||
} | ||
|
||
/** | ||
* Set the {@link Serializer}. | ||
* | ||
* @param serializer the {@link Serializer} | ||
*/ | ||
public void setSerializer(Serializer serializer) | ||
{ | ||
m_serializer = serializer; | ||
} | ||
|
||
/** | ||
* Return the {@link Serializer}. | ||
* | ||
* @return the {@link Serializer} | ||
*/ | ||
public Serializer getSerializer() | ||
{ | ||
return m_serializer; | ||
} | ||
|
||
/** | ||
* Return {@code true} if the {@link StreamObserver} should be | ||
* completed after returning the response. | ||
* | ||
* @return {@code true} if the {@link StreamObserver} should be | ||
* completed after returning the response | ||
*/ | ||
public boolean completeStream() | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Create a protobuf response message. | ||
* | ||
* @return a protobuf response message | ||
*/ | ||
public abstract Message getProtoResponse(); | ||
|
||
// ----- data members --------------------------------------------------- | ||
|
||
/** | ||
* The proxy identifier. | ||
*/ | ||
protected int m_nProxyId; | ||
|
||
/** | ||
* The {@link Serializer}. | ||
*/ | ||
protected Serializer m_serializer; | ||
|
||
/** | ||
* The {@link StreamObserver} to send responses to. | ||
*/ | ||
protected StreamObserver<? extends Message> m_observer; | ||
} |
60 changes: 60 additions & 0 deletions
60
...n/java/com/tangosol/coherence/component/net/extend/messageFactory/GrpcMessageFactory.java
This file contains 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,60 @@ | ||
/* | ||
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. | ||
* | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* https://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
package com.tangosol.coherence.component.net.extend.messageFactory; | ||
|
||
import com.google.protobuf.Message; | ||
|
||
import com.tangosol.coherence.component.net.extend.message.GrpcMessageWrapper; | ||
|
||
import com.tangosol.coherence.component.net.extend.message.response.GrpcResponse; | ||
|
||
import com.tangosol.io.Serializer; | ||
|
||
import com.tangosol.net.messaging.Protocol; | ||
|
||
/** | ||
* A {@link Protocol.MessageFactory} that can also produce messages | ||
* from Protobuf requests. | ||
* | ||
* @author Jonathan Knight 2025.01.25 | ||
*/ | ||
public interface GrpcMessageFactory<Req extends Message, Resp extends Message> | ||
extends Protocol.MessageFactory | ||
{ | ||
/** | ||
* Create a {@link GrpcMessageWrapper} from a Protobuf {@link Message}. | ||
* | ||
* @param request the {@link Message} to create the {@link GrpcMessageWrapper} from | ||
* @param serializer the {@link Serializer} to use to deserialize binary payloads | ||
* @param <M> the expected type of the message to return | ||
* | ||
* @return a {@link GrpcMessageWrapper} created from a Protobuf {@link Message} | ||
*/ | ||
<M extends GrpcMessageWrapper> M createRequestMessage(Req request, Serializer serializer); | ||
|
||
/** | ||
* Create a response {@link Message} that will be wrapped in a proxy response | ||
* before being sent to the response stream observer. | ||
* | ||
* @param response the {@link GrpcResponse} to convert to a {@link Message} | ||
* | ||
* @return the response {@link Message} | ||
*/ | ||
Resp createResponse(GrpcResponse response); | ||
|
||
/** | ||
* Convert a Coherence {@link com.tangosol.net.messaging.Message} | ||
* into a corresponding Protobuf {@link Message}. | ||
* | ||
* @param message the Coherence message to convert | ||
* @param nProxyId the proxy identifier for the message | ||
* | ||
* @return the corresponding Protobuf {@link Message} | ||
*/ | ||
Resp toProtoMessage(com.tangosol.net.messaging.Message message, int nProxyId); | ||
} |
41 changes: 41 additions & 0 deletions
41
...ents/src/main/java/com/tangosol/coherence/component/net/extend/proxy/GrpcExtendProxy.java
This file contains 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,41 @@ | ||
/* | ||
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. | ||
* | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* https://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
package com.tangosol.coherence.component.net.extend.proxy; | ||
|
||
import com.google.protobuf.Message; | ||
|
||
import com.tangosol.coherence.component.util.daemon.queueProcessor.service.peer.acceptor.grpcAcceptor.GrpcChannel; | ||
|
||
import com.tangosol.net.messaging.Channel; | ||
|
||
/** | ||
* A gRPC extend proxy. | ||
* | ||
* @author Jonathan Knight 2025.01.25 | ||
*/ | ||
public interface GrpcExtendProxy<Resp extends Message> | ||
extends Channel.Receiver | ||
{ | ||
/** | ||
* Return the {@link GrpcChannel} used by this proxy. | ||
* | ||
* @return the {@link GrpcChannel} used by this proxy | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
default GrpcChannel<Resp> getGrpcChannel() | ||
{ | ||
return (GrpcChannel<Resp>) getChannel(); | ||
} | ||
|
||
/** | ||
* Return the {@link Channel} used by this proxy. | ||
* | ||
* @return the {@link Channel} used by this proxy | ||
*/ | ||
Channel getChannel(); | ||
} |
Oops, something went wrong.