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

The following examples show how to use org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl. 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: ContainerStartDataPBImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
private void mergeLocalToBuilder() {
  if (this.containerId != null
      && !((ContainerIdPBImpl) this.containerId).getProto().equals(
        builder.getContainerId())) {
    builder.setContainerId(convertToProtoFormat(this.containerId));
  }
  if (this.resource != null
      && !((ResourcePBImpl) this.resource).getProto().equals(
        builder.getAllocatedResource())) {
    builder.setAllocatedResource(convertToProtoFormat(this.resource));
  }
  if (this.nodeId != null
      && !((NodeIdPBImpl) this.nodeId).getProto().equals(
        builder.getAssignedNodeId())) {
    builder.setAssignedNodeId(convertToProtoFormat(this.nodeId));
  }
  if (this.priority != null
      && !((PriorityPBImpl) this.priority).getProto().equals(
        builder.getPriority())) {
    builder.setPriority(convertToProtoFormat(this.priority));
  }
}
 
Example #2
Source File: NMContainerStatusPBImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
private void mergeLocalToBuilder() {
  if (this.containerId != null
      && !((ContainerIdPBImpl) containerId).getProto().equals(
        builder.getContainerId())) {
    builder.setContainerId(convertToProtoFormat(this.containerId));
  }

  if (this.resource != null
      && !((ResourcePBImpl) this.resource).getProto().equals(
        builder.getResource())) {
    builder.setResource(convertToProtoFormat(this.resource));
  }

  if (this.priority != null) {
    builder.setPriority(convertToProtoFormat(this.priority));
  }
}
 
Example #3
Source File: NMContainerStatusPBImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private void mergeLocalToBuilder() {
  if (this.containerId != null
      && !((ContainerIdPBImpl) containerId).getProto().equals(
        builder.getContainerId())) {
    builder.setContainerId(convertToProtoFormat(this.containerId));
  }

  if (this.resource != null
      && !((ResourcePBImpl) this.resource).getProto().equals(
        builder.getResource())) {
    builder.setResource(convertToProtoFormat(this.resource));
  }

  if (this.priority != null) {
    builder.setPriority(convertToProtoFormat(this.priority));
  }
}
 
Example #4
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 #5
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 #6
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 #7
Source File: ContainerTokenIdentifier.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public UserGroupInformation getUser() {
  String containerId = null;
  if (proto.hasContainerId()) {
    containerId = new ContainerIdPBImpl(proto.getContainerId()).toString();
  }
  return UserGroupInformation.createRemoteUser(
      containerId);
}
 
Example #8
Source File: ContainerTokenIdentifier.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public ContainerTokenIdentifier(ContainerId containerID, String hostName,
    String appSubmitter, Resource r, long expiryTimeStamp, int masterKeyId,
    long rmIdentifier, Priority priority, long creationTime,
    LogAggregationContext logAggregationContext) {
  ContainerTokenIdentifierProto.Builder builder = 
      ContainerTokenIdentifierProto.newBuilder();
  if (containerID != null) {
    builder.setContainerId(((ContainerIdPBImpl)containerID).getProto());
  }
  builder.setNmHostAddr(hostName);
  builder.setAppSubmitter(appSubmitter);
  if (r != null) {
    builder.setResource(((ResourcePBImpl)r).getProto());
  }
  builder.setExpiryTimeStamp(expiryTimeStamp);
  builder.setMasterKeyId(masterKeyId);
  builder.setRmIdentifier(rmIdentifier);
  if (priority != null) {
    builder.setPriority(((PriorityPBImpl)priority).getProto());
  }
  builder.setCreationTime(creationTime);
  
  if (logAggregationContext != null) {
    builder.setLogAggregationContext(
        ((LogAggregationContextPBImpl)logAggregationContext).getProto());
  }
  proto = builder.build();
}
 
