@ThreadSafe
public final class MultiProcessCluster
extends java.lang.Object
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.| Modifier and Type | Class and Description |
|---|---|
static class |
MultiProcessCluster.Builder
Builder for
MultiProcessCluster. |
static class |
MultiProcessCluster.DeployMode
Deploy mode for the cluster.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
PORTS_PER_MASTER |
static int |
PORTS_PER_WORKER |
| Modifier and Type | Method and Description |
|---|---|
void |
addExternalMasterAddress(MasterNetAddress externalMasterAddress)
Updates internal master list with an external address.
|
void |
destroy()
Destroys the cluster.
|
void |
formatJournal()
Formats the cluster journal.
|
Clients |
getClients() |
MultiProcessCluster.DeployMode |
getDeployMode() |
FileSystem |
getFileSystemClient() |
FileSystemContext |
getFilesystemContext() |
java.lang.String |
getJournalDir() |
java.lang.String |
getJournalDir(int masterId) |
JournalMasterClient |
getJournalMasterClientForMaster() |
java.util.List<MasterNetAddress> |
getMasterAddresses() |
MasterInquireClient |
getMasterInquireClient() |
MetaMasterClient |
getMetaMasterClient() |
MetricsMasterClient |
getMetricsMasterClient() |
int |
getPrimaryMasterIndex(int timeoutMs)
Gets the index of the primary master.
|
static MultiProcessCluster.Builder |
newBuilder(java.util.List<PortCoordination.ReservedPort> reservedPorts) |
void |
notifySuccess()
Informs the cluster that the test succeeded.
|
void |
restartZk()
Restarts the Zookeeper cluster.
|
void |
saveWorkdir()
Copies the work directory to the artifacts folder.
|
void |
start()
Starts the cluster, launching all server processes.
|
void |
startMaster(int i)
Starts the specified master.
|
void |
startMasters()
Starts all masters.
|
void |
startNewMasters(int count,
boolean format)
Start a number of new master nodes.
|
void |
startWorker(int i)
Starts the specified worker.
|
void |
stopAndRemoveMaster(int i)
Removes master i from the cluster.
|
void |
stopMaster(int i) |
void |
stopMasters()
Stops all masters.
|
void |
stopWorker(int i) |
void |
stopZk()
Stops the Zookeeper cluster.
|
void |
updateDeployMode(MultiProcessCluster.DeployMode mode)
Updates the cluster's deploy mode.
|
void |
updateMasterConf(PropertyKey key,
java.lang.String value)
Updates master configuration for all masters.
|
void |
waitForAllNodesRegistered(int timeoutMs)
Waits for all nodes to be registered.
|
int |
waitForAndKillPrimaryMaster(int timeoutMs)
Kills the primary master.
|
public static final int PORTS_PER_MASTER
public static final int PORTS_PER_WORKER
public void start()
throws java.lang.Exception
java.lang.Exceptionpublic void startNewMasters(int count,
boolean format)
throws java.lang.Exception
count - the count of the masters to startformat - whether to format the master firstjava.lang.Exception - if any error occurspublic int waitForAndKillPrimaryMaster(int timeoutMs)
throws java.util.concurrent.TimeoutException,
java.lang.InterruptedException
timeoutMs - maximum amount of time to wait, in millisecondsjava.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionpublic int getPrimaryMasterIndex(int timeoutMs)
throws java.util.concurrent.TimeoutException,
java.lang.InterruptedException
timeoutMs - maximum amount of time to wait, in millisecondsjava.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionpublic void waitForAllNodesRegistered(int timeoutMs)
throws java.util.concurrent.TimeoutException,
java.lang.InterruptedException
timeoutMs - maximum amount of time to wait, in millisecondsjava.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionpublic MultiProcessCluster.DeployMode getDeployMode()
public FileSystemContext getFilesystemContext()
FileSystemContext which can be used to access the clusterpublic FileSystem getFileSystemClient()
public MetaMasterClient getMetaMasterClient()
public MetricsMasterClient getMetricsMasterClient()
public JournalMasterClient getJournalMasterClientForMaster()
public Clients getClients()
public void notifySuccess()
public void saveWorkdir()
throws java.io.IOException
java.io.IOExceptionpublic void destroy()
throws java.io.IOException
java.io.IOExceptionpublic void startMasters()
public void startMaster(int i)
throws java.io.IOException
i - the index of the master to startjava.io.IOExceptionpublic void startWorker(int i)
throws java.io.IOException
i - the index of the worker to startjava.io.IOExceptionpublic void stopMasters()
public void stopMaster(int i)
throws java.io.IOException
i - the index of the master to stopjava.io.IOExceptionpublic void stopAndRemoveMaster(int i)
throws java.io.IOException
i - index of the master to be removedjava.io.IOExceptionpublic void updateMasterConf(PropertyKey key, @Nullable java.lang.String value)
key - the key to updatevalue - the value to set, or null to unset the keypublic void addExternalMasterAddress(MasterNetAddress externalMasterAddress)
externalMasterAddress - external master addresspublic void updateDeployMode(MultiProcessCluster.DeployMode mode)
mode - the mode to setpublic void stopWorker(int i)
throws java.io.IOException
i - the index of the worker to stopjava.io.IOExceptionpublic java.lang.String getJournalDir()
public java.lang.String getJournalDir(int masterId)
masterId - index of the masterpublic java.util.List<MasterNetAddress> getMasterAddresses()
public void stopZk()
throws java.io.IOException
java.io.IOExceptionpublic void restartZk()
throws java.lang.Exception
java.lang.Exceptionpublic void formatJournal()
throws java.io.IOException
java.io.IOExceptionpublic MasterInquireClient getMasterInquireClient()
public static MultiProcessCluster.Builder newBuilder(java.util.List<PortCoordination.ReservedPort> reservedPorts)
reservedPorts - ports reserved for usage by this clusterMultiProcessClusterCopyright © 2023. All Rights Reserved.