Search in sources :

Example 61 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class SendAdapterTestCase method assertVersionedSend.

// //////////////////////////////////////////////////////////////////////////////
// 
// Utilities
// 
// //////////////////////////////////////////////////////////////////////////////
private void assertVersionedSend(Version srcVersion, Version itrVersion, Version dstVersion) {
    System.out.println("Sending from " + srcVersion + " through " + itrVersion + " to " + dstVersion + ":");
    srcServer.net.setVersion(srcVersion);
    itrServer.net.setVersion(itrVersion);
    dstServer.net.setVersion(dstVersion);
    Message msg = new SimpleMessage("foo");
    msg.getTrace().setLevel(9);
    assertTrue(srcSession.send(msg, Route.parse("itr/session dst/session")).isAccepted());
    assertNotNull(msg = ((Receptor) itrSession.getMessageHandler()).getMessage(300));
    System.out.println("\tMessage version " + srcProtocol.lastVersion + " serialized at source.");
    Version minVersion = srcVersion.compareTo(itrVersion) < 0 ? srcVersion : itrVersion;
    assertEquals(minVersion, srcProtocol.lastVersion);
    System.out.println("\tMessage version " + itrProtocol.lastVersion + " reached intermediate.");
    assertEquals(minVersion, itrProtocol.lastVersion);
    itrSession.forward(msg);
    assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(300));
    System.out.println("\tMessage version " + itrProtocol.lastVersion + " serialized at intermediate.");
    minVersion = itrVersion.compareTo(dstVersion) < 0 ? itrVersion : dstVersion;
    assertEquals(minVersion, itrProtocol.lastVersion);
    System.out.println("\tMessage version " + dstProtocol.lastVersion + " reached destination.");
    assertEquals(minVersion, dstProtocol.lastVersion);
    Reply reply = new SimpleReply("bar");
    reply.swapState(msg);
    dstSession.reply(reply);
    assertNotNull(reply = ((Receptor) itrSession.getReplyHandler()).getReply(300));
    System.out.println("\tReply version " + dstProtocol.lastVersion + " serialized at destination.");
    assertEquals(minVersion, dstProtocol.lastVersion);
    System.out.println("\tReply version " + itrProtocol.lastVersion + " reached intermediate.");
    assertEquals(minVersion, itrProtocol.lastVersion);
    itrSession.forward(reply);
    assertNotNull(((Receptor) srcSession.getReplyHandler()).getReply(300));
    System.out.println("\tReply version " + itrProtocol.lastVersion + " serialized at intermediate.");
    minVersion = srcVersion.compareTo(itrVersion) < 0 ? srcVersion : itrVersion;
    assertEquals(minVersion, itrProtocol.lastVersion);
    System.out.println("\tReply version " + srcProtocol.lastVersion + " reached source.");
    assertEquals(minVersion, srcProtocol.lastVersion);
}
Also used : SimpleReply(com.yahoo.messagebus.test.SimpleReply) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Receptor(com.yahoo.messagebus.test.Receptor) Version(com.yahoo.component.Version) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleReply(com.yahoo.messagebus.test.SimpleReply)

Example 62 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class RPCSendV2 method createReply.

@Override
protected Reply createReply(Values ret, String serviceName, Trace trace) {
    CompressionType compression = CompressionType.valueOf(ret.get(3).asInt8());
    byte[] slimeBytes = compressor.decompress(ret.get(5).asData(), compression, ret.get(4).asInt32());
    Slime slime = BinaryFormat.decode(slimeBytes);
    Inspector root = slime.get();
    Version version = new Version(root.field(VERSION_F).asString());
    byte[] payload = root.field(BLOB_F).asData();
    // Make sure that the owner understands the protocol.
    Reply reply = null;
    Error error = null;
    if (payload.length > 0) {
        Object retval = decode(new Utf8Array(root.field(PROTOCOL_F).asUtf8()), version, payload);
        if (retval instanceof Reply) {
            reply = (Reply) retval;
        } else {
            error = (Error) retval;
        }
    }
    if (reply == null) {
        reply = new EmptyReply();
    }
    if (error != null) {
        reply.addError(error);
    }
    reply.setRetryDelay(root.field(RETRYDELAY_F).asDouble());
    Inspector errors = root.field(ERRORS_F);
    for (int i = 0; i < errors.entries(); i++) {
        Inspector e = errors.entry(i);
        String service = e.field(SERVICE_F).asString();
        reply.addError(new Error((int) e.field(CODE_F).asLong(), e.field(MSG_F).asString(), (service != null && service.length() > 0) ? service : serviceName));
    }
    if (trace.getLevel() > 0) {
        trace.getRoot().addChild(TraceNode.decode(root.field(TRACE_F).asString()));
    }
    return reply;
}
Also used : Version(com.yahoo.component.Version) Inspector(com.yahoo.slime.Inspector) Reply(com.yahoo.messagebus.Reply) EmptyReply(com.yahoo.messagebus.EmptyReply) Error(com.yahoo.messagebus.Error) Slime(com.yahoo.slime.Slime) CompressionType(com.yahoo.compress.CompressionType) Utf8Array(com.yahoo.text.Utf8Array) EmptyReply(com.yahoo.messagebus.EmptyReply)

