public VespaModelFactory(ConfigModelRegistry configModelRegistry, Clock clock) { this(new Version(VespaVersion.major, VespaVersion.minor, VespaVersion.micro), configModelRegistry, clock); } public VespaModelFactory(Version version, ConfigModelRegistry configModelRegistry, Clock clock) {
/** Returns new Version(versionString), or Version.emptyVersion if the input string is null or "" */ public static Version fromString(String versionString) { if (versionString == null) { return emptyVersion; } else { return new Version(versionString); } }
/** * Create id with given name, using default version 1. * * @param tagName Name of the id * @return A ConfigModelId instance */ public static ConfigModelId fromName(String tagName) { return new ConfigModelId(tagName, new Version(1)); }
/** returns the version of a bundle, as specified by Bundle-Version in the manifest */ private static com.yahoo.component.Version versionOf(Bundle bundle) { Object bundleVersion=bundle.getHeaders().get("Bundle-Version"); if (bundleVersion==null) return com.yahoo.component.Version.emptyVersion; return new com.yahoo.component.Version(bundleVersion.toString()); }
private void checkVersion(Element spec) { String version = spec.getAttribute("version"); if ( ! Version.fromString(version).equals(new Version(1))) { throw new RuntimeException("Expected container version to be 1.0, but got " + version); } }
@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); }
String newId=id.substring(0,dash); try { version=new Version(id.substring(dash+1)); id=newId;
/** Creates a factory for vespa models for this version of the source */ @Inject public VespaModelFactory(ComponentRegistry<ConfigModelPlugin> pluginRegistry, ComponentRegistry<MlModelImporter> modelImporters, Zone zone) { this.version = new Version(VespaVersion.major, VespaVersion.minor, VespaVersion.micro); List<ConfigModelBuilder> modelBuilders = new ArrayList<>(); for (ConfigModelPlugin plugin : pluginRegistry.allComponents()) { if (plugin instanceof ConfigModelBuilder) { modelBuilders.add((ConfigModelBuilder) plugin); } } this.configModelRegistry = new MapConfigModelRegistry(modelBuilders); this.modelImporters = modelImporters.allComponents(); this.zone = zone; this.clock = Clock.systemUTC(); }
/** * Returns the lowest possible Version object that matches this spec **/ public Version lowestMatchingVersion() { return new Version(getMajor(), getMinor(), getMicro(), getQualifier()); }
private void validate(ApplicationPackage appPkg) throws IOException { if (!validate) { return; } SchemaValidators schemaValidators = new SchemaValidators(new Version(VespaVersion.major)); if (appPkg.getHosts() != null) { schemaValidators.hostsXmlValidator().validate(appPkg.getHosts()); } schemaValidators.servicesXmlValidator().validate(appPkg.getServices()); } }
@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); } }
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; }
@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();
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; }
Inspector root = slime.get(); Version version = new Version(root.field(VERSION_F).asString()); byte[] payload = root.field(BLOB_F).asData();