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(); }
@Override public UserGroupInformation getUser() { String appAttemptId = null; if (proto.hasAppAttemptId()) { appAttemptId = new ApplicationAttemptIdPBImpl( proto.getAppAttemptId()).toString(); } return UserGroupInformation.createRemoteUser(appAttemptId); }
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(); }
@Private public ApplicationAttemptId getApplicationAttemptId() { if (!proto.hasAppAttemptId()) { return null; } return new ApplicationAttemptIdPBImpl(proto.getAppAttemptId()); }
@Override public UserGroupInformation getUser() { String appAttemptId = null; if (proto.hasAppAttemptId()) { appAttemptId = new ApplicationAttemptIdPBImpl(proto.getAppAttemptId()).toString(); } return UserGroupInformation.createRemoteUser(appAttemptId); }
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(); }
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(); }
@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); }
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)); } }
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)); } }
private void mergeLocalToBuilder() { if (this.applicationAttemptId != null && !((ApplicationAttemptIdPBImpl) this.applicationAttemptId).getProto() .equals(builder.getApplicationAttemptId())) { builder .setApplicationAttemptId(convertToProtoFormat(this.applicationAttemptId)); } }
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)); } }
@Test @Ignore // ignore cause ApplicationIdPBImpl is immutable public void testApplicationAttemptIdPBImpl() throws Exception { validatePBImplRecord(ApplicationAttemptIdPBImpl.class, ApplicationAttemptIdProto.class); }
@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.getLogDirs()).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); }