Interface NodeManagement
- All Superinterfaces:
AutoCloseable
API to lease node IDs, primarily to generate snowflake IDs.
The default configuration for the snowflake IDs allows generation of 4096 IDs per millisecond (12 sequence bits), which should be more than enough. As a consequence, it is very likely enough to have only one ID generator per JVM, across all realms and catalogs.
Implementation is provided as an @ApplicationScoped bean
-
Method Summary
Modifier and TypeMethodDescriptionorg.apache.polaris.ids.api.IdGeneratorbuildIdGenerator(NodeLease leasedNode) Build a new and independent ID generator instance of a leased node using the given clock.getNodeInfo(int nodeId) Retrieve information about a specific node.lease()Lease a node.intThe maximum number of concurrently leased nodes that are supported.longsystemIdForNode(int nodeId) Get the persistence ID for a node by its ID.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
buildIdGenerator
Build a new and independent ID generator instance of a leased node using the given clock.This function must only be called from
@ApplicationScopedCDI producers providing the sameIdGeneratorfor the lifetime of the givenNode, aka at most once for aNodeinstance. -
maxNumberOfNodes
int maxNumberOfNodes()The maximum number of concurrently leased nodes that are supported. -
getNodeInfo
Retrieve information about a specific node. -
systemIdForNode
long systemIdForNode(int nodeId) Get the persistence ID for a node by its ID. -
lease
Lease a node.The implementation takes care of periodically renewing the lease. It is not necessary to explicitly call
NodeLease.renew().It is possible that the ID of the leased node changes over time.
Each invocation returns a new, independent lease.
- Returns:
- the leased node
- Throws:
IllegalStateException- if no node ID could be leased
-