Example #9
Source File: ContainerTokenIdentifierForTest.java    From big-c with Apache License 2.0 5 votes vote down vote up
public ContainerTokenIdentifierForTest(ContainerId containerID,
    String hostName, String appSubmitter, Resource r, long expiryTimeStamp,
    int masterKeyId, long rmIdentifier, Priority priority, long creationTime,
    LogAggregationContext logAggregationContext) {
  ContainerTokenIdentifierForTestProto.Builder builder =
      ContainerTokenIdentifierForTestProto.newBuilder();
  if (containerID != null) {
    builder.setContainerId(((ContainerIdPBImpl)containerID).getProto());
  }
  builder.setNmHostAddr(hostName);
  builder.setAppSubmitter(appSubmitter);
  if (r != null) {
    builder.setResource(((ResourcePBImpl)r).getProto());
  }
  builder.setExpiryTimeStamp(expiryTimeStamp);
  builder.setMasterKeyId(masterKeyId);
  builder.setRmIdentifier(rmIdentifier);
  if (priority != null) {
    builder.setPriority(((PriorityPBImpl)priority).getProto());
  }
  builder.setCreationTime(creationTime);
  
  if (logAggregationContext != null) {
    builder.setLogAggregationContext(
        ((LogAggregationContextPBImpl)logAggregationContext).getProto());
  }
  proto = builder.build();
}
 
Example #10
Source File: ContainerTokenIdentifierForTest.java    From big-c with Apache License 2.0 5 votes vote down vote up
public ContainerTokenIdentifierForTest(ContainerTokenIdentifier identifier,
    String message) {
  ContainerTokenIdentifierForTestProto.Builder builder =
      ContainerTokenIdentifierForTestProto.newBuilder();
  ContainerIdPBImpl containerID = 
      (ContainerIdPBImpl)identifier.getContainerID();
  if (containerID != null) {
    builder.setContainerId(containerID.getProto());
  }
  builder.setNmHostAddr(identifier.getNmHostAddress());
  builder.setAppSubmitter(identifier.getApplicationSubmitter());
  
  ResourcePBImpl resource = (ResourcePBImpl)identifier.getResource();
  if (resource != null) {
    builder.setResource(resource.getProto());
  }
  
  builder.setExpiryTimeStamp(identifier.getExpiryTimeStamp());
  builder.setMasterKeyId(identifier.getMasterKeyId());
  builder.setRmIdentifier(identifier.getRMIdentifier());
  
  PriorityPBImpl priority = (PriorityPBImpl)identifier.getPriority();
  if (priority != null) {
    builder.setPriority(priority.getProto());
  }
  
  builder.setCreationTime(identifier.getCreationTime());
  builder.setMessage(message);
  
  LogAggregationContextPBImpl logAggregationContext = 
      (LogAggregationContextPBImpl)identifier.getLogAggregationContext();
  
  if (logAggregationContext != null) {
    builder.setLogAggregationContext(logAggregationContext.getProto());
  }
  
  proto = builder.build();
}
 
Example #11
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 #12
Source File: ContainerTokenIdentifierForTest.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public ContainerTokenIdentifierForTest(ContainerId containerID,
    String hostName, String appSubmitter, Resource r, long expiryTimeStamp,
    int masterKeyId, long rmIdentifier, Priority priority, long creationTime,
    LogAggregationContext logAggregationContext) {
  ContainerTokenIdentifierForTestProto.Builder builder =
      ContainerTokenIdentifierForTestProto.newBuilder();
  if (containerID != null) {
    builder.setContainerId(((ContainerIdPBImpl)containerID).getProto());
  }
  builder.setNmHostAddr(hostName);
  builder.setAppSubmitter(appSubmitter);
  if (r != null) {
    builder.setResource(((ResourcePBImpl)r).getProto());
  }
  builder.setExpiryTimeStamp(expiryTimeStamp);
  builder.setMasterKeyId(masterKeyId);
  builder.setRmIdentifier(rmIdentifier);
  if (priority != null) {
    builder.setPriority(((PriorityPBImpl)priority).getProto());
  }
  builder.setCreationTime(creationTime);
  
  if (logAggregationContext != null) {
    builder.setLogAggregationContext(
        ((LogAggregationContextPBImpl)logAggregationContext).getProto());
  }
  proto = builder.build();
}
 
