List of usage examples for org.apache.hadoop.yarn.api.records NodeId toString
@Override
public String toString()
From source file:io.hops.ha.common.FairSchedulerNodeInfo.java
License:Apache License
private void persistFSSchedulerNodesToAdd(FSSchedulerNodeDataAccess FSSNodeDA) throws StorageException { if (fsschedulerNodesToAdd != null) { List<FSSchedulerNode> toAddFSSchedulerNodes = new ArrayList<FSSchedulerNode>(); for (NodeId nodeId : fsschedulerNodesToAdd.keySet()) { org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSSchedulerNode fssnode = fsschedulerNodesToAdd .get(nodeId);//w w w . j av a 2 s. c om toAddFSSchedulerNodes .add(new FSSchedulerNode(nodeId.toString(), fssnode.getNumContainers(), null, null)); } FSSNodeDA.prepare(toAddFSSchedulerNodes, null); } }
From source file:io.hops.ha.common.RMContextInfo.java
License:Apache License
public void persistActiveNodeToRemove() throws StorageException { if (!activeNodesToRemove.isEmpty()) { ArrayList<RMContextActiveNodes> rmctxnodesToRemove = new ArrayList<RMContextActiveNodes>(); for (NodeId activeNodeToRemove : activeNodesToRemove) { LOG.debug("HOP :: remove active node " + activeNodeToRemove.getId()); rmctxnodesToRemove.add(new RMContextActiveNodes(activeNodeToRemove.toString())); }/*from w w w . jav a 2 s.co m*/ RMContextActiveNodesDataAccess rmctxnodesDA = (RMContextActiveNodesDataAccess) RMStorageFactory .getDataAccess(RMContextActiveNodesDataAccess.class); rmctxnodesDA.removeAll(rmctxnodesToRemove); } }
From source file:io.hops.ha.common.RMContextInfo.java
License:Apache License
public void persistInactiveNodesToRemove() throws StorageException { if (!inactiveNodesToRemove.isEmpty()) { ArrayList<RMContextInactiveNodes> inactiveToRemove = new ArrayList<RMContextInactiveNodes>(); ArrayList<RMNode> nodesToRemove = new ArrayList<RMNode>(); ArrayList<Resource> resourceToRemove = new ArrayList<Resource>(); for (NodeId inactiveNodeToRemove : inactiveNodesToRemove) { LOG.debug("HOP :: remove inactive node " + inactiveNodeToRemove); inactiveToRemove.add(new RMContextInactiveNodes(inactiveNodeToRemove.toString())); nodesToRemove.add(new RMNode(inactiveNodeToRemove.toString())); resourceToRemove.add(/*from ww w .j a va 2s. c om*/ new Resource(inactiveNodeToRemove.toString(), Resource.TOTAL_CAPABILITY, Resource.RMNODE)); } RMContextInactiveNodesDataAccess rmctxInactiveNodesDA = (RMContextInactiveNodesDataAccess) RMStorageFactory .getDataAccess(RMContextInactiveNodesDataAccess.class); rmctxInactiveNodesDA.removeAll(inactiveToRemove); //clean all the tables depending of RMNode: JustLaunchedContainers, //ContainersToClean, FinishedApplications, UpdatedContainerInfo, NodeHeartBeatResponse, ha_rmnode //ha_node //clearing ha_rmNode is enough because the other tables will be cleared by cascade RMNodeDataAccess rmnodeDA = (RMNodeDataAccess) RMStorageFactory.getDataAccess(RMNodeDataAccess.class); rmnodeDA.removeAll(nodesToRemove); //clean ha_resource ResourceDataAccess resourceDA = (ResourceDataAccess) YarnAPIStorageFactory .getDataAccess(ResourceDataAccess.class); resourceDA.removeAll(resourceToRemove); } }
From source file:io.hops.ha.common.RMContextInfo.java
License:Apache License
public void persistInactiveNodesToAdd(RMContextInactiveNodesDataAccess rmctxInactiveNodesDA) throws StorageException { if (inactiveNodeToAdd != null) { ArrayList<RMContextInactiveNodes> inactiveToAdd = new ArrayList<RMContextInactiveNodes>(); for (NodeId key : inactiveNodeToAdd.keySet()) { if (!inactiveNodesToRemove.remove(key)) { inactiveToAdd.add(new RMContextInactiveNodes(key.toString())); }/*from w w w . j a va2 s . c om*/ } rmctxInactiveNodesDA.addAll(inactiveToAdd); } }
From source file:io.hops.util.DBUtility.java
License:Apache License
public static void removeContainersToClean(final Set<ContainerId> containers, final org.apache.hadoop.yarn.api.records.NodeId nodeId) throws IOException { long start = System.currentTimeMillis(); AsyncLightWeightRequestHandler removeContainerToClean = new AsyncLightWeightRequestHandler( YARNOperationType.TEST) {//from ww w . j a v a2 s .co m @Override public Object performTask() throws StorageException { connector.beginTransaction(); connector.writeLock(); ContainerIdToCleanDataAccess ctcDA = (ContainerIdToCleanDataAccess) RMStorageFactory .getDataAccess(ContainerIdToCleanDataAccess.class); List<io.hops.metadata.yarn.entity.ContainerId> containersToClean = new ArrayList<io.hops.metadata.yarn.entity.ContainerId>(); for (ContainerId cid : containers) { containersToClean .add(new io.hops.metadata.yarn.entity.ContainerId(nodeId.toString(), cid.toString())); } ctcDA.removeAll(containersToClean); connector.commit(); return null; } }; removeContainerToClean.handle(); long duration = System.currentTimeMillis() - start; if (duration > 10) { LOG.error("too long " + duration); } }
From source file:io.hops.util.DBUtility.java
License:Apache License
public static void removeContainersToSignal(final Set<SignalContainerRequest> containerRequests, final NodeId nodeId) throws IOException { long start = System.currentTimeMillis(); AsyncLightWeightRequestHandler removeContainerToSignal = new AsyncLightWeightRequestHandler( YARNOperationType.TEST) {/* w w w . ja v a 2s .c o m*/ @Override public Object performTask() throws StorageException { connector.beginTransaction(); connector.writeLock(); ContainerToSignalDataAccess ctsDA = (ContainerToSignalDataAccess) RMStorageFactory .getDataAccess(ContainerToSignalDataAccess.class); List<ContainerToSignal> containersToSignal = new ArrayList<ContainerToSignal>(); for (SignalContainerRequest cr : containerRequests) { containersToSignal.add(new ContainerToSignal(nodeId.toString(), cr.getContainerId().toString(), cr.getCommand().toString())); } ctsDA.removeAll(containersToSignal); connector.commit(); return null; } }; removeContainerToSignal.handle(); long duration = System.currentTimeMillis() - start; if (duration > 10) { LOG.error("too long " + duration); } }
From source file:io.hops.util.DBUtility.java
License:Apache License
public static void addContainerToSignal(final SignalContainerRequest containerRequest, final NodeId nodeId) throws IOException { long start = System.currentTimeMillis(); AsyncLightWeightRequestHandler addContainerToSignal = new AsyncLightWeightRequestHandler( YARNOperationType.TEST) {/*from ww w . ja va2s.c o m*/ @Override public Object performTask() throws StorageException { connector.beginTransaction(); connector.writeLock(); ContainerToSignalDataAccess ctsDA = (ContainerToSignalDataAccess) RMStorageFactory .getDataAccess(ContainerToSignalDataAccess.class); ContainerToSignal containerToSignal = new ContainerToSignal(nodeId.toString(), containerRequest.getContainerId().toString(), containerRequest.getCommand().toString()); ctsDA.add(containerToSignal); connector.commit(); return null; } }; addContainerToSignal.handle(); long duration = System.currentTimeMillis() - start; if (duration > 10) { LOG.error("too long " + duration); } }
From source file:io.hops.util.DBUtility.java
License:Apache License
public static void removeRMNodeApplications(final List<ApplicationId> applications, final org.apache.hadoop.yarn.api.records.NodeId nodeId, final RMNodeApplication.RMNodeApplicationStatus status) throws IOException { long start = System.currentTimeMillis(); AsyncLightWeightRequestHandler removeRMNodeApplication = new AsyncLightWeightRequestHandler( YARNOperationType.TEST) {/*from ww w . j a va2s .co m*/ @Override public Object performTask() throws StorageException { connector.beginTransaction(); connector.writeLock(); RMNodeApplicationsDataAccess faDA = (RMNodeApplicationsDataAccess) RMStorageFactory .getDataAccess(RMNodeApplicationsDataAccess.class); List<RMNodeApplication> rmNodeApps = new ArrayList<RMNodeApplication>(); for (ApplicationId appId : applications) { rmNodeApps.add(new RMNodeApplication(nodeId.toString(), appId.toString(), status)); } faDA.removeAll(rmNodeApps); connector.commit(); return null; } }; removeRMNodeApplication.handle(); long duration = System.currentTimeMillis() - start; if (duration > 10) { LOG.error("too long " + duration); } }
From source file:io.hops.util.DBUtility.java
License:Apache License
public static void removeRMNodeApplication(final ApplicationId appId, final org.apache.hadoop.yarn.api.records.NodeId nodeId, final RMNodeApplication.RMNodeApplicationStatus status) throws IOException { long start = System.currentTimeMillis(); AsyncLightWeightRequestHandler removeRMNodeApplication = new AsyncLightWeightRequestHandler( YARNOperationType.TEST) {// w ww. java 2 s. c o m @Override public Object performTask() throws StorageException { connector.beginTransaction(); connector.writeLock(); RMNodeApplicationsDataAccess faDA = (RMNodeApplicationsDataAccess) RMStorageFactory .getDataAccess(RMNodeApplicationsDataAccess.class); RMNodeApplication rmNodeApp = new RMNodeApplication(nodeId.toString(), appId.toString(), status); faDA.remove(rmNodeApp); connector.commit(); return null; } }; removeRMNodeApplication.handle(); long duration = System.currentTimeMillis() - start; if (duration > 10) { LOG.error("too long " + duration); } }
From source file:io.hops.util.DBUtility.java
License:Apache License
public static void addRMNodeApplication(final ApplicationId appId, final org.apache.hadoop.yarn.api.records.NodeId nodeId, final RMNodeApplication.RMNodeApplicationStatus status) throws IOException { long start = System.currentTimeMillis(); AsyncLightWeightRequestHandler addRMNodeApplication = new AsyncLightWeightRequestHandler( YARNOperationType.TEST) {//from w w w . j ava 2 s . c o m @Override public Object performTask() throws StorageException { connector.beginTransaction(); connector.writeLock(); RMNodeApplicationsDataAccess faDA = (RMNodeApplicationsDataAccess) RMStorageFactory .getDataAccess(RMNodeApplicationsDataAccess.class); faDA.add(new RMNodeApplication(nodeId.toString(), appId.toString(), status)); connector.commit(); return null; } }; addRMNodeApplication.handle(); long duration = System.currentTimeMillis() - start; if (duration > 10) { LOG.error("too long " + duration); } }