org.apache.hadoop.yarn.api.records.impl.pb.ApplicationAttemptIdPBImpl Java Examples

The following examples show how to use org.apache.hadoop.yarn.api.records.impl.pb.ApplicationAttemptIdPBImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestAggregatedLogsBlock.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void writeLog(Configuration configuration, String user)
    throws Exception {
  ApplicationId appId =  ApplicationIdPBImpl.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =  ApplicationAttemptIdPBImpl.newInstance(appId, 1);
  ContainerId containerId = ContainerIdPBImpl.newContainerId(appAttemptId, 1);

  String path = "target/logs/" + user
      + "/logs/application_0_0001/localhost_1234";
  File f = new File(path);
  if (!f.getParentFile().exists()) {
   assertTrue(f.getParentFile().mkdirs());
  }
  List<String> rootLogDirs = Arrays.asList("target/logs/logs");
  UserGroupInformation ugi = UserGroupInformation.getCurrentUser();

  AggregatedLogFormat.LogWriter writer = new AggregatedLogFormat.LogWriter(
      configuration, new Path(path), ugi);
  writer.writeApplicationOwner(ugi.getUserName());

  Map<ApplicationAccessType, String> appAcls = new HashMap<ApplicationAccessType, String>();
  appAcls.put(ApplicationAccessType.VIEW_APP, ugi.getUserName());
  writer.writeApplicationACLs(appAcls);

  writer.append(new AggregatedLogFormat.LogKey("container_0_0001_01_000001"),
      new AggregatedLogFormat.LogValue(rootLogDirs, containerId,UserGroupInformation.getCurrentUser().getShortUserName()));
  writer.close();
}
 
Example #2
Source File: AMRMTokenIdentifier.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Private
public ApplicationAttemptId getApplicationAttemptId() {
  if (!proto.hasAppAttemptId()) {
    return null;
  }
  return new ApplicationAttemptIdPBImpl(proto.getAppAttemptId());
}
 
Example #3
Source File: AMRMTokenIdentifier.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public AMRMTokenIdentifier(ApplicationAttemptId appAttemptId,
    int masterKeyId) {
  AMRMTokenIdentifierProto.Builder builder = 
      AMRMTokenIdentifierProto.newBuilder();
  if (appAttemptId != null) {
    builder.setAppAttemptId(
        ((ApplicationAttemptIdPBImpl)appAttemptId).getProto());
  }
  builder.setKeyId(masterKeyId);
  proto = builder.build();
}
 
Example #4
Source File: AMRMTokenIdentifier.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public UserGroupInformation getUser() {
  String appAttemptId = null;
  if (proto.hasAppAttemptId()) {
    appAttemptId = 
        new ApplicationAttemptIdPBImpl(proto.getAppAttemptId()).toString();
  }
  return UserGroupInformation.createRemoteUser(appAttemptId);
}
 
Example #5
Source File: AMRMTokenIdentifier.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Private
public ApplicationAttemptId getApplicationAttemptId() {
  if (!proto.hasAppAttemptId()) {
    return null;
  }
  return new ApplicationAttemptIdPBImpl(proto.getAppAttemptId());
}
 
Example #6
Source File: ClientToAMTokenIdentifier.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public ClientToAMTokenIdentifier(ApplicationAttemptId id, String client) {
  ClientToAMTokenIdentifierProto.Builder builder = 
      ClientToAMTokenIdentifierProto.newBuilder();
  if (id != null) {
    builder.setAppAttemptId(((ApplicationAttemptIdPBImpl)id).getProto());
  }
  if (client != null) {
    builder.setClientName(client);
  }
  proto = builder.build();
}
 
Example #7
Source File: AMRMTokenIdentifier.java    From big-c with Apache License 2.0 5 votes vote down vote up
public AMRMTokenIdentifier(ApplicationAttemptId appAttemptId,
    int masterKeyId) {
  AMRMTokenIdentifierProto.Builder builder = 
      AMRMTokenIdentifierProto.newBuilder();
  if (appAttemptId != null) {
    builder.setAppAttemptId(
        ((ApplicationAttemptIdPBImpl)appAttemptId).getProto());
  }
  builder.setKeyId(masterKeyId);
  proto = builder.build();
}
 
Example #8
Source File: AMInfoPBImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
private synchronized void mergeLocalToBuilder() {
  if (this.appAttemptId != null
      && !((ApplicationAttemptIdPBImpl) this.appAttemptId).getProto().equals(
          builder.getApplicationAttemptId())) {
    builder.setApplicationAttemptId(convertToProtoFormat(this.appAttemptId));
  }
  if (this.getContainerId() != null
      && !((ContainerIdPBImpl) this.containerId).getProto().equals(
          builder.getContainerId())) {
    builder.setContainerId(convertToProtoFormat(this.containerId));
  }
}
 
