use of com.yahoo.component.Version in project vespa by vespa-engine.
the class RPCNetwork method attach.
@Override
public void attach(NetworkOwner owner) {
if (this.owner != null) {
throw new IllegalStateException("Network is already attached to another owner.");
}
this.owner = owner;
RPCSendAdapter adapter1 = new RPCSendV1();
RPCSendAdapter adapter2 = new RPCSendV2();
addSendAdapter(new Version(5), adapter1);
addSendAdapter(new Version(6, 149), adapter2);
}
use of com.yahoo.component.Version in project vespa by vespa-engine.
the class RPCSendV1 method toParams.
protected Params toParams(Values args) {
Params p = new Params();
p.version = new Version(args.get(0).asUtf8Array());
p.route = args.get(1).asString();
p.session = args.get(2).asString();
p.retryEnabled = (args.get(3).asInt8() != 0);
p.retry = args.get(4).asInt32();
p.timeRemaining = args.get(5).asInt64();
p.protocolName = args.get(6).asUtf8Array();
p.payload = args.get(7).asData();
p.traceLevel = args.get(8).asInt32();
return p;
}
use of com.yahoo.component.Version in project vespa by vespa-engine.
the class RPCSendV1 method createReply.
@Override
protected Reply createReply(Values ret, String serviceName, Trace trace) {
Version version = new Version(ret.get(0).asUtf8Array());
double retryDelay = ret.get(1).asDouble();
int[] errorCodes = ret.get(2).asInt32Array();
String[] errorMessages = ret.get(3).asStringArray();
String[] errorServices = ret.get(4).asStringArray();
Utf8Array protocolName = ret.get(5).asUtf8Array();
byte[] payload = ret.get(6).asData();
String replyTrace = ret.get(7).asString();
// Make sure that the owner understands the protocol.
Reply reply = null;
Error error = null;
if (payload.length > 0) {
Object retval = decode(protocolName, 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(retryDelay);
for (int i = 0; i < errorCodes.length && i < errorMessages.length; i++) {
reply.addError(new Error(errorCodes[i], errorMessages[i], errorServices[i].length() > 0 ? errorServices[i] : serviceName));
}
if (trace.getLevel() > 0) {
trace.getRoot().addChild(TraceNode.decode(replyTrace));
}
return reply;
}
use of com.yahoo.component.Version in project vespa by vespa-engine.
the class SendAdapterTestCase method requireCorrectVersionSelection.
// //////////////////////////////////////////////////////////////////////////////
//
// Tests
//
// //////////////////////////////////////////////////////////////////////////////
@Test
public void requireCorrectVersionSelection() {
assertNull(srcServer.net.getSendAdapter(new Version(4, 999)));
assertTrue(srcServer.net.getSendAdapter(new Version(5, 0)) instanceof RPCSendV1);
assertTrue(srcServer.net.getSendAdapter(new Version(6, 148)) instanceof RPCSendV1);
assertTrue(srcServer.net.getSendAdapter(new Version(6, 149)) instanceof RPCSendV2);
assertTrue(srcServer.net.getSendAdapter(new Version(9, 9999)) instanceof RPCSendV2);
}
use of com.yahoo.component.Version in project vespa by vespa-engine.
the class ApplicationApiTest method testJobStatusReporting.
@Test
public void testJobStatusReporting() throws Exception {
ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles);
addUserToHostedOperatorRole(HostedAthenzIdentities.from(HOSTED_VESPA_OPERATOR));
tester.containerTester().updateSystemVersion();
long projectId = 1;
Application app = tester.createApplication();
ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("corp-us-east-1").build();
// system version from mock config server client
Version vespaVersion = new Version("6.1");
BuildJob job = new BuildJob(report -> notifyCompletion(report, tester), tester.artifactRepository()).application(app).projectId(projectId);
job.type(DeploymentJobs.JobType.component).uploadArtifact(applicationPackage).submit();
tester.deploy(app, applicationPackage, TEST_ZONE, projectId);
job.type(DeploymentJobs.JobType.systemTest).submit();
// Notifying about unknown job fails
Request request = request("/application/v4/tenant/tenant1/application/application1/jobreport", POST).data(asJson(job.type(DeploymentJobs.JobType.productionUsEast3).report())).userIdentity(HOSTED_VESPA_OPERATOR).get();
tester.containerTester().assertResponse(request, new File("jobreport-unexpected-completion.json"), 400);
// ... and assert it was recorded
JobStatus recordedStatus = tester.controller().applications().get(app.id()).get().deploymentJobs().jobStatus().get(DeploymentJobs.JobType.component);
assertNotNull("Status was recorded", recordedStatus);
assertTrue(recordedStatus.isSuccess());
assertEquals(vespaVersion, recordedStatus.lastCompleted().get().version());
recordedStatus = tester.controller().applications().get(app.id()).get().deploymentJobs().jobStatus().get(DeploymentJobs.JobType.productionApNortheast2);
assertNull("Status of never-triggered jobs is empty", recordedStatus);
Response response;
response = container.handleRequest(request("/screwdriver/v1/jobsToRun", GET).get());
assertTrue("Response contains system-test", response.getBodyAsString().contains(DeploymentJobs.JobType.systemTest.jobName()));
assertTrue("Response contains staging-test", response.getBodyAsString().contains(DeploymentJobs.JobType.stagingTest.jobName()));
assertEquals("Response contains only two items", 2, SlimeUtils.jsonToSlime(response.getBody()).get().entries());
// Check that GET didn't affect the enqueued jobs.
response = container.handleRequest(request("/screwdriver/v1/jobsToRun", GET).get());
assertTrue("Response contains system-test", response.getBodyAsString().contains(DeploymentJobs.JobType.systemTest.jobName()));
assertTrue("Response contains staging-test", response.getBodyAsString().contains(DeploymentJobs.JobType.stagingTest.jobName()));
assertEquals("Response contains only two items", 2, SlimeUtils.jsonToSlime(response.getBody()).get().entries());
}
Aggregations