Class MultiProcessCluster


  • @ThreadSafe
    public final class MultiProcessCluster
    extends java.lang.Object
    Class for starting, stopping, and interacting with an Alluxio cluster where each master and worker runs in its own process. Compared to LocalAlluxioCluster, MultiProcessCluster is - Slower - Black box testing only (No access to master/worker internals) - Destructible (You can kill -9 masters/workers) - More realistic of real deployments Due to the slower speed, [@link LocalAlluxioCluster} should generally be preferred. MultiProcessCluster is primarily for tests which want to stop or restart servers. The synchronization strategy for this class is to synchronize all public methods.
    • Method Detail

      • start

        public void start()
                   throws java.lang.Exception
        Starts the cluster, launching all server processes.
        Throws:
        java.lang.Exception
      • waitForAndKillPrimaryMaster

        public int waitForAndKillPrimaryMaster​(int timeoutMs)
                                        throws java.util.concurrent.TimeoutException,
                                               java.lang.InterruptedException
        Kills the primary master. If no master is currently primary, this method blocks until a primary has been elected, then kills it.
        Parameters:
        timeoutMs - maximum amount of time to wait, in milliseconds
        Returns:
        the ID of the killed master
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
      • getPrimaryMasterIndex

        public int getPrimaryMasterIndex​(int timeoutMs)
                                  throws java.util.concurrent.TimeoutException,
                                         java.lang.InterruptedException
        Gets the index of the primary master.
        Parameters:
        timeoutMs - maximum amount of time to wait, in milliseconds
        Returns:
        the index of the primary master
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
      • waitForAllNodesRegistered

        public void waitForAllNodesRegistered​(int timeoutMs)
                                       throws java.util.concurrent.TimeoutException,
                                              java.lang.InterruptedException
        Waits for all nodes to be registered.
        Parameters:
        timeoutMs - maximum amount of time to wait, in milliseconds
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
      • getFilesystemContext

        public alluxio.client.file.FileSystemContext getFilesystemContext()
        Returns:
        the FileSystemContext which can be used to access the cluster
      • getFileSystemClient

        public alluxio.client.file.FileSystem getFileSystemClient()
        Returns:
        a client for interacting with the cluster
      • getMetaMasterClient

        public alluxio.client.meta.MetaMasterClient getMetaMasterClient()
        Returns:
        a meta master client
      • getMetricsMasterClient

        public alluxio.client.metrics.MetricsMasterClient getMetricsMasterClient()
        Returns:
        a metrics master client
      • getJournalMasterClientForMaster

        public alluxio.client.journal.JournalMasterClient getJournalMasterClientForMaster()
        Returns:
        a journal master client for alluxio master
      • getClients

        public Clients getClients()
        Returns:
        clients for communicating with the cluster
      • notifySuccess

        public void notifySuccess()
        Informs the cluster that the test succeeded. If this method is never called, the cluster will save a copy of its state during teardown.
      • saveWorkdir

        public void saveWorkdir()
                         throws java.io.IOException
        Copies the work directory to the artifacts folder.
        Throws:
        java.io.IOException
      • destroy

        public void destroy()
                     throws java.io.IOException
        Destroys the cluster. It may not be re-started after being destroyed.
        Throws:
        java.io.IOException
      • startMasters

        public void startMasters()
        Starts all masters.
      • startMaster

        public void startMaster​(int i)
                         throws java.io.IOException
        Starts the specified master.
        Parameters:
        i - the index of the master to start
        Throws:
        java.io.IOException
      • startWorker

        public void startWorker​(int i)
                         throws java.io.IOException
        Starts the specified worker.
        Parameters:
        i - the index of the worker to start
        Throws:
        java.io.IOException
      • stopMasters

        public void stopMasters()
        Stops all masters.
      • stopMaster

        public void stopMaster​(int i)
                        throws java.io.IOException
        Parameters:
        i - the index of the master to stop
        Throws:
        java.io.IOException
      • updateMasterConf

        public void updateMasterConf​(alluxio.conf.PropertyKey key,
                                     @Nullable
                                     java.lang.String value)
        Updates master configuration for all masters. This will take effect on a master the next time the master is started.
        Parameters:
        key - the key to update
        value - the value to set, or null to unset the key
      • addExternalMasterAddress

        public void addExternalMasterAddress​(MasterNetAddress externalMasterAddress)
        Updates internal master list with an external address. This API is to provide support when this cluster is joined by external masters. Calling this API with an external master address will make this cluster aware of it when creating clients/contexts etc.
        Parameters:
        externalMasterAddress - external master address
      • updateDeployMode

        public void updateDeployMode​(MultiProcessCluster.DeployMode mode)
        Updates the cluster's deploy mode.
        Parameters:
        mode - the mode to set
      • stopWorker

        public void stopWorker​(int i)
                        throws java.io.IOException
        Parameters:
        i - the index of the worker to stop
        Throws:
        java.io.IOException
      • getJournalDir

        public java.lang.String getJournalDir()
        Returns:
        the journal directory
      • getJournalDir

        public java.lang.String getJournalDir​(int masterId)
        Parameters:
        masterId - index of the master
        Returns:
        the journal directory for the specified master
      • getMasterAddresses

        public java.util.List<MasterNetAddress> getMasterAddresses()
        Returns:
        return the list of master addresses
      • stopZk

        public void stopZk()
                    throws java.io.IOException
        Stops the Zookeeper cluster.
        Throws:
        java.io.IOException
      • restartZk

        public void restartZk()
                       throws java.lang.Exception
        Restarts the Zookeeper cluster.
        Throws:
        java.lang.Exception
      • formatJournal

        public void formatJournal()
                           throws java.io.IOException
        Formats the cluster journal.
        Throws:
        java.io.IOException
      • getMasterInquireClient

        public alluxio.master.MasterInquireClient getMasterInquireClient()
        Returns:
        a client for determining the serving master