Skip to content

Commit

Permalink
[ISSUE alibaba#11456]Remove supportCommunicationTypes.
Browse files Browse the repository at this point in the history
  • Loading branch information
stone-98 committed Dec 24, 2023
1 parent 57f9d40 commit 0eb0159
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

package com.alibaba.nacos.core.remote.grpc.negotiator;

import com.alibaba.nacos.core.remote.CommunicationType;

import java.util.List;

/**
* Protocol negotiator builder.
*
Expand All @@ -40,14 +36,4 @@ public interface ProtocolNegotiatorBuilder {
* @return type
*/
String type();

/**
* Get a list of supported communication types by the ProtocolNegotiator.
*
* <p>The communication types represent the different types of communication
* scenarios that the ProtocolNegotiator can handle.</p>
*
* @return List of supported CommunicationType values.
*/
List<CommunicationType> supportCommunicationTypes();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,15 @@

package com.alibaba.nacos.core.remote.grpc.negotiator.tls;

import com.alibaba.nacos.core.remote.CommunicationType;
import com.alibaba.nacos.core.remote.grpc.negotiator.NacosGrpcProtocolNegotiator;
import com.alibaba.nacos.core.remote.grpc.negotiator.ProtocolNegotiatorBuilder;
import com.alibaba.nacos.core.remote.tls.RpcClusterServerTlsConfig;
import com.alibaba.nacos.core.remote.tls.RpcServerTlsConfig;
import io.grpc.netty.shaded.io.netty.handler.ssl.SslContext;

import java.util.Collections;
import java.util.List;

/**
* The {@code ClusterDefaultTlsProtocolNegotiatorBuilder} class is an implementation of the
* {@link ProtocolNegotiatorBuilder} interface for constructing a ProtocolNegotiator specifically for cluster-to-cluster
* The {@code ClusterDefaultTlsProtocolNegotiatorBuilder} class is an implementation of the {@link
* ProtocolNegotiatorBuilder} interface for constructing a ProtocolNegotiator specifically for cluster-to-cluster
* communication with TLS encryption.
*
* <p>It defines the type as {@code CLUSTER_DEFAULT_TLS} and supports communication types for clusters.
Expand All @@ -44,10 +40,6 @@
* builder.
* </p>
*
* <p>The {@code supportCommunicationTypes()} method returns a list containing the supported communication type
* {@link CommunicationType#CLUSTER} for cluster communication.
* </p>
*
* <p>Example Usage:
* <pre>{@code
* ProtocolNegotiatorBuilder builder = new ClusterDefaultTlsProtocolNegotiatorBuilder();
Expand Down Expand Up @@ -93,16 +85,5 @@ public NacosGrpcProtocolNegotiator build() {
public String type() {
return CLUSTER_TYPE_DEFAULT_TLS;
}

/**
* Returns a list containing the supported communication type {@link CommunicationType#CLUSTER} for cluster
* communication.
*
* @return List of supported communication types.
*/
@Override
public List<CommunicationType> supportCommunicationTypes() {
return Collections.singletonList(CommunicationType.CLUSTER);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class OptionalTlsProtocolNegotiator implements NacosGrpcProtocolNegotiato

private SslContext sslContext;

public OptionalTlsProtocolNegotiator(SslContext sslContext,RpcServerTlsConfig config) {
public OptionalTlsProtocolNegotiator(SslContext sslContext, RpcServerTlsConfig config) {
this.sslContext = sslContext;
this.config = config;
this.supportPlainText = config.getCompatibility();
Expand Down Expand Up @@ -82,20 +82,19 @@ public void reloadNegotiator() {
}

private ProtocolNegotiationEvent getDefPne() {
ProtocolNegotiationEvent protocolNegotiationEvent = null;
try {
Field aDefault = ProtocolNegotiationEvent.class.getDeclaredField("DEFAULT");
aDefault.setAccessible(true);
return (ProtocolNegotiationEvent) aDefault.get(protocolNegotiationEvent);
return (ProtocolNegotiationEvent) aDefault.get(null);
} catch (Exception e) {
e.printStackTrace();
}
return protocolNegotiationEvent;
return null;
}

public class PortUnificationServerHandler extends ByteToMessageDecoder {

private ProtocolNegotiationEvent pne;
private final ProtocolNegotiationEvent pne;

private final ChannelHandler ssl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@

package com.alibaba.nacos.core.remote.grpc.negotiator.tls;

import com.alibaba.nacos.core.remote.CommunicationType;
import com.alibaba.nacos.core.remote.grpc.negotiator.NacosGrpcProtocolNegotiator;
import com.alibaba.nacos.core.remote.grpc.negotiator.ProtocolNegotiatorBuilder;
import com.alibaba.nacos.core.remote.tls.RpcSdkServerTlsConfig;
import com.alibaba.nacos.core.remote.tls.RpcServerTlsConfig;
import io.grpc.netty.shaded.io.netty.handler.ssl.SslContext;

import java.util.Collections;
import java.util.List;

/**
* Default optional tls protocol negotiator builder.
*
Expand All @@ -49,9 +45,4 @@ public NacosGrpcProtocolNegotiator build() {
public String type() {
return SDK_TYPE_DEFAULT_TLS;
}

@Override
public List<CommunicationType> supportCommunicationTypes() {
return Collections.singletonList(CommunicationType.SDK);
}
}

0 comments on commit 0eb0159

Please sign in to comment.