本文整理汇总了Java中org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread方法的典型用法代码示例。如果您正苦于以下问题:Java JVMClusterUtil.MasterThread方法的具体用法?Java JVMClusterUtil.MasterThread怎么用?Java JVMClusterUtil.MasterThread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.util.JVMClusterUtil
的用法示例。
在下文中一共展示了JVMClusterUtil.MasterThread方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addMaster
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
public JVMClusterUtil.MasterThread addMaster(Configuration c, final int index)
throws IOException {
// Create each master with its own Configuration instance so each has
// its HConnection instance rather than share (see HBASE_INSTANCES down in
// the guts of HConnectionManager.
// Also, create separate CoordinatedStateManager instance per Server.
// This is special case when we have to have more than 1 CoordinatedStateManager
// within 1 process.
CoordinatedStateManager cp = CoordinatedStateManagerFactory.getCoordinatedStateManager(conf);
JVMClusterUtil.MasterThread mt = JVMClusterUtil.createMasterThread(c, cp,
(Class<? extends HMaster>) conf.getClass(HConstants.MASTER_IMPL, this.masterClass), index);
this.masterThreads.add(mt);
return mt;
}
示例2: waitOnMaster
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* Wait for the specified master to stop
* Removes this thread from list of running threads.
* @param masterThread
* @return Name of master that just went down.
*/
public String waitOnMaster(JVMClusterUtil.MasterThread masterThread) {
while (masterThread.isAlive()) {
try {
LOG.info("Waiting on " +
masterThread.getMaster().getServerName().toString());
masterThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
for (int i=0;i<masterThreads.size();i++) {
if (masterThreads.get(i) == masterThread) {
masterThreads.remove(i);
break;
}
}
return masterThread.getName();
}
示例3: waitForActiveAndReadyMaster
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* Blocks until there is an active master and that master has completed
* initialization.
*
* @return true if an active master becomes available. false if there are no
* masters left.
* @throws InterruptedException
*/
public boolean waitForActiveAndReadyMaster(long timeout) throws IOException {
List<JVMClusterUtil.MasterThread> mts;
long start = System.currentTimeMillis();
while (!(mts = getMasterThreads()).isEmpty()
&& (System.currentTimeMillis() - start) < timeout) {
for (JVMClusterUtil.MasterThread mt : mts) {
if (mt.getMaster().isActiveMaster() && mt.getMaster().isInitialized()) {
return true;
}
}
Threads.sleep(100);
}
return false;
}
示例4: getActiveMaster
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* Gets the current active master, if available. If no active master, returns
* null.
* @return the HMaster for the active master
*/
public HMaster getActiveMaster() {
for (JVMClusterUtil.MasterThread mt : masterThreads) {
if (mt.getMaster().isActiveMaster()) {
// Ensure that the current active master is not stopped.
// We don't want to return a stopping master as an active master.
if (mt.getMaster().isActiveMaster() && !mt.getMaster().isStopped()) {
return mt.getMaster();
}
}
}
return null;
}
示例5: getLiveMasters
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* @return List of running master servers (Some servers may have been killed
* or aborted during lifetime of cluster; these servers are not included in
* this list).
*/
public List<JVMClusterUtil.MasterThread> getLiveMasters() {
List<JVMClusterUtil.MasterThread> liveServers =
new ArrayList<JVMClusterUtil.MasterThread>();
List<JVMClusterUtil.MasterThread> list = getMasters();
for (JVMClusterUtil.MasterThread mt: list) {
if (mt.isAlive()) {
liveServers.add(mt);
}
}
return liveServers;
}
示例6: waitOnMasterThreads
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
private void waitOnMasterThreads(LocalHBaseCluster cluster) throws InterruptedException{
List<JVMClusterUtil.MasterThread> masters = cluster.getMasters();
List<JVMClusterUtil.RegionServerThread> regionservers = cluster.getRegionServers();
if (masters != null) {
for (JVMClusterUtil.MasterThread t : masters) {
t.join();
if(t.getMaster().isAborted()) {
closeAllRegionServerThreads(regionservers);
throw new RuntimeException("HMaster Aborted");
}
}
}
}
示例7: startMaster
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* Starts a master thread running
*
* @throws IOException
* @return New RegionServerThread
*/
public JVMClusterUtil.MasterThread startMaster() throws IOException {
Configuration c = HBaseConfiguration.create(conf);
User user =
HBaseTestingUtility.getDifferentUser(c, ".hfs."+index++);
JVMClusterUtil.MasterThread t = null;
try {
t = hbaseCluster.addMaster(c, hbaseCluster.getMasters().size(), user);
t.start();
} catch (InterruptedException ie) {
throw new IOException("Interrupted adding master to cluster", ie);
}
return t;
}
示例8: countServedRegions
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* Counts the total numbers of regions being served by the currently online
* region servers by asking each how many regions they have. Does not look
* at hbase:meta at all. Count includes catalog tables.
* @return number of regions being served by all region servers
*/
public long countServedRegions() {
long count = 0;
for (JVMClusterUtil.RegionServerThread rst : getLiveRegionServerThreads()) {
count += rst.getRegionServer().getNumberOfOnlineRegions();
}
for (JVMClusterUtil.MasterThread mt : getLiveMasterThreads()) {
count += mt.getMaster().getNumberOfOnlineRegions();
}
return count;
}
示例9: getActiveMasterIndex
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* return the index of the active master in the cluster
*
* @throws org.apache.hadoop.hbase.MasterNotRunningException
* if no active master found
*/
private int getActiveMasterIndex(MiniHBaseCluster cluster) throws MasterNotRunningException {
// get all the master threads
List<JVMClusterUtil.MasterThread> masterThreads = cluster.getMasterThreads();
for (int i = 0; i < masterThreads.size(); i++) {
if (masterThreads.get(i).getMaster().isActiveMaster()) {
return i;
}
}
throw new MasterNotRunningException();
}
示例10: addMaster
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
public JVMClusterUtil.MasterThread addMaster(Configuration c, final int index)
throws IOException {
// Create each master with its own Configuration instance so each has
// its HConnection instance rather than share (see HBASE_INSTANCES down in
// the guts of HConnectionManager.
JVMClusterUtil.MasterThread mt = JVMClusterUtil.createMasterThread(c,
(Class<? extends HMaster>) conf.getClass(HConstants.MASTER_IMPL, this.masterClass), index);
this.masterThreads.add(mt);
return mt;
}
示例11: waitOnMaster
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* Wait for the specified master to stop
* Removes this thread from list of running threads.
* @param serverNumber
* @return Name of master that just went down.
*/
public String waitOnMaster(int serverNumber) {
JVMClusterUtil.MasterThread masterThread =
this.masterThreads.remove(serverNumber);
while (masterThread.isAlive()) {
try {
LOG.info("Waiting on " +
masterThread.getMaster().getServerName().toString());
masterThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return masterThread.getName();
}
示例12: addMaster
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
public JVMClusterUtil.MasterThread addMaster(
final Configuration c, final int index, User user)
throws IOException, InterruptedException {
return user.runAs(
new PrivilegedExceptionAction<JVMClusterUtil.MasterThread>() {
public JVMClusterUtil.MasterThread run() throws Exception {
return addMaster(c, index);
}
});
}
示例13: waitOnMasterThreads
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
private void waitOnMasterThreads(LocalHBaseCluster cluster) throws InterruptedException {
List<JVMClusterUtil.MasterThread> masters = cluster.getMasters();
List<JVMClusterUtil.RegionServerThread> regionservers = cluster.getRegionServers();
if (masters != null) {
for (JVMClusterUtil.MasterThread t : masters) {
t.join();
if (t.getMaster().isAborted()) {
closeAllRegionServerThreads(regionservers);
throw new RuntimeException("HMaster Aborted");
}
}
}
}
示例14: getMasters
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* @return Read-only list of master threads.
*/
public List<JVMClusterUtil.MasterThread> getMasters() {
return Collections.unmodifiableList(this.masterThreads);
}
示例15: getMasterThreads
import org.apache.hadoop.hbase.util.JVMClusterUtil; //导入方法依赖的package包/类
/**
* @return List of master threads.
*/
public List<JVMClusterUtil.MasterThread> getMasterThreads() {
return this.hbaseCluster.getMasters();
}