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


Java ClientRMService类代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.resourcemanager.ClientRMService的典型用法代码示例。如果您正苦于以下问题:Java ClientRMService类的具体用法?Java ClientRMService怎么用?Java ClientRMService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ClientRMService类属于org.apache.hadoop.yarn.server.resourcemanager包,在下文中一共展示了ClientRMService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  counter = new AtomicInteger(0);
  conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
      "kerberos");
  UserGroupInformation.setConfiguration(conf);
  eventQueue = new LinkedBlockingQueue<Event>();
  dispatcher = new AsyncDispatcher(eventQueue);
  Renewer.reset();
  delegationTokenRenewer = createNewDelegationTokenRenewer(conf, counter);
  RMContext mockContext =  mock(RMContext.class);
  ClientRMService mockClientRMService = mock(ClientRMService.class);
  when(mockContext.getSystemCredentialsForApps()).thenReturn(
    new ConcurrentHashMap<ApplicationId, ByteBuffer>());
  when(mockContext.getDelegationTokenRenewer()).thenReturn(
      delegationTokenRenewer);
  when(mockContext.getDispatcher()).thenReturn(dispatcher);
  when(mockContext.getClientRMService()).thenReturn(mockClientRMService);
  InetSocketAddress sockAddr =
      InetSocketAddress.createUnresolved("localhost", 1234);
  when(mockClientRMService.getBindAddress()).thenReturn(sockAddr);
  delegationTokenRenewer.setRMContext(mockContext);
  delegationTokenRenewer.init(conf);
  delegationTokenRenewer.start();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestDelegationTokenRenewer.java

示例2: setUp

import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  counter = new AtomicInteger(0);
  conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
      "kerberos");
  UserGroupInformation.setConfiguration(conf);
  eventQueue = new LinkedBlockingQueue<Event>();
  dispatcher = new AsyncDispatcher(eventQueue);
  Renewer.reset();
  delegationTokenRenewer = createNewDelegationTokenRenewer(conf, counter);
  RMContext mockContext = mock(RMContext.class);
  ClientRMService mockClientRMService = mock(ClientRMService.class);
  when(mockContext.getDelegationTokenRenewer()).thenReturn(
      delegationTokenRenewer);
  when(mockContext.getDispatcher()).thenReturn(dispatcher);
  when(mockContext.getClientRMService()).thenReturn(mockClientRMService);
  InetSocketAddress sockAddr =
      InetSocketAddress.createUnresolved("localhost", 1234);
  when(mockClientRMService.getBindAddress()).thenReturn(sockAddr);
  delegationTokenRenewer.setRMContext(mockContext);
  delegationTokenRenewer.init(conf);
  delegationTokenRenewer.start();
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:24,代码来源:TestDelegationTokenRenewer.java

示例3: testDTRonAppSubmission

import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; //导入依赖的package包/类
@Test(timeout=20000)
public void testDTRonAppSubmission()
    throws IOException, InterruptedException, BrokenBarrierException {
  final Credentials credsx = new Credentials();
  final Token<DelegationTokenIdentifier> tokenx = mock(Token.class);
  when(tokenx.getKind()).thenReturn(new Text("HDFS_DELEGATION_TOKEN"));
  DelegationTokenIdentifier dtId1 = 
      new DelegationTokenIdentifier(new Text("user1"), new Text("renewer"),
        new Text("user1"));
  when(tokenx.decodeIdentifier()).thenReturn(dtId1);
  credsx.addToken(new Text("token"), tokenx);
  doReturn(true).when(tokenx).isManaged();
  doThrow(new IOException("boom"))
      .when(tokenx).renew(any(Configuration.class));
    // fire up the renewer
  final DelegationTokenRenewer dtr =
       createNewDelegationTokenRenewer(conf, counter);
  RMContext mockContext = mock(RMContext.class);
  when(mockContext.getSystemCredentialsForApps()).thenReturn(
    new ConcurrentHashMap<ApplicationId, ByteBuffer>());
  ClientRMService mockClientRMService = mock(ClientRMService.class);
  when(mockContext.getClientRMService()).thenReturn(mockClientRMService);
  InetSocketAddress sockAddr =
      InetSocketAddress.createUnresolved("localhost", 1234);
  when(mockClientRMService.getBindAddress()).thenReturn(sockAddr);
  dtr.setRMContext(mockContext);
  when(mockContext.getDelegationTokenRenewer()).thenReturn(dtr);
  dtr.init(conf);
  dtr.start();

  try {
    dtr.addApplicationSync(mock(ApplicationId.class), credsx, false, "user");
    fail("Catch IOException on app submission");
  } catch (IOException e){
    Assert.assertTrue(e.getMessage().contains(tokenx.toString()));
    Assert.assertTrue(e.getCause().toString().contains("boom"));
  }

}
 
