private void mergeLocalToBuilder() { if (this.containerId != null && !((ContainerIdPBImpl) containerId).getProto().equals( builder.getContainerId())) { builder.setContainerId(convertToProtoFormat(this.containerId)); } if (this.resource != null && !((ResourcePBImpl) this.resource).getProto().equals( builder.getResource())) { builder.setResource(convertToProtoFormat(this.resource)); } if (this.priority != null) { builder.setPriority(convertToProtoFormat(this.priority)); } }
private void mergeLocalToBuilder() { if (this.containerId != null && !((ContainerIdPBImpl) this.containerId).getProto().equals( builder.getContainerId())) { builder.setContainerId(convertToProtoFormat(this.containerId)); } if (this.resource != null && !((ResourcePBImpl) this.resource).getProto().equals( builder.getAllocatedResource())) { builder.setAllocatedResource(convertToProtoFormat(this.resource)); } if (this.nodeId != null && !((NodeIdPBImpl) this.nodeId).getProto().equals( builder.getAssignedNodeId())) { builder.setAssignedNodeId(convertToProtoFormat(this.nodeId)); } if (this.priority != null && !((PriorityPBImpl) this.priority).getProto().equals( builder.getPriority())) { builder.setPriority(convertToProtoFormat(this.priority)); } }
public ContainerTokenIdentifier(ContainerId containerID, String hostName, String appSubmitter, Resource r, long expiryTimeStamp, int masterKeyId, long rmIdentifier, Priority priority, long creationTime, LogAggregationContext logAggregationContext) { ContainerTokenIdentifierProto.Builder builder = ContainerTokenIdentifierProto.newBuilder(); if (containerID != null) { builder.setContainerId(((ContainerIdPBImpl)containerID).getProto()); } builder.setNmHostAddr(hostName); builder.setAppSubmitter(appSubmitter); if (r != null) { builder.setResource(((ResourcePBImpl)r).getProto()); } builder.setExpiryTimeStamp(expiryTimeStamp); builder.setMasterKeyId(masterKeyId); builder.setRmIdentifier(rmIdentifier); if (priority != null) { builder.setPriority(((PriorityPBImpl)priority).getProto()); } builder.setCreationTime(creationTime); if (logAggregationContext != null) { builder.setLogAggregationContext( ((LogAggregationContextPBImpl)logAggregationContext).getProto()); } proto = builder.build(); }
public ContainerTokenIdentifierForTest(ContainerId containerID, String hostName, String appSubmitter, Resource r, long expiryTimeStamp, int masterKeyId, long rmIdentifier, Priority priority, long creationTime, LogAggregationContext logAggregationContext) { ContainerTokenIdentifierForTestProto.Builder builder = ContainerTokenIdentifierForTestProto.newBuilder(); if (containerID != null) { builder.setContainerId(((ContainerIdPBImpl)containerID).getProto()); } builder.setNmHostAddr(hostName); builder.setAppSubmitter(appSubmitter); if (r != null) { builder.setResource(((ResourcePBImpl)r).getProto()); } builder.setExpiryTimeStamp(expiryTimeStamp); builder.setMasterKeyId(masterKeyId); builder.setRmIdentifier(rmIdentifier); if (priority != null) { builder.setPriority(((PriorityPBImpl)priority).getProto()); } builder.setCreationTime(creationTime); if (logAggregationContext != null) { builder.setLogAggregationContext( ((LogAggregationContextPBImpl)logAggregationContext).getProto()); } proto = builder.build(); }
public ContainerTokenIdentifierForTest(ContainerTokenIdentifier identifier, String message) { ContainerTokenIdentifierForTestProto.Builder builder = ContainerTokenIdentifierForTestProto.newBuilder(); ContainerIdPBImpl containerID = (ContainerIdPBImpl)identifier.getContainerID(); if (containerID != null) { builder.setContainerId(containerID.getProto()); } builder.setNmHostAddr(identifier.getNmHostAddress()); builder.setAppSubmitter(identifier.getApplicationSubmitter()); ResourcePBImpl resource = (ResourcePBImpl)identifier.getResource(); if (resource != null) { builder.setResource(resource.getProto()); } builder.setExpiryTimeStamp(identifier.getExpiryTimeStamp()); builder.setMasterKeyId(identifier.getMasterKeyId()); builder.setRmIdentifier(identifier.getRMIdentifier()); PriorityPBImpl priority = (PriorityPBImpl)identifier.getPriority(); if (priority != null) { builder.setPriority(priority.getProto()); } builder.setCreationTime(identifier.getCreationTime()); builder.setMessage(message); LogAggregationContextPBImpl logAggregationContext = (LogAggregationContextPBImpl)identifier.getLogAggregationContext(); if (logAggregationContext != null) { builder.setLogAggregationContext(logAggregationContext.getProto()); } proto = builder.build(); }
public ContainerTokenIdentifier(ContainerId containerID, String hostName, String appSubmitter, Resource r, long expiryTimeStamp, int masterKeyId, long rmIdentifier, Priority priority, long creationTime, LogAggregationContext logAggregationContext, String nodeLabelExpression, ContainerType containerType, ExecutionType executionType) { ContainerTokenIdentifierProto.Builder builder = ContainerTokenIdentifierProto.newBuilder(); if (containerID != null) { builder.setContainerId(((ContainerIdPBImpl)containerID).getProto()); } builder.setNmHostAddr(hostName); builder.setAppSubmitter(appSubmitter); if (r != null) { builder.setResource(((ResourcePBImpl)r).getProto()); } builder.setExpiryTimeStamp(expiryTimeStamp); builder.setMasterKeyId(masterKeyId); builder.setRmIdentifier(rmIdentifier); if (priority != null) { builder.setPriority(((PriorityPBImpl)priority).getProto()); } builder.setCreationTime(creationTime); if (logAggregationContext != null) { builder.setLogAggregationContext( ((LogAggregationContextPBImpl)logAggregationContext).getProto()); } if (nodeLabelExpression != null) { builder.setNodeLabelExpression(nodeLabelExpression); } builder.setContainerType(convertToProtoFormat(containerType)); builder.setExecutionType(convertToProtoFormat(executionType)); proto = builder.build(); }
private RecoveredContainerState loadContainerState(ContainerId containerId, LeveldbIterator iter, String keyPrefix) throws IOException { RecoveredContainerState rcs = new RecoveredContainerState(); rcs.status = RecoveredContainerStatus.REQUESTED; while (iter.hasNext()) { Entry<byte[],byte[]> entry = iter.peekNext(); String key = asString(entry.getKey()); if (!key.startsWith(keyPrefix)) { break; } iter.next(); String suffix = key.substring(keyPrefix.length()-1); // start with '/' if (suffix.equals(CONTAINER_REQUEST_KEY_SUFFIX)) { rcs.startRequest = new StartContainerRequestPBImpl( StartContainerRequestProto.parseFrom(entry.getValue())); } else if (suffix.equals(CONTAINER_DIAGS_KEY_SUFFIX)) { rcs.diagnostics = asString(entry.getValue()); } else if (suffix.equals(CONTAINER_LAUNCHED_KEY_SUFFIX)) { if (rcs.status == RecoveredContainerStatus.REQUESTED) { rcs.status = RecoveredContainerStatus.LAUNCHED; } } else if (suffix.equals(CONTAINER_KILLED_KEY_SUFFIX)) { rcs.killed = true; } else if (suffix.equals(CONTAINER_EXIT_CODE_KEY_SUFFIX)) { rcs.status = RecoveredContainerStatus.COMPLETED; rcs.exitCode = Integer.parseInt(asString(entry.getValue())); } else if (suffix.equals(CONTAINER_RESOURCE_CHANGED_KEY_SUFFIX)) { rcs.capability = new ResourcePBImpl( ResourceProto.parseFrom(entry.getValue())); } else { throw new IOException("Unexpected container state key: " + key); } } return rcs; }
@Override public void storeContainerResourceChanged(ContainerId containerId, Resource capability) throws IOException { String key = CONTAINERS_KEY_PREFIX + containerId.toString() + CONTAINER_RESOURCE_CHANGED_KEY_SUFFIX; try { // New value will overwrite old values for the same key db.put(bytes(key), ((ResourcePBImpl) capability).getProto().toByteArray()); } catch (DBException e) { throw new IOException(e); } }
public ContainerTokenIdentifier(ContainerId containerID, int containerVersion, String hostName, String appSubmitter, Resource r, long expiryTimeStamp, int masterKeyId, long rmIdentifier, Priority priority, long creationTime, LogAggregationContext logAggregationContext, String nodeLabelExpression, ContainerType containerType, String appSubmitterFolder) { ContainerTokenIdentifierProto.Builder builder = ContainerTokenIdentifierProto.newBuilder(); if (containerID != null) { builder.setContainerId(((ContainerIdPBImpl)containerID).getProto()); } builder.setVersion(containerVersion); builder.setNmHostAddr(hostName); builder.setAppSubmitter(appSubmitter); builder.setAppSubmitterFolder(appSubmitterFolder); if (r != null) { builder.setResource(((ResourcePBImpl)r).getProto()); } builder.setExpiryTimeStamp(expiryTimeStamp); builder.setMasterKeyId(masterKeyId); builder.setRmIdentifier(rmIdentifier); if (priority != null) { builder.setPriority(((PriorityPBImpl)priority).getProto()); } builder.setCreationTime(creationTime); if (logAggregationContext != null) { builder.setLogAggregationContext( ((LogAggregationContextPBImpl)logAggregationContext).getProto()); } if (nodeLabelExpression != null) { builder.setNodeLabelExpression(nodeLabelExpression); } builder.setContainerType(convertToProtoFormat(containerType)); proto = builder.build(); }
public ContainerTokenIdentifierForTest(ContainerTokenIdentifier identifier, String message) { ContainerTokenIdentifierForTestProto.Builder builder = ContainerTokenIdentifierForTestProto.newBuilder(); ContainerIdPBImpl containerID = (ContainerIdPBImpl)identifier.getContainerID(); if (containerID != null) { builder.setContainerId(containerID.getProto()); } builder.setNmHostAddr(identifier.getNmHostAddress()); builder.setAppSubmitter(identifier.getApplicationSubmitter()); builder.setAppSubmitterFolder(identifier.getApplicationSubmitterFolder()); ResourcePBImpl resource = (ResourcePBImpl)identifier.getResource(); if (resource != null) { builder.setResource(resource.getProto()); } builder.setExpiryTimeStamp(identifier.getExpiryTimeStamp()); builder.setMasterKeyId(identifier.getMasterKeyId()); builder.setRmIdentifier(identifier.getRMIdentifier()); PriorityPBImpl priority = (PriorityPBImpl)identifier.getPriority(); if (priority != null) { builder.setPriority(priority.getProto()); } builder.setCreationTime(identifier.getCreationTime()); builder.setMessage(message); LogAggregationContextPBImpl logAggregationContext = (LogAggregationContextPBImpl)identifier.getLogAggregationContext(); if (logAggregationContext != null) { builder.setLogAggregationContext(logAggregationContext.getProto()); } proto = builder.build(); }
private RecoveredContainerState loadContainerState(ContainerId containerId, LeveldbIterator iter, String keyPrefix) throws IOException { RecoveredContainerState rcs = new RecoveredContainerState(); rcs.status = RecoveredContainerStatus.REQUESTED; while (iter.hasNext()) { Entry<byte[],byte[]> entry = iter.peekNext(); String key = asString(entry.getKey()); if (!key.startsWith(keyPrefix)) { break; } iter.next(); String suffix = key.substring(keyPrefix.length()-1); // start with '/' if (suffix.equals(CONTAINER_REQUEST_KEY_SUFFIX)) { rcs.startRequest = new StartContainerRequestPBImpl( StartContainerRequestProto.parseFrom(entry.getValue())); } else if (suffix.equals(CONTAINER_VERSION_KEY_SUFFIX)) { rcs.version = Integer.parseInt(asString(entry.getValue())); } else if (suffix.equals(CONTAINER_DIAGS_KEY_SUFFIX)) { rcs.diagnostics = asString(entry.getValue()); } else if (suffix.equals(CONTAINER_LAUNCHED_KEY_SUFFIX)) { if (rcs.status == RecoveredContainerStatus.REQUESTED) { rcs.status = RecoveredContainerStatus.LAUNCHED; } } else if (suffix.equals(CONTAINER_KILLED_KEY_SUFFIX)) { rcs.killed = true; } else if (suffix.equals(CONTAINER_EXIT_CODE_KEY_SUFFIX)) { rcs.status = RecoveredContainerStatus.COMPLETED; rcs.exitCode = Integer.parseInt(asString(entry.getValue())); } else if (suffix.equals(CONTAINER_RESOURCE_CHANGED_KEY_SUFFIX)) { rcs.capability = new ResourcePBImpl( ResourceProto.parseFrom(entry.getValue())); } else { throw new IOException("Unexpected container state key: " + key); } } return rcs; }
@Override public void storeContainerResourceChanged(ContainerId containerId, int containerVersion, Resource capability) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("storeContainerResourceChanged: containerId=" + containerId + ", capability=" + capability); } String keyResChng = CONTAINERS_KEY_PREFIX + containerId.toString() + CONTAINER_RESOURCE_CHANGED_KEY_SUFFIX; String keyVersion = CONTAINERS_KEY_PREFIX + containerId.toString() + CONTAINER_VERSION_KEY_SUFFIX; try { WriteBatch batch = db.createWriteBatch(); try { // New value will overwrite old values for the same key batch.put(bytes(keyResChng), ((ResourcePBImpl) capability).getProto().toByteArray()); batch.put(bytes(keyVersion), bytes(Integer.toString(containerVersion))); db.write(batch); } finally { batch.close(); } } catch (DBException e) { throw new IOException(e); } }
@Before public void setUp() throws Exception { NodeStore store = new NodeStore(); NodeIdProto nodeId = NodeIdProto.newBuilder().setHost("localhost").setPort(8000).build(); RMNode rmNode = new RMNodeImpl(new NodeIdPBImpl(nodeId), new MockRMContext(), "localhost", 8000, 8070, new NodeBase(), new ResourcePBImpl(), "1.0"); SchedulerNode node = new FiCaSchedulerNode(rmNode, false); store.add(node); manager = new OfferLifecycleManager(store, new MyriadDriver(new MockSchedulerDriver())); }
public Resource getResource() { if (!proto.hasResource()) { return null; } return new ResourcePBImpl(proto.getResource()); }
private Resource convertFromProtoFormat(ResourceProto resource) { return new ResourcePBImpl(resource); }
private ResourceProto convertToProtoFormat(Resource resource) { return ((ResourcePBImpl)resource).getProto(); }
private synchronized ResourcePBImpl convertFromProtoFormat(ResourceProto p) { return new ResourcePBImpl(p); }
private synchronized ResourceProto convertToProtoFormat(Resource r) { return ((ResourcePBImpl) r).getProto(); }
private ResourcePBImpl convertFromProtoFormat(ResourceProto p) { return new ResourcePBImpl(p); }
private ResourceProto convertToProtoFormat(Resource t) { return ((ResourcePBImpl) t).getProto(); }
private ResourceProto convertToProtoFormat(Resource t) { return ((ResourcePBImpl)t).getProto(); }
public Resource getResource() { return new ResourcePBImpl(proto.getResource()); }
private ResourceProto convertToProtoFormat(Resource resource) { return ((ResourcePBImpl) resource).getProto(); }