use of com.yahoo.slime.Inspector in project vespa by vespa-engine.
the class ControllerApiHandler method configureUpgrader.
private HttpResponse configureUpgrader(HttpRequest request) {
String upgradesPerMinuteField = "upgradesPerMinute";
String confidenceOverrideField = "confidenceOverride";
byte[] jsonBytes = toJsonBytes(request.getData());
Inspector inspect = SlimeUtils.jsonToSlime(jsonBytes).get();
Upgrader upgrader = maintenance.upgrader();
if (inspect.field(upgradesPerMinuteField).valid()) {
upgrader.setUpgradesPerMinute(inspect.field(upgradesPerMinuteField).asDouble());
} else {
return ErrorResponse.badRequest("No such modifiable field(s)");
}
return new UpgraderResponse(maintenance.upgrader());
}
use of com.yahoo.slime.Inspector 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;
}
use of com.yahoo.slime.Inspector 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;
}
use of com.yahoo.slime.Inspector in project vespa by vespa-engine.
the class Maintainer method parseDeleteFilesJob.
private static void parseDeleteFilesJob(Inspector arguments) {
Path basePath = Paths.get(getFieldOrFail(arguments, "basePath").asString());
Duration maxAge = Duration.ofSeconds(getFieldOrFail(arguments, "maxAgeSeconds").asLong());
Optional<String> fileNameRegex = SlimeUtils.optionalString(arguments.field("fileNameRegex"));
boolean recursive = getFieldOrFail(arguments, "recursive").asBool();
try {
FileHelper.deleteFiles(basePath, maxAge, fileNameRegex, recursive);
} catch (IOException e) {
throw new RuntimeException("Failed deleting files under " + basePath.toAbsolutePath() + fileNameRegex.map(regex -> ", matching '" + regex + "'").orElse("") + ", " + (recursive ? "" : "not ") + "recursively" + " and older than " + maxAge, e);
}
}
use of com.yahoo.slime.Inspector in project vespa by vespa-engine.
the class ApplicationSerializer method changeFromSlime.
private Change changeFromSlime(Inspector object) {
if (!object.valid())
return Change.empty();
Inspector versionFieldValue = object.field(versionField);
Change change = Change.empty();
if (versionFieldValue.valid())
change = Change.of(Version.fromString(versionFieldValue.asString()));
if (object.field(applicationBuildNumberField).valid())
change = change.with(applicationVersionFromSlime(object));
if (// A deploy object with no fields -> unknown application change
!change.isPresent())
change = Change.empty();
return change;
}
Aggregations