当前位置: 首页>>代码示例>>Java>>正文


Java HAServiceProtocol类代码示例

本文整理汇总了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());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestMiniYARNClusterForHA.java

示例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");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:ResourceManager.java

示例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");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:ResourceManager.java

示例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);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:AdminService.java

示例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));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestRMAdminCLI.java

示例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));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestRMAdminCLI.java

示例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));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestDFSHAAdmin.java

示例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");
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:18,代码来源:ResourceManager.java

示例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();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:19,代码来源:TestRMAdminCLI.java

示例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);
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:25,代码来源:AdminService.java

示例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);
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:25,代码来源:AdminService.java

示例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();
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:19,代码来源:TestRMAdminCLI.java

示例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));
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:17,代码来源:TestRMAdminCLI.java

示例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");
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:24,代码来源:ResourceManager.java

示例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");
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:21,代码来源:ResourceManager.java


注:本文中的org.apache.hadoop.ha.HAServiceProtocol类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。