Example #13
Source File: ContainerTokenIdentifierForTest.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public ContainerTokenIdentifierForTest(ContainerTokenIdentifier identifier,
    String message) {
  ContainerTokenIdentifierForTestProto.Builder builder =
      ContainerTokenIdentifierForTestProto.newBuilder();
  ContainerIdPBImpl containerID = 
      (ContainerIdPBImpl)identifier.getContainerID();
  if (containerID != null) {
    builder.setContainerId(containerID.getProto());
  }
  builder.setNmHostAddr(identifier.getNmHostAddress());
  builder.setAppSubmitter(identifier.getApplicationSubmitter());
  
  ResourcePBImpl resource = (ResourcePBImpl)identifier.getResource();
  if (resource != null) {
    builder.setResource(resource.getProto());
  }
  
  builder.setExpiryTimeStamp(identifier.getExpiryTimeStamp());
  builder.setMasterKeyId(identifier.getMasterKeyId());
  builder.setRmIdentifier(identifier.getRMIdentifier());
  
  PriorityPBImpl priority = (PriorityPBImpl)identifier.getPriority();
  if (priority != null) {
    builder.setPriority(priority.getProto());
  }
  
  builder.setCreationTime(identifier.getCreationTime());
  builder.setMessage(message);
  
  LogAggregationContextPBImpl logAggregationContext = 
      (LogAggregationContextPBImpl)identifier.getLogAggregationContext();
  
  if (logAggregationContext != null) {
    builder.setLogAggregationContext(logAggregationContext.getProto());
  }
  
  proto = builder.build();
}
 
Example #14
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 #15
Source File: ContainerFinishDataPBImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void mergeLocalToBuilder() {
  if (this.containerId != null
      && !((ContainerIdPBImpl) this.containerId).getProto().equals(
        builder.getContainerId())) {
    builder.setContainerId(convertToProtoFormat(this.containerId));
  }
}
 
Example #16
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 #17
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 #18
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 #19
Source File: TaskAttemptReportPBImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private ContainerIdProto convertToProtoFormat(ContainerId t) {
  return ((ContainerIdPBImpl)t).getProto();
}
 
Example #20
Source File: NMContainerStatusPBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) {
  return new ContainerIdPBImpl(p);
}
 
Example #21
Source File: TestYarnServerApiClasses.java    From big-c with Apache License 2.0 4 votes vote down vote up
private ContainerId getContainerId(int containerID, int appAttemptId) {
  ContainerId containerId = ContainerIdPBImpl.newContainerId(
      getApplicationAttemptId(appAttemptId), containerID);
  return containerId;
}
 
Example #22
Source File: AMInfoPBImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) {
  return new ContainerIdPBImpl(p);
}
 
Example #23
Source File: ContainerFinishDataPBImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private ContainerIdPBImpl
    convertFromProtoFormat(ContainerIdProto containerId) {
  return new ContainerIdPBImpl(containerId);
}
 
Example #24
Source File: NMContainerStatusPBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
private ContainerIdProto convertToProtoFormat(ContainerId t) {
  return ((ContainerIdPBImpl) t).getProto();
}
 
Example #25
Source File: ContainerStartDataPBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
private ContainerIdProto convertToProtoFormat(ContainerId containerId) {
  return ((ContainerIdPBImpl) containerId).getProto();
}
 
Example #26
Source File: NodeHeartbeatResponsePBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
private ContainerIdProto convertToProtoFormat(ContainerId t) {
  return ((ContainerIdPBImpl) t).getProto();
}
 
Example #27
Source File: ApplicationAttemptStartDataPBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
private ContainerIdPBImpl
    convertFromProtoFormat(ContainerIdProto containerId) {
  return new ContainerIdPBImpl(containerId);
}
 
Example #28
Source File: NodeHeartbeatResponsePBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) {
  return new ContainerIdPBImpl(p);
}
 
Example #29
Source File: GetContainerStatusesRequestPBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) {
  return new ContainerIdPBImpl(p);
}
 
Example #30
Source File: ContainerTokenIdentifier.java    From big-c with Apache License 2.0 4 votes vote down vote up
public ContainerId getContainerID() {
  if (!proto.hasContainerId()) {
    return null;
  }
  return new ContainerIdPBImpl(proto.getContainerId());
}