Example 63 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class RPCSendV2 method toParams.

protected Params toParams(Values args) {
    CompressionType compression = CompressionType.valueOf(args.get(3).asInt8());
    byte[] slimeBytes = compressor.decompress(args.get(5).asData(), compression, args.get(4).asInt32());
    Slime slime = BinaryFormat.decode(slimeBytes);
    Inspector root = slime.get();
    Params p = new Params();
    p.version = new Version(root.field(VERSION_F).asString());
    p.route = root.field(ROUTE_F).asString();
    p.session = root.field(SESSION_F).asString();
    p.retryEnabled = root.field(USERETRY_F).asBool();
    p.retry = (int) root.field(RETRY_F).asLong();
    p.timeRemaining = root.field(TIMEREMAINING_F).asLong();
    p.protocolName = new Utf8Array(Utf8.toBytes(root.field(PROTOCOL_F).asString()));
    p.payload = root.field(BLOB_F).asData();
    p.traceLevel = (int) root.field(TRACELEVEL_F).asLong();
    return p;
}
Also used : Version(com.yahoo.component.Version) Inspector(com.yahoo.slime.Inspector) Slime(com.yahoo.slime.Slime) CompressionType(com.yahoo.compress.CompressionType) Utf8Array(com.yahoo.text.Utf8Array)

Example 64 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class RPCTarget method handleRequestDone.

@Override
public void handleRequestDone(Request req) {
    List<VersionHandler> handlers;
    boolean shouldLog = log.isLoggable(LogLevel.DEBUG);
    synchronized (this) {
        targetInvoked = false;
        if (req.checkReturnTypes("s")) {
            String str = req.returnValues().get(0).asString();
            try {
                version = new Version(str);
                if (shouldLog) {
                    log.log(LogLevel.DEBUG, "Target '" + name + "' has version " + version + ".");
                }
            } catch (IllegalArgumentException e) {
                log.log(LogLevel.WARNING, "Failed to parse '" + str + "' as version for target '" + name + "'.", e);
            }
        } else {
            log.log(LogLevel.INFO, "Method mbus.getVersion() failed for target '" + name + "'; " + req.errorMessage());
        }
        handlers = versionHandlers;
        versionHandlers = new LinkedList<>();
    }
    for (VersionHandler handler : handlers) {
        handler.handleVersion(version);
    }
}
Also used : Version(com.yahoo.component.Version)

Example 65 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class ProvisioningTest method prepare.