Example #9
Source File: NMTokenIdentifier.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public NMTokenIdentifier(ApplicationAttemptId appAttemptId, 
    NodeId nodeId, String applicationSubmitter, int masterKeyId) {
  NMTokenIdentifierProto.Builder builder = NMTokenIdentifierProto.newBuilder();
  if (appAttemptId != null) {
    builder.setAppAttemptId(
        ((ApplicationAttemptIdPBImpl)appAttemptId).getProto());
  }
  if (nodeId != null) {
    builder.setNodeId(((NodeIdPBImpl)nodeId).getProto());
  }
  builder.setAppSubmitter(applicationSubmitter);
  builder.setKeyId(masterKeyId);
  proto = builder.build();
}
 
Example #10
Source File: AMRMTokenIdentifier.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public UserGroupInformation getUser() {
  String appAttemptId = null;
  if (proto.hasAppAttemptId()) {
    appAttemptId = 
        new ApplicationAttemptIdPBImpl(proto.getAppAttemptId()).toString();
  }
  return UserGroupInformation.createRemoteUser(appAttemptId);
}
 
Example #11
Source File: ClientToAMTokenIdentifier.java    From big-c with Apache License 2.0 5 votes vote down vote up
public ClientToAMTokenIdentifier(ApplicationAttemptId id, String client) {
  ClientToAMTokenIdentifierProto.Builder builder = 
      ClientToAMTokenIdentifierProto.newBuilder();
  if (id != null) {
    builder.setAppAttemptId(((ApplicationAttemptIdPBImpl)id).getProto());
  }
  if (client != null) {
    builder.setClientName(client);
  }
  proto = builder.build();
}
 
Example #12
Source File: ApplicationAttemptFinishDataPBImpl.java    From ambari-metrics with Apache License 2.0 5 votes vote down vote up
private void mergeLocalToBuilder() {
  if (this.applicationAttemptId != null
      && !((ApplicationAttemptIdPBImpl) this.applicationAttemptId).getProto()
        .equals(builder.getApplicationAttemptId())) {
    builder
      .setApplicationAttemptId(convertToProtoFormat(this.applicationAttemptId));
  }
}
 
Example #13
Source File: TajoResourceAllocator.java    From incubator-tajo with Apache License 2.0 5 votes vote down vote up
@Override
public ContainerId makeContainerId(YarnProtos.ContainerIdProto containerIdProto) {
  TajoWorkerContainerId containerId = new TajoWorkerContainerId();
  ApplicationAttemptId appAttemptId = new ApplicationAttemptIdPBImpl(containerIdProto.getAppAttemptId());
  containerId.setApplicationAttemptId(appAttemptId);
  containerId.setId(containerIdProto.getId());
  return containerId;
}
 
Example #14
Source File: NMTokenIdentifier.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public UserGroupInformation getUser() {
  String appAttemptId = null;
  if (proto.hasAppAttemptId()) {
    appAttemptId = new ApplicationAttemptIdPBImpl(
        proto.getAppAttemptId()).toString();
  }
  return UserGroupInformation.createRemoteUser(appAttemptId);
}
 
Example #15
Source File: NMTokenIdentifier.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public UserGroupInformation getUser() {
  String appAttemptId = null;
  if (proto.hasAppAttemptId()) {
    appAttemptId = new ApplicationAttemptIdPBImpl(
        proto.getAppAttemptId()).toString();
  }
  return UserGroupInformation.createRemoteUser(appAttemptId);
}
 
Example #16
Source File: TestAggregatedLogsBlock.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void writeLog(Configuration configuration, String user)
    throws Exception {
  ApplicationId appId =  ApplicationIdPBImpl.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =  ApplicationAttemptIdPBImpl.newInstance(appId, 1);
  ContainerId containerId = ContainerIdPBImpl.newContainerId(appAttemptId, 1);

  String path = "target/logs/" + user
      + "/logs/application_0_0001/localhost_1234";
  File f = new File(path);
  if (!f.getParentFile().exists()) {
   assertTrue(f.getParentFile().mkdirs());
  }
  List<String> rootLogDirs = Arrays.asList("target/logs/logs");
  UserGroupInformation ugi = UserGroupInformation.getCurrentUser();

  AggregatedLogFormat.LogWriter writer = new AggregatedLogFormat.LogWriter(
      configuration, new Path(path), ugi);
  writer.writeApplicationOwner(ugi.getUserName());

  Map<ApplicationAccessType, String> appAcls = new HashMap<ApplicationAccessType, String>();
  appAcls.put(ApplicationAccessType.VIEW_APP, ugi.getUserName());
  writer.writeApplicationACLs(appAcls);

  writer.append(new AggregatedLogFormat.LogKey("container_0_0001_01_000001"),
      new AggregatedLogFormat.LogValue(rootLogDirs, containerId,UserGroupInformation.getCurrentUser().getShortUserName()));
  writer.close();
}
 
