Skip to content

Commit

Permalink
KYLIN-3597 fix snoar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
whuwb authored and shaofengshi committed Dec 10, 2018
1 parent 684f21c commit 4e171c8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,26 +144,21 @@ private static void generateFindAndReplaceScript(String kylinRepoPath, String ou
BackwardCompatibilityConfig bcc = new BackwardCompatibilityConfig();
File repoDir = new File(kylinRepoPath).getCanonicalFile();
File outputDir = new File(outputPath).getCanonicalFile();
PrintWriter out = null;

// generate sed file
File sedFile = new File(outputDir, "upgrade-old-config.sed");
try {
out = new PrintWriter(sedFile, "UTF-8");
try (PrintWriter out = new PrintWriter(sedFile, "UTF-8")) {
for (Entry<String, String> e : bcc.old2new.entrySet()) {
out.println("s/" + quote(e.getKey()) + "/" + e.getValue() + "/g");
}
for (Entry<String, String> e : bcc.old2newPrefix.entrySet()) {
out.println("s/" + quote(e.getKey()) + "/" + e.getValue() + "/g");
}
} finally {
IOUtils.closeQuietly(out);
}

// generate sh file
File shFile = new File(outputDir, "upgrade-old-config.sh");
try {
out = new PrintWriter(shFile, "UTF-8");
try (PrintWriter out = new PrintWriter(shFile, "UTF-8")) {
out.println("#!/bin/bash");
Stack<File> stack = new Stack<>();
stack.push(repoDir);
Expand All @@ -179,8 +174,6 @@ private static void generateFindAndReplaceScript(String kylinRepoPath, String ou
out.println("sed -i -f upgrade-old-config.sed " + f.getAbsolutePath());
}
}
} finally {
IOUtils.closeQuietly(out);
}

System.out.println("Files generated:");
Expand Down
22 changes: 8 additions & 14 deletions core-common/src/main/java/org/apache/kylin/common/KylinConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
public class KylinConfig extends KylinConfigBase {
private static final long serialVersionUID = 1L;
private static final Logger logger = LoggerFactory.getLogger(KylinConfig.class);
private static final String METADATA_URI_PREFIX = "Metadata uri : ";

/**
* Kylin properties file name
Expand Down Expand Up @@ -192,20 +193,20 @@ private static UriType decideUriType(String metaUri) {
return UriType.PROPERTIES_FILE;
} else {
throw new IllegalStateException(
"Metadata uri : " + metaUri + " is a local file but not kylin.properties");
METADATA_URI_PREFIX + metaUri + " is a local file but not kylin.properties");
}
} else {
throw new IllegalStateException(
"Metadata uri : " + metaUri + " looks like a file but it's neither a file nor a directory");
METADATA_URI_PREFIX + metaUri + " looks like a file but it's neither a file nor a directory");
}
} else {
if (RestClient.matchFullRestPattern(metaUri))
return UriType.REST_ADDR;
else
throw new IllegalStateException("Metadata uri : " + metaUri + " is not a valid REST URI address");
throw new IllegalStateException(METADATA_URI_PREFIX + metaUri + " is not a valid REST URI address");
}
} catch (Exception e) {
throw new IllegalStateException("Metadata uri : " + metaUri + " is not recognized", e);
throw new IllegalStateException(METADATA_URI_PREFIX + metaUri + " is not recognized", e);
}
}

Expand Down Expand Up @@ -393,18 +394,15 @@ private static OrderedProperties buildSiteOrderedProps() {
*/
private static void loadPropertiesFromInputStream(InputStream inputStream, OrderedProperties properties) {
Preconditions.checkNotNull(properties);
BufferedReader confReader = null;
try {
confReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));

try (BufferedReader confReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"))) {
OrderedProperties temp = new OrderedProperties();
temp.load(confReader);
temp = BCC.check(temp);

properties.putAll(temp);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
IOUtils.closeQuietly(confReader);
}
}

Expand Down Expand Up @@ -521,12 +519,8 @@ public String exportToString(Collection<String> propertyKeys) throws IOException
}

public void exportToFile(File file) throws IOException {
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
try (FileOutputStream fos = new FileOutputStream(file)) {
getAllProperties().store(fos, file.getAbsolutePath());
} finally {
IOUtils.closeQuietly(fos);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core-common/src/main/resources/kylin-defaults.properties
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ kylin.source.hive.beeline-shell=beeline
# While hive client uses above settings to read hive table metadata,
# table operations can go through a separate SparkSQL command line, given SparkSQL connects to the same Hive metastore.
kylin.source.hive.enable-sparksql-for-table-ops=false
#kylin.source.hive.sparksql-beeline-shell=/path/to/spark-client/bin/beeline
#kylin.source.hive.sparksql-beeline-shell=/path/to/spark-client/bin/bee
#kylin.source.hive.sparksql-beeline-params=-n root --hiveconf hive.security.authorization.sqlstd.confwhitelist.append='mapreduce.job.*|dfs.*' -u jdbc:hive2://localhost:10000

kylin.source.hive.keep-flat-table=false
Expand Down

0 comments on commit 4e171c8

Please sign in to comment.