本文整理汇总了Java中org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread类的典型用法代码示例。如果您正苦于以下问题:Java MasterThread类的具体用法?Java MasterThread怎么用?Java MasterThread使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MasterThread类属于org.apache.hadoop.hbase.util.JVMClusterUtil包,在下文中一共展示了MasterThread类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: waitForActiveAndReadyMaster
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的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;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:MiniHBaseCluster.java
示例2: waitForRSShutdownToStartAndFinish
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的package包/类
private void waitForRSShutdownToStartAndFinish(MasterThread activeMaster,
ServerName serverName) throws InterruptedException {
ServerManager sm = activeMaster.getMaster().getServerManager();
// First wait for it to be in dead list
while (!sm.getDeadServers().isDeadServer(serverName)) {
log("Waiting for [" + serverName + "] to be listed as dead in master");
Thread.sleep(1);
}
log("Server [" + serverName + "] marked as dead, waiting for it to " +
"finish dead processing");
while (sm.areDeadServersInProgress()) {
log("Server [" + serverName + "] still being processed, waiting");
Thread.sleep(100);
}
log("Server [" + serverName + "] done with server shutdown processing");
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:TestRollingRestart.java
示例3: waitForActiveAndReadyMaster
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的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) {
ServerManager serverManager = mt.getMaster().getServerManager();
if (mt.getMaster().isActiveMaster() && mt.getMaster().isInitialized()
&& !serverManager.areDeadServersInProgress()) {
return true;
}
}
Threads.sleep(100);
}
return false;
}
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:26,代码来源:MiniHBaseCluster.java
示例4: waitForRSShutdownToStartAndFinish
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的package包/类
private void waitForRSShutdownToStartAndFinish(MasterThread activeMaster,
ServerName serverName) throws InterruptedException {
ServerManager sm = activeMaster.getMaster().getServerManager();
// First wait for it to be in dead list
while (!sm.getDeadServers().contains(serverName)) {
log("Waiting for [" + serverName + "] to be listed as dead in master");
Thread.sleep(1);
}
log("Server [" + serverName + "] marked as dead, waiting for it to " +
"finish dead processing");
while (sm.areDeadServersInProgress()) {
log("Server [" + serverName + "] still being processed, waiting");
Thread.sleep(100);
}
log("Server [" + serverName + "] done with server shutdown processing");
}
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:17,代码来源:TestRollingRestart.java
示例5: testMasterAndBackupMastersStatus
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的package包/类
@Test
public void testMasterAndBackupMastersStatus() throws Exception {
// get all the master threads
List<MasterThread> masterThreads = CLUSTER.getMasterThreads();
int numActive = 0;
int activeIndex = 0;
ServerName activeName = null;
HMaster active = null;
for (int i = 0; i < masterThreads.size(); i++) {
if (masterThreads.get(i).getMaster().isActiveMaster()) {
numActive++;
activeIndex = i;
active = masterThreads.get(activeIndex).getMaster();
activeName = active.getServerName();
}
}
Assert.assertNotNull(active);
Assert.assertEquals(1, numActive);
Assert.assertEquals(MASTERS, masterThreads.size());
// Retrieve master and backup masters infos only.
EnumSet<Option> options = EnumSet.of(Option.MASTER, Option.BACKUP_MASTERS);
ClusterStatus status = new ClusterStatus(ADMIN.getClusterMetrics(options));
Assert.assertTrue(status.getMaster().equals(activeName));
Assert.assertEquals(MASTERS - 1, status.getBackupMastersSize());
}
开发者ID:apache,项目名称:hbase,代码行数:26,代码来源:TestClientClusterStatus.java
示例6: waitForActiveAndReadyMaster
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的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
*/
@Override
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;
}
开发者ID:apache,项目名称:hbase,代码行数:25,代码来源:MiniHBaseCluster.java
示例7: killAll
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的package包/类
/**
* Do a simulated kill all masters and regionservers. Useful when it is
* impossible to bring the mini-cluster back for clean shutdown.
*/
public void killAll() {
// Do backups first.
MasterThread activeMaster = null;
for (MasterThread masterThread : getMasterThreads()) {
if (!masterThread.getMaster().isActiveMaster()) {
masterThread.getMaster().abort("killAll");
} else {
activeMaster = masterThread;
}
}
// Do active after.
if (activeMaster != null) {
activeMaster.getMaster().abort("killAll");
}
for (RegionServerThread rst : getRegionServerThreads()) {
rst.getRegionServer().abort("killAll");
}
}
开发者ID:apache,项目名称:hbase,代码行数:23,代码来源:MiniHBaseCluster.java
示例8: testMasterAndBackupMastersStatus
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的package包/类
@Test
public void testMasterAndBackupMastersStatus() throws Exception {
// get all the master threads
List<MasterThread> masterThreads = CLUSTER.getMasterThreads();
int numActive = 0;
int activeIndex = 0;
ServerName activeName = null;
HMaster active = null;
for (int i = 0; i < masterThreads.size(); i++) {
if (masterThreads.get(i).getMaster().isActiveMaster()) {
numActive++;
activeIndex = i;
active = masterThreads.get(activeIndex).getMaster();
activeName = active.getServerName();
}
}
Assert.assertNotNull(active);
Assert.assertEquals(1, numActive);
Assert.assertEquals(MASTERS, masterThreads.size());
// Retrieve master and backup masters infos only.
EnumSet<Option> options = EnumSet.of(Option.MASTER, Option.BACKUP_MASTERS);
ClusterMetrics metrics = ADMIN.getClusterMetrics(options);
Assert.assertTrue(metrics.getMasterName().equals(activeName));
Assert.assertEquals(MASTERS - 1, metrics.getBackupMasterNames().size());
}
开发者ID:apache,项目名称:hbase,代码行数:26,代码来源:TestClientClusterMetrics.java
示例9: testShutdownWhileBecomingActive
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的package包/类
@Test
public void testShutdownWhileBecomingActive() throws InterruptedException {
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
HMaster activeMaster = null;
HMaster backupMaster = null;
for (MasterThread t : cluster.getMasterThreads()) {
if (t.getMaster().isActiveMaster()) {
activeMaster = t.getMaster();
} else {
backupMaster = t.getMaster();
}
}
assertNotNull(activeMaster);
assertNotNull(backupMaster);
ARRIVE = new CountDownLatch(1);
CONTINUE = new CountDownLatch(1);
activeMaster.abort("Aborting active master for test");
// wait until we arrive the initClusterSchemaService
ARRIVE.await();
// killall RSes
cluster.getRegionServerThreads().stream().map(t -> t.getRegionServer())
.forEachOrdered(rs -> rs.abort("Aborting RS for test"));
CONTINUE.countDown();
}
开发者ID:apache,项目名称:hbase,代码行数:25,代码来源:TestShutdownBackupMaster.java
示例10: startMaster
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的package包/类
/**
* Start Master. Get as far as the state where Master is waiting on
* RegionServers to check in, then return.
*/
private MasterThread startMaster(MasterThread master) {
master.start();
// It takes a while until ServerManager creation to happen inside Master startup.
while (master.getMaster().getServerManager() == null) {
continue;
}
// Set a listener for the waiting-on-RegionServers state. We want to wait
// until this condition before we leave this method and start regionservers.
final AtomicBoolean waiting = new AtomicBoolean(false);
if (master.getMaster().getServerManager() == null) throw new NullPointerException("SM");
master.getMaster().getServerManager().registerListener(new ServerListener() {
@Override
public void waiting() {
waiting.set(true);
}
});
// Wait until the Master gets to place where it is waiting on RegionServers to check in.
while (!waiting.get()) {
continue;
}
// Set the global master-is-active; gets picked up by regionservers later.
masterActive.set(true);
return master;
}
开发者ID:apache,项目名称:hbase,代码行数:29,代码来源:TestRSKilledWhenInitializing.java
示例11: startMaster
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的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;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:MiniHBaseCluster.java
示例12: getMasterThread
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的package包/类
/**
* Returns the current active master thread, if available.
* @return the active MasterThread, null if none is active.
*/
public MasterThread getMasterThread() {
for (MasterThread mt: hbaseCluster.getLiveMasters()) {
if (mt.getMaster().isActiveMaster()) {
return mt;
}
}
return null;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:13,代码来源:MiniHBaseCluster.java
示例13: countServedRegions
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的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;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:MiniHBaseCluster.java
示例14: killAll
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的package包/类
/**
* Do a simulated kill all masters and regionservers. Useful when it is
* impossible to bring the mini-cluster back for clean shutdown.
*/
public void killAll() {
for (RegionServerThread rst : getRegionServerThreads()) {
rst.getRegionServer().abort("killAll");
}
for (MasterThread masterThread : getMasterThreads()) {
masterThread.getMaster().abort("killAll", new Throwable());
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:13,代码来源:MiniHBaseCluster.java
示例15: getMasterIndex
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的package包/类
protected int getMasterIndex(ServerName serverName) {
List<MasterThread> masters = getMasterThreads();
for (int i = 0; i < masters.size(); i++) {
if (masters.get(i).getMaster().getServerName().equals(serverName)) {
return i;
}
}
return -1;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:10,代码来源:MiniHBaseCluster.java
示例16: decrementMinRegionServerCount
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的package包/类
private void decrementMinRegionServerCount() {
// decrement the count for this.conf, for newly spwaned master
// this.hbaseCluster shares this configuration too
decrementMinRegionServerCount(getConfiguration());
// each master thread keeps a copy of configuration
for (MasterThread master : getHBaseCluster().getMasterThreads()) {
decrementMinRegionServerCount(master.getMaster().getConfiguration());
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:HBaseTestingUtility.java
示例17: getNumberOfOnlineRegions
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的package包/类
private int getNumberOfOnlineRegions(MiniHBaseCluster cluster) {
int numFound = 0;
for (RegionServerThread rst : cluster.getLiveRegionServerThreads()) {
numFound += rst.getRegionServer().getNumberOfOnlineRegions();
}
for (MasterThread mt : cluster.getMasterThreads()) {
numFound += mt.getMaster().getNumberOfOnlineRegions();
}
return numFound;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:TestRollingRestart.java
示例18: waitForClusterOnline
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; //导入依赖的package包/类
private void waitForClusterOnline(MasterThread master) throws InterruptedException {
while (true) {
if (master.getMaster().isInitialized()) {
break;
}
Thread.sleep(SLEEP_INTERVAL);
LOG.debug("Waiting for master to come online ...");
}
rs.waitForServerOnline();
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:TestRegionServerReportForDuty.java
注:本文中的org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论