本文整理汇总了Java中org.apache.hadoop.ha.HAServiceProtocol类的典型用法代码示例。如果您正苦于以下问题:Java HAServiceProtocol类的具体用法?Java HAServiceProtocol怎么用?Java HAServiceProtocol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HAServiceProtocol类属于org.apache.hadoop.ha包,在下文中一共展示了HAServiceProtocol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import org.apache.hadoop.ha.HAServiceProtocol; //导入依赖的package包/类
@Before
public void setup() throws IOException, InterruptedException {
Configuration conf = new YarnConfiguration();
conf.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false);
conf.set(YarnConfiguration.RM_WEBAPP_ADDRESS, "localhost:0");
cluster = new MiniYARNCluster(TestMiniYARNClusterForHA.class.getName(),
2, 1, 1, 1);
cluster.init(conf);
cluster.start();
cluster.getResourceManager(0).getRMContext().getRMAdminService()
.transitionToActive(new HAServiceProtocol.StateChangeRequestInfo(
HAServiceProtocol.RequestSource.REQUEST_BY_USER));
assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex());
}
示例2: transitionToActive
import org.apache.hadoop.ha.HAServiceProtocol; //导入依赖的package包/类
synchronized void transitionToActive() throws Exception {
if (rmContext.getHAServiceState() == HAServiceProtocol.HAServiceState.ACTIVE) {
LOG.info("Already in active state");
return;
}
LOG.info("Transitioning to active state");
this.rmLoginUGI.doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
try {
startActiveServices();
return null;
} catch (Exception e) {
reinitialize(true);
throw e;
}
}
});
rmContext.setHAServiceState(HAServiceProtocol.HAServiceState.ACTIVE);
LOG.info("Transitioned to active state");
}
示例3: transitionToStandby
import org.apache.hadoop.ha.HAServiceProtocol; //导入依赖的package包/类
synchronized void transitionToStandby(boolean initialize)
throws Exception {
if (rmContext.getHAServiceState() ==
HAServiceProtocol.HAServiceState.STANDBY) {
LOG.info("Already in standby state");
return;
}
LOG.info("Transitioning to standby state");
if (rmContext.getHAServiceState() ==
HAServiceProtocol.HAServiceState.ACTIVE) {
stopActiveServices();
reinitialize(initialize);
}
rmContext.setHAServiceState(HAServiceProtocol.HAServiceState.STANDBY);
LOG.info("Transitioned to standby state");
}
示例4: transitionToStandby
import org.apache.hadoop.ha.HAServiceProtocol; //导入依赖的package包/类
@Override
public synchronized void transitionToStandby(
HAServiceProtocol.StateChangeRequestInfo reqInfo) throws IOException {
// call refreshAdminAcls before HA state transition
// for the case that adminAcls have been updated in previous active RM
try {
refreshAdminAcls(false);
} catch (YarnException ex) {
throw new ServiceFailedException("Can not execute refreshAdminAcls", ex);
}
UserGroupInformation user = checkAccess("transitionToStandby");
checkHaStateChange(reqInfo);
try {
rm.transitionToStandby(true);
RMAuditLogger.logSuccess(user.getShortUserName(),
"transitionToStandby", "RMHAProtocolService");
} catch (Exception e) {
RMAuditLogger.logFailure(user.getShortUserName(), "transitionToStandby",
"", "RMHAProtocolService",
"Exception transitioning to standby");
throw new ServiceFailedException(
"Error when transitioning to Standby mode", e);
}
}
示例5: testTransitionToActive
import org.apache.hadoop.ha.HAServiceProtocol; //导入依赖的package包/类
@Test(timeout = 500)
public void testTransitionToActive() throws Exception {
String[] args = {"-transitionToActive", "rm1"};
// RM HA is disabled.
// transitionToActive should not be executed
assertEquals(-1, rmAdminCLI.run(args));
verify(haadmin, never()).transitionToActive(
any(HAServiceProtocol.StateChangeRequestInfo.class));
// Now RM HA is enabled.
// transitionToActive should be executed
assertEquals(0, rmAdminCLIWithHAEnabled.run(args));
verify(haadmin).transitionToActive(
any(HAServiceProtocol.StateChangeRequestInfo.class));
}
示例6: testTransitionToStandby
import org.apache.hadoop.ha.HAServiceProtocol; //导入依赖的package包/类
@Test(timeout = 500)
public void testTransitionToStandby() throws Exception {
String[] args = {"-transitionToStandby", "rm1"};
// RM HA is disabled.
// transitionToStandby should not be executed
assertEquals(-1, rmAdminCLI.run(args));
verify(haadmin, never()).transitionToStandby(
any(HAServiceProtocol.StateChangeRequestInfo.class));
// Now RM HA is enabled.
// transitionToActive should be executed
assertEquals(0, rmAdminCLIWithHAEnabled.run(args));
verify(haadmin).transitionToStandby(
any(HAServiceProtocol.StateChangeRequestInfo.class));
}
示例7: setup
import org.apache.hadoop.ha.HAServiceProtocol; //导入依赖的package包/类
@Before
public void setup() throws IOException {
mockProtocol = MockitoUtil.mockProtocol(HAServiceProtocol.class);
mockZkfcProtocol = MockitoUtil.mockProtocol(ZKFCProtocol.class);
tool = new DFSHAAdmin() {
@Override
protected HAServiceTarget resolveTarget(String nnId) {
HAServiceTarget target = super.resolveTarget(nnId);
HAServiceTarget spy = Mockito.spy(target);
// OVerride the target to return our mock protocol
try {
Mockito.doReturn(mockProtocol).when(spy).getProxy(
Mockito.<Configuration>any(), Mockito.anyInt());
Mockito.doReturn(mockZkfcProtocol).when(spy).getZKFCProxy(
Mockito.<Configuration>any(), Mockito.anyInt());
} catch (IOException e) {
throw new AssertionError(e); // mock setup doesn't really throw
}
return spy;
}
};
tool.setConf(getHAConf());
tool.setErrOut(new PrintStream(errOutBytes));
tool.setOut(new PrintStream(outBytes));
}
示例8: transitionToStandby
import org.apache.hadoop.ha.HAServiceProtocol; //导入依赖的package包/类
synchronized void transitionToStandby(boolean initialize)
throws Exception {
if (rmContext.getHAServiceState() ==
HAServiceProtocol.HAServiceState.STANDBY) {
LOG.info("Already in standby state");
return;
}
LOG.info("Transitioning to standby state");
HAServiceState state = rmContext.getHAServiceState();
rmContext.setHAServiceState(HAServiceProtocol.HAServiceState.STANDBY);
if (state == HAServiceProtocol.HAServiceState.ACTIVE) {
stopActiveServices();
reinitialize(initialize);
}
LOG.info("Transitioned to standby state");
}
示例9: testTransitionToActive
import org.apache.hadoop.ha.HAServiceProtocol; //导入依赖的package包/类
@Test(timeout = 500)
public void testTransitionToActive() throws Exception {
String[] args = {"-transitionToActive", "rm1"};
// RM HA is disabled.
// transitionToActive should not be executed
assertEquals(-1, rmAdminCLI.run(args));
verify(haadmin, never()).transitionToActive(
any(HAServiceProtocol.StateChangeRequestInfo.class));
// Now RM HA is enabled.
// transitionToActive should be executed
assertEquals(0, rmAdminCLIWithHAEnabled.run(args));
verify(haadmin).transitionToActive(
any(HAServiceProtocol.StateChangeRequestInfo.class));
// HAAdmin#isOtherTargetNodeActive should check state of non-target node.
verify(haadmin, times(1)).getServiceStatus();
}
示例10: transitionToStandby
import org.apache.hadoop.ha.HAServiceProtocol; //导入依赖的package包/类
@Override
public synchronized void transitionToStandby(
HAServiceProtocol.StateChangeRequestInfo reqInfo) throws IOException {
// call refreshAdminAcls before HA state transition
// for the case that adminAcls have been updated in previous active RM
try {
refreshAdminAcls(false);
} catch (YarnException ex) {
throw new ServiceFailedException("Can not execute refreshAdminAcls", ex);
}
UserGroupInformation user = checkAccess("transitionToStandby");
checkHaStateChange(reqInfo);
try {
rm.transitionToStandby(true);
RMAuditLogger.logSuccess(user.getShortUserName(),
"transitionToStandby", "RMHAProtocolService");
} catch (Exception e) {
RMAuditLogger.logFailure(user.getShortUserName(), "transitionToStandby",
adminAcl.toString(), "RMHAProtocolService",
"Exception transitioning to standby");
throw new ServiceFailedException(
"Error when transitioning to Standby mode", e);
}
}
示例11: transitionToStandby
import org.apache.hadoop.ha.HAServiceProtocol; //导入依赖的package包/类
@Override
public synchronized void transitionToStandby(
HAServiceProtocol.StateChangeRequestInfo reqInfo) throws IOException {
// call refreshAdminAcls before HA state transition
// for the case that adminAcls have been updated in previous active RM
try {
refreshAdminAcls(false);
} catch (YarnException ex) {
throw new ServiceFailedException("Can not execute refreshAdminAcls", ex);
}
UserGroupInformation user = checkAccess("transitionToStandby");
checkHaStateChange(reqInfo);
try {
rm.transitionToStandby(true);
RMAuditLogger.logSuccess(user.getShortUserName(),
"transitionToStandby", "RM");
} catch (Exception e) {
RMAuditLogger.logFailure(user.getShortUserName(), "transitionToStandby",
"", "RM",
"Exception transitioning to standby");
throw new ServiceFailedException(
"Error when transitioning to Standby mode", e);
}
}
示例12: testTransitionToActive
import org.apache.hadoop.ha.HAServiceProtocol; //导入依赖的package包/类
@Test
public void testTransitionToActive() throws Exception {
String[] args = {"-transitionToActive", "rm1"};
// RM HA is disabled.
// transitionToActive should not be executed
assertEquals(-1, rmAdminCLI.run(args));
verify(haadmin, never()).transitionToActive(
any(HAServiceProtocol.StateChangeRequestInfo.class));
// Now RM HA is enabled.
// transitionToActive should be executed
assertEquals(0, rmAdminCLIWithHAEnabled.run(args));
verify(haadmin).transitionToActive(
any(HAServiceProtocol.StateChangeRequestInfo.class));
// HAAdmin#isOtherTargetNodeActive should check state of non-target node.
verify(haadmin, times(1)).getServiceStatus();
}
示例13: testTransitionToStandby
import org.apache.hadoop.ha.HAServiceProtocol; //导入依赖的package包/类
@Test
public void testTransitionToStandby() throws Exception {
String[] args = {"-transitionToStandby", "rm1"};
// RM HA is disabled.
// transitionToStandby should not be executed
assertEquals(-1, rmAdminCLI.run(args));
verify(haadmin, never()).transitionToStandby(
any(HAServiceProtocol.StateChangeRequestInfo.class));
// Now RM HA is enabled.
// transitionToActive should be executed
assertEquals(0, rmAdminCLIWithHAEnabled.run(args));
verify(haadmin).transitionToStandby(
any(HAServiceProtocol.StateChangeRequestInfo.class));
}
示例14: transitionToActive
import org.apache.hadoop.ha.HAServiceProtocol; //导入依赖的package包/类
synchronized void transitionToActive() throws Exception {
if (rmContext.getHAServiceState() ==
HAServiceProtocol.HAServiceState.ACTIVE) {
LOG.info("Already in active state");
return;
}
LOG.info("Transitioning to active state");
// use rmLoginUGI to startActiveServices.
// in non-secure model, rmLoginUGI will be current UGI
// in secure model, rmLoginUGI will be LoginUser UGI
this.rmLoginUGI.doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
startActiveServices();
return null;
}
});
rmContext.setHAServiceState(HAServiceProtocol.HAServiceState.ACTIVE);
LOG.info("Transitioned to active state");
}
示例15: transitionToStandby
import org.apache.hadoop.ha.HAServiceProtocol; //导入依赖的package包/类
synchronized void transitionToStandby(boolean initialize)
throws Exception {
if (rmContext.getHAServiceState() ==
HAServiceProtocol.HAServiceState.STANDBY) {
LOG.info("Already in standby state");
return;
}
LOG.info("Transitioning to standby state");
if (rmContext.getHAServiceState() ==
HAServiceProtocol.HAServiceState.ACTIVE) {
stopActiveServices();
if (initialize) {
resetDispatcher();
createAndInitActiveServices();
}
}
rmContext.setHAServiceState(HAServiceProtocol.HAServiceState.STANDBY);
LOG.info("Transitioned to standby state");
}