Package io.littlehorse.sdk.common.config
Class LHConfig
- java.lang.Object
-
- io.littlehorse.sdk.common.config.ConfigBase
-
- io.littlehorse.sdk.common.config.LHConfig
-
public class LHConfig extends io.littlehorse.sdk.common.config.ConfigBaseThis class is used to configure the LHClient class.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAPI_HOST_KEYThe bootstrap host for the LH Server.static java.lang.StringAPI_PORT_KEYThe bootstrap port for the LH Server.static java.lang.StringAPI_PROTOCOL_KEYThe bootstrap protocol for the LH Server.static java.lang.StringCA_CERT_KEYOptional location of CA Cert File.static java.lang.StringCLIENT_CERT_KEYOptional location of Client Cert file.static java.lang.StringCLIENT_KEY_KEYOptional location of Client Private Key File.static java.lang.StringDEFAULT_PROTOCOLstatic java.lang.StringDEFAULT_PUBLIC_LISTENERstatic java.lang.StringGRPC_KEEPALIVE_TIME_MS_KEYGRPC Connection Keepalive Intervalstatic java.lang.StringGRPC_KEEPALIVE_TIMEOUT_MS_KEYGRPC Connection Keepalive Intervalstatic java.lang.StringNUM_WORKER_THREADS_KEYThe number of worker threads to run.static java.lang.StringOAUTH_ACCESS_TOKEN_URLstatic java.lang.StringOAUTH_CLIENT_ID_KEYstatic java.lang.StringOAUTH_CLIENT_SECRET_KEYstatic java.lang.StringSERVER_CONNECT_LISTENER_KEYListener to connect to.static java.lang.StringTASK_WORKER_ID_KEYThe Client Id.static java.lang.StringTASK_WORKER_VERSION_KEYstatic java.lang.StringTENANT_ID_KEYThe Tenant Id for this client, null will be used if not set
-
Constructor Summary
Constructors Constructor Description LHConfig()Creates an LHClientConfig.LHConfig(java.lang.String propLocation)Creates an LHClientConfig with config props in a specified .properties file.LHConfig(java.nio.file.Path propLocation)Creates an LHClientConfig with config props in a specified .properties file.LHConfig(java.util.Map<java.lang.String,java.lang.Object> configs)Creates an LHClientConfig with provided config values.LHConfig(java.util.Properties props)Creates an LHClientConfig with provided config values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.Set<java.lang.String>configNames()Returns a set of all config names.java.lang.StringgetApiBootstrapHost()intgetApiBootstrapPort()java.lang.StringgetApiProtocol()io.littlehorse.sdk.common.proto.LittleHorseGrpc.LittleHorseStubgetAsyncStub()Gets an Async gRPC stub for the LH Public API on the configured host/port, which is generally the loadbalancer url.io.littlehorse.sdk.common.proto.LittleHorseGrpc.LittleHorseStubgetAsyncStub(java.lang.String host, int port)Gets an Async gRPC stub for the LH Public API on a specified host and port.io.littlehorse.sdk.common.proto.LittleHorseGrpc.LittleHorseBlockingStubgetBlockingStub()Gets a Blocking gRPC stub for the LH Public API on the configured host/port, which is generally the loadbalancer url.io.littlehorse.sdk.common.proto.LittleHorseGrpc.LittleHorseBlockingStubgetBlockingStub(java.lang.String host, int port)Gets a Blocking gRPC stub for the LH Public API on a specified host and port.java.lang.StringgetConnectListener()Returns the name of the listener to connect to.longgetKeepaliveTimeMs()longgetKeepaliveTimeoutMs()io.littlehorse.sdk.common.proto.TaskDefgetTaskDef(java.lang.String taskDefName)Gets the `TaskDefPb` for a given taskDefName.java.lang.StringgetTaskWorkerId()java.lang.StringgetTaskWorkerVersion()Returns the TaskWorker Version of this worker.java.lang.StringgetTenantId()intgetWorkerThreads()Returns the number of worker threads to run.booleanisOauth()
-
-
-
Field Detail
-
API_HOST_KEY
public static final java.lang.String API_HOST_KEY
The bootstrap host for the LH Server.- See Also:
- Constant Field Values
-
API_PORT_KEY
public static final java.lang.String API_PORT_KEY
The bootstrap port for the LH Server.- See Also:
- Constant Field Values
-
API_PROTOCOL_KEY
public static final java.lang.String API_PROTOCOL_KEY
The bootstrap protocol for the LH Server.- See Also:
- Constant Field Values
-
TASK_WORKER_ID_KEY
public static final java.lang.String TASK_WORKER_ID_KEY
The Client Id.- See Also:
- Constant Field Values
-
TENANT_ID_KEY
public static final java.lang.String TENANT_ID_KEY
The Tenant Id for this client, null will be used if not set- See Also:
- Constant Field Values
-
CLIENT_CERT_KEY
public static final java.lang.String CLIENT_CERT_KEY
Optional location of Client Cert file.- See Also:
- Constant Field Values
-
CLIENT_KEY_KEY
public static final java.lang.String CLIENT_KEY_KEY
Optional location of Client Private Key File.- See Also:
- Constant Field Values
-
CA_CERT_KEY
public static final java.lang.String CA_CERT_KEY
Optional location of CA Cert File.- See Also:
- Constant Field Values
-
OAUTH_CLIENT_ID_KEY
public static final java.lang.String OAUTH_CLIENT_ID_KEY
- See Also:
- Constant Field Values
-
OAUTH_CLIENT_SECRET_KEY
public static final java.lang.String OAUTH_CLIENT_SECRET_KEY
- See Also:
- Constant Field Values
-
OAUTH_ACCESS_TOKEN_URL
public static final java.lang.String OAUTH_ACCESS_TOKEN_URL
- See Also:
- Constant Field Values
-
NUM_WORKER_THREADS_KEY
public static final java.lang.String NUM_WORKER_THREADS_KEY
The number of worker threads to run.- See Also:
- Constant Field Values
-
SERVER_CONNECT_LISTENER_KEY
public static final java.lang.String SERVER_CONNECT_LISTENER_KEY
Listener to connect to.- See Also:
- Constant Field Values
-
GRPC_KEEPALIVE_TIME_MS_KEY
public static final java.lang.String GRPC_KEEPALIVE_TIME_MS_KEY
GRPC Connection Keepalive Interval- See Also:
- Constant Field Values
-
GRPC_KEEPALIVE_TIMEOUT_MS_KEY
public static final java.lang.String GRPC_KEEPALIVE_TIMEOUT_MS_KEY
GRPC Connection Keepalive Interval- See Also:
- Constant Field Values
-
TASK_WORKER_VERSION_KEY
public static final java.lang.String TASK_WORKER_VERSION_KEY
- See Also:
- Constant Field Values
-
DEFAULT_PUBLIC_LISTENER
public static final java.lang.String DEFAULT_PUBLIC_LISTENER
- See Also:
- Constant Field Values
-
DEFAULT_PROTOCOL
public static final java.lang.String DEFAULT_PROTOCOL
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LHConfig
public LHConfig()
Creates an LHClientConfig. Loads default values for config from env vars.
-
LHConfig
public LHConfig(java.util.Properties props)
Creates an LHClientConfig with provided config values.- Parameters:
props- configuration values.
-
LHConfig
public LHConfig(java.nio.file.Path propLocation)
Creates an LHClientConfig with config props in a specified .properties file.- Parameters:
propLocation- the location of the .properties file.
-
LHConfig
public LHConfig(java.lang.String propLocation)
Creates an LHClientConfig with config props in a specified .properties file.- Parameters:
propLocation- the location of the .properties file.
-
LHConfig
public LHConfig(java.util.Map<java.lang.String,java.lang.Object> configs)
Creates an LHClientConfig with provided config values.- Parameters:
configs- configuration values.
-
-
Method Detail
-
configNames
public static java.util.Set<java.lang.String> configNames()
Returns a set of all config names.- Returns:
- A Set of all config names.
-
getBlockingStub
public io.littlehorse.sdk.common.proto.LittleHorseGrpc.LittleHorseBlockingStub getBlockingStub()
Gets a Blocking gRPC stub for the LH Public API on the configured host/port, which is generally the loadbalancer url.- Returns:
- a blocking gRPC stub for the configured host/port.
-
getAsyncStub
public io.littlehorse.sdk.common.proto.LittleHorseGrpc.LittleHorseStub getAsyncStub()
Gets an Async gRPC stub for the LH Public API on the configured host/port, which is generally the loadbalancer url.- Returns:
- an async gRPC stub for the configured host/port.
-
getTaskDef
public io.littlehorse.sdk.common.proto.TaskDef getTaskDef(java.lang.String taskDefName)
Gets the `TaskDefPb` for a given taskDefName.- Parameters:
taskDefName- is the TaskDef's name.- Returns:
- the specified TaskDefPb.
-
getTaskWorkerVersion
public java.lang.String getTaskWorkerVersion()
Returns the TaskWorker Version of this worker.- Returns:
- Task Worker Version.
-
getConnectListener
public java.lang.String getConnectListener()
Returns the name of the listener to connect to.- Returns:
- the name of the listener on the LH Server to connect to.
-
getAsyncStub
public io.littlehorse.sdk.common.proto.LittleHorseGrpc.LittleHorseStub getAsyncStub(java.lang.String host, int port)Gets an Async gRPC stub for the LH Public API on a specified host and port. Generally used by the Task Worker, which needs to connect directly to a specific LH Server rather than the bootstrap host (loadbalancer).- Parameters:
host- is the host that the LH Server lives on.port- is the port that the LH Server lives on.- Returns:
- an async gRPC stub for that host/port combo.
-
getBlockingStub
public io.littlehorse.sdk.common.proto.LittleHorseGrpc.LittleHorseBlockingStub getBlockingStub(java.lang.String host, int port)Gets a Blocking gRPC stub for the LH Public API on a specified host and port. Generally used by the Task Worker, which needs to connect directly to a specific LH Server rather than the bootstrap host (loadbalancer).- Parameters:
host- is the host that the LH Server lives on.port- is the port that the LH Server lives on.- Returns:
- a blocking gRPC stub for that host/port combo.
-
getKeepaliveTimeMs
public long getKeepaliveTimeMs()
-
getKeepaliveTimeoutMs
public long getKeepaliveTimeoutMs()
-
getApiBootstrapHost
public java.lang.String getApiBootstrapHost()
-
getApiBootstrapPort
public int getApiBootstrapPort()
-
getApiProtocol
public java.lang.String getApiProtocol()
-
getTaskWorkerId
public java.lang.String getTaskWorkerId()
-
getTenantId
public java.lang.String getTenantId()
-
isOauth
public boolean isOauth()
-
getWorkerThreads
public int getWorkerThreads()
Returns the number of worker threads to run.- Returns:
- the number of worker threads to run.
-
-