Class GRPCClientConfig

java.lang.Object
org.summerboot.jexpress.boot.config.BootConfig
org.summerboot.jexpress.nio.grpc.GRPCClientConfig
All Implemented Interfaces:
JExpressConfig

public abstract class GRPCClientConfig extends BootConfig
Author:
Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵
  • Field Details

    • FILENAME_TRUSTSTORE_4CLIENT

      protected static final String FILENAME_TRUSTSTORE_4CLIENT
      See Also:
    • ID

      protected static final String ID
      See Also:
    • loadBalancingServers

      @ConfigHeader(title="1. gRpc.client provider", format="server1:port1, server2:port2, ..., serverN:portN", example="localhost:8424, remotehost:8425, 127.0.0.1:8426") @Config(key="gRpc.client.LoadBalancing.servers", predefinedValue="0.0.0.0:8424, 0.0.0.0:8425", required=false) protected volatile List<InetSocketAddress> loadBalancingServers
    • loadBalancingTargetScheme

      @Config(key="gRpc.client.LoadBalancing.scheme", defaultValue="grpc", desc="In case you have more than one gRPC client needs to connect to different gRPC services, you can set this to distinguish them") protected volatile String loadBalancingTargetScheme
    • loadBalancingPolicy

      @Config(key="gRpc.client.LoadBalancing.policy", defaultValue="ROUND_ROBIN", desc="available options: ROUND_ROBIN, PICK_FIRST") protected volatile GRPCClientConfig.LoadBalancingPolicy loadBalancingPolicy
    • nameResolverProvider

      protected volatile io.grpc.NameResolverProvider nameResolverProvider
    • uri

      @Config(key="gRpc.client.target.url", defaultValue="grpc:///", desc="grpc:///\ngrpc://127.0.0.1:8424\nunix:/tmp/grpcsrver.socket") protected volatile URI uri
    • sslProtocols

      @Config(key="gRpc.client.ssl.Protocols", defaultValue="TLSv1.3") protected String[] sslProtocols
    • ciphers

      @Config(key="gRpc.client.ssl.ciphers") protected List ciphers
    • KEY_kmf_key

      protected static final String KEY_kmf_key
      See Also:
    • KEY_kmf_StorePwdKey

      protected static final String KEY_kmf_StorePwdKey
      See Also:
    • KEY_kmf_AliasKey

      protected static final String KEY_kmf_AliasKey
      See Also:
    • KEY_kmf_AliasPwdKey

      protected static final String KEY_kmf_AliasPwdKey
      See Also:
    • kmf

      @ConfigHeader(title="2. gRpc.client keystore") @Config(key="gRpc.client.ssl.KeyStore", StorePwdKey="gRpc.client.ssl.KeyStorePwd", AliasKey="gRpc.client.ssl.KeyAlias", AliasPwdKey="gRpc.client.ssl.KeyPwd", desc="Path to key store file. Use SSL/TLS when keystore is provided, otherwise use plain socket", callbackMethodName4Dump="generateTemplate_keystore") protected volatile KeyManagerFactory kmf
    • KEY_tmf_key

      protected static final String KEY_tmf_key
      See Also:
    • KEY_tmf_StorePwdKey

      protected static final String KEY_tmf_StorePwdKey
      See Also:
    • tmf

      @ConfigHeader(title="3. gRpc.client truststore") @Config(key="gRpc.client.ssl.TrustStore", StorePwdKey="gRpc.client.ssl.TrustStorePwd", callbackMethodName4Dump="generateTemplate_truststore", desc="Path to trust store file. Auth the remote peer certificate when a truststore is provided, otherwise blindly trust all remote peer certificate") protected volatile TrustManagerFactory tmf
    • overrideAuthority

      @Config(key="gRpc.client.ssl.overrideAuthority", predefinedValue="server2.4096.jexpress.org", desc="NOT for PRODUCTION! Set server certificate DNS name here when server is not yet running on its certificate Subject Alternative Names (SAN)") protected volatile String overrideAuthority
    • channelBuilder

      protected volatile io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder channelBuilder
    • userAgent

      @ConfigHeader(title="4. gRpc.client Channel Settings", desc="The following settings are for NettyChannelBuilder, which is used to create a gRPC channel") @Config(key="gRpc.client.channel.userAgent", desc="string: default null") protected volatile String userAgent
    • maxInboundMessageSize

      @Config(key="gRpc.client.channel.maxInboundMessageSize", desc="int: default 4194304 if not set") protected volatile Integer maxInboundMessageSize
    • maxHeaderListSize

      @Config(key="gRpc.client.channel.maxHeaderListSize", desc="int: default 8192 if not set") protected volatile Integer maxHeaderListSize
    • perRpcBufferLimit

      @Config(key="gRpc.client.channel.perRpcBufferLimit", desc="long: default 1048576L if not set") protected volatile Long perRpcBufferLimit
    • maxHedgedAttempts

      @Config(key="gRpc.client.channel.maxHedgedAttempts", desc="int: default 5 if not set") protected volatile Integer maxHedgedAttempts
    • idleTimeoutSeconds

      @Config(key="gRpc.client.channel.idleTimeoutSeconds", desc="long: default 1800 (30 minutes) if not set") protected volatile Long idleTimeoutSeconds
    • keepAliveWithoutCalls

      @Config(key="gRpc.client.channel.keepAliveWithoutCalls", desc="boolean: default false if not set. keepAliveWithoutCalls is used when you are willing to spend client, server, and network resources to have lower latency for very infrequent RPCs") protected volatile Boolean keepAliveWithoutCalls
    • keepAliveTimeSeconds

      @Config(key="gRpc.client.channel.keepAliveTimeSeconds", desc="long: default Long.MAX_VALUE (never) if not set. The interval in seconds between PING frames.") protected volatile Long keepAliveTimeSeconds
    • keepAliveTimeoutSeconds

      @Config(key="gRpc.client.channel.keepAliveTimeoutSeconds", desc="long: default 20 seconds if not set. The timeout in seconds for a PING frame to be acknowledged. If sender does not receive an acknowledgment within this time, it will close the connection.") protected volatile Long keepAliveTimeoutSeconds
    • retryEnabled

      @Config(key="gRpc.client.channel.retryEnabled", desc="boolean: default true if not set") protected volatile Boolean retryEnabled
    • maxRetryAttempts

      @Config(key="gRpc.client.channel.maxRetryAttempts", desc="int: default 5 if not set") protected volatile Integer maxRetryAttempts
    • retryBufferSize

      @Config(key="gRpc.client.channel.retryBufferSize", desc="int: default 16777216L if not set") protected volatile Long retryBufferSize
    • priority

      protected static int priority
  • Constructor Details

    • GRPCClientConfig

      protected GRPCClientConfig()
  • Method Details

    • main

      public static void main(String[] args)
    • generateTemplate_keystore

      protected void generateTemplate_keystore(StringBuilder sb)
    • generateTemplate_truststore

      protected void generateTemplate_truststore(StringBuilder sb)
    • preLoad

      protected void preLoad(File cfgFile, boolean isReal, ConfigUtil helper, Properties props)
      Overrides:
      preLoad in class BootConfig
    • loadCustomizedConfigs

      protected void loadCustomizedConfigs(File cfgFile, boolean isReal, ConfigUtil helper, Properties props) throws IOException
      Specified by:
      loadCustomizedConfigs in class BootConfig
      Throws:
      IOException
    • configNettyChannelBuilder

      protected void configNettyChannelBuilder(io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder nettyChannelBuilder)
    • shutdown

      public void shutdown()
    • addConfigUpdateListener

      public void addConfigUpdateListener(GRPCClient listener)
    • removeConfigUpdateListener

      public void removeConfigUpdateListener(GRPCClient listener)
    • initNettyChannelBuilder

      public static io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder initNettyChannelBuilder(io.grpc.NameResolverProvider nameResolverProvider, GRPCClientConfig.LoadBalancingPolicy loadBalancingPolicy, URI uri, @Nullable KeyManagerFactory keyManagerFactory, @Nullable TrustManagerFactory trustManagerFactory, @Nullable String overrideAuthority, @Nullable Iterable<String> ciphers, @Nullable String... tlsVersionProtocols) throws SSLException
      Parameters:
      nameResolverProvider - for client side load balancing
      loadBalancingPolicy -
      uri - The URI format should be one of grpc://host:port, grpcs://host:port, or unix:///path/to/uds.sock
      keyManagerFactory - The Remote Caller identity
      trustManagerFactory - The Remote Caller trusted identities
      overrideAuthority -
      ciphers -
      tlsVersionProtocols - "TLSv1.2", "TLSv1.3"
      Returns:
      Throws:
      SSLException
    • getLoadBalancingServers

      public List<InetSocketAddress> getLoadBalancingServers()
    • getLoadBalancingPolicy

      public GRPCClientConfig.LoadBalancingPolicy getLoadBalancingPolicy()
    • getNameResolverProvider

      public io.grpc.NameResolverProvider getNameResolverProvider()
    • getUri

      public URI getUri()
    • getSslProtocols

      public String[] getSslProtocols()
    • getCiphers

      public List getCiphers()
    • getKmf

      public KeyManagerFactory getKmf()
    • getTmf

      public TrustManagerFactory getTmf()
    • getOverrideAuthority

      public String getOverrideAuthority()
    • getChannelBuilder

      public io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder getChannelBuilder()