use of com.yahoo.slime.ArrayTraverser 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.ArrayTraverser 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.ArrayTraverser 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.ArrayTraverser in project vespa by vespa-engine.
the class JobQueueSerializer method fromJson.
public Deque<ApplicationId> fromJson(byte[] data) {
Inspector inspector = SlimeUtils.jsonToSlime(data).get();
Deque<ApplicationId> queue = new ArrayDeque<>();
inspector.traverse((ArrayTraverser) (index, value) -> queue.addLast(ApplicationId.fromSerializedForm(value.asString())));
return queue;
}
use of com.yahoo.slime.ArrayTraverser in project vespa by vespa-engine.
the class StringSetSerializer method fromJson.
public Set<String> fromJson(byte[] data) {
Inspector inspector = SlimeUtils.jsonToSlime(data).get();
Set<String> stringSet = new HashSet<>();
inspector.traverse((ArrayTraverser) (index, name) -> stringSet.add(name.asString()));
return stringSet;
}
Aggregations