private void loadReservationSystemState(RMState rmState) throws IOException { ReservationStateDataAccess DA = (ReservationStateDataAccess) RMStorageFactory.getDataAccess( ReservationStateDataAccess.class); List<ReservationState> reservationStates = DA.getAll(); for (ReservationState state : reservationStates) { if (!rmState.getReservationState().containsKey(state.getPlanName())) { rmState.getReservationState().put(state.getPlanName(), new HashMap<ReservationId, YarnProtos.ReservationAllocationStateProto>()); }; rmState.getReservationState().get(state.getPlanName()).put(ReservationId.parseReservationId(state. getReservationIdName()), YarnProtos.ReservationAllocationStateProto.parseFrom(state.getState())); } }
protected void storeReservationState(final YarnProtos.ReservationAllocationStateProto reservationAllocation, final String planName, final String reservationIdName) throws Exception { LightWeightRequestHandler storeReservationStateHandler = new LightWeightRequestHandler(YARNOperationType.TEST) { @Override public Object performTask() throws StorageException { connector.beginTransaction(); connector.writeLock(); ReservationStateDataAccess DA = (ReservationStateDataAccess) RMStorageFactory.getDataAccess( ReservationStateDataAccess.class); DA.add(new ReservationState(reservationAllocation.toByteArray(), planName, reservationIdName)); connector.commit(); return null; } }; storeReservationStateHandler.handle(); }
public YarnProtos.ContainerIdProto getProto() { YarnProtos.ApplicationIdProto appIdProto = YarnProtos.ApplicationIdProto.newBuilder() .setClusterTimestamp(applicationAttemptId.getApplicationId().getClusterTimestamp()) .setId(applicationAttemptId.getApplicationId().getId()) .build(); YarnProtos.ApplicationAttemptIdProto attemptIdProto = YarnProtos.ApplicationAttemptIdProto.newBuilder() .setAttemptId(applicationAttemptId.getAttemptId()) .setApplicationId(appIdProto) .build(); return YarnProtos.ContainerIdProto.newBuilder() .setAppAttemptId(attemptIdProto) .setAppId(appIdProto) .setId(id) .build(); }
public static YarnProtos.ContainerIdProto getContainerIdProto(ContainerId containerId) { if(containerId instanceof TajoWorkerContainerId) { return ((TajoWorkerContainerId)containerId).getProto(); } else { YarnProtos.ApplicationIdProto appIdProto = YarnProtos.ApplicationIdProto.newBuilder() .setClusterTimestamp(containerId.getApplicationAttemptId().getApplicationId().getClusterTimestamp()) .setId(containerId.getApplicationAttemptId().getApplicationId().getId()) .build(); YarnProtos.ApplicationAttemptIdProto attemptIdProto = YarnProtos.ApplicationAttemptIdProto.newBuilder() .setAttemptId(containerId.getApplicationAttemptId().getAttemptId()) .setApplicationId(appIdProto) .build(); return YarnProtos.ContainerIdProto.newBuilder() .setAppAttemptId(attemptIdProto) .setAppId(appIdProto) .setId(containerId.getId()) .build(); } }
@Override public void releaseWorkerResource(ExecutionBlockId ebId, YarnProtos.ContainerIdProto containerId) { synchronized(workerResourceLock) { AllocatedWorkerResource allocatedWorkerResource = allocatedResourceMap.get(containerId); if(allocatedWorkerResource != null) { LOG.info("Release Resource:" + ebId + "," + allocatedWorkerResource.allocatedDiskSlots + "," + allocatedWorkerResource.allocatedMemoryMB); allocatedWorkerResource.workerResource.releaseResource( allocatedWorkerResource.allocatedDiskSlots, allocatedWorkerResource.allocatedMemoryMB); } else { LOG.warn("No AllocatedWorkerResource data for [" + ebId + "," + containerId + "]"); return; } } synchronized(reAllocationList) { reAllocationList.notifyAll(); } }
private void initIncreaseRequests() { if (this.deprecatedIncreaseReqs != null) { return; } AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; List<YarnProtos.ContainerResourceIncreaseRequestProto> list = p.getIncreaseRequestList(); this.deprecatedIncreaseReqs = new ArrayList<>(); for (YarnProtos.ContainerResourceIncreaseRequestProto c : list) { this.deprecatedIncreaseReqs.add(convertFromProtoFormat(c)); } }
private void addIncreaseRequestsToProto() { maybeInitBuilder(); builder.clearIncreaseRequest(); if (deprecatedIncreaseReqs == null) { return; } Iterable<YarnProtos.ContainerResourceIncreaseRequestProto> iterable = new Iterable<YarnProtos.ContainerResourceIncreaseRequestProto>() { @Override public Iterator<YarnProtos.ContainerResourceIncreaseRequestProto> iterator() { return new Iterator<YarnProtos.ContainerResourceIncreaseRequestProto>() { private Iterator<ContainerResourceIncreaseRequest> iter = deprecatedIncreaseReqs.iterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public YarnProtos.ContainerResourceIncreaseRequestProto next() { return convertToProtoFormat(iter.next()); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; builder.addAllIncreaseRequest(iterable); }
public static ContainerStatusPBImpl convertFromProtoFormat( YarnProtos.ContainerStatusProto p) { return new ContainerStatusPBImpl(p); }
public static QueryId appIdToQueryId(YarnProtos.ApplicationIdProto appId) { return QueryIdFactory.newQueryId(appId.getClusterTimestamp(), appId.getId()); }
public static void releaseWorkerResource(QueryMasterTask.QueryMasterTaskContext context, ExecutionBlockId executionBlockId, List<ContainerId> containerIds) throws Exception { List<YarnProtos.ContainerIdProto> containerIdProtos = new ArrayList<YarnProtos.ContainerIdProto>(); for(ContainerId eachContainerId: containerIds) { containerIdProtos.add(TajoWorkerContainerId.getContainerIdProto(eachContainerId)); } RpcConnectionPool connPool = RpcConnectionPool.getPool(context.getConf()); NettyClientBase tmClient = null; try { tmClient = connPool.getConnection(context.getQueryMasterContext().getWorkerContext().getTajoMasterAddress(), TajoMasterProtocol.class, true); TajoMasterProtocol.TajoMasterProtocolService masterClientService = tmClient.getStub(); masterClientService.releaseWorkerResource(null, TajoMasterProtocol.WorkerResourceReleaseRequest.newBuilder() .setExecutionBlockId(executionBlockId.getProto()) .addAllContainerIds(containerIdProtos) .build(), NullCallback.get()); } catch (Exception e) { LOG.error(e.getMessage(), e); } finally { connPool.releaseConnection(tmClient); } }
@Override public void releaseWorkerResource(RpcController controller, TajoMasterProtocol.WorkerResourceReleaseRequest request, RpcCallback<PrimitiveProtos.BoolProto> done) { List<YarnProtos.ContainerIdProto> containerIds = request.getContainerIdsList(); for(YarnProtos.ContainerIdProto eachContainer: containerIds) { context.getResourceManager().releaseWorkerResource(eachContainer); } done.run(BOOL_TRUE); }
@Override public void releaseWorkerResource(YarnProtos.ContainerIdProto containerId) { throw new UnimplementedException("releaseWorkerResource"); }
@Override public ContainerId makeContainerId(YarnProtos.ContainerIdProto containerIdProto) { TajoWorkerContainerId containerId = new TajoWorkerContainerId(); ApplicationAttemptId appAttemptId = new ApplicationAttemptIdPBImpl(containerIdProto.getAppAttemptId()); containerId.setApplicationAttemptId(appAttemptId); containerId.setId(containerIdProto.getId()); return containerId; }
@Override public void releaseWorkerResource(RpcController controller, TajoMasterProtocol.WorkerResourceReleaseRequest request, RpcCallback<PrimitiveProtos.BoolProto> done) { List<YarnProtos.ContainerIdProto> containerIds = request.getContainerIdsList(); ExecutionBlockId ebId = new ExecutionBlockId(request.getExecutionBlockId()); for(YarnProtos.ContainerIdProto eachContainer: containerIds) { context.getResourceManager().releaseWorkerResource(ebId, eachContainer); } done.run(BOOL_TRUE); }
public static ResourceProto convertToProtoFormat(Resource e) { return YarnProtos.ResourceProto.newBuilder() .setMemory(e.getMemory()) .setVirtualCores(e.getVirtualCores()) .build(); }
private ContainerResourceIncreaseRequestPBImpl convertFromProtoFormat( YarnProtos.ContainerResourceIncreaseRequestProto p) { return new ContainerResourceIncreaseRequestPBImpl(p); }
private YarnProtos.ContainerResourceIncreaseRequestProto convertToProtoFormat( ContainerResourceIncreaseRequest t) { return ((ContainerResourceIncreaseRequestPBImpl) t).getProto(); }
public static YarnProtos.ContainerProto convertToProtoFormat( Container t) { return ((ContainerPBImpl)t).getProto(); }
public static ContainerPBImpl convertFromProtoFormat( YarnProtos.ContainerProto t) { return new ContainerPBImpl(t); }
public static ResourceProto convertToProtoFormat(Resource e) { return YarnProtos.ResourceProto.newBuilder() .setMemory(e.getMemorySize()) .setVirtualCores(e.getVirtualCores()) .build(); }
@Override public ContainerId makeContainerId(YarnProtos.ContainerIdProto containerId) { return new ContainerIdPBImpl(containerId); }
@Override public void releaseWorkerResource(ExecutionBlockId ebId, YarnProtos.ContainerIdProto containerId) { throw new UnimplementedException("releaseWorkerResource"); }
public ContainerId makeContainerId(YarnProtos.ContainerIdProto containerId);