Example #17
Source File: NMTokenIdentifier.java    From big-c with Apache License 2.0 5 votes vote down vote up
public NMTokenIdentifier(ApplicationAttemptId appAttemptId, 
    NodeId nodeId, String applicationSubmitter, int masterKeyId) {
  NMTokenIdentifierProto.Builder builder = NMTokenIdentifierProto.newBuilder();
  if (appAttemptId != null) {
    builder.setAppAttemptId(
        ((ApplicationAttemptIdPBImpl)appAttemptId).getProto());
  }
  if (nodeId != null) {
    builder.setNodeId(((NodeIdPBImpl)nodeId).getProto());
  }
  builder.setAppSubmitter(applicationSubmitter);
  builder.setKeyId(masterKeyId);
  proto = builder.build();
}
 
Example #18
Source File: ApplicationAttemptStartDataPBImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void mergeLocalToBuilder() {
  if (this.applicationAttemptId != null
      && !((ApplicationAttemptIdPBImpl) this.applicationAttemptId).getProto()
        .equals(builder.getApplicationAttemptId())) {
    builder
      .setApplicationAttemptId(convertToProtoFormat(this.applicationAttemptId));
  }
  if (this.masterContainerId != null
      && !((ContainerIdPBImpl) this.masterContainerId).getProto().equals(
        builder.getMasterContainerId())) {
    builder
      .setMasterContainerId(convertToProtoFormat(this.masterContainerId));
  }
}
 
Example #19
Source File: TestContainerLogsPage.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testLogDirWithDriveLetter() throws Exception {
  //To verify that logs paths which include drive letters (Windows)
  //do not lose their drive letter specification
  LocalDirsHandlerService localDirs = mock(LocalDirsHandlerService.class);
  List<String> logDirs = new ArrayList<String>();
  logDirs.add("F:/nmlogs");
  when(localDirs.getLogDirsForRead()).thenReturn(logDirs);
  
  ApplicationIdPBImpl appId = mock(ApplicationIdPBImpl.class);
  when(appId.toString()).thenReturn("app_id_1");
  
  ApplicationAttemptIdPBImpl appAttemptId =
             mock(ApplicationAttemptIdPBImpl.class);
  when(appAttemptId.getApplicationId()).thenReturn(appId);
  
  ContainerId containerId = mock(ContainerIdPBImpl.class);
  when(containerId.getApplicationAttemptId()).thenReturn(appAttemptId);
  
  List<File> logDirFiles = ContainerLogsUtils.getContainerLogDirs(
    containerId, localDirs);
  
  Assert.assertTrue("logDir lost drive letter " +
    logDirFiles.get(0),
    logDirFiles.get(0).toString().indexOf("F:" + File.separator +
      "nmlogs") > -1);
}
 
Example #20
Source File: ApplicationAttemptStateDataPBImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void mergeLocalToBuilder() {
  if (this.attemptId != null) {
    builder.setAttemptId(((ApplicationAttemptIdPBImpl)attemptId).getProto());
  }
  if(this.masterContainer != null) {
    builder.setMasterContainer(((ContainerPBImpl)masterContainer).getProto());
  }
  if(this.appAttemptTokens != null) {
    builder.setAppAttemptTokens(ProtoUtils.convertToProtoFormat(
        this.appAttemptTokens));
  }
}
 
Example #21
Source File: ApplicationAttemptStateDataPBImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void mergeLocalToBuilder() {
  if (this.attemptId != null) {
    builder.setAttemptId(((ApplicationAttemptIdPBImpl)attemptId).getProto());
  }
  if(this.masterContainer != null) {
    builder.setMasterContainer(((ContainerPBImpl)masterContainer).getProto());
  }
  if(this.appAttemptTokens != null) {
    builder.setAppAttemptTokens(ProtoUtils.convertToProtoFormat(
        this.appAttemptTokens));
  }
}
 
