Component

Stateless cluster state

Masters use the object store for election leasing and persisted cluster-state Lucene files, so master node loss does not imply loss of durable cluster metadata.

Factory wiring

The stateless plugin supplies both a persisted-state factory and a persisted-cluster-state-service factory. The service receives the election strategy and object-store service suppliers, binding coordination to blob-store durability.

return ((StatelessPersistedClusterStateService) persistedClusterStateService)
    .createPersistedState(settings, transportService.getLocalNode());
Lease-backed term

The persisted state does not write the current term locally. The package documentation explains that the stateless election strategy claims ownership of a term through a compare-and-set lease in cluster_state/lease.

protected void writeCurrentTermToDisk(long currentTerm) {
    // never write term to disk, the lease takes care
}
Cluster-state file upload

BlobStoreSyncDirectory wraps a Lucene directory. It intercepts sync-like writes and uploads files into the cluster-state blob container. Metadata blobs are written atomically, and normal files are written with the cluster-state operation purpose.

if (atomic) {
    blobContainer.writeMetadataBlob(OperationPurpose.CLUSTER_STATE, fileName, false, true, ...);
} else {
    blobContainer.writeBlob(OperationPurpose.CLUSTER_STATE, fileName, inputStream, length, false);
}