开发者ID:naver,项目名称:hadoop,代码行数:40,代码来源:TestDelegationTokenRenewer.java

示例4: testStartupFailure

import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; //导入依赖的package包/类
@Test
public void testStartupFailure() throws Exception {
  Configuration conf = new Configuration();
  DelegationTokenRenewer delegationTokenRenewer =
      new DelegationTokenRenewer();
  RMContext mockContext = mock(RMContext.class);
  ClientRMService mockClientRMService = mock(ClientRMService.class);
  when(mockContext.getClientRMService()).thenReturn(mockClientRMService);
  delegationTokenRenewer.setRMContext(mockContext);
  delegationTokenRenewer.init(conf);
  delegationTokenRenewer.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:TestDelegationTokenRenewerLifecycle.java

示例5: testAppsRace

import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; //导入依赖的package包/类
@Test
public void testAppsRace() throws Exception {
  // mock up an RM that returns app reports for apps that don't exist
  // in the RMApps list
  ApplicationId appId = ApplicationId.newInstance(1, 1);
  ApplicationReport mockReport = mock(ApplicationReport.class);
  when(mockReport.getApplicationId()).thenReturn(appId);
  GetApplicationsResponse mockAppsResponse =
      mock(GetApplicationsResponse.class);
  when(mockAppsResponse.getApplicationList())
    .thenReturn(Arrays.asList(new ApplicationReport[] { mockReport }));
  ClientRMService mockClientSvc = mock(ClientRMService.class);
  when(mockClientSvc.getApplications(isA(GetApplicationsRequest.class),
      anyBoolean())).thenReturn(mockAppsResponse);
  ResourceManager mockRM = mock(ResourceManager.class);
  RMContextImpl rmContext = new RMContextImpl(null, null, null, null, null,
      null, null, null, null, null);
  when(mockRM.getRMContext()).thenReturn(rmContext);
  when(mockRM.getClientRMService()).thenReturn(mockClientSvc);

  RMWebServices webSvc = new RMWebServices(mockRM, new Configuration(),
      mock(HttpServletResponse.class));

  final Set<String> emptySet =
      Collections.unmodifiableSet(Collections.<String>emptySet());

  // verify we don't get any apps when querying
  HttpServletRequest mockHsr = mock(HttpServletRequest.class);
  AppsInfo appsInfo = webSvc.getApps(mockHsr, null, emptySet, null,
      null, null, null, null, null, null, null, emptySet, emptySet);
  assertTrue(appsInfo.getApps().isEmpty());

  // verify we don't get an NPE when specifying a final status query
  appsInfo = webSvc.getApps(mockHsr, null, emptySet, "FAILED",
      null, null, null, null, null, null, null, emptySet, emptySet);
  assertTrue(appsInfo.getApps().isEmpty());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:38,代码来源:TestRMWebServices.java

示例6: mockRm

import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; //导入依赖的package包/类
public static ResourceManager mockRm(RMContext rmContext) throws IOException {
  ResourceManager rm = mock(ResourceManager.class);
  ResourceScheduler rs = mockCapacityScheduler();
  ApplicationACLsManager aclMgr = mockAppACLsManager();
  ClientRMService clientRMService = mockClientRMService(rmContext);
  when(rm.getResourceScheduler()).thenReturn(rs);
  when(rm.getRMContext()).thenReturn(rmContext);
  when(rm.getApplicationACLsManager()).thenReturn(aclMgr);
  when(rm.getClientRMService()).thenReturn(clientRMService);
  return rm;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:TestRMWebApp.java

示例7: mockClientRMService

import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; //导入依赖的package包/类
public static ClientRMService mockClientRMService(RMContext rmContext) {
  ClientRMService clientRMService = mock(ClientRMService.class);
  List<ApplicationReport> appReports = new ArrayList<ApplicationReport>();
  for (RMApp app : rmContext.getRMApps().values()) {
    ApplicationReport appReport =
        ApplicationReport.newInstance(
            app.getApplicationId(), (ApplicationAttemptId) null,
            app.getUser(), app.getQueue(),
            app.getName(), (String) null, 0, (Token) null,
            app.createApplicationState(),
            app.getDiagnostics().toString(), (String) null,
            app.getStartTime(), app.getFinishTime(),
            app.getFinalApplicationStatus(),
            (ApplicationResourceUsageReport) null, app.getTrackingUrl(),
            app.getProgress(), app.getApplicationType(), (Token) null);
    appReports.add(appReport);
  }
  GetApplicationsResponse response = mock(GetApplicationsResponse.class);
  when(response.getApplicationList()).thenReturn(appReports);
  try {
    when(clientRMService.getApplications(any(GetApplicationsRequest.class)))
        .thenReturn(response);
  } catch (YarnException e) {
    Assert.fail("Exception is not expteced.");
  }
  return clientRMService;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:TestRMWebApp.java

示例8: mockRm

import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; //导入依赖的package包/类
private static ResourceManager mockRm(RMContext rmContext) throws
    IOException {
  ResourceManager rm = mock(ResourceManager.class);
  ResourceScheduler rs = mockFairScheduler();
  ClientRMService clientRMService = mockClientRMService(rmContext);
  when(rm.getResourceScheduler()).thenReturn(rs);
  when(rm.getRMContext()).thenReturn(rmContext);
  when(rm.getClientRMService()).thenReturn(clientRMService);
  return rm;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestRMWebAppFairScheduler.java

示例9: mockRmWithApps

import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; //导入依赖的package包/类
private static ResourceManager mockRmWithApps(RMContext rmContext) throws
    IOException {
  ResourceManager rm = mock(ResourceManager.class);
  ResourceScheduler rs =  mockFairSchedulerWithoutApps(rmContext);
  ClientRMService clientRMService = mockClientRMService(rmContext);
  when(rm.getResourceScheduler()).thenReturn(rs);
  when(rm.getRMContext()).thenReturn(rmContext);
  when(rm.getClientRMService()).thenReturn(clientRMService);
  return rm;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestRMWebAppFairScheduler.java

示例10: createResourceManager

import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; //导入依赖的package包/类
@Override
protected ResourceManager createResourceManager() {
  return new ResourceManager() {
    @Override
    protected void doSecureLogin() throws IOException {
      // Don't try to login using keytab in the testcases.
    }
    @Override
    protected ClientRMService createClientRMService() {
      if (overrideClientRMService) {
        return new CustomedClientRMService(this.rmContext, this.scheduler,
            this.rmAppManager, this.applicationACLsManager,
            this.queueACLsManager,
            this.rmContext.getRMDelegationTokenSecretManager());
      }
      return super.createClientRMService();
    }
    @Override
    protected ResourceTrackerService createResourceTrackerService() {
      if (overrideRTS) {
        return new CustomedResourceTrackerService(this.rmContext,
            this.nodesListManager, this.nmLivelinessMonitor,
            this.rmContext.getContainerTokenSecretManager(),
            this.rmContext.getNMTokenSecretManager());
      }
      return super.createResourceTrackerService();
    }
    @Override
    protected ApplicationMasterService createApplicationMasterService() {
      if (overrideApplicationMasterService) {
        return new CustomedApplicationMasterService(this.rmContext,
            this.scheduler);
      }
      return super.createApplicationMasterService();
    }
  };
}
 
开发者ID:naver,项目名称:hadoop,代码行数:38,代码来源:ProtocolHATestBase.java

示例11: testDTRonAppSubmission

import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; //导入依赖的package包/类
@Test(timeout=20000)
public void testDTRonAppSubmission()
    throws IOException, InterruptedException, BrokenBarrierException {
  final Credentials credsx = new Credentials();
  final Token<DelegationTokenIdentifier> tokenx = mock(Token.class);
  when(tokenx.getKind()).thenReturn(KIND);
  DelegationTokenIdentifier dtId1 = 
      new DelegationTokenIdentifier(new Text("user1"), new Text("renewer"),
        new Text("user1"));
  when(tokenx.decodeIdentifier()).thenReturn(dtId1);
  credsx.addToken(new Text("token"), tokenx);
  doReturn(true).when(tokenx).isManaged();
  doThrow(new IOException("boom"))
      .when(tokenx).renew(any(Configuration.class));
    // fire up the renewer
  final DelegationTokenRenewer dtr =
       createNewDelegationTokenRenewer(conf, counter);
  RMContext mockContext = mock(RMContext.class);
  when(mockContext.getSystemCredentialsForApps()).thenReturn(
    new ConcurrentHashMap<ApplicationId, ByteBuffer>());
  ClientRMService mockClientRMService = mock(ClientRMService.class);
  when(mockContext.getClientRMService()).thenReturn(mockClientRMService);
  InetSocketAddress sockAddr =
      InetSocketAddress.createUnresolved("localhost", 1234);
  when(mockClientRMService.getBindAddress()).thenReturn(sockAddr);
  dtr.setRMContext(mockContext);
  when(mockContext.getDelegationTokenRenewer()).thenReturn(dtr);
  dtr.init(conf);
  dtr.start();

  try {
    dtr.addApplicationSync(mock(ApplicationId.class), credsx, false, "user");
    fail("Catch IOException on app submission");
  } catch (IOException e){
    Assert.assertTrue(e.getMessage().contains(tokenx.toString()));
    Assert.assertTrue(e.getCause().toString().contains("boom"));
  }

}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:40,代码来源:TestDelegationTokenRenewer.java

示例12: testAppsRace

import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; //导入依赖的package包/类
@Test
public void testAppsRace() throws Exception {
  // mock up an RM that returns app reports for apps that don't exist
  // in the RMApps list
  ApplicationId appId = ApplicationId.newInstance(1, 1);
  ApplicationReport mockReport = mock(ApplicationReport.class);
  when(mockReport.getApplicationId()).thenReturn(appId);
  GetApplicationsResponse mockAppsResponse =
      mock(GetApplicationsResponse.class);
  when(mockAppsResponse.getApplicationList())
    .thenReturn(Arrays.asList(new ApplicationReport[] { mockReport }));
  ClientRMService mockClientSvc = mock(ClientRMService.class);
  when(mockClientSvc.getApplications(isA(GetApplicationsRequest.class),
      anyBoolean())).thenReturn(mockAppsResponse);
  ResourceManager mockRM = mock(ResourceManager.class);
  RMContextImpl rmContext = new RMContextImpl(null, null, null, null, null,
      null, null, null, null, null);
  when(mockRM.getRMContext()).thenReturn(rmContext);
  when(mockRM.getClientRMService()).thenReturn(mockClientSvc);
  rmContext.setNodeLabelManager(mock(RMNodeLabelsManager.class));

  RMWebServices webSvc = new RMWebServices(mockRM, new Configuration(),
      mock(HttpServletResponse.class));

  final Set<String> emptySet =
      Collections.unmodifiableSet(Collections.<String>emptySet());

  // verify we don't get any apps when querying
  HttpServletRequest mockHsr = mock(HttpServletRequest.class);
  AppsInfo appsInfo = webSvc.getApps(mockHsr, null, emptySet, null,
      null, null, null, null, null, null, null, emptySet, emptySet);
  assertTrue(appsInfo.getApps().isEmpty());

  // verify we don't get an NPE when specifying a final status query
  appsInfo = webSvc.getApps(mockHsr, null, emptySet, "FAILED",
      null, null, null, null, null, null, null, emptySet, emptySet);
  assertTrue(appsInfo.getApps().isEmpty());
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:39,代码来源:TestRMWebServices.java

示例13: getApplicationResourceReport

import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; //导入依赖的package包/类
public ApplicationResourceUsageReport getApplicationResourceReport(String appId) throws Exception {
  List<String> splits = Lists.newArrayList(Splitter.on('_').split(appId));
  Preconditions.checkArgument(splits.size() == 3, "Invalid application id - " + appId);
  ApplicationId applicationId =
    YarnUtils.createApplicationId(Long.parseLong(splits.get(1)), Integer.parseInt(splits.get(2)));

  ClientRMService clientRMService = cluster.getResourceManager().getClientRMService();
  GetApplicationReportRequest request = Records.newRecord(GetApplicationReportRequest.class);
  request.setApplicationId(applicationId);
  return clientRMService.getApplicationReport(request)
    .getApplicationReport().getApplicationResourceUsageReport();
}
 
开发者ID:apache,项目名称:twill,代码行数:13,代码来源:TwillTester.java

示例14: checkNodeState

import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; //导入依赖的package包/类
private void checkNodeState() throws YarnException
{
  GetClusterNodesRequest request = Records.newRecord(GetClusterNodesRequest.class);
  ClientRMService clientRMService = yarnCluster.getResourceManager().getClientRMService();
  GetClusterNodesResponse response = clientRMService.getClusterNodes(request);
  List<NodeReport> nodeReports = response.getNodeReports();
  LOG.info("{}", nodeReports);

  for (NodeReport nr: nodeReports) {
    if (!nr.getNodeState().isUnusable()) {
      return;
    }
  }
  fail("Yarn Mini cluster should have at least one usable node.");
}
 
开发者ID:apache,项目名称:apex-core,代码行数:16,代码来源:StramMiniClusterTest.java

示例15: setUp

import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  counter = new AtomicInteger(0);
  YarnAPIStorageFactory.setConfiguration(conf);
  RMStorageFactory.setConfiguration(conf);
  DBUtility.InitializeDB();
  conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
      "kerberos");
  UserGroupInformation.setConfiguration(conf);
  eventQueue = new LinkedBlockingQueue<Event>();
  dispatcher = new AsyncDispatcher(eventQueue);
  Renewer.reset();
  delegationTokenRenewer = createNewDelegationTokenRenewer(conf, counter);
  RMContext mockContext =  mock(RMContext.class);
  ClientRMService mockClientRMService = mock(ClientRMService.class);
  when(mockContext.getSystemCredentialsForApps()).thenReturn(
    new ConcurrentHashMap<ApplicationId, ByteBuffer>());
  when(mockContext.getDelegationTokenRenewer()).thenReturn(
      delegationTokenRenewer);
  when(mockContext.getDispatcher()).thenReturn(dispatcher);
  when(mockContext.getClientRMService()).thenReturn(mockClientRMService);
  InetSocketAddress sockAddr =
      InetSocketAddress.createUnresolved("localhost", 1234);
  when(mockClientRMService.getBindAddress()).thenReturn(sockAddr);
  delegationTokenRenewer.setRMContext(mockContext);
  delegationTokenRenewer.init(conf);
  delegationTokenRenewer.start();
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:29,代码来源:TestDelegationTokenRenewer.java


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