Skip to content

Commit

Permalink
ISSUE-596: Fixed the Bootstrap script error on passing "drop-create" …
Browse files Browse the repository at this point in the history
…option. (#597)

* Fixed the deprecated parser usages.
* Moved the exclusion of jackson jars from 'jersey-media-json-jackson'
  to the dependencyManagement to apply it across all the sub-modules.
* Typo error corrected.
  • Loading branch information
kamalcph authored and raju-saravanan committed Oct 3, 2019
1 parent 01a2f32 commit b05ed4e
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 31 deletions.
13 changes: 9 additions & 4 deletions bootstrap/bootstrap-storage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,17 @@ else
fi

TABLE_INITIALIZER_MAIN_CLASS=com.hortonworks.registries.storage.tool.sql.TablesInitializer
for file in "${BOOTSTRAP_DIR}"/lib/*.jar;
do
CLASSPATH="$CLASSPATH":"$file"
done

buildClasspath() {
for file in "${BOOTSTRAP_DIR}"/lib/*.jar;
do
CLASSPATH="$CLASSPATH":"$file"
done
}

execute() {
# Building the classpath for each option so that the driver jars gets loaded when using the "drop-create" option.
buildClasspath
echo "Using Configuration file: ${CONFIG_FILE_PATH}"
${JAVA} -Dbootstrap.dir=$BOOTSTRAP_DIR -cp ${CLASSPATH} ${TABLE_INITIALIZER_MAIN_CLASS} -m ${MYSQL_JAR_URL_PATH} -c ${CONFIG_FILE_PATH} -s ${SCRIPT_ROOT_DIR} --${1}
}
Expand Down
14 changes: 14 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,20 @@
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey.version}</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-base</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.fge</groupId>
Expand Down
15 changes: 0 additions & 15 deletions schema-registry/serdes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,6 @@
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.22.1</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-base</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
public class MySqlDriverHelper {
public static final String MYSQL_JAR_FILE_PATTERN = "mysql-connector-java.*?.jar";

public static void downloadMySQLJarIfNeeded(StorageProviderConfiguration storageProperties, String bootstrapDirPath, String mysqlJarUrl, Proxy proxy) throws
Exception {
public static void downloadMySQLJarIfNeeded(StorageProviderConfiguration storageProperties,
String bootstrapDirPath,
String mysqlJarUrl,
Proxy proxy) throws Exception {
/* Due to license issues we will not be able to ship mysql driver.
If the dbtype is mysql we will prompt user to download the jar and place
it under bootstrap/lib and libs folder. This runs only one-time and for
Expand All @@ -59,14 +61,14 @@ public static void downloadMySQLJarIfNeeded(StorageProviderConfiguration storage
}

private static boolean isMySQLJarFileAvailableOnAnyOfDirectories(List<File> directories) {
return directories.stream().anyMatch(dir -> MySqlDriverHelper.fileExists(dir, MYSQL_JAR_FILE_PATTERN));
return directories.stream().anyMatch(dir -> fileExists(dir, MYSQL_JAR_FILE_PATTERN));
}

private static void downloadMySQLJar(String mysqlJarUrl, File bootstrapLibDir, Proxy proxy) throws Exception {
if (mysqlJarUrl == null || mysqlJarUrl.equals(""))
throw new IllegalArgumentException("Missing mysql client jar url. " +
"Please pass mysql client jar url using -m option.");
String mysqlJarFileName = MySqlDriverHelper.downloadMysqlJarAndCopyToLibDir(bootstrapLibDir, mysqlJarUrl, MYSQL_JAR_FILE_PATTERN, proxy);
String mysqlJarFileName = downloadMysqlJarAndCopyToLibDir(bootstrapLibDir, mysqlJarUrl, MYSQL_JAR_FILE_PATTERN, proxy);
if (mysqlJarFileName != null) {
File mysqlJarFile = new File(bootstrapLibDir+ File.separator + mysqlJarFileName);
System.out.println("mysqlJarFile " + mysqlJarFile);
Expand Down Expand Up @@ -115,11 +117,11 @@ public static String downloadMysqlJarAndCopyToLibDir(File bootstrapLibDir, Strin
String libDir = bootstrapLibDir.getAbsolutePath() + File.separator + "../../libs/";
System.out.println("Unzipping downloaded mysql driver and copying");
try {
String mysqlJarFileName = MySqlDriverHelper.copyFileFromZipToDir(tmpFileName, fileNamePattern, bootstrapLibDir);
String mysqlJarFileName = copyFileFromZipToDir(tmpFileName, fileNamePattern, bootstrapLibDir);
File bootstrapLibFile = new File(bootstrapLibDir + File.separator + mysqlJarFileName);
File libFile = new File(libDir + File.separator + mysqlJarFileName);
System.out.println("Copying file to libs " + libFile);
MySqlDriverHelper.copyFile(bootstrapLibFile, libFile);
copyFile(bootstrapLibFile, libFile);
return mysqlJarFileName;
} catch (IOException ie) {
ie.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public class SchemaFlywayFactory {
private static final boolean cleanOnValidationError = false;


public static Flyway get(StorageProviderConfiguration conf, String scriptRootPath, boolean validateOnMigrate) {
public static Flyway get(StorageProviderConfiguration conf,
String scriptRootPath,
boolean validateOnMigrate) {
Flyway flyway = new Flyway();

String location = "filesystem:" + scriptRootPath + File.separator + conf.getDbType();
Expand All @@ -46,7 +48,7 @@ public static Flyway get(StorageProviderConfiguration conf, String scriptRootPat
flyway.setBaselineVersion(MigrationVersion.fromVersion(baselineVersion));
flyway.setCleanOnValidationError(cleanOnValidationError);
flyway.setLocations(location);
flyway.setDataSource(conf.getUrl(), conf.getUser(), conf.getPassword(), null);
flyway.setDataSource(conf.getUrl(), conf.getUser(), conf.getPassword());

return flyway;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.hortonworks.registries.storage.tool.sql;

import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
Expand Down Expand Up @@ -72,7 +72,7 @@ public static void main(String[] args) throws Exception {
Option.builder()
.hasArg(false)
.longOpt(SchemaMigrationOption.CREATE.toString())
.desc("Run sql migrations from scatch")
.desc("Run sql migrations from scratch")
.build()
);

Expand Down Expand Up @@ -132,7 +132,7 @@ public static void main(String[] args) throws Exception {
.build()
);

CommandLineParser parser = new BasicParser();
CommandLineParser parser = new DefaultParser();
CommandLine commandLine = parser.parse(options, args);

if (!commandLine.hasOption(OPTION_CONFIG_FILE_PATH) || !commandLine.hasOption(OPTION_SCRIPT_ROOT_PATH)) {
Expand Down
2 changes: 1 addition & 1 deletion webservice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
<dependency>
<groupId>com.hortonworks.registries</groupId>
<artifactId>schema-registry-core</artifactId>
<version>0.8.0-SNAPSHOT</version>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
Expand Down

0 comments on commit b05ed4e

Please sign in to comment.