Package org.apache.hadoop.hbase.util
Class ProcessBasedLocalHBaseCluster
java.lang.Object
org.apache.hadoop.hbase.util.ProcessBasedLocalHBaseCluster
A helper class for process-based mini-cluster tests. Unlike
SingleProcessHBaseCluster
,
starts daemons as separate processes, allowing to do real kill testing.-
Nested Class Summary
Modifier and TypeClassDescriptionprivate final class
private static enum
-
Field Summary
Modifier and TypeFieldDescriptionprivate final org.apache.hadoop.conf.Configuration
private org.apache.hadoop.hdfs.MiniDFSCluster
private String
private final String
private static final org.slf4j.Logger
private static final Pattern
private Thread
private static final int
private final int
private final int
private final int
private boolean
private HBaseTestingUtil
private static final Pattern
private final String
private final int
-
Constructor Summary
ConstructorDescriptionProcessBasedLocalHBaseCluster
(org.apache.hadoop.conf.Configuration conf, int numDataNodes, int numRegionServers) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
private void
private void
executeCommand
(String command) private void
executeCommand
(String command, Map<String, String> envOverrides) private final String
generateConfig
(ProcessBasedLocalHBaseCluster.ServerType serverType, int rpcPort, String daemonDir) org.apache.hadoop.conf.Configuration
getConf()
private int
getServerPID
(ProcessBasedLocalHBaseCluster.ServerType serverType, int port) void
private void
killProcess
(int pid) void
killRegionServer
(int port) private void
killServer
(ProcessBasedLocalHBaseCluster.ServerType serverType, int port) private String
pidFilePath
(ProcessBasedLocalHBaseCluster.ServerType serverType, int port) private static String
processLine
(String line) private static int
readPidFromFile
(String pidFile) private static void
reportWebUIPort
(String daemon, int port) private String
serverWorkingDir
(ProcessBasedLocalHBaseCluster.ServerType serverType, int port) void
shutdown()
private void
sortedPorts
(int n) Generates a list of random port numbers in the sorted order.private void
void
void
startMaster
(int port) void
Makes this local HBase cluster use a mini-DFS cluster.void
startRegionServer
(int port) private void
startServer
(ProcessBasedLocalHBaseCluster.ServerType serverType, int rsPort) void
startZK()
private void
writeStringToFile
(String s, String fileName)
-
Field Details
-
hbaseHome
-
workDir
-
conf
-
numMasters
-
numRegionServers
-
numDataNodes
-
rsPorts
-
masterPorts
-
zkClientPort
-
MAX_FILE_SIZE_OVERRIDE
- See Also:
-
LOG
-
daemonPidFiles
-
shutdownHookInstalled
-
hbaseDaemonScript
-
dfsCluster
-
testUtil
-
logTailerThread
-
logTailDirs
-
TO_REMOVE_FROM_LOG_LINES_RE
-
LOG_PATH_FORMAT_RE
-
-
Constructor Details
-
ProcessBasedLocalHBaseCluster
public ProcessBasedLocalHBaseCluster(org.apache.hadoop.conf.Configuration conf, int numDataNodes, int numRegionServers) Constructor. Modifies the passed configuration.- Parameters:
conf
- theConfiguration
to usenumDataNodes
- the number of data nodesnumRegionServers
- the number of region servers
-
-
Method Details
-
startMiniDFS
Makes this local HBase cluster use a mini-DFS cluster. Must be called beforestartHBase()
.- Throws:
Exception
-
sortedPorts
Generates a list of random port numbers in the sorted order. A sorted order makes sense if we ever want to refer to these servers by their index in the returned array, e.g. server #0, #1, etc. -
startHBase
- Throws:
IOException
-
startRegionServer
-
startMaster
-
killRegionServer
- Throws:
IOException
-
killMaster
- Throws:
IOException
-
startZK
-
executeCommand
-
executeCommand
-
shutdownAllProcesses
-
ensureShutdownHookInstalled
-
cleanupOldState
-
writeStringToFile
-
serverWorkingDir
-
getServerPID
private int getServerPID(ProcessBasedLocalHBaseCluster.ServerType serverType, int port) throws IOException - Throws:
IOException
-
readPidFromFile
- Throws:
IOException
-
pidFilePath
-
killServer
private void killServer(ProcessBasedLocalHBaseCluster.ServerType serverType, int port) throws IOException - Throws:
IOException
-
killProcess
-
startServer
-
generateConfig
private final String generateConfig(ProcessBasedLocalHBaseCluster.ServerType serverType, int rpcPort, String daemonDir) -
reportWebUIPort
-
getConf
-
shutdown
-
processLine
-
startDaemonLogTailer
-