Class SyncServerBuilder
- java.lang.Object
-
- io.objectbox.sync.server.SyncServerBuilder
-
public final class SyncServerBuilder extends java.lang.ObjectCreates aSyncServerand allows to set additional configuration.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) BoxStoreboxStoreprivate java.lang.StringcertificatePath(package private) SyncChangeListenerchangeListenerprivate java.lang.StringclaimAudprivate java.lang.StringclaimIssprivate intclusterFlagsprivate java.lang.StringclusterIdprivate java.util.List<ClusterPeerInfo>clusterPeersprivate java.util.List<SyncCredentialsToken>credentialsprivate longhistorySizeMaxKbprivate longhistorySizeTargetKbprivate java.lang.StringpublicKeyprivate java.lang.StringpublicKeyUrlprivate intsyncFlagsprivate intsyncServerFlags(package private) java.net.URIurlprivate intworkerThreads
-
Constructor Summary
Constructors Constructor Description SyncServerBuilder(BoxStore boxStore, java.lang.String url, SyncCredentials authenticatorCredentials)UseSync.server(BoxStore, String, SyncCredentials)instead.SyncServerBuilder(BoxStore boxStore, java.lang.String url, SyncCredentials[] multipleAuthenticatorCredentials)UseSync.server(BoxStore, String, SyncCredentials)instead.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SyncServerBuilderauthenticatorCredentials(SyncCredentials authenticatorCredentials)Adds additional authenticator credentials to authenticate clients or peers with.SyncServerBuilderauthenticatorCredentials(SyncCredentials[] multipleAuthenticatorCredentials)Adds additional authenticator credentials to authenticate clients or peers with.SyncServerbuild()Builds and returns a Sync server ready toSyncServer.start().SyncServerbuildAndStart()Builds,startsand returns a Sync server.private intbuildAuthenticationMethods(FlatBufferBuilder fbb)private intbuildClusterPeers(FlatBufferBuilder fbb)private intbuildCredentials(FlatBufferBuilder fbb, SyncCredentialsToken tokenCredentials)private intbuildJwtConfig(FlatBufferBuilder fbb, java.lang.String publicKey, java.lang.String publicKeyUrl, java.lang.String claimIss, java.lang.String claimAud)(package private) byte[]buildSyncServerOptions()From this configuration, builds aSyncServerOptionsFlatBuffer and returns it as bytes.SyncServerBuildercertificatePath(java.lang.String certificatePath)Sets the path to a directory that contains a cert.pem and key.pem file to use to establish encrypted connections.SyncServerBuilderchangeListener(SyncChangeListener changeListener)Sets a listener to observe fine granular changes happening during sync.private static voidcheckFeatureSyncServerAvailable()private voidcheckNotNull(java.lang.Object object, java.lang.String message)SyncServerBuilderclusterFlags(int flags)Sets bit flags to configure the cluster behavior of the Sync server (aka cluster peer).SyncServerBuilderclusterId(java.lang.String id)Enables cluster mode (requires the Cluster feature) and associates this cluster peer with the given ID.SyncServerBuilderclusterPeer(java.lang.String url, SyncCredentials credentials)Adds a (remote) cluster peer, to which this server should connect to as a client using the given credentials.SyncServerBuilderhistorySizeMaxKb(long historySizeMaxKb)Sets the maximum transaction history size.SyncServerBuilderhistorySizeTargetKb(long historySizeTargetKb)Sets the target transaction history size.SyncServerBuilderjwtConfigClaimAud(java.lang.String claimAud)Set the JWT claim "aud" (audience) used to verify JWT tokens.SyncServerBuilderjwtConfigClaimIss(java.lang.String claimIss)Set the JWT claim "iss" (issuer) used to verify JWT tokens.SyncServerBuilderjwtConfigPublicKey(java.lang.String publicKey)Set the public key used to verify JWT tokens.SyncServerBuilderjwtConfigPublicKeyUrl(java.lang.String publicKeyUrl)Set the JWKS (Json Web Key Sets) URL to fetch the current public key used to verify JWT tokens.SyncServerBuilderpeer(java.lang.String url)Deprecated.UseclusterPeer(url, SyncCredentials.none())instead.SyncServerBuilderpeer(java.lang.String url, SyncCredentials credentials)Deprecated.UseclusterPeer(String, SyncCredentials)instead.SyncServerBuildersyncFlags(int syncFlags)Sets bit flags to adjust Sync behavior, like additional logging.SyncServerBuildersyncServerFlags(int syncServerFlags)Sets bit flags to configure the Sync server.SyncServerBuilderworkerThreads(int workerThreads)Sets the number of workers for the main task pool.
-
-
-
Field Detail
-
boxStore
final BoxStore boxStore
-
url
final java.net.URI url
-
credentials
private final java.util.List<SyncCredentialsToken> credentials
-
certificatePath
@Nullable private java.lang.String certificatePath
-
changeListener
SyncChangeListener changeListener
-
clusterId
@Nullable private java.lang.String clusterId
-
clusterPeers
private final java.util.List<ClusterPeerInfo> clusterPeers
-
clusterFlags
private int clusterFlags
-
historySizeMaxKb
private long historySizeMaxKb
-
historySizeTargetKb
private long historySizeTargetKb
-
syncFlags
private int syncFlags
-
syncServerFlags
private int syncServerFlags
-
workerThreads
private int workerThreads
-
publicKey
private java.lang.String publicKey
-
publicKeyUrl
private java.lang.String publicKeyUrl
-
claimIss
private java.lang.String claimIss
-
claimAud
private java.lang.String claimAud
-
-
Constructor Detail
-
SyncServerBuilder
@Internal public SyncServerBuilder(BoxStore boxStore, java.lang.String url, SyncCredentials authenticatorCredentials)
UseSync.server(BoxStore, String, SyncCredentials)instead.
-
SyncServerBuilder
@Internal public SyncServerBuilder(BoxStore boxStore, java.lang.String url, SyncCredentials[] multipleAuthenticatorCredentials)
UseSync.server(BoxStore, String, SyncCredentials)instead.
-
-
Method Detail
-
checkFeatureSyncServerAvailable
private static void checkFeatureSyncServerAvailable()
-
certificatePath
public SyncServerBuilder certificatePath(java.lang.String certificatePath)
Sets the path to a directory that contains a cert.pem and key.pem file to use to establish encrypted connections.Use the "wss://" protocol for the server URL to turn on encrypted connections.
-
authenticatorCredentials
public SyncServerBuilder authenticatorCredentials(SyncCredentials authenticatorCredentials)
Adds additional authenticator credentials to authenticate clients or peers with.For the embedded server, currently only
SyncCredentials.sharedSecret(java.lang.String)andSyncCredentials.none()are supported.
-
authenticatorCredentials
public SyncServerBuilder authenticatorCredentials(SyncCredentials[] multipleAuthenticatorCredentials)
Adds additional authenticator credentials to authenticate clients or peers with.For the embedded server, currently only
SyncCredentials.sharedSecret(java.lang.String)andSyncCredentials.none()are supported.
-
changeListener
public SyncServerBuilder changeListener(SyncChangeListener changeListener)
Sets a listener to observe fine granular changes happening during sync.This listener can also be
set or removedon the Sync server directly.
-
clusterId
public SyncServerBuilder clusterId(java.lang.String id)
Enables cluster mode (requires the Cluster feature) and associates this cluster peer with the given ID.Cluster peers need to share the same ID to be in the same cluster.
-
peer
@Deprecated public SyncServerBuilder peer(java.lang.String url)
Deprecated.UseclusterPeer(url, SyncCredentials.none())instead.
-
peer
@Deprecated public SyncServerBuilder peer(java.lang.String url, SyncCredentials credentials)
Deprecated.UseclusterPeer(String, SyncCredentials)instead.
-
clusterPeer
public SyncServerBuilder clusterPeer(java.lang.String url, SyncCredentials credentials)
Adds a (remote) cluster peer, to which this server should connect to as a client using the given credentials.To use this, must set a
clusterId(String).
-
clusterFlags
public SyncServerBuilder clusterFlags(int flags)
Sets bit flags to configure the cluster behavior of the Sync server (aka cluster peer).To use this, must set a
clusterId(String).- Parameters:
flags- One or more ofClusterFlags.
-
historySizeMaxKb
public SyncServerBuilder historySizeMaxKb(long historySizeMaxKb)
Sets the maximum transaction history size.Once the maximum size is reached, old transaction logs are deleted to stay below this limit. This is sometimes also called "history pruning" in the context of Sync.
If not set or set to 0, defaults to no limit.
- See Also:
historySizeTargetKb(long)
-
historySizeTargetKb
public SyncServerBuilder historySizeTargetKb(long historySizeTargetKb)
Sets the target transaction history size.Once the maximum size (
historySizeMaxKb(long)) is reached, old transaction logs are deleted until this size target is reached (lower than the maximum size). Using this target size typically lowers the frequency of history pruning and thus may improve efficiency.If not set or set to 0, defaults to
historySizeMaxKb(long).
-
syncFlags
public SyncServerBuilder syncFlags(int syncFlags)
Sets bit flags to adjust Sync behavior, like additional logging.- Parameters:
syncFlags- One or more ofSyncFlags.
-
syncServerFlags
public SyncServerBuilder syncServerFlags(int syncServerFlags)
Sets bit flags to configure the Sync server.- Parameters:
syncServerFlags- One or more ofSyncServerFlags.
-
workerThreads
public SyncServerBuilder workerThreads(int workerThreads)
Sets the number of workers for the main task pool.If not set or set to 0, this uses a hardware-dependant default, e.g. 3 * CPU "cores".
-
jwtConfigPublicKey
public SyncServerBuilder jwtConfigPublicKey(java.lang.String publicKey)
Set the public key used to verify JWT tokens.The public key should be in the PEM format.
-
jwtConfigPublicKeyUrl
public SyncServerBuilder jwtConfigPublicKeyUrl(java.lang.String publicKeyUrl)
Set the JWKS (Json Web Key Sets) URL to fetch the current public key used to verify JWT tokens.
-
jwtConfigClaimIss
public SyncServerBuilder jwtConfigClaimIss(java.lang.String claimIss)
Set the JWT claim "iss" (issuer) used to verify JWT tokens.
-
jwtConfigClaimAud
public SyncServerBuilder jwtConfigClaimAud(java.lang.String claimAud)
Set the JWT claim "aud" (audience) used to verify JWT tokens.
-
build
public SyncServer build()
Builds and returns a Sync server ready toSyncServer.start().Note: this clears all previously set authenticator credentials.
-
buildAndStart
public SyncServer buildAndStart()
Builds,startsand returns a Sync server.
-
checkNotNull
private void checkNotNull(java.lang.Object object, java.lang.String message)
-
buildSyncServerOptions
byte[] buildSyncServerOptions()
From this configuration, builds aSyncServerOptionsFlatBuffer and returns it as bytes.Clears configured credentials, they can not be used again after this returns.
-
buildAuthenticationMethods
private int buildAuthenticationMethods(FlatBufferBuilder fbb)
-
buildCredentials
private int buildCredentials(FlatBufferBuilder fbb, SyncCredentialsToken tokenCredentials)
-
buildJwtConfig
private int buildJwtConfig(FlatBufferBuilder fbb, @Nullable java.lang.String publicKey, @Nullable java.lang.String publicKeyUrl, java.lang.String claimIss, java.lang.String claimAud)
-
buildClusterPeers
private int buildClusterPeers(FlatBufferBuilder fbb)
-
-