Example #22
Source File: ApplicationAttemptStartDataPBImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void mergeLocalToBuilder() {
  if (this.applicationAttemptId != null
      && !((ApplicationAttemptIdPBImpl) this.applicationAttemptId).getProto()
        .equals(builder.getApplicationAttemptId())) {
    builder
      .setApplicationAttemptId(convertToProtoFormat(this.applicationAttemptId));
  }
  if (this.masterContainerId != null
      && !((ContainerIdPBImpl) this.masterContainerId).getProto().equals(
        builder.getMasterContainerId())) {
    builder
      .setMasterContainerId(convertToProtoFormat(this.masterContainerId));
  }
}
 
Example #23
Source File: TestContainerLogsPage.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testLogDirWithDriveLetter() throws Exception {
  //To verify that logs paths which include drive letters (Windows)
  //do not lose their drive letter specification
  LocalDirsHandlerService localDirs = mock(LocalDirsHandlerService.class);
  List<String> logDirs = new ArrayList<String>();
  logDirs.add("F:/nmlogs");
  when(localDirs.getLogDirsForRead()).thenReturn(logDirs);
  
  ApplicationIdPBImpl appId = mock(ApplicationIdPBImpl.class);
  when(appId.toString()).thenReturn("app_id_1");
  
  ApplicationAttemptIdPBImpl appAttemptId =
             mock(ApplicationAttemptIdPBImpl.class);
  when(appAttemptId.getApplicationId()).thenReturn(appId);
  
  ContainerId containerId = mock(ContainerIdPBImpl.class);
  when(containerId.getApplicationAttemptId()).thenReturn(appAttemptId);
  
  List<File> logDirFiles = ContainerLogsUtils.getContainerLogDirs(
    containerId, localDirs);
  
  Assert.assertTrue("logDir lost drive letter " +
    logDirFiles.get(0),
    logDirFiles.get(0).toString().indexOf("F:" + File.separator +
      "nmlogs") > -1);
}
 
Example #24
Source File: ApplicationAttemptFinishDataPBImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void mergeLocalToBuilder() {
  if (this.applicationAttemptId != null
      && !((ApplicationAttemptIdPBImpl) this.applicationAttemptId).getProto()
        .equals(builder.getApplicationAttemptId())) {
    builder
      .setApplicationAttemptId(convertToProtoFormat(this.applicationAttemptId));
  }
}
 
Example #25
Source File: ApplicationAttemptStartDataPBImpl.java    From ambari-metrics with Apache License 2.0 5 votes vote down vote up
private void mergeLocalToBuilder() {
  if (this.applicationAttemptId != null
      && !((ApplicationAttemptIdPBImpl) this.applicationAttemptId).getProto()
        .equals(builder.getApplicationAttemptId())) {
    builder
      .setApplicationAttemptId(convertToProtoFormat(this.applicationAttemptId));
  }
  if (this.masterContainerId != null
      && !((ContainerIdPBImpl) this.masterContainerId).getProto().equals(
        builder.getMasterContainerId())) {
    builder
      .setMasterContainerId(convertToProtoFormat(this.masterContainerId));
  }
}
 
Example #26
Source File: AMInfoPBImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private synchronized void mergeLocalToBuilder() {
  if (this.appAttemptId != null
      && !((ApplicationAttemptIdPBImpl) this.appAttemptId).getProto().equals(
          builder.getApplicationAttemptId())) {
    builder.setApplicationAttemptId(convertToProtoFormat(this.appAttemptId));
  }
  if (this.getContainerId() != null
      && !((ContainerIdPBImpl) this.containerId).getProto().equals(
          builder.getContainerId())) {
    builder.setContainerId(convertToProtoFormat(this.containerId));
  }
}
 
Example #27
Source File: ApplicationAttemptFinishDataPBImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void mergeLocalToBuilder() {
  if (this.applicationAttemptId != null
      && !((ApplicationAttemptIdPBImpl) this.applicationAttemptId).getProto()
        .equals(builder.getApplicationAttemptId())) {
    builder
      .setApplicationAttemptId(convertToProtoFormat(this.applicationAttemptId));
  }
}
 
Example #28
Source File: GetContainersRequestPBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
private ApplicationAttemptIdProto
    convertToProtoFormat(ApplicationAttemptId t) {
  return ((ApplicationAttemptIdPBImpl) t).getProto();
}
 
Example #29
Source File: AMInfoPBImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private ApplicationAttemptIdPBImpl convertFromProtoFormat(
    ApplicationAttemptIdProto p) {
  return new ApplicationAttemptIdPBImpl(p);
}
 
Example #30
Source File: GetContainersRequestPBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
private ApplicationAttemptIdPBImpl convertFromProtoFormat(
    ApplicationAttemptIdProto p) {
  return new ApplicationAttemptIdPBImpl(p);
}