org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl Java Examples
The following examples show how to use
org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl.
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: TestBlocks.java From hadoop with Apache License 2.0 | 6 votes |
private Job getJob() { Job job = mock(Job.class); JobId jobId = new JobIdPBImpl(); ApplicationId appId = ApplicationIdPBImpl.newInstance(System.currentTimeMillis(),4); jobId.setAppId(appId); jobId.setId(1); when(job.getID()).thenReturn(jobId); JobReport report = mock(JobReport.class); when(report.getStartTime()).thenReturn(100010L); when(report.getFinishTime()).thenReturn(100015L); when(job.getReport()).thenReturn(report); when(job.getName()).thenReturn("JobName"); when(job.getUserName()).thenReturn("UserName"); when(job.getQueueName()).thenReturn("QueueName"); when(job.getState()).thenReturn(JobState.SUCCEEDED); when(job.getTotalMaps()).thenReturn(3); when(job.getCompletedMaps()).thenReturn(2); when(job.getTotalReduces()).thenReturn(2); when(job.getCompletedReduces()).thenReturn(1); when(job.getCompletedReduces()).thenReturn(1); return job; }
Example #2
Source File: TestBlocks.java From big-c with Apache License 2.0 | 6 votes |
private Job getJob() { Job job = mock(Job.class); JobId jobId = new JobIdPBImpl(); ApplicationId appId = ApplicationIdPBImpl.newInstance(System.currentTimeMillis(),4); jobId.setAppId(appId); jobId.setId(1); when(job.getID()).thenReturn(jobId); JobReport report = mock(JobReport.class); when(report.getStartTime()).thenReturn(100010L); when(report.getFinishTime()).thenReturn(100015L); when(job.getReport()).thenReturn(report); when(job.getName()).thenReturn("JobName"); when(job.getUserName()).thenReturn("UserName"); when(job.getQueueName()).thenReturn("QueueName"); when(job.getState()).thenReturn(JobState.SUCCEEDED); when(job.getTotalMaps()).thenReturn(3); when(job.getCompletedMaps()).thenReturn(2); when(job.getTotalReduces()).thenReturn(2); when(job.getCompletedReduces()).thenReturn(1); when(job.getCompletedReduces()).thenReturn(1); return job; }
Example #3
Source File: TestBlocks.java From big-c with Apache License 2.0 | 6 votes |
private Task getTask(long timestamp) { JobId jobId = new JobIdPBImpl(); jobId.setId(0); jobId.setAppId(ApplicationIdPBImpl.newInstance(timestamp,1)); TaskId taskId = new TaskIdPBImpl(); taskId.setId(0); taskId.setTaskType(TaskType.REDUCE); taskId.setJobId(jobId); Task task = mock(Task.class); when(task.getID()).thenReturn(taskId); TaskReport report = mock(TaskReport.class); when(report.getProgress()).thenReturn(0.7f); when(report.getTaskState()).thenReturn(TaskState.SUCCEEDED); when(report.getStartTime()).thenReturn(100001L); when(report.getFinishTime()).thenReturn(100011L); when(task.getReport()).thenReturn(report); when(task.getType()).thenReturn(TaskType.REDUCE); return task; }
Example #4
Source File: JobIdPBImpl.java From big-c with Apache License 2.0 | 5 votes |
private synchronized void mergeLocalToBuilder() { if (this.applicationId != null && !((ApplicationIdPBImpl) this.applicationId).getProto().equals( builder.getAppId())) { builder.setAppId(convertToProtoFormat(this.applicationId)); } }
Example #5
Source File: ApplicationFinishDataPBImpl.java From big-c with Apache License 2.0 | 5 votes |
private void mergeLocalToBuilder() { if (this.applicationId != null && !((ApplicationIdPBImpl) this.applicationId).getProto().equals( builder.getApplicationId())) { builder.setApplicationId(convertToProtoFormat(this.applicationId)); } }
Example #6
Source File: TestContainerLogsPage.java From big-c with Apache License 2.0 | 5 votes |
@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 #7
Source File: ContainerManagerImpl.java From big-c with Apache License 2.0 | 5 votes |
private ContainerManagerApplicationProto buildAppProto(ApplicationId appId, String user, Credentials credentials, Map<ApplicationAccessType, String> appAcls, LogAggregationContext logAggregationContext) { ContainerManagerApplicationProto.Builder builder = ContainerManagerApplicationProto.newBuilder(); builder.setId(((ApplicationIdPBImpl) appId).getProto()); builder.setUser(user); if (logAggregationContext != null) { builder.setLogAggregationContext(( (LogAggregationContextPBImpl)logAggregationContext).getProto()); } builder.clearCredentials(); if (credentials != null) { DataOutputBuffer dob = new DataOutputBuffer(); try { credentials.writeTokenStorageToStream(dob); builder.setCredentials(ByteString.copyFrom(dob.getData())); } catch (IOException e) { // should not occur LOG.error("Cannot serialize credentials", e); } } builder.clearAcls(); if (appAcls != null) { for (Map.Entry<ApplicationAccessType, String> acl : appAcls.entrySet()) { ApplicationACLMapProto p = ApplicationACLMapProto.newBuilder() .setAccessType(ProtoUtils.convertToProtoFormat(acl.getKey())) .setAcl(acl.getValue()) .build(); builder.addAcls(p); } } return builder.build(); }
Example #8
Source File: ContainerManagerImpl.java From big-c with Apache License 2.0 | 5 votes |
private void recoverApplication(ContainerManagerApplicationProto p) throws IOException { ApplicationId appId = new ApplicationIdPBImpl(p.getId()); Credentials creds = new Credentials(); creds.readTokenStorageStream( new DataInputStream(p.getCredentials().newInput())); List<ApplicationACLMapProto> aclProtoList = p.getAclsList(); Map<ApplicationAccessType, String> acls = new HashMap<ApplicationAccessType, String>(aclProtoList.size()); for (ApplicationACLMapProto aclProto : aclProtoList) { acls.put(ProtoUtils.convertFromProtoFormat(aclProto.getAccessType()), aclProto.getAcl()); } LogAggregationContext logAggregationContext = null; if (p.getLogAggregationContext() != null) { logAggregationContext = new LogAggregationContextPBImpl(p.getLogAggregationContext()); } LOG.info("Recovering application " + appId); ApplicationImpl app = new ApplicationImpl(dispatcher, p.getUser(), appId, creds, context); context.getApplications().put(appId, app); app.handle(new ApplicationInitEvent(appId, acls, logAggregationContext)); }
Example #9
Source File: ApplicationFinishDataPBImpl.java From ambari-metrics with Apache License 2.0 | 5 votes |
private void mergeLocalToBuilder() { if (this.applicationId != null && !((ApplicationIdPBImpl) this.applicationId).getProto().equals( builder.getApplicationId())) { builder.setApplicationId(convertToProtoFormat(this.applicationId)); } }
Example #10
Source File: TestYarnServerApiClasses.java From big-c with Apache License 2.0 | 5 votes |
private ApplicationId getApplicationId(int applicationId) { ApplicationIdPBImpl appId = new ApplicationIdPBImpl() { public ApplicationIdPBImpl setParameters(int id, long timestamp) { setClusterTimestamp(timestamp); setId(id); build(); return this; } }.setParameters(applicationId, 1000); return new ApplicationIdPBImpl(appId.getProto()); }
Example #11
Source File: ApplicationStartDataPBImpl.java From ambari-metrics with Apache License 2.0 | 5 votes |
private void mergeLocalToBuilder() { if (this.applicationId != null && !((ApplicationIdPBImpl) this.applicationId).getProto().equals( builder.getApplicationId())) { builder.setApplicationId(convertToProtoFormat(this.applicationId)); } }
Example #12
Source File: TestAggregatedLogsBlock.java From hadoop with Apache License 2.0 | 5 votes |
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 #13
Source File: TestAggregatedLogsBlock.java From big-c with Apache License 2.0 | 5 votes |
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 #14
Source File: TestYarnServerApiClasses.java From hadoop with Apache License 2.0 | 5 votes |
private ApplicationId getApplicationId(int applicationId) { ApplicationIdPBImpl appId = new ApplicationIdPBImpl() { public ApplicationIdPBImpl setParameters(int id, long timestamp) { setClusterTimestamp(timestamp); setId(id); build(); return this; } }.setParameters(applicationId, 1000); return new ApplicationIdPBImpl(appId.getProto()); }
Example #15
Source File: ContainerManagerImpl.java From hadoop with Apache License 2.0 | 5 votes |
private void recoverApplication(ContainerManagerApplicationProto p) throws IOException { ApplicationId appId = new ApplicationIdPBImpl(p.getId()); Credentials creds = new Credentials(); creds.readTokenStorageStream( new DataInputStream(p.getCredentials().newInput())); List<ApplicationACLMapProto> aclProtoList = p.getAclsList(); Map<ApplicationAccessType, String> acls = new HashMap<ApplicationAccessType, String>(aclProtoList.size()); for (ApplicationACLMapProto aclProto : aclProtoList) { acls.put(ProtoUtils.convertFromProtoFormat(aclProto.getAccessType()), aclProto.getAcl()); } LogAggregationContext logAggregationContext = null; if (p.getLogAggregationContext() != null) { logAggregationContext = new LogAggregationContextPBImpl(p.getLogAggregationContext()); } LOG.info("Recovering application " + appId); ApplicationImpl app = new ApplicationImpl(dispatcher, p.getUser(), appId, creds, context); context.getApplications().put(appId, app); app.handle(new ApplicationInitEvent(appId, acls, logAggregationContext)); }
Example #16
Source File: ContainerManagerImpl.java From hadoop with Apache License 2.0 | 5 votes |
private ContainerManagerApplicationProto buildAppProto(ApplicationId appId, String user, Credentials credentials, Map<ApplicationAccessType, String> appAcls, LogAggregationContext logAggregationContext) { ContainerManagerApplicationProto.Builder builder = ContainerManagerApplicationProto.newBuilder(); builder.setId(((ApplicationIdPBImpl) appId).getProto()); builder.setUser(user); if (logAggregationContext != null) { builder.setLogAggregationContext(( (LogAggregationContextPBImpl)logAggregationContext).getProto()); } builder.clearCredentials(); if (credentials != null) { DataOutputBuffer dob = new DataOutputBuffer(); try { credentials.writeTokenStorageToStream(dob); builder.setCredentials(ByteString.copyFrom(dob.getData())); } catch (IOException e) { // should not occur LOG.error("Cannot serialize credentials", e); } } builder.clearAcls(); if (appAcls != null) { for (Map.Entry<ApplicationAccessType, String> acl : appAcls.entrySet()) { ApplicationACLMapProto p = ApplicationACLMapProto.newBuilder() .setAccessType(ProtoUtils.convertToProtoFormat(acl.getKey())) .setAcl(acl.getValue()) .build(); builder.addAcls(p); } } return builder.build(); }
Example #17
Source File: TestContainerLogsPage.java From hadoop with Apache License 2.0 | 5 votes |
@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 #18
Source File: ApplicationStartDataPBImpl.java From hadoop with Apache License 2.0 | 5 votes |
private void mergeLocalToBuilder() { if (this.applicationId != null && !((ApplicationIdPBImpl) this.applicationId).getProto().equals( builder.getApplicationId())) { builder.setApplicationId(convertToProtoFormat(this.applicationId)); } }
Example #19
Source File: ApplicationFinishDataPBImpl.java From hadoop with Apache License 2.0 | 5 votes |
private void mergeLocalToBuilder() { if (this.applicationId != null && !((ApplicationIdPBImpl) this.applicationId).getProto().equals( builder.getApplicationId())) { builder.setApplicationId(convertToProtoFormat(this.applicationId)); } }
Example #20
Source File: JobIdPBImpl.java From hadoop with Apache License 2.0 | 5 votes |
private synchronized void mergeLocalToBuilder() { if (this.applicationId != null && !((ApplicationIdPBImpl) this.applicationId).getProto().equals( builder.getAppId())) { builder.setAppId(convertToProtoFormat(this.applicationId)); } }
Example #21
Source File: GetNewApplicationResponsePBImpl.java From big-c with Apache License 2.0 | 4 votes |
private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { return new ApplicationIdPBImpl(p); }
Example #22
Source File: GetApplicationReportRequestPBImpl.java From big-c with Apache License 2.0 | 4 votes |
private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { return new ApplicationIdPBImpl(p); }
Example #23
Source File: TestUnnecessaryBlockingOnHistoryFileInfo.java From hadoop with Apache License 2.0 | 4 votes |
private static JobId createJobId(int id) { JobId jobId = new JobIdPBImpl(); jobId.setId(id); jobId.setAppId(ApplicationIdPBImpl.newInstance(0, id)); return jobId; }
Example #24
Source File: ApplicationFinishDataPBImpl.java From big-c with Apache License 2.0 | 4 votes |
private ApplicationIdProto convertToProtoFormat(ApplicationId applicationId) { return ((ApplicationIdPBImpl) applicationId).getProto(); }
Example #25
Source File: GetApplicationReportRequestPBImpl.java From big-c with Apache License 2.0 | 4 votes |
private ApplicationIdProto convertToProtoFormat(ApplicationId t) { return ((ApplicationIdPBImpl)t).getProto(); }
Example #26
Source File: GetNewApplicationResponsePBImpl.java From big-c with Apache License 2.0 | 4 votes |
private ApplicationIdProto convertToProtoFormat(ApplicationId t) { return ((ApplicationIdPBImpl)t).getProto(); }
Example #27
Source File: ApplicationFinishDataPBImpl.java From big-c with Apache License 2.0 | 4 votes |
private ApplicationIdPBImpl convertFromProtoFormat( ApplicationIdProto applicationId) { return new ApplicationIdPBImpl(applicationId); }
Example #28
Source File: TestBlocks.java From big-c with Apache License 2.0 | 4 votes |
/** * test AttemptsBlock's rendering. */ @Test public void testAttemptsBlock() { AppContext ctx = mock(AppContext.class); AppForTest app = new AppForTest(ctx); Task task = getTask(0); Map<TaskAttemptId, TaskAttempt> attempts = new HashMap<TaskAttemptId, TaskAttempt>(); TaskAttempt attempt = mock(TaskAttempt.class); TaskAttemptId taId = new TaskAttemptIdPBImpl(); taId.setId(0); taId.setTaskId(task.getID()); when(attempt.getID()).thenReturn(taId); when(attempt.getNodeHttpAddress()).thenReturn("Node address"); ApplicationId appId = ApplicationIdPBImpl.newInstance(0, 5); ApplicationAttemptId appAttemptId = ApplicationAttemptIdPBImpl.newInstance(appId, 1); ContainerId containerId = ContainerIdPBImpl.newContainerId(appAttemptId, 1); when(attempt.getAssignedContainerID()).thenReturn(containerId); when(attempt.getAssignedContainerMgrAddress()).thenReturn( "assignedContainerMgrAddress"); when(attempt.getNodeRackName()).thenReturn("nodeRackName"); final long taStartTime = 100002L; final long taFinishTime = 100012L; final long taShuffleFinishTime = 100010L; final long taSortFinishTime = 100011L; final TaskAttemptState taState = TaskAttemptState.SUCCEEDED; when(attempt.getLaunchTime()).thenReturn(taStartTime); when(attempt.getFinishTime()).thenReturn(taFinishTime); when(attempt.getShuffleFinishTime()).thenReturn(taShuffleFinishTime); when(attempt.getSortFinishTime()).thenReturn(taSortFinishTime); when(attempt.getState()).thenReturn(taState); TaskAttemptReport taReport = mock(TaskAttemptReport.class); when(taReport.getStartTime()).thenReturn(taStartTime); when(taReport.getFinishTime()).thenReturn(taFinishTime); when(taReport.getShuffleFinishTime()).thenReturn(taShuffleFinishTime); when(taReport.getSortFinishTime()).thenReturn(taSortFinishTime); when(taReport.getContainerId()).thenReturn(containerId); when(taReport.getProgress()).thenReturn(1.0f); when(taReport.getStateString()).thenReturn("Processed 128/128 records <p> \n"); when(taReport.getTaskAttemptState()).thenReturn(taState); when(taReport.getDiagnosticInfo()).thenReturn(""); when(attempt.getReport()).thenReturn(taReport); attempts.put(taId, attempt); when(task.getAttempts()).thenReturn(attempts); app.setTask(task); Job job = mock(Job.class); when(job.getUserName()).thenReturn("User"); app.setJob(job); AttemptsBlockForTest block = new AttemptsBlockForTest(app); block.addParameter(AMParams.TASK_TYPE, "r"); PrintWriter pWriter = new PrintWriter(data); Block html = new BlockForTest(new HtmlBlockForTest(), pWriter, 0, false); block.render(html); pWriter.flush(); // should be printed information about attempts assertTrue(data.toString().contains("0 attempt_0_0001_r_000000_0")); assertTrue(data.toString().contains("SUCCEEDED")); assertFalse(data.toString().contains("Processed 128/128 records <p> \n")); assertTrue(data.toString().contains("Processed 128\\/128 records <p> \\n")); assertTrue(data.toString().contains( "_0005_01_000001:attempt_0_0001_r_000000_0:User:")); assertTrue(data.toString().contains("100002")); assertTrue(data.toString().contains("100010")); assertTrue(data.toString().contains("100011")); assertTrue(data.toString().contains("100012")); }
Example #29
Source File: ReleaseSharedCacheResourceRequestPBImpl.java From big-c with Apache License 2.0 | 4 votes |
private ApplicationIdProto convertToProtoFormat(ApplicationId t) { return ((ApplicationIdPBImpl) t).getProto(); }
Example #30
Source File: MoveApplicationAcrossQueuesRequestPBImpl.java From big-c with Apache License 2.0 | 4 votes |
private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { return new ApplicationIdPBImpl(p); }