diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-03 15:45:36 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-03 22:35:31 +0100 |
commit | ec3fadac88fd1e3705193003a684ab557e188b2d (patch) | |
tree | 2f97382c37e1f13a64a7c712c75eaf436e459a56 /container-disc | |
parent | 7e8c84f97d8bd41dbafd9c8305d1d2479fb38b09 (diff) |
Add a provider for cluster information.
Diffstat (limited to 'container-disc')
-rw-r--r-- | container-disc/src/main/java/com/yahoo/container/jdisc/ClusterInfoProvider.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/container-disc/src/main/java/com/yahoo/container/jdisc/ClusterInfoProvider.java b/container-disc/src/main/java/com/yahoo/container/jdisc/ClusterInfoProvider.java new file mode 100644 index 00000000000..3b40e87777d --- /dev/null +++ b/container-disc/src/main/java/com/yahoo/container/jdisc/ClusterInfoProvider.java @@ -0,0 +1,29 @@ + +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.container.jdisc; + +import ai.vespa.cloud.Cluster; +import com.yahoo.cloud.config.ClusterInfoConfig; +import com.yahoo.component.annotation.Inject; +import com.yahoo.component.AbstractComponent; +import com.yahoo.container.di.componentgraph.Provider; + +/** + * Provides information about the zone in which this container is running. + * This is available and can be injected when running in a cloud environment. + * + * @author bratseth + */ +public class ClusterInfoProvider extends AbstractComponent implements Provider<Cluster> { + + private final Cluster instance; + + @Inject + public ClusterInfoProvider(ClusterInfoConfig cfg) { + this.instance = new Cluster(cfg.clusterId(), cfg.nodeCount(), cfg.nodeIndices()); + } + + @Override + public Cluster get() { return instance; } + +} |