Package uk.co.ractf.polaris.state
Class ConsulState
- java.lang.Object
-
- uk.co.ractf.polaris.state.ConsulState
-
- All Implemented Interfaces:
ClusterState
public class ConsulState extends java.lang.Object implements ClusterState
-
-
Constructor Summary
Constructors Constructor Description ConsulState(com.orbitz.consul.Consul consul, com.codahale.metrics.MetricRegistry metricRegistry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteAPIToken(java.lang.String id)
void
deleteCredential(uk.co.ractf.polaris.api.namespace.NamespacedId id)
void
deleteInstance(uk.co.ractf.polaris.api.instance.Instance instance)
Unregisters anInstance
from a givenTask
, probably because its been descheduledvoid
deleteNamespace(java.lang.String id)
void
deleteNotificationReceiver(uk.co.ractf.polaris.api.namespace.NamespacedId id)
void
deleteTask(uk.co.ractf.polaris.api.namespace.NamespacedId id)
uk.co.ractf.polaris.api.authentication.APIToken
getAPIToken(java.lang.String id)
java.util.Map<java.lang.String,uk.co.ractf.polaris.api.authentication.APIToken>
getAPITokens()
uk.co.ractf.polaris.api.registry.credentials.ContainerRegistryCredentials
getCredential(uk.co.ractf.polaris.api.namespace.NamespacedId id)
java.util.Map<uk.co.ractf.polaris.api.namespace.NamespacedId,uk.co.ractf.polaris.api.registry.credentials.ContainerRegistryCredentials>
getCredentials()
java.util.Map<uk.co.ractf.polaris.api.namespace.NamespacedId,uk.co.ractf.polaris.api.registry.credentials.ContainerRegistryCredentials>
getCredentials(java.lang.String namespace)
@Nullable uk.co.ractf.polaris.api.instance.Instance
getInstance(java.lang.String id)
Gets anInstance
by idjava.util.Map<uk.co.ractf.polaris.api.namespace.NamespacedId,java.lang.Integer>
getInstanceCounts()
java.util.List<java.lang.String>
getInstanceIds()
java.util.Map<java.lang.String,uk.co.ractf.polaris.api.instance.Instance>
getInstances()
java.util.Map<java.lang.String,uk.co.ractf.polaris.api.instance.Instance>
getInstancesOfTask(uk.co.ractf.polaris.api.namespace.NamespacedId namespacedId)
@NotNull java.util.Map<java.lang.String,uk.co.ractf.polaris.api.instance.Instance>
getInstancesOnNode(java.lang.String node)
Gets a list ofInstance
s on a given node.uk.co.ractf.polaris.api.namespace.Namespace
getNamespace(java.lang.String id)
java.util.Map<java.lang.String,uk.co.ractf.polaris.api.namespace.Namespace>
getNamespaces()
@Nullable uk.co.ractf.polaris.api.node.NodeInfo
getNode(java.lang.String id)
Gets aNodeInfo
by id@NotNull java.util.Map<java.lang.String,uk.co.ractf.polaris.api.node.NodeInfo>
getNodes()
Gets aMap
of host id toNode
uk.co.ractf.polaris.api.notification.NotificationReceiver
getNotificationReceiver(uk.co.ractf.polaris.api.namespace.NamespacedId id)
java.util.Map<uk.co.ractf.polaris.api.namespace.NamespacedId,uk.co.ractf.polaris.api.notification.NotificationReceiver>
getNotificationReceivers()
java.util.Map<uk.co.ractf.polaris.api.namespace.NamespacedId,uk.co.ractf.polaris.api.notification.NotificationReceiver>
getNotificationReceivers(java.lang.String namespace)
uk.co.ractf.polaris.api.task.Task
getTask(uk.co.ractf.polaris.api.namespace.NamespacedId id)
java.util.List<uk.co.ractf.polaris.api.namespace.NamespacedId>
getTaskIds()
java.util.Map<uk.co.ractf.polaris.api.namespace.NamespacedId,uk.co.ractf.polaris.api.task.Task>
getTasks()
java.util.Map<uk.co.ractf.polaris.api.namespace.NamespacedId,uk.co.ractf.polaris.api.task.Task>
getTasks(java.lang.String namespace)
boolean
instanceExists(java.lang.String id)
boolean
lockTask(uk.co.ractf.polaris.api.task.Task task)
void
setAPIToken(uk.co.ractf.polaris.api.authentication.APIToken apiToken)
void
setCredential(uk.co.ractf.polaris.api.registry.credentials.ContainerRegistryCredentials credential)
void
setInstance(uk.co.ractf.polaris.api.instance.Instance instance)
Sets the state of an instancevoid
setNamespace(uk.co.ractf.polaris.api.namespace.Namespace namespace)
void
setNodeInfo(uk.co.ractf.polaris.api.node.NodeInfo nodeInfo)
Sets the info for a nodevoid
setNotificationReceiver(uk.co.ractf.polaris.api.notification.NotificationReceiver receiver)
void
setTask(uk.co.ractf.polaris.api.task.Task task)
boolean
unlockTask(uk.co.ractf.polaris.api.task.Task task)
-
-
-
Method Detail
-
getNodes
@NotNull public @NotNull java.util.Map<java.lang.String,uk.co.ractf.polaris.api.node.NodeInfo> getNodes()
Description copied from interface:ClusterState
Gets aMap
of host id toNode
- Specified by:
getNodes
in interfaceClusterState
- Returns:
- map of hosts
-
getNode
@Nullable public @Nullable uk.co.ractf.polaris.api.node.NodeInfo getNode(java.lang.String id)
Description copied from interface:ClusterState
Gets aNodeInfo
by id- Specified by:
getNode
in interfaceClusterState
- Parameters:
id
- host id- Returns:
- the host
-
setNodeInfo
public void setNodeInfo(uk.co.ractf.polaris.api.node.NodeInfo nodeInfo)
Description copied from interface:ClusterState
Sets the info for a node- Specified by:
setNodeInfo
in interfaceClusterState
- Parameters:
nodeInfo
- node info
-
getInstance
@Nullable public @Nullable uk.co.ractf.polaris.api.instance.Instance getInstance(java.lang.String id)
Description copied from interface:ClusterState
Gets anInstance
by id- Specified by:
getInstance
in interfaceClusterState
- Parameters:
id
- the instance id- Returns:
- the instance
-
deleteInstance
public void deleteInstance(uk.co.ractf.polaris.api.instance.Instance instance)
Description copied from interface:ClusterState
Unregisters anInstance
from a givenTask
, probably because its been descheduled- Specified by:
deleteInstance
in interfaceClusterState
- Parameters:
instance
- the instance
-
setInstance
public void setInstance(uk.co.ractf.polaris.api.instance.Instance instance)
Description copied from interface:ClusterState
Sets the state of an instance- Specified by:
setInstance
in interfaceClusterState
- Parameters:
instance
- the instance details
-
instanceExists
public boolean instanceExists(java.lang.String id)
- Specified by:
instanceExists
in interfaceClusterState
-
getInstancesOnNode
@NotNull public @NotNull java.util.Map<java.lang.String,uk.co.ractf.polaris.api.instance.Instance> getInstancesOnNode(java.lang.String node)
Description copied from interface:ClusterState
Gets a list ofInstance
s on a given node. Returns an empty collection if the node id is invalid.- Specified by:
getInstancesOnNode
in interfaceClusterState
- Parameters:
node
- node id- Returns:
- instances on the node
-
getInstancesOfTask
public java.util.Map<java.lang.String,uk.co.ractf.polaris.api.instance.Instance> getInstancesOfTask(uk.co.ractf.polaris.api.namespace.NamespacedId namespacedId)
- Specified by:
getInstancesOfTask
in interfaceClusterState
-
getInstanceIds
public java.util.List<java.lang.String> getInstanceIds()
- Specified by:
getInstanceIds
in interfaceClusterState
-
getInstances
public java.util.Map<java.lang.String,uk.co.ractf.polaris.api.instance.Instance> getInstances()
- Specified by:
getInstances
in interfaceClusterState
-
getInstanceCounts
public java.util.Map<uk.co.ractf.polaris.api.namespace.NamespacedId,java.lang.Integer> getInstanceCounts()
- Specified by:
getInstanceCounts
in interfaceClusterState
-
getTasks
public java.util.Map<uk.co.ractf.polaris.api.namespace.NamespacedId,uk.co.ractf.polaris.api.task.Task> getTasks()
- Specified by:
getTasks
in interfaceClusterState
-
getTaskIds
public java.util.List<uk.co.ractf.polaris.api.namespace.NamespacedId> getTaskIds()
- Specified by:
getTaskIds
in interfaceClusterState
-
getTasks
public java.util.Map<uk.co.ractf.polaris.api.namespace.NamespacedId,uk.co.ractf.polaris.api.task.Task> getTasks(java.lang.String namespace)
- Specified by:
getTasks
in interfaceClusterState
-
getTask
public uk.co.ractf.polaris.api.task.Task getTask(uk.co.ractf.polaris.api.namespace.NamespacedId id)
- Specified by:
getTask
in interfaceClusterState
-
setTask
public void setTask(uk.co.ractf.polaris.api.task.Task task)
- Specified by:
setTask
in interfaceClusterState
-
deleteTask
public void deleteTask(uk.co.ractf.polaris.api.namespace.NamespacedId id)
- Specified by:
deleteTask
in interfaceClusterState
-
lockTask
public boolean lockTask(uk.co.ractf.polaris.api.task.Task task)
- Specified by:
lockTask
in interfaceClusterState
-
unlockTask
public boolean unlockTask(uk.co.ractf.polaris.api.task.Task task)
- Specified by:
unlockTask
in interfaceClusterState
-
getNamespaces
public java.util.Map<java.lang.String,uk.co.ractf.polaris.api.namespace.Namespace> getNamespaces()
- Specified by:
getNamespaces
in interfaceClusterState
-
getNamespace
public uk.co.ractf.polaris.api.namespace.Namespace getNamespace(java.lang.String id)
- Specified by:
getNamespace
in interfaceClusterState
-
setNamespace
public void setNamespace(uk.co.ractf.polaris.api.namespace.Namespace namespace)
- Specified by:
setNamespace
in interfaceClusterState
-
deleteNamespace
public void deleteNamespace(java.lang.String id)
- Specified by:
deleteNamespace
in interfaceClusterState
-
getCredentials
public java.util.Map<uk.co.ractf.polaris.api.namespace.NamespacedId,uk.co.ractf.polaris.api.registry.credentials.ContainerRegistryCredentials> getCredentials()
- Specified by:
getCredentials
in interfaceClusterState
-
getCredentials
public java.util.Map<uk.co.ractf.polaris.api.namespace.NamespacedId,uk.co.ractf.polaris.api.registry.credentials.ContainerRegistryCredentials> getCredentials(java.lang.String namespace)
- Specified by:
getCredentials
in interfaceClusterState
-
getCredential
public uk.co.ractf.polaris.api.registry.credentials.ContainerRegistryCredentials getCredential(uk.co.ractf.polaris.api.namespace.NamespacedId id)
- Specified by:
getCredential
in interfaceClusterState
-
setCredential
public void setCredential(uk.co.ractf.polaris.api.registry.credentials.ContainerRegistryCredentials credential)
- Specified by:
setCredential
in interfaceClusterState
-
deleteCredential
public void deleteCredential(uk.co.ractf.polaris.api.namespace.NamespacedId id)
- Specified by:
deleteCredential
in interfaceClusterState
-
getAPITokens
public java.util.Map<java.lang.String,uk.co.ractf.polaris.api.authentication.APIToken> getAPITokens()
- Specified by:
getAPITokens
in interfaceClusterState
-
getAPIToken
public uk.co.ractf.polaris.api.authentication.APIToken getAPIToken(java.lang.String id)
- Specified by:
getAPIToken
in interfaceClusterState
-
setAPIToken
public void setAPIToken(uk.co.ractf.polaris.api.authentication.APIToken apiToken)
- Specified by:
setAPIToken
in interfaceClusterState
-
deleteAPIToken
public void deleteAPIToken(java.lang.String id)
- Specified by:
deleteAPIToken
in interfaceClusterState
-
setNotificationReceiver
public void setNotificationReceiver(uk.co.ractf.polaris.api.notification.NotificationReceiver receiver)
- Specified by:
setNotificationReceiver
in interfaceClusterState
-
deleteNotificationReceiver
public void deleteNotificationReceiver(uk.co.ractf.polaris.api.namespace.NamespacedId id)
- Specified by:
deleteNotificationReceiver
in interfaceClusterState
-
getNotificationReceivers
public java.util.Map<uk.co.ractf.polaris.api.namespace.NamespacedId,uk.co.ractf.polaris.api.notification.NotificationReceiver> getNotificationReceivers()
- Specified by:
getNotificationReceivers
in interfaceClusterState
-
getNotificationReceivers
public java.util.Map<uk.co.ractf.polaris.api.namespace.NamespacedId,uk.co.ractf.polaris.api.notification.NotificationReceiver> getNotificationReceivers(java.lang.String namespace)
- Specified by:
getNotificationReceivers
in interfaceClusterState
-
getNotificationReceiver
public uk.co.ractf.polaris.api.notification.NotificationReceiver getNotificationReceiver(uk.co.ractf.polaris.api.namespace.NamespacedId id)
- Specified by:
getNotificationReceiver
in interfaceClusterState
-
-