protected Object _deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { final TreeNode treeNode = p.readValueAsTree(); final TreeNode typeNode = treeNode.path("type"); if (!typeNode.isObject()) { ctxt.reportWrongTokenException(typeNode.traverse(), JsonToken.START_OBJECT, "expected START_OBJECT before the type information and deserialized value"); } final TreeNode valueNode = typeNode.path("@value"); if (!valueNode.isValueNode()) { ctxt.reportWrongTokenException(typeNode.traverse(), JsonToken.VALUE_STRING, "expected VALUE_STRING as type information and deserialized value"); } final JsonParser jsonParser = valueNode.traverse(); final String typeId = jsonParser.nextTextValue(); final JsonDeserializer<Object> deser = _findDeserializer(ctxt, typeId); final JsonParser newParser = treeNode.traverse(); if (newParser.nextToken() != JsonToken.START_OBJECT) { ctxt.reportWrongTokenException(newParser, JsonToken.START_OBJECT, "expected START_OBJECT"); } return deser.deserialize(newParser, ctxt); } }
public boolean parse() throws IOException, JsonProcessingException { JsonParser parser=factory.createParser(input); boolean done=false; do { TreeNode t=parser.readValueAsTree(); if(t==null) { done=true; } else { if(t instanceof ObjectNode) { if(!documentCompleted((ObjectNode)t)) return false; } else if(t instanceof ArrayNode) { int n=t.size(); for(int i=0;i<n;i++) { TreeNode elem=t.path(i); if(elem!=null) { if(!documentCompleted((ObjectNode)elem)) return false; } } } else { throw new RuntimeException("Ill formed stream"); } } } while(!done); return true; }
final int memory = resourceNode.get("memory_mb").traverse().getIntValue(); final int capacity = resourceNode.get("capacity").traverse().getIntValue(); final int executorNum = resourceNode.path("num").traverse().nextIntValue(1); final int poisonSec = resourceNode.path("poison_sec").traverse().nextIntValue(-1); resourceRequestCount.getAndAdd(executorNum); containerManager.requestContainer(executorNum, new ResourceSpecification(type, capacity, memory, poisonSec));
final int memory = resourceNode.get("memory_mb").traverse().getIntValue(); final int capacity = resourceNode.get("capacity").traverse().getIntValue(); final int executorNum = resourceNode.path("num").traverse().nextIntValue(1); final int poisonSec = resourceNode.path("poison_sec").traverse().nextIntValue(-1); resourceRequestCount.getAndAdd(executorNum); containerManager.requestContainer(executorNum, new ResourceSpecification(type, capacity, memory, poisonSec));