Search in sources :

Example 1 with Inspector

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);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Inspector(com.yahoo.slime.Inspector) ArrayTraverser(com.yahoo.slime.ArrayTraverser)

Example 2 with Inspector

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()));
}
Also used : JsonDecoder(com.yahoo.slime.JsonDecoder) Inspector(com.yahoo.slime.Inspector) Slime(com.yahoo.slime.Slime) Test(org.junit.Test)

Example 3 with Inspector

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;
}
Also used : Inspector(com.yahoo.slime.Inspector) TraceNode(com.yahoo.yolean.trace.TraceNode) ArrayTraverser(com.yahoo.slime.ArrayTraverser)

Example 4 with Inspector

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;
}
Also used : Slime(com.yahoo.slime.Slime) JsonDecoder(com.yahoo.slime.JsonDecoder) Inspector(com.yahoo.slime.Inspector) ArrayTraverser(com.yahoo.slime.ArrayTraverser)

Example 5 with Inspector

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();
}
Also used : ObjectTraverser(com.yahoo.slime.ObjectTraverser) Inspector(com.yahoo.slime.Inspector)

Aggregations

Inspector (com.yahoo.slime.Inspector)27 ArrayTraverser (com.yahoo.slime.ArrayTraverser)10 Slime (com.yahoo.slime.Slime)10 IOException (java.io.IOException)6 Cursor (com.yahoo.slime.Cursor)4 SlimeUtils (com.yahoo.vespa.config.SlimeUtils)4 CompressionType (com.yahoo.compress.CompressionType)3 ApplicationId (com.yahoo.config.provision.ApplicationId)3 JsonDecoder (com.yahoo.slime.JsonDecoder)3 Tenant (com.yahoo.vespa.hosted.controller.api.Tenant)3 TenantId (com.yahoo.vespa.hosted.controller.api.identifiers.TenantId)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 Version (com.yahoo.component.Version)2 ObjectTraverser (com.yahoo.slime.ObjectTraverser)2 Utf8Array (com.yahoo.text.Utf8Array)2 AthenzDomain (com.yahoo.vespa.athenz.api.AthenzDomain)2 Change (com.yahoo.vespa.hosted.controller.application.Change)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2