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


Java YarnClientImpl类代码示例

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


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

示例1: tesAllJobs

import org.apache.hadoop.yarn.client.api.impl.YarnClientImpl; //导入依赖的package包/类
@Test
public void tesAllJobs() throws Exception {
  final ApplicationClientProtocol applicationsManager = Mockito.mock(ApplicationClientProtocol.class);
  GetApplicationsResponse allApplicationsResponse = Records
      .newRecord(GetApplicationsResponse.class);
  List<ApplicationReport> applications = new ArrayList<ApplicationReport>();
  applications.add(getApplicationReport(YarnApplicationState.FINISHED,
      FinalApplicationStatus.FAILED));
  applications.add(getApplicationReport(YarnApplicationState.FINISHED,
      FinalApplicationStatus.SUCCEEDED));
  applications.add(getApplicationReport(YarnApplicationState.FINISHED,
      FinalApplicationStatus.KILLED));
  applications.add(getApplicationReport(YarnApplicationState.FAILED,
      FinalApplicationStatus.FAILED));
  allApplicationsResponse.setApplicationList(applications);
  Mockito.when(
      applicationsManager.getApplications(Mockito
          .any(GetApplicationsRequest.class))).thenReturn(
      allApplicationsResponse);
  ResourceMgrDelegate resourceMgrDelegate = new ResourceMgrDelegate(
    new YarnConfiguration()) {
    @Override
    protected void serviceStart() throws Exception {
      Assert.assertTrue(this.client instanceof YarnClientImpl);
      ((YarnClientImpl) this.client).setRMClient(applicationsManager);
    }
  };
  JobStatus[] allJobs = resourceMgrDelegate.getAllJobs();

  Assert.assertEquals(State.FAILED, allJobs[0].getState());
  Assert.assertEquals(State.SUCCEEDED, allJobs[1].getState());
  Assert.assertEquals(State.KILLED, allJobs[2].getState());
  Assert.assertEquals(State.FAILED, allJobs[3].getState());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:TestResourceMgrDelegate.java

示例2: testClusterGetDelegationToken

import org.apache.hadoop.yarn.client.api.impl.YarnClientImpl; //导入依赖的package包/类
@Test
public void testClusterGetDelegationToken() throws Exception {

  Configuration conf = new Configuration(false);
  Cluster cluster = null;
  try {
    conf = new Configuration();
    conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME);
    cluster = new Cluster(conf);
    YARNRunner yrunner = (YARNRunner) cluster.getClient();
    GetDelegationTokenResponse getDTResponse = 
        recordFactory.newRecordInstance(GetDelegationTokenResponse.class);
    org.apache.hadoop.yarn.api.records.Token rmDTToken = recordFactory.newRecordInstance(
      org.apache.hadoop.yarn.api.records.Token.class);
    rmDTToken.setIdentifier(ByteBuffer.wrap(new byte[2]));
    rmDTToken.setKind("Testclusterkind");
    rmDTToken.setPassword(ByteBuffer.wrap("testcluster".getBytes()));
    rmDTToken.setService("0.0.0.0:8032");
    getDTResponse.setRMDelegationToken(rmDTToken);
    final ApplicationClientProtocol cRMProtocol = mock(ApplicationClientProtocol.class);
    when(cRMProtocol.getDelegationToken(any(
        GetDelegationTokenRequest.class))).thenReturn(getDTResponse);
    ResourceMgrDelegate rmgrDelegate = new ResourceMgrDelegate(
        new YarnConfiguration(conf)) {
      @Override
      protected void serviceStart() throws Exception {
        assertTrue(this.client instanceof YarnClientImpl);
        ((YarnClientImpl) this.client).setRMClient(cRMProtocol);
      }
    };
    yrunner.setResourceMgrDelegate(rmgrDelegate);
    Token t = cluster.getDelegationToken(new Text(" "));
    assertTrue("Token kind is instead " + t.getKind().toString(),
      "Testclusterkind".equals(t.getKind().toString()));
  } finally {
    if (cluster != null) {
      cluster.close();
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:41,代码来源:TestYarnClientProtocolProvider.java

示例3: InlineAM

import org.apache.hadoop.yarn.client.api.impl.YarnClientImpl; //导入依赖的package包/类
/**
 */
public InlineAM(Configuration conf) throws Exception
{

  appName = "UnmanagedAM";
  amPriority = 0;
  amQueue = "default";

  YarnConfiguration yarnConf = new YarnConfiguration(conf);
  rmClient = new YarnClientImpl();
  rmClient.init(yarnConf);
}
 
开发者ID:apache,项目名称:apex-core,代码行数:14,代码来源:InlineAM.java

示例4: DAGClientRPCImpl

import org.apache.hadoop.yarn.client.api.impl.YarnClientImpl; //导入依赖的package包/类
public DAGClientRPCImpl(ApplicationId appId, String dagId,
    TezConfiguration conf) {
  this.appId = appId;
  this.dagId = dagId;
  this.conf = conf;
  yarnClient = new YarnClientImpl();
  yarnClient.init(new YarnConfiguration(conf));
  yarnClient.start();
  appReport = null;
}
 
开发者ID:apache,项目名称:incubator-tez,代码行数:11,代码来源:DAGClientRPCImpl.java

示例5: createYarnClient

import org.apache.hadoop.yarn.client.api.impl.YarnClientImpl; //导入依赖的package包/类
/**
 * Create a new instance of YarnClient.
 */
@Public
public static YarnClient createYarnClient() {
  YarnClient client = new YarnClientImpl();
  return client;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:YarnClient.java

示例6: testResourceMgrDelegate

import org.apache.hadoop.yarn.client.api.impl.YarnClientImpl; //导入依赖的package包/类
@Test(timeout=20000)
public void testResourceMgrDelegate() throws Exception {
  /* we not want a mock of resource mgr delegate */
  final ApplicationClientProtocol clientRMProtocol = mock(ApplicationClientProtocol.class);
  ResourceMgrDelegate delegate = new ResourceMgrDelegate(conf) {
    @Override
    protected void serviceStart() throws Exception {
      assertTrue(this.client instanceof YarnClientImpl);
      ((YarnClientImpl) this.client).setRMClient(clientRMProtocol);
    }
  };
  /* make sure kill calls finish application master */
  when(clientRMProtocol.forceKillApplication(any(KillApplicationRequest.class)))
  .thenReturn(KillApplicationResponse.newInstance(true));
  delegate.killApplication(appId);
  verify(clientRMProtocol).forceKillApplication(any(KillApplicationRequest.class));

  /* make sure getalljobs calls get all applications */
  when(clientRMProtocol.getApplications(any(GetApplicationsRequest.class))).
  thenReturn(recordFactory.newRecordInstance(GetApplicationsResponse.class));
  delegate.getAllJobs();
  verify(clientRMProtocol).getApplications(any(GetApplicationsRequest.class));

  /* make sure getapplication report is called */
  when(clientRMProtocol.getApplicationReport(any(GetApplicationReportRequest.class)))
  .thenReturn(recordFactory.newRecordInstance(GetApplicationReportResponse.class));
  delegate.getApplicationReport(appId);
  verify(clientRMProtocol).getApplicationReport(any(GetApplicationReportRequest.class));

  /* make sure metrics is called */
  GetClusterMetricsResponse clusterMetricsResponse = recordFactory.newRecordInstance
      (GetClusterMetricsResponse.class);
  clusterMetricsResponse.setClusterMetrics(recordFactory.newRecordInstance(
      YarnClusterMetrics.class));
  when(clientRMProtocol.getClusterMetrics(any(GetClusterMetricsRequest.class)))
  .thenReturn(clusterMetricsResponse);
  delegate.getClusterMetrics();
  verify(clientRMProtocol).getClusterMetrics(any(GetClusterMetricsRequest.class));

  when(clientRMProtocol.getClusterNodes(any(GetClusterNodesRequest.class))).
  thenReturn(recordFactory.newRecordInstance(GetClusterNodesResponse.class));
  delegate.getActiveTrackers();
  verify(clientRMProtocol).getClusterNodes(any(GetClusterNodesRequest.class));
  
  GetNewApplicationResponse newAppResponse = recordFactory.newRecordInstance(
      GetNewApplicationResponse.class);
  newAppResponse.setApplicationId(appId);
  when(clientRMProtocol.getNewApplication(any(GetNewApplicationRequest.class))).
  thenReturn(newAppResponse);
  delegate.getNewJobID();
  verify(clientRMProtocol).getNewApplication(any(GetNewApplicationRequest.class));
  
  GetQueueInfoResponse queueInfoResponse = recordFactory.newRecordInstance(
      GetQueueInfoResponse.class);
  queueInfoResponse.setQueueInfo(recordFactory.newRecordInstance(QueueInfo.class));
  when(clientRMProtocol.getQueueInfo(any(GetQueueInfoRequest.class))).
  thenReturn(queueInfoResponse);
  delegate.getQueues();
  verify(clientRMProtocol).getQueueInfo(any(GetQueueInfoRequest.class));

  GetQueueUserAclsInfoResponse aclResponse = recordFactory.newRecordInstance(
      GetQueueUserAclsInfoResponse.class);
  when(clientRMProtocol.getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class)))
  .thenReturn(aclResponse);
  delegate.getQueueAclsForCurrentUser();
  verify(clientRMProtocol).getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:68,代码来源:TestYARNRunner.java

示例7: testResourceMgrDelegate

import org.apache.hadoop.yarn.client.api.impl.YarnClientImpl; //导入依赖的package包/类
@Test(timeout=20000)
public void testResourceMgrDelegate() throws Exception {
  /* we not want a mock of resource mgr delegate */
  final ApplicationClientProtocol clientRMProtocol = mock(ApplicationClientProtocol.class);
  ResourceMgrDelegate delegate = new ResourceMgrDelegate(conf) {
    @Override
    protected void serviceStart() throws Exception {
      assertTrue(this.client instanceof YarnClientImpl);
      ((YarnClientImpl) this.client).setRMClient(clientRMProtocol);
    }
  };
  /* make sure kill calls finish application master */
  when(clientRMProtocol.forceKillApplication(any(KillApplicationRequest.class)))
  .thenReturn(null);
  delegate.killApplication(appId);
  verify(clientRMProtocol).forceKillApplication(any(KillApplicationRequest.class));

  /* make sure getalljobs calls get all applications */
  when(clientRMProtocol.getApplications(any(GetApplicationsRequest.class))).
  thenReturn(recordFactory.newRecordInstance(GetApplicationsResponse.class));
  delegate.getAllJobs();
  verify(clientRMProtocol).getApplications(any(GetApplicationsRequest.class));

  /* make sure getapplication report is called */
  when(clientRMProtocol.getApplicationReport(any(GetApplicationReportRequest.class)))
  .thenReturn(recordFactory.newRecordInstance(GetApplicationReportResponse.class));
  delegate.getApplicationReport(appId);
  verify(clientRMProtocol).getApplicationReport(any(GetApplicationReportRequest.class));

  /* make sure metrics is called */
  GetClusterMetricsResponse clusterMetricsResponse = recordFactory.newRecordInstance
      (GetClusterMetricsResponse.class);
  clusterMetricsResponse.setClusterMetrics(recordFactory.newRecordInstance(
      YarnClusterMetrics.class));
  when(clientRMProtocol.getClusterMetrics(any(GetClusterMetricsRequest.class)))
  .thenReturn(clusterMetricsResponse);
  delegate.getClusterMetrics();
  verify(clientRMProtocol).getClusterMetrics(any(GetClusterMetricsRequest.class));

  when(clientRMProtocol.getClusterNodes(any(GetClusterNodesRequest.class))).
  thenReturn(recordFactory.newRecordInstance(GetClusterNodesResponse.class));
  delegate.getActiveTrackers();
  verify(clientRMProtocol).getClusterNodes(any(GetClusterNodesRequest.class));
  
  GetNewApplicationResponse newAppResponse = recordFactory.newRecordInstance(
      GetNewApplicationResponse.class);
  newAppResponse.setApplicationId(appId);
  when(clientRMProtocol.getNewApplication(any(GetNewApplicationRequest.class))).
  thenReturn(newAppResponse);
  delegate.getNewJobID();
  verify(clientRMProtocol).getNewApplication(any(GetNewApplicationRequest.class));
  
  GetQueueInfoResponse queueInfoResponse = recordFactory.newRecordInstance(
      GetQueueInfoResponse.class);
  queueInfoResponse.setQueueInfo(recordFactory.newRecordInstance(QueueInfo.class));
  when(clientRMProtocol.getQueueInfo(any(GetQueueInfoRequest.class))).
  thenReturn(queueInfoResponse);
  delegate.getQueues();
  verify(clientRMProtocol).getQueueInfo(any(GetQueueInfoRequest.class));

  GetQueueUserAclsInfoResponse aclResponse = recordFactory.newRecordInstance(
      GetQueueUserAclsInfoResponse.class);
  when(clientRMProtocol.getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class)))
  .thenReturn(aclResponse);
  delegate.getQueueAclsForCurrentUser();
  verify(clientRMProtocol).getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class));
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:68,代码来源:TestYARNRunner.java

