From 7be2c8809e4324ee119f684b30c55f45747d3b3a Mon Sep 17 00:00:00 2001 From: Harald Musum Date: Thu, 15 Feb 2018 08:31:50 +0100 Subject: Remove dead code --- .../provider/FilesApplicationPackage.java | 6 - .../config/application/api/ApplicationPackage.java | 17 --- .../config/application/api/RuleConfigDeriver.java | 14 --- .../semantics/config/RuleConfigDeriver.java | 133 --------------------- .../config/test/RuleConfigDeriverTestCase.java | 77 ------------ 5 files changed, 247 deletions(-) delete mode 100644 config-model-api/src/main/java/com/yahoo/config/application/api/RuleConfigDeriver.java delete mode 100644 container-search/src/main/java/com/yahoo/prelude/semantics/config/RuleConfigDeriver.java delete mode 100644 container-search/src/test/java/com/yahoo/prelude/semantics/config/test/RuleConfigDeriverTestCase.java diff --git a/config-application-package/src/main/java/com/yahoo/config/model/application/provider/FilesApplicationPackage.java b/config-application-package/src/main/java/com/yahoo/config/model/application/provider/FilesApplicationPackage.java index 391d284a325..9bfcd4ecb6d 100644 --- a/config-application-package/src/main/java/com/yahoo/config/model/application/provider/FilesApplicationPackage.java +++ b/config-application-package/src/main/java/com/yahoo/config/model/application/provider/FilesApplicationPackage.java @@ -8,7 +8,6 @@ import com.yahoo.config.application.XmlPreProcessor; import com.yahoo.config.application.api.ApplicationMetaData; import com.yahoo.config.application.api.ComponentInfo; import com.yahoo.config.application.api.DeployLogger; -import com.yahoo.config.application.api.RuleConfigDeriver; import com.yahoo.config.application.api.UnparsedConfigDefinition; import com.yahoo.config.codegen.DefParser; import com.yahoo.config.application.api.ApplicationFile; @@ -668,11 +667,6 @@ public class FilesApplicationPackage implements ApplicationPackage { } } - @Override - public ApplicationPackage preprocess(Zone zone, RuleConfigDeriver ignored, DeployLogger logger) throws IOException, TransformerException, ParserConfigurationException, SAXException { - return preprocess(zone, logger); - } - @Override public ApplicationPackage preprocess(Zone zone, DeployLogger logger) throws IOException, TransformerException, ParserConfigurationException, SAXException { IOUtils.recursiveDeleteDir(preprocessedDir); diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java b/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java index c2f6dbcbf4b..fe6f7da2092 100644 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java +++ b/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java @@ -265,23 +265,6 @@ public interface ApplicationPackage { Collection getSearchDefinitions(); - /** - * Preprocess an application for a given zone and return a new application package pointing to the preprocessed - * application package. This is the entry point for the multi environment application package support. This method - * will not mutate the existing application package. - * - * @param zone A valid {@link Zone} instance, used to decide which parts of services to keep and remove - * @param ruleConfigDeriver ignored - * @param logger A {@link DeployLogger} to add output that will be returned to the user - * - * @return A new application package instance pointing to a new location - */ - // TODO: Remove when last version in use is 6.202 - default ApplicationPackage preprocess(Zone zone, RuleConfigDeriver ruleConfigDeriver, DeployLogger logger) - throws IOException, TransformerException, ParserConfigurationException, SAXException { - throw new UnsupportedOperationException("This application package does not support preprocessing"); - } - /** * Preprocess an application for a given zone and return a new application package pointing to the preprocessed * application package. This is the entry point for the multi environment application package support. This method diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/RuleConfigDeriver.java b/config-model-api/src/main/java/com/yahoo/config/application/api/RuleConfigDeriver.java deleted file mode 100644 index 49cdd281809..00000000000 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/RuleConfigDeriver.java +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.config.application.api; - -/** - * Interface to hide dependency on prelude from application package module due to semantic rules - * rewriting. - * - * @author lulf - * @since 5.22 - */ -// TODO: This is not used any more. Do a phased removal while keeping config model compatibility -public interface RuleConfigDeriver { - void derive(String ruleBaseDir, String outputDir) throws Exception; -} diff --git a/container-search/src/main/java/com/yahoo/prelude/semantics/config/RuleConfigDeriver.java b/container-search/src/main/java/com/yahoo/prelude/semantics/config/RuleConfigDeriver.java deleted file mode 100644 index b9fd6fbd51d..00000000000 --- a/container-search/src/main/java/com/yahoo/prelude/semantics/config/RuleConfigDeriver.java +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.prelude.semantics.config; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.IOException; -import java.io.Writer; -import java.util.ArrayList; -import java.util.List; - -import com.yahoo.io.IOUtils; -import com.yahoo.io.reader.NamedReader; -import com.yahoo.prelude.semantics.RuleBase; -import com.yahoo.prelude.semantics.RuleImporter; -import com.yahoo.prelude.semantics.parser.ParseException; - -/** - * Reads the rule base files in the given directory and creates a - * semantic-rules.cfg file containing those rule bases in the given output dir. - * - * @author bratseth - */ -// Note: This is not used by the config model any more and can be removed -public class RuleConfigDeriver { - - public void derive(String ruleBaseDir, String outputDir) throws IOException, ParseException { - // Validate output dir - File outputDirFile=new File(outputDir); - if (!outputDirFile.exists()) - throw new IOException("Output dir " + outputDirFile.getAbsolutePath() + - " does not exist"); - - List ruleBases = derive(ruleBaseDir); - // Convert file to config - exportConfig(ruleBases,outputDir); - } - - public List derive(String ruleBaseDir) throws IOException, ParseException { - // Validate the rule bases - boolean ignoreAutomatas=true; // Don't fail if they are not available in config - List ruleBases = new RuleImporter(ignoreAutomatas).importDir(ruleBaseDir); - ensureZeroOrOneDefault(ruleBases); - return ruleBases; - } - - public List derive(List readers) throws IOException, ParseException { - // Validate the rule bases - boolean ignoreAutomatas = true; // Don't fail if they are not available in config - List ruleBases = new ArrayList<>(); - RuleImporter importer = new RuleImporter(ignoreAutomatas); - for (NamedReader reader : readers) { - ruleBases.add(importer.importFromReader(reader, reader.getName(), null)); - } - ensureZeroOrOneDefault(ruleBases); - return ruleBases; - } - - private void ensureZeroOrOneDefault(List ruleBases) throws ParseException { - String defaultName=null; - for (RuleBase ruleBase : ruleBases) { - if (defaultName != null && ruleBase.isDefault()) - throw new ParseException("Both '" + defaultName + "' and '" + ruleBase.getName() + - "' is marked as default, there can only be one"); - if (ruleBase.isDefault()) - defaultName = ruleBase.getName(); - } - } - - private void exportConfig(List ruleBases, String outputDir) - throws IOException { - BufferedWriter writer=null; - try { - writer=IOUtils.createWriter(outputDir + "/semantic-rules.cfg","utf-8",false); - writer.write("rulebase[" + ruleBases.size() + "]\n"); - for (int i=0; i readers = new ArrayList<>(); - readers.add(namedReader); - RuleConfigDeriver deriver = new RuleConfigDeriver(); - deriver.derive(readers); - } - - protected void assertEqualFiles(String correctFileName,String checkFileName) - throws java.io.IOException { - BufferedReader correct=null; - BufferedReader check=null; - try { - correct=IOUtils.createReader(correctFileName); - check = IOUtils.createReader(checkFileName); - String correctLine; - int lineNumber=1; - while ( null != (correctLine=correct.readLine())) { - String checkLine=check.readLine(); - assertNotNull("Too few lines, in " + checkFileName + - ", first missing is\n" + lineNumber + - ": " + correctLine,checkLine); - assertTrue("\nIn " + checkFileName + ":\n" + - "Expected line " + lineNumber + ":\n" + - correctLine.replaceAll("\\\\n","\n") + - "\nGot line " + lineNumber + ":\n" + - checkLine.replaceAll("\\\\n","\n") + "\n", - correctLine.trim().equals(checkLine.trim())); - lineNumber++; - } - assertNull("Excess line(s) in " + checkFileName + " starting at " + - lineNumber, - check.readLine()); - - } - finally { - IOUtils.closeReader(correct); - IOUtils.closeReader(check); - } - } - -} -- cgit v1.2.3