private SystemState prepare(ApplicationId application, int container0Size, int container1Size, int content0Size, int content1Size, boolean required, String flavor, Version wantedVersion, ProvisioningTester tester) {
    // "deploy prepare" with a two container clusters and a storage cluster having of two groups
    ClusterSpec containerCluster0 = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("container0"), wantedVersion, false);
    ClusterSpec containerCluster1 = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("container1"), wantedVersion, false);
    ClusterSpec contentCluster0 = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("content0"), wantedVersion, false);
    ClusterSpec contentCluster1 = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("content1"), wantedVersion, false);
    Set<HostSpec> container0 = prepare(application, containerCluster0, container0Size, 1, required, flavor, tester);
    Set<HostSpec> container1 = prepare(application, containerCluster1, container1Size, 1, required, flavor, tester);
    Set<HostSpec> content0 = prepare(application, contentCluster0, content0Size, 1, required, flavor, tester);
    Set<HostSpec> content1 = prepare(application, contentCluster1, content1Size, 1, required, flavor, tester);
    Set<HostSpec> allHosts = new HashSet<>();
    allHosts.addAll(container0);
    allHosts.addAll(container1);
    allHosts.addAll(content0);
    allHosts.addAll(content1);
    Function<Integer, Capacity> capacity = count -> Capacity.fromNodeCount(count, Optional.empty(), required);
    int expectedContainer0Size = tester.capacityPolicies().decideSize(capacity.apply(container0Size));
    int expectedContainer1Size = tester.capacityPolicies().decideSize(capacity.apply(container1Size));
    int expectedContent0Size = tester.capacityPolicies().decideSize(capacity.apply(content0Size));
    int expectedContent1Size = tester.capacityPolicies().decideSize(capacity.apply(content1Size));
    assertEquals("Hosts in each group cluster is disjunct and the total number of unretired nodes is correct", expectedContainer0Size + expectedContainer1Size + expectedContent0Size + expectedContent1Size, tester.nonRetired(allHosts).size());
    // Check cluster/group sizes
    assertEquals(expectedContainer0Size, tester.nonRetired(container0).size());
    assertEquals(expectedContainer1Size, tester.nonRetired(container1).size());
    assertEquals(expectedContent0Size, tester.nonRetired(content0).size());
    assertEquals(expectedContent1Size, tester.nonRetired(content1).size());
    // Check cluster membership
    tester.assertMembersOf(containerCluster0, container0);
    tester.assertMembersOf(containerCluster1, container1);
    tester.assertMembersOf(contentCluster0, content0);
    tester.assertMembersOf(contentCluster1, content1);
    return new SystemState(allHosts, container0, container1, content0, content1);
}
Also used : Capacity(com.yahoo.config.provision.Capacity) InstanceName(com.yahoo.config.provision.InstanceName) ApplicationName(com.yahoo.config.provision.ApplicationName) Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) ClusterMembership(com.yahoo.config.provision.ClusterMembership) ClusterSpec(com.yahoo.config.provision.ClusterSpec) Node(com.yahoo.vespa.hosted.provision.Node) ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) Function(java.util.function.Function) RegionName(com.yahoo.config.provision.RegionName) NameResolver(com.yahoo.vespa.hosted.provision.persistence.NameResolver) TenantName(com.yahoo.config.provision.TenantName) Curator(com.yahoo.vespa.curator.Curator) HashSet(java.util.HashSet) ReservationExpirer(com.yahoo.vespa.hosted.provision.maintenance.ReservationExpirer) History(com.yahoo.vespa.hosted.provision.node.History) NestedTransaction(com.yahoo.transaction.NestedTransaction) Duration(java.time.Duration) NodeList(com.yahoo.vespa.hosted.provision.NodeList) Assert.fail(org.junit.Assert.fail) NodeFlavors(com.yahoo.config.provision.NodeFlavors) Iterator(java.util.Iterator) Environment(com.yahoo.config.provision.Environment) Predicate(java.util.function.Predicate) OutOfCapacityException(com.yahoo.config.provision.OutOfCapacityException) JobControl(com.yahoo.vespa.hosted.provision.maintenance.JobControl) HostSpec(com.yahoo.config.provision.HostSpec) FlavorsConfig(com.yahoo.config.provisioning.FlavorsConfig) MockNameResolver(com.yahoo.vespa.hosted.provision.testutils.MockNameResolver) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) HostFilter(com.yahoo.config.provision.HostFilter) List(java.util.List) Agent(com.yahoo.vespa.hosted.provision.node.Agent) Ignore(org.junit.Ignore) Flavor(com.yahoo.config.provision.Flavor) Assert.assertFalse(org.junit.Assert.assertFalse) Zone(com.yahoo.config.provision.Zone) Optional(java.util.Optional) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Capacity(com.yahoo.config.provision.Capacity) ClusterSpec(com.yahoo.config.provision.ClusterSpec) HostSpec(com.yahoo.config.provision.HostSpec) HashSet(java.util.HashSet)

Aggregations

Version (com.yahoo.component.Version)83 Test (org.junit.Test)46 Application (com.yahoo.vespa.hosted.controller.Application)32 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)30 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)25 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)25 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)24 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)22 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)17 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)15 ApplicationId (com.yahoo.config.provision.ApplicationId)11 Collections (java.util.Collections)11 List (java.util.List)11 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)10 Optional (java.util.Optional)10 Slime (com.yahoo.slime.Slime)9 Map (java.util.Map)9 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)7 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)7 URI (java.net.URI)7