/** * Creates a complete derived configuration from a search definition. * * @param search The search to derive a configuration from. Derived objects will be snapshots, but this argument is * live. Which means that this object will be inconsistent when the given search definition is later * modified. * @param rankProfileRegistry a {@link com.yahoo.searchdefinition.RankProfileRegistry} */ public DerivedConfiguration(Search search, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfiles, ImportedMlModels importedModels) { this(search, new BaseDeployLogger(), rankProfileRegistry, queryProfiles, importedModels); }
private SchemaValidator createValidator(File schemaDir, String schemaFile) { try { File file = new File(schemaDir + File.separator + "schema" + File.separator + schemaFile); return new SchemaValidator(file, new BaseDeployLogger()); } catch (SAXException e) { throw new RuntimeException("Invalid schema '" + schemaFile + "'", e); } catch (IOException e) { throw new RuntimeException("IO error reading schema '" + schemaFile + "'", e); } }
/** * Import search definition. * * @param fileName The name of the file to import. * @return The name of the imported object. * @throws IOException Thrown if the file can not be read for some reason. * @throws ParseException Thrown if the file does not contain a valid search definition. */ public String importFile(String fileName) throws IOException, ParseException { return importFile(fileName, new BaseDeployLogger()); } public String importFile(Path file) throws IOException, ParseException {
/** * Convenience factory method to import and build a {@link Search} object from a string. * * @param sd The string to build from. * @return The built {@link SearchBuilder} object. * @throws ParseException Thrown if there was a problem parsing the string. */ public static SearchBuilder createFromString(String sd) throws ParseException { return createFromString(sd, new BaseDeployLogger()); }
/** * Convenience factory method to import and build a {@link Search} object from a file. Only for testing. * * @param fileName the file to build from * @return the built {@link SearchBuilder} object * @throws IOException if there was a problem reading the file. * @throws ParseException if there was a problem parsing the file content. */ public static SearchBuilder createFromFile(String fileName) throws IOException, ParseException { return createFromFile(fileName, new BaseDeployLogger()); }
/** * Import search definition. * * @param str the string to parse. * @return the name of the imported object. * @throws ParseException thrown if the file does not contain a valid search definition. */ public String importString(String str) throws ParseException { return importString(str, null, new BaseDeployLogger()); }
/** * Only for testing. * * Processes and finalizes the imported search definitions so that they become available through the {@link * #getSearch(String)} method. * * @throws IllegalStateException Thrown if this method has already been called. */ public void build() { build(true, new BaseDeployLogger()); }
/** * Convenience factory methdd to create a SearchBuilder from multiple SD files. Only for testing. */ public static SearchBuilder createFromFiles(Collection<String> fileNames) throws IOException, ParseException { return createFromFiles(fileNames, new BaseDeployLogger()); }
public String importFile(Path file) throws IOException, ParseException { return importFile(file.toString(), new BaseDeployLogger()); }
/** * Convenience factory method to import and build a {@link Search} object from a file. * * @param fileName The file to build from. * @param rankProfileRegistry Registry for rank profiles. * @return The built {@link Search} object. * @throws IOException Thrown if there was a problem reading the file. * @throws ParseException Thrown if there was a problem parsing the file content. */ public static Search buildFromFile(String fileName, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException { return buildFromFile(fileName, new BaseDeployLogger(), rankProfileRegistry, queryProfileRegistry); }
/** * See #{@link #importReader} * * Convenience, should only be used for testing as logs will be swallowed. */ public String importReader(NamedReader reader, String searchDefDir) throws IOException, ParseException { return importString(IOUtils.readAll(reader), searchDefDir, new BaseDeployLogger()); }
public static SearchBuilder createFromDirectory(String dir, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException { SearchBuilder builder = new SearchBuilder(MockApplicationPackage.fromSearchDefinitionDirectory(dir), rankProfileRegistry, queryProfileRegistry); for (Iterator<Path> i = Files.list(new File(dir).toPath()).filter(p -> p.getFileName().toString().endsWith(".sd")).iterator(); i.hasNext(); ) { builder.importFile(i.next()); } builder.build(true, new BaseDeployLogger()); return builder; }
/** * Convenience factory method to import and build a {@link Search} object from a file. Only for testing. * * @param fileName The file to build from. * @return The built {@link Search} object. * @throws IOException Thrown if there was a problem reading the file. * @throws ParseException Thrown if there was a problem parsing the file content. */ public static Search buildFromFile(String fileName) throws IOException, ParseException { return buildFromFile(fileName, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfileRegistry()); }
static Pair<VespaModel, Container> createContainerModel(Path applicationPath, FileRegistry fileRegistry, File preprocessedApplicationDir, Networking networkingOption, ConfigModelRepo configModelRepo) throws Exception { DeployLogger logger = new BaseDeployLogger(); FilesApplicationPackage rawApplicationPackage = new FilesApplicationPackage.Builder(applicationPath.toFile()) .includeSourceFiles(true).preprocessedDir(preprocessedApplicationDir).build(); ApplicationPackage applicationPackage = rawApplicationPackage.preprocess(getZone(), logger); validateApplication(applicationPackage); DeployState deployState = createDeployState(applicationPackage, fileRegistry, logger); VespaModel root = VespaModel.createIncomplete(deployState); ApplicationConfigProducerRoot vespaRoot = new ApplicationConfigProducerRoot(root, "vespa", deployState.getDocumentModel(), deployState.getVespaVersion(), deployState.getProperties().applicationId()); Element spec = containerRootElement(applicationPackage); ContainerModel containerModel = newContainerModelBuilder(networkingOption).build(deployState, root, configModelRepo, vespaRoot, spec); containerModel.getCluster().prepare(deployState); initializeContainerModel(containerModel, configModelRepo); Container container = first(containerModel.getCluster().getContainers()); // TODO: Separate out model finalization from the VespaModel constructor, // such that the above and below code to finalize the container can be // replaced by root.finalize(); initializeContainer(deployState.getDeployLogger(), container, spec); root.freezeModelTopology(); return new Pair<>(root, container); }