use of com.yahoo.slime.Inspector in project vespa by vespa-engine.
the class AllocatedHosts method fromSlime.
private static AllocatedHosts fromSlime(Inspector inspector, Optional<NodeFlavors> nodeFlavors) {
Inspector array = inspector.field(mappingKey);
Set<HostSpec> hosts = new LinkedHashSet<>();
array.traverse(new ArrayTraverser() {
@Override
public void entry(int i, Inspector inspector) {
hosts.add(hostsFromSlime(inspector.field(hostSpecKey), nodeFlavors));
}
});
return new AllocatedHosts(hosts);
}
use of com.yahoo.slime.Inspector in project vespa by vespa-engine.
the class JRTConfigRequestBase method error_response_adds_common_elements.
@Test
public void error_response_adds_common_elements() {
serverReq.addErrorResponse(ErrorCode.APPLICATION_NOT_LOADED, ErrorCode.getName(ErrorCode.APPLICATION_NOT_LOADED));
assertThat(serverReq.getRequest().returnValues().size(), is(1));
Slime data = new JsonDecoder().decode(new Slime(), Utf8.toBytes(serverReq.getRequest().returnValues().get(0).asString()));
Inspector response = data.get();
assertThat(response.field(SlimeResponseData.RESPONSE_DEF_NAME).asString(), is(defName));
assertThat(response.field(SlimeResponseData.RESPONSE_DEF_NAMESPACE).asString(), is(defNamespace));
assertThat(response.field(SlimeResponseData.RESPONSE_DEF_MD5).asString(), is(defMd5));
assertThat(response.field(SlimeResponseData.RESPONSE_CONFIGID).asString(), is(configId));
assertThat(response.field(SlimeResponseData.RESPONSE_CLIENT_HOSTNAME).asString(), is(hostname));
Trace t = Trace.fromSlime(response.field(SlimeResponseData.RESPONSE_TRACE));
assertThat(t.toString(), is(trace.toString()));
}
use of com.yahoo.slime.Inspector in project vespa by vespa-engine.
the class SlimeTraceDeserializer method deserialize.
private static TraceNode deserialize(Inspector entry) {
Object payload = decodePayload(entry.field(SlimeTraceSerializer.PAYLOAD));
long timestamp = decodeTimestamp(entry.field(SlimeTraceSerializer.TIMESTAMP));
final TraceNode node = new TraceNode(payload, timestamp);
Inspector children = entry.field(SlimeTraceSerializer.CHILDREN);
children.traverse(new ArrayTraverser() {
@Override
public void entry(int idx, Inspector inspector) {
node.add(deserialize(inspector));
}
});
return node;
}
use of com.yahoo.slime.Inspector in project vespa by vespa-engine.
the class ConfigVerification method listConfigs.
private static Map<String, Stack<String>> listConfigs(List<String> urls) throws IOException {
Map<String, String> outputs = performRequests(urls);
Map<String, Stack<String>> recurseMappings = new LinkedHashMap<>();
for (Map.Entry<String, String> entry : outputs.entrySet()) {
Slime slime = new JsonDecoder().decode(new Slime(), Utf8.toBytes(entry.getValue()));
final List<String> list = new ArrayList<>();
slime.get().field("configs").traverse(new ArrayTraverser() {
@Override
public void entry(int idx, Inspector inspector) {
list.add(inspector.asString());
}
});
Stack<String> stack = new Stack<>();
Collections.sort(list);
stack.addAll(list);
recurseMappings.put(entry.getKey(), stack);
}
return recurseMappings;
}
use of com.yahoo.slime.Inspector in project vespa by vespa-engine.
the class ConfigPayloadApplier method handleInnerMap.
private void handleInnerMap(String name, Inspector inspector) {
NamedBuilder builder = createBuilder(stack.peek(), stack.peek().peekName());
setMapLeafValue(name, builder.builder());
stack.push(builder);
inspector.traverse(new ObjectTraverser() {
@Override
public void field(String name, Inspector inspector) {
handleObjectEntry(name, inspector);
}
});
stack.pop();
}
Aggregations