示例8: testClusterGetDelegationToken

import org.apache.hadoop.yarn.client.api.impl.YarnClientImpl; //导入依赖的package包/类
@Test
public void testClusterGetDelegationToken() throws Exception {

  Configuration conf = new Configuration(false);
  Cluster cluster = null;
  try {
    conf = new Configuration();
    conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME);
    cluster = new Cluster(conf);
    YARNRunner yrunner = (YARNRunner) cluster.getClient();
    GetDelegationTokenResponse getDTResponse = 
        recordFactory.newRecordInstance(GetDelegationTokenResponse.class);
    org.apache.hadoop.yarn.api.records.Token rmDTToken = recordFactory.newRecordInstance(
      org.apache.hadoop.yarn.api.records.Token.class);
    rmDTToken.setIdentifier(ByteBuffer.wrap(new byte[2]));
    rmDTToken.setKind("Testclusterkind");
    rmDTToken.setPassword(ByteBuffer.wrap("testcluster".getBytes()));
    rmDTToken.setService("0.0.0.0:8032");
    getDTResponse.setRMDelegationToken(rmDTToken);
    final ApplicationClientProtocol cRMProtocol = mock(ApplicationClientProtocol.class);
    when(cRMProtocol.getDelegationToken(any(
        GetDelegationTokenRequest.class))).thenReturn(getDTResponse);
    ResourceMgrDelegate rmgrDelegate = new ResourceMgrDelegate(
        new YarnConfiguration(conf)) {
      @Override
      protected void serviceStart() throws Exception {
        assertTrue(this.client instanceof YarnClientImpl);
        this.client = spy(this.client);
        doNothing().when(this.client).close();
        ((YarnClientImpl) this.client).setRMClient(cRMProtocol);
      }
    };
    yrunner.setResourceMgrDelegate(rmgrDelegate);
    Token t = cluster.getDelegationToken(new Text(" "));
    assertTrue("Token kind is instead " + t.getKind().toString(),
      "Testclusterkind".equals(t.getKind().toString()));
  } finally {
    if (cluster != null) {
      cluster.close();
    }
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:43,代码来源:TestYarnClientProtocolProvider.java

示例9: connectYarnClient

import org.apache.hadoop.yarn.client.api.impl.YarnClientImpl; //导入依赖的package包/类
private void connectYarnClient() {
  this.yarnClient = new YarnClientImpl();
  this.yarnClient.init(conf);
  this.yarnClient.start();
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:6,代码来源:YarnTajoResourceManager.java

示例10: connectYarnClient

import org.apache.hadoop.yarn.client.api.impl.YarnClientImpl; //导入依赖的package包/类
private void connectYarnClient() {
  this.yarnClient = new YarnClientImpl();
  this.yarnClient.init(systemConf);
  this.yarnClient.start();
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:6,代码来源:YarnResourceAllocator.java


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