Package org.apache.hadoop.hbase.util
Class JVMClusterUtil
java.lang.Object
org.apache.hadoop.hbase.util.JVMClusterUtil
Utility used running a cluster all in the one JVM.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDatastructure to hold Master Thread and Master instancestatic classDatastructure to hold RegionServer Thread and RegionServer instance -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic JVMClusterUtil.MasterThreadcreateMasterThread(org.apache.hadoop.conf.Configuration c, Class<? extends HMaster> hmc, int index) Creates aJVMClusterUtil.MasterThread.createRegionServerThread(org.apache.hadoop.conf.Configuration c, Class<? extends HRegionServer> hrsc, int index) Creates aJVMClusterUtil.RegionServerThread.private static JVMClusterUtil.MasterThreadfindActiveMaster(List<JVMClusterUtil.MasterThread> masters) static voidshutdown(List<JVMClusterUtil.MasterThread> masters, List<JVMClusterUtil.RegionServerThread> regionservers) static Stringstartup(List<JVMClusterUtil.MasterThread> masters, List<JVMClusterUtil.RegionServerThread> regionservers) Start the cluster.private static voidwaitForEvent(long millis, String action, Supplier<Boolean> check) Utility method to wait some time for an event to occur, and then return control to the caller.
-
Field Details
-
LOG
-
-
Constructor Details
-
JVMClusterUtil
public JVMClusterUtil()
-
-
Method Details
-
createRegionServerThread
public static JVMClusterUtil.RegionServerThread createRegionServerThread(org.apache.hadoop.conf.Configuration c, Class<? extends HRegionServer> hrsc, int index) throws IOException Creates aJVMClusterUtil.RegionServerThread. Call 'start' on the returned thread to make it run.- Parameters:
c- Configuration to use.hrsc- Class to create.index- Used distinguishing the object returned.- Returns:
- Region server added.
- Throws:
IOException
-
createMasterThread
public static JVMClusterUtil.MasterThread createMasterThread(org.apache.hadoop.conf.Configuration c, Class<? extends HMaster> hmc, int index) throws IOException Creates aJVMClusterUtil.MasterThread. Call 'start' on the returned thread to make it run.- Parameters:
c- Configuration to use.hmc- Class to create.index- Used distinguishing the object returned.- Returns:
- Master added.
- Throws:
IOException
-
findActiveMaster
private static JVMClusterUtil.MasterThread findActiveMaster(List<JVMClusterUtil.MasterThread> masters) -
startup
public static String startup(List<JVMClusterUtil.MasterThread> masters, List<JVMClusterUtil.RegionServerThread> regionservers) throws IOException Start the cluster. Waits until there is a primary master initialized and returns its address.- Returns:
- Address to use contacting primary master.
- Throws:
IOException
-
waitForEvent
private static void waitForEvent(long millis, String action, Supplier<Boolean> check) throws InterruptedIOException Utility method to wait some time for an event to occur, and then return control to the caller.- Parameters:
millis- How long to wait, in milliseconds.action- The action that we are waiting for. Will be used in log message if the event does not occur.check- A Supplier that will be checked periodically to produce an updated true/false result indicating if the expected event has happened or not.- Throws:
InterruptedIOException- If we are interrupted while waiting for the event.RuntimeException- If we reach the specified timeout while waiting for the event.
-
shutdown
public static void shutdown(List<JVMClusterUtil.MasterThread> masters, List<JVMClusterUtil.RegionServerThread> regionservers)
-