Class DockerRunner

  • All Implemented Interfaces:
    Runner<uk.co.ractf.polaris.api.pod.Container>

    public class DockerRunner
    extends java.lang.Object
    implements Runner<uk.co.ractf.polaris.api.pod.Container>
    An implementation of Runner that is capable of running docker Containers through the docker-java DockerClient
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canStartPod​(uk.co.ractf.polaris.api.pod.Container pod)
      Returns if the runner is currently able to start this Pod
      void createNetwork​(java.util.List<uk.co.ractf.polaris.api.pod.Container> pods, uk.co.ractf.polaris.api.task.Task task, uk.co.ractf.polaris.api.instance.Instance instance)
      Creates a network between a list of pods.
      void createPod​(uk.co.ractf.polaris.api.task.Task task, uk.co.ractf.polaris.api.pod.Container container, uk.co.ractf.polaris.api.instance.Instance instance)
      Creates a Pod with given Instance details
      void forceUpdatePod​(uk.co.ractf.polaris.api.task.Task task, uk.co.ractf.polaris.api.pod.Container pod, uk.co.ractf.polaris.api.instance.Instance instance)
      Forcefully update a specific Instance of a Pod
      void garbageCollect()
      Clean up after pods that are currently dead
      java.util.List<java.lang.String> getImages()
      Returns the images that can be used by this runner and are stored locally on the node.
      java.lang.String getName()
      Gets the name of the runner.
      java.lang.Class<uk.co.ractf.polaris.api.pod.Container> getType()
      Returns a class of type T where T is the type of Pod this runner can run
      boolean isPodStarted​(uk.co.ractf.polaris.api.pod.Container pod, uk.co.ractf.polaris.api.instance.Instance instance)
      Returns if the runner has started this Instance of this Pod
      void killOrphans()
      Find orphaned pods that are not tracked in the Controller and kill them
      void preparePod​(uk.co.ractf.polaris.api.task.Task task, uk.co.ractf.polaris.api.pod.Container pod)
      Prepares a Pod that currently cannot be started so it can be started in the future (e.g.
      void restartPod​(uk.co.ractf.polaris.api.pod.Container pod, uk.co.ractf.polaris.api.instance.Instance instance)
      Restart a specific Instance of a Pod
      void startPod​(uk.co.ractf.polaris.api.task.Task task, uk.co.ractf.polaris.api.pod.Container container, uk.co.ractf.polaris.api.instance.Instance instance)
      Starts a Pod with given Instance details
      void stopPod​(uk.co.ractf.polaris.api.pod.Container pod, uk.co.ractf.polaris.api.instance.Instance instance)
      Stops a Pod with given Instance details
      void updatePod​(uk.co.ractf.polaris.api.task.Task task, uk.co.ractf.polaris.api.pod.Container pod)
      Update a Pod if an update is available.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • createPod

        public void createPod​(uk.co.ractf.polaris.api.task.Task task,
                              uk.co.ractf.polaris.api.pod.Container container,
                              uk.co.ractf.polaris.api.instance.Instance instance)
        Description copied from interface: Runner
        Creates a Pod with given Instance details
        Specified by:
        createPod in interface Runner<uk.co.ractf.polaris.api.pod.Container>
        Parameters:
        task - the task
        container - the pod
        instance - instance details
      • startPod

        public void startPod​(uk.co.ractf.polaris.api.task.Task task,
                             uk.co.ractf.polaris.api.pod.Container container,
                             uk.co.ractf.polaris.api.instance.Instance instance)
        Description copied from interface: Runner
        Starts a Pod with given Instance details
        Specified by:
        startPod in interface Runner<uk.co.ractf.polaris.api.pod.Container>
        Parameters:
        task - the task
        container - the pod
        instance - instance details
      • stopPod

        public void stopPod​(uk.co.ractf.polaris.api.pod.Container pod,
                            uk.co.ractf.polaris.api.instance.Instance instance)
        Description copied from interface: Runner
        Stops a Pod with given Instance details
        Specified by:
        stopPod in interface Runner<uk.co.ractf.polaris.api.pod.Container>
        Parameters:
        pod - the pod
        instance - instance details
      • forceUpdatePod

        public void forceUpdatePod​(uk.co.ractf.polaris.api.task.Task task,
                                   uk.co.ractf.polaris.api.pod.Container pod,
                                   uk.co.ractf.polaris.api.instance.Instance instance)
        Description copied from interface: Runner
        Forcefully update a specific Instance of a Pod
        Specified by:
        forceUpdatePod in interface Runner<uk.co.ractf.polaris.api.pod.Container>
        pod - the pod
        instance - the instance to update
      • updatePod

        public void updatePod​(uk.co.ractf.polaris.api.task.Task task,
                              uk.co.ractf.polaris.api.pod.Container pod)
        Description copied from interface: Runner
        Update a Pod if an update is available.
        Specified by:
        updatePod in interface Runner<uk.co.ractf.polaris.api.pod.Container>
        pod - the pod
      • restartPod

        public void restartPod​(uk.co.ractf.polaris.api.pod.Container pod,
                               uk.co.ractf.polaris.api.instance.Instance instance)
        Description copied from interface: Runner
        Restart a specific Instance of a Pod
        Specified by:
        restartPod in interface Runner<uk.co.ractf.polaris.api.pod.Container>
        Parameters:
        pod - the pod
        instance - the instance to restart
      • canStartPod

        public boolean canStartPod​(uk.co.ractf.polaris.api.pod.Container pod)
        Description copied from interface: Runner
        Returns if the runner is currently able to start this Pod
        Specified by:
        canStartPod in interface Runner<uk.co.ractf.polaris.api.pod.Container>
        Parameters:
        pod - the pod
        Returns:
        can it be started
      • isPodStarted

        public boolean isPodStarted​(uk.co.ractf.polaris.api.pod.Container pod,
                                    uk.co.ractf.polaris.api.instance.Instance instance)
        Description copied from interface: Runner
        Returns if the runner has started this Instance of this Pod
        Specified by:
        isPodStarted in interface Runner<uk.co.ractf.polaris.api.pod.Container>
        Parameters:
        pod - the pod
        instance - the instance
        Returns:
        if its started
      • preparePod

        public void preparePod​(uk.co.ractf.polaris.api.task.Task task,
                               uk.co.ractf.polaris.api.pod.Container pod)
        Description copied from interface: Runner
        Prepares a Pod that currently cannot be started so it can be started in the future (e.g. DockerRunner will pull the docker image)
        Specified by:
        preparePod in interface Runner<uk.co.ractf.polaris.api.pod.Container>
        Parameters:
        task - the task the pod belongs to
        pod - the pod to prepare
      • garbageCollect

        public void garbageCollect()
        Description copied from interface: Runner
        Clean up after pods that are currently dead
        Specified by:
        garbageCollect in interface Runner<uk.co.ractf.polaris.api.pod.Container>
      • killOrphans

        public void killOrphans()
        Description copied from interface: Runner
        Find orphaned pods that are not tracked in the Controller and kill them
        Specified by:
        killOrphans in interface Runner<uk.co.ractf.polaris.api.pod.Container>
      • getType

        public java.lang.Class<uk.co.ractf.polaris.api.pod.Container> getType()
        Description copied from interface: Runner
        Returns a class of type T where T is the type of Pod this runner can run
        Specified by:
        getType in interface Runner<uk.co.ractf.polaris.api.pod.Container>
        Returns:
        the class of T
      • getName

        public java.lang.String getName()
        Description copied from interface: Runner
        Gets the name of the runner.
        Specified by:
        getName in interface Runner<uk.co.ractf.polaris.api.pod.Container>
        Returns:
        name
      • getImages

        public java.util.List<java.lang.String> getImages()
        Description copied from interface: Runner
        Returns the images that can be used by this runner and are stored locally on the node.
        Specified by:
        getImages in interface Runner<uk.co.ractf.polaris.api.pod.Container>
        Returns:
        the locally stored images
      • createNetwork

        public void createNetwork​(java.util.List<uk.co.ractf.polaris.api.pod.Container> pods,
                                  uk.co.ractf.polaris.api.task.Task task,
                                  uk.co.ractf.polaris.api.instance.Instance instance)
        Description copied from interface: Runner
        Creates a network between a list of pods.
        Specified by:
        createNetwork in interface Runner<uk.co.ractf.polaris.api.pod.Container>
        Parameters:
        pods - the pods to network
        task - the task the pods belong to.
        instance - the instance