Java Code Examples for org.apache.hadoop.yarn.util.ConverterUtils#toNodeId()
The following examples show how to use
org.apache.hadoop.yarn.util.ConverterUtils#toNodeId() .
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: AggregatedLogsBlock.java From hadoop with Apache License 2.0 | 6 votes |
private NodeId verifyAndGetNodeId(Block html) { String nodeIdStr = $(NM_NODENAME); if (nodeIdStr == null || nodeIdStr.isEmpty()) { html.h1()._("Cannot get container logs without a NodeId")._(); return null; } NodeId nodeId = null; try { nodeId = ConverterUtils.toNodeId(nodeIdStr); } catch (IllegalArgumentException e) { html.h1()._("Cannot get container logs. Invalid nodeId: " + nodeIdStr) ._(); return null; } return nodeId; }
Example 2
Source File: AggregatedLogsBlock.java From big-c with Apache License 2.0 | 6 votes |
private NodeId verifyAndGetNodeId(Block html) { String nodeIdStr = $(NM_NODENAME); if (nodeIdStr == null || nodeIdStr.isEmpty()) { html.h1()._("Cannot get container logs without a NodeId")._(); return null; } NodeId nodeId = null; try { nodeId = ConverterUtils.toNodeId(nodeIdStr); } catch (IllegalArgumentException e) { html.h1()._("Cannot get container logs. Invalid nodeId: " + nodeIdStr) ._(); return null; } return nodeId; }
Example 3
Source File: RMWebServices.java From hadoop with Apache License 2.0 | 5 votes |
@GET @Path("/nodes/{nodeId}") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public NodeInfo getNode(@PathParam("nodeId") String nodeId) { init(); if (nodeId == null || nodeId.isEmpty()) { throw new NotFoundException("nodeId, " + nodeId + ", is empty or null"); } ResourceScheduler sched = this.rm.getResourceScheduler(); if (sched == null) { throw new NotFoundException("Null ResourceScheduler instance"); } NodeId nid = ConverterUtils.toNodeId(nodeId); RMNode ni = this.rm.getRMContext().getRMNodes().get(nid); boolean isInactive = false; if (ni == null) { ni = this.rm.getRMContext().getInactiveRMNodes().get(nid.getHost()); if (ni == null) { throw new NotFoundException("nodeId, " + nodeId + ", is not found"); } isInactive = true; } NodeInfo nodeInfo = new NodeInfo(ni, sched); if (isInactive) { nodeInfo.setNodeHTTPAddress(EMPTY); } return nodeInfo; }
Example 4
Source File: RMWebServices.java From big-c with Apache License 2.0 | 5 votes |
@GET @Path("/nodes/{nodeId}") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public NodeInfo getNode(@PathParam("nodeId") String nodeId) { init(); if (nodeId == null || nodeId.isEmpty()) { throw new NotFoundException("nodeId, " + nodeId + ", is empty or null"); } ResourceScheduler sched = this.rm.getResourceScheduler(); if (sched == null) { throw new NotFoundException("Null ResourceScheduler instance"); } NodeId nid = ConverterUtils.toNodeId(nodeId); RMNode ni = this.rm.getRMContext().getRMNodes().get(nid); boolean isInactive = false; if (ni == null) { ni = this.rm.getRMContext().getInactiveRMNodes().get(nid.getHost()); if (ni == null) { throw new NotFoundException("nodeId, " + nodeId + ", is not found"); } isInactive = true; } NodeInfo nodeInfo = new NodeInfo(ni, sched); if (isInactive) { nodeInfo.setNodeHTTPAddress(EMPTY); } return nodeInfo; }
Example 5
Source File: NodeCLI.java From hadoop with Apache License 2.0 | 4 votes |
/** * Prints the node report for node id. * * @param nodeIdStr * @throws YarnException */ private void printNodeStatus(String nodeIdStr) throws YarnException, IOException { NodeId nodeId = ConverterUtils.toNodeId(nodeIdStr); List<NodeReport> nodesReport = client.getNodeReports(); // Use PrintWriter.println, which uses correct platform line ending. ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintWriter nodeReportStr = new PrintWriter( new OutputStreamWriter(baos, Charset.forName("UTF-8"))); NodeReport nodeReport = null; for (NodeReport report : nodesReport) { if (!report.getNodeId().equals(nodeId)) { continue; } nodeReport = report; nodeReportStr.println("Node Report : "); nodeReportStr.print("\tNode-Id : "); nodeReportStr.println(nodeReport.getNodeId()); nodeReportStr.print("\tRack : "); nodeReportStr.println(nodeReport.getRackName()); nodeReportStr.print("\tNode-State : "); nodeReportStr.println(nodeReport.getNodeState()); nodeReportStr.print("\tNode-Http-Address : "); nodeReportStr.println(nodeReport.getHttpAddress()); nodeReportStr.print("\tLast-Health-Update : "); nodeReportStr.println(DateFormatUtils.format( new Date(nodeReport.getLastHealthReportTime()), "E dd/MMM/yy hh:mm:ss:SSzz")); nodeReportStr.print("\tHealth-Report : "); nodeReportStr .println(nodeReport.getHealthReport()); nodeReportStr.print("\tContainers : "); nodeReportStr.println(nodeReport.getNumContainers()); nodeReportStr.print("\tMemory-Used : "); nodeReportStr.println((nodeReport.getUsed() == null) ? "0MB" : (nodeReport.getUsed().getMemory() + "MB")); nodeReportStr.print("\tMemory-Capacity : "); nodeReportStr.println(nodeReport.getCapability().getMemory() + "MB"); nodeReportStr.print("\tCPU-Used : "); nodeReportStr.println((nodeReport.getUsed() == null) ? "0 vcores" : (nodeReport.getUsed().getVirtualCores() + " vcores")); nodeReportStr.print("\tCPU-Capacity : "); nodeReportStr.println(nodeReport.getCapability().getVirtualCores() + " vcores"); nodeReportStr.print("\tGPU-Used : "); nodeReportStr.println((nodeReport.getUsed() == null) ? "0 gcores" : (nodeReport.getUsed().getGpuCores() + " gcores")); nodeReportStr.print("\tGPU-Capacity : "); nodeReportStr.println(nodeReport.getCapability().getGpuCores() + " gcores"); nodeReportStr.print("\tNode-Labels : "); // Create a List for node labels since we need it get sorted List<String> nodeLabelsList = new ArrayList<String>(report.getNodeLabels()); Collections.sort(nodeLabelsList); nodeReportStr.println(StringUtils.join(nodeLabelsList.iterator(), ',')); } if (nodeReport == null) { nodeReportStr.print("Could not find the node report for node id : " + nodeIdStr); } nodeReportStr.close(); sysout.println(baos.toString("UTF-8")); }
Example 6
Source File: NodeCLI.java From big-c with Apache License 2.0 | 4 votes |
/** * Prints the node report for node id. * * @param nodeIdStr * @throws YarnException */ private void printNodeStatus(String nodeIdStr) throws YarnException, IOException { NodeId nodeId = ConverterUtils.toNodeId(nodeIdStr); List<NodeReport> nodesReport = client.getNodeReports(); // Use PrintWriter.println, which uses correct platform line ending. ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintWriter nodeReportStr = new PrintWriter( new OutputStreamWriter(baos, Charset.forName("UTF-8"))); NodeReport nodeReport = null; for (NodeReport report : nodesReport) { if (!report.getNodeId().equals(nodeId)) { continue; } nodeReport = report; nodeReportStr.println("Node Report : "); nodeReportStr.print("\tNode-Id : "); nodeReportStr.println(nodeReport.getNodeId()); nodeReportStr.print("\tRack : "); nodeReportStr.println(nodeReport.getRackName()); nodeReportStr.print("\tNode-State : "); nodeReportStr.println(nodeReport.getNodeState()); nodeReportStr.print("\tNode-Http-Address : "); nodeReportStr.println(nodeReport.getHttpAddress()); nodeReportStr.print("\tLast-Health-Update : "); nodeReportStr.println(DateFormatUtils.format( new Date(nodeReport.getLastHealthReportTime()), "E dd/MMM/yy hh:mm:ss:SSzz")); nodeReportStr.print("\tHealth-Report : "); nodeReportStr .println(nodeReport.getHealthReport()); nodeReportStr.print("\tContainers : "); nodeReportStr.println(nodeReport.getNumContainers()); nodeReportStr.print("\tMemory-Used : "); nodeReportStr.println((nodeReport.getUsed() == null) ? "0MB" : (nodeReport.getUsed().getMemory() + "MB")); nodeReportStr.print("\tMemory-Capacity : "); nodeReportStr.println(nodeReport.getCapability().getMemory() + "MB"); nodeReportStr.print("\tCPU-Used : "); nodeReportStr.println((nodeReport.getUsed() == null) ? "0 vcores" : (nodeReport.getUsed().getVirtualCores() + " vcores")); nodeReportStr.print("\tCPU-Capacity : "); nodeReportStr.println(nodeReport.getCapability().getVirtualCores() + " vcores"); nodeReportStr.print("\tNode-Labels : "); // Create a List for node labels since we need it get sorted List<String> nodeLabelsList = new ArrayList<String>(report.getNodeLabels()); Collections.sort(nodeLabelsList); nodeReportStr.println(StringUtils.join(nodeLabelsList.iterator(), ',')); } if (nodeReport == null) { nodeReportStr.print("Could not find the node report for node id : " + nodeIdStr); } nodeReportStr.close(); sysout.println(baos.toString("UTF-8")); }
Example 7
Source File: TaskRunner.java From incubator-tajo with Apache License 2.0 | 4 votes |
public TaskRunner(TaskRunnerManager taskRunnerManager, TajoConf conf, String[] args) { super(TaskRunner.class.getName()); this.taskRunnerManager = taskRunnerManager; this.connPool = RpcConnectionPool.getPool(conf); this.fetchLauncher = Executors.newFixedThreadPool( conf.getIntVar(ConfVars.SHUFFLE_FETCHER_PARALLEL_EXECUTION_MAX_NUM)); try { final ExecutionBlockId executionBlockId = TajoIdUtils.createExecutionBlockId(args[1]); LOG.info("Tajo Root Dir: " + conf.getVar(ConfVars.ROOT_DIR)); LOG.info("Worker Local Dir: " + conf.getVar(ConfVars.WORKER_TEMPORAL_DIR)); UserGroupInformation.setConfiguration(conf); // QueryBlockId from String // NodeId has a form of hostname:port. NodeId nodeId = ConverterUtils.toNodeId(args[2]); this.containerId = ConverterUtils.toContainerId(args[3]); // QueryMaster's address String host = args[4]; int port = Integer.parseInt(args[5]); this.qmMasterAddr = NetUtils.createSocketAddrForHost(host, port); LOG.info("QueryMaster Address:" + qmMasterAddr); // TODO - 'load credential' should be implemented // Getting taskOwner UserGroupInformation taskOwner = UserGroupInformation.createRemoteUser(conf.getVar(ConfVars.USERNAME)); //taskOwner.addToken(token); // initialize MasterWorkerProtocol as an actual task owner. // this.client = // taskOwner.doAs(new PrivilegedExceptionAction<AsyncRpcClient>() { // @Override // public AsyncRpcClient run() throws Exception { // return new AsyncRpcClient(TajoWorkerProtocol.class, masterAddr); // } // }); // this.master = client.getStub(); this.executionBlockId = executionBlockId; this.queryId = executionBlockId.getQueryId(); this.nodeId = nodeId; this.taskOwner = taskOwner; this.taskRunnerContext = new TaskRunnerContext(); } catch (Exception e) { LOG.error(e.getMessage(), e); } }
Example 8
Source File: TaskAttemptStartedEvent.java From incubator-tez with Apache License 2.0 | 4 votes |
public void fromProto(TaskAttemptStartedProto proto) { this.taskAttemptId = TezTaskAttemptID.fromString(proto.getTaskAttemptId()); this.startTime = proto.getStartTime(); this.containerId = ConverterUtils.toContainerId(proto.getContainerId()); this.nodeId = ConverterUtils.toNodeId(proto.getNodeId()); }
Example 9
Source File: TaskAttemptFinishedEvent.java From tez with Apache License 2.0 | 4 votes |
public void fromProto(TaskAttemptFinishedProto proto) throws IOException { this.taskAttemptId = TezTaskAttemptID.fromString(proto.getTaskAttemptId()); this.state = TaskAttemptState.values()[proto.getState()]; this.creationTime = proto.getCreationTime(); this.allocationTime = proto.getAllocationTime(); this.startTime = proto.getStartTime(); this.finishTime = proto.getFinishTime(); if (proto.hasTaskFailureType()) { this.taskFailureType = TezConverterUtils.failureTypeFromProto(proto.getTaskFailureType()); } if (proto.hasCreationCausalTA()) { this.creationCausalTA = TezTaskAttemptID.fromString(proto.getCreationCausalTA()); } if (proto.hasDiagnostics()) { this.diagnostics = proto.getDiagnostics(); } if (proto.hasErrorEnum()) { this.error = TaskAttemptTerminationCause.valueOf(proto.getErrorEnum()); } if (proto.hasCounters()) { this.tezCounters = DagTypeConverters.convertTezCountersFromProto( proto.getCounters()); } if (proto.getDataEventsCount() > 0) { this.dataEvents = Lists.newArrayListWithCapacity(proto.getDataEventsCount()); for (DataEventDependencyInfoProto protoEvent : proto.getDataEventsList()) { this.dataEvents.add(DataEventDependencyInfo.fromProto(protoEvent)); } } if (proto.getTaGeneratedEventsCount() > 0) { this.taGeneratedEvents = Lists.newArrayListWithCapacity(proto.getTaGeneratedEventsCount()); for (TezEventProto eventProto : proto.getTaGeneratedEventsList()) { this.taGeneratedEvents.add(TezEventUtils.fromProto(eventProto)); } } if (proto.hasContainerId()) { this.containerId = ConverterUtils.toContainerId(proto.getContainerId()); } if (proto.hasNodeId()) { this.nodeId = ConverterUtils.toNodeId(proto.getNodeId()); } if (proto.hasNodeHttpAddress()) { this.nodeHttpAddress = proto.getNodeHttpAddress(); } }
Example 10
Source File: TaskAttemptStartedEvent.java From tez with Apache License 2.0 | 4 votes |
public void fromProto(TaskAttemptStartedProto proto) { this.taskAttemptId = TezTaskAttemptID.fromString(proto.getTaskAttemptId()); this.launchTime = proto.getStartTime(); this.containerId = ConverterUtils.toContainerId(proto.getContainerId()); this.nodeId = ConverterUtils.toNodeId(proto.getNodeId()); }