Skip to content

Commit

Permalink
refactored commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jruaux committed Aug 16, 2019
1 parent 8a2d1e9 commit 4fa84e0
Show file tree
Hide file tree
Showing 145 changed files with 1,794 additions and 2,252 deletions.
14 changes: 7 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ buildNumber.properties

# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar
/.settings/
/.sts4-cache/
/.classpath
/.factorypath
/.project
.settings/
.sts4-cache/
.classpath
.factorypath
.project
.DS_Store
/.asciidoctor/
/bin/
.asciidoctor/
bin/
6 changes: 3 additions & 3 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ mysql> describe employees;
To import the whole table run the following command:
[source,shell]
----
riot db --url "jdbc:mysql://localhost:3306/employees?serverTimezone=PST&useLegacyDatetimeCode=false&useSSL=false" --username root --password "select * from employees" redis hash --keyspace employee --keys emp_no
riot db-import --url "jdbc:mysql://localhost:3306/employees?serverTimezone=PST&useLegacyDatetimeCode=false&useSSL=false" --username root --password "select * from employees" redis hash --keyspace employee --keys emp_no
----

[#database-target]
==== Redis -> SQL Database
This command exports all hashes under keyspace `beer:<id>` to MySQL:
[source,shell]
----
riot redis --keyspace beer --keys id db --url "jdbc:mysql://localhost:3306/employees?serverTimezone=PST&useLegacyDatetimeCode=false&useSSL=false" --username root --password "INSERT INTO beers (id, name, style_name) VALUES (:id, :name, :style_name)"
riot db-export --keyspace beer --keys id --url "jdbc:mysql://localhost:3306/employees?serverTimezone=PST&useLegacyDatetimeCode=false&useSSL=false" --username root --password --sql "INSERT INTO beers (id, name, style_name) VALUES (:id, :name, :style_name)"
----

=== CSV Files
Expand All @@ -135,7 +135,7 @@ Here is an excerpt of https://raw.githubusercontent.com/jpatokal/openflights/mas
==== CSV -> Redis
[source,shell]
----
riot file --type=csv https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat --fields AirportID Name City Country IATA ICAO Latitude Longitude Altitude Timezone DST Tz Type Source redis geo --keyspace airportgeo --fields AirportID --lon Longitude --lat Latitude
riot file-import --type csv -u https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat --fields AirportID Name City Country IATA ICAO Latitude Longitude Altitude Timezone DST Tz Type Source redis geo --keyspace airportgeo --fields AirportID --lon Longitude --lat Latitude
----

Query the `airportgeo` geoset using redis-cli
Expand Down
182 changes: 128 additions & 54 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,120 +3,198 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<groupId>com.redislabs</groupId>
<artifactId>riot</artifactId>
<version>0.6.9</version>
<version>0.7.0</version>
<packaging>jar</packaging>
<name>RIOT</name>
<description>Redis Input/Output Tool</description>

<properties>
<start-class>com.redislabs.riot.RiotApplication</start-class>
</properties>

<scm>
<url>https://github.com/Redislabs-Solution-Architects/riot</url>
<connection>scm:git:https://github.com/Redislabs-Solution-Architects/riot.git</connection>
<developerConnection>scm:git:https://github.com/Redislabs-Solution-Architects/riot.git</developerConnection>
<tag>HEAD</tag>
</scm>

<properties>
<start-class>com.redislabs.riot.Riot</start-class>
<java.version>8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<commons-pool2.version>2.6.1</commons-pool2.version>
<hsqldb.version>2.4.1</hsqldb.version>
<jackson-dataformat-xml.version>2.9.8</jackson-dataformat-xml.version>
<jedis.version>3.1.0</jedis.version>
<jredisearch.version>1.0.0</jredisearch.version>
<junit.version>4.12</junit.version>
<lettusearch.version>1.5.1</lettusearch.version>
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
<picocli.version>4.0.2</picocli.version>
<slf4j.version>1.7.25</slf4j.version>
<spring-batch.version>4.1.2.RELEASE</spring-batch.version>
<spring-boot-autoconfigure.version>2.1.6.RELEASE</spring-boot-autoconfigure.version>
<spring-jdbc.version>5.1.6.RELEASE</spring-jdbc.version>
<hikaricp.version>3.2.0</hikaricp.version>
<junit.version>4.12</junit.version>
<latencyutils.version>2.0.3</latencyutils.version>
<lombok.version>1.18.8</lombok.version>
<javafaker.version>0.18</javafaker.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>${picocli.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
<version>${spring-batch.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${spring-boot-autoconfigure.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring-jdbc.version}</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>${hikaricp.version}</version>
</dependency>
<dependency>
<groupId>com.redislabs</groupId>
<artifactId>lettusearch</artifactId>
<version>1.4.2</version>
<version>${lettusearch.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>${commons-pool2.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>4.0.0-beta-2</version>
<groupId>org.latencyutils</groupId>
<artifactId>LatencyUtils</artifactId>
<version>${latencyutils.version}</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.1.0-m1</version>
<version>${jedis.version}</version>
</dependency>
<dependency>
<groupId>com.redislabs</groupId>
<artifactId>jredisearch</artifactId>
<version>0.25.0</version>
<version>${jredisearch.version}</version>
</dependency>
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>0.18</version>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>${jackson-dataformat-xml.version}</version>
</dependency>
<dependency>
<groupId>org.latencyutils</groupId>
<artifactId>LatencyUtils</artifactId>
<version>2.0.3</version>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>${javafaker.version}</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>${hsqldb.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<archive>
<manifest>
<mainClass>${start-class}</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<parameters>true</parameters>
<annotationProcessorPaths>
<path>
<groupId>info.picocli</groupId>
<artifactId>picocli-codegen</artifactId>
<version>${picocli.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-Aproject=${project.groupId}/${project.artifactId}</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
<executions>
<execution>
<id>generate-autocompletion-script</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-Dpicocli.autocomplete.systemExitOnError</argument>
<argument>-cp</argument>
<classpath />
<argument>picocli.AutoComplete</argument>
<argument>--force</argument><!-- overwrite if exists -->
<argument>--completionScript</argument>
<argument>${project.build.directory}/riot_completion.sh</argument>
<argument>com.redislabs.riot.Riot</argument><!-- replace with your class -->
</arguments>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
Expand Down Expand Up @@ -153,10 +231,6 @@
</fileSets>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

Expand Down
Binary file removed riot-performance-streams.png
Binary file not shown.
Binary file removed riot-performance-strings.png
Binary file not shown.
8 changes: 8 additions & 0 deletions src/main/assembly/descriptor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,13 @@
<include>riot.bat</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory></outputDirectory>
<fileMode>0755</fileMode>
<includes>
<include>riot_completion.sh</include>
</includes>
</fileSet>
</fileSets>
</assembly>
15 changes: 0 additions & 15 deletions src/main/java/com/redislabs/riot/ConsoleWriter.java

This file was deleted.

34 changes: 34 additions & 0 deletions src/main/java/com/redislabs/riot/Riot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.redislabs.riot;

import org.slf4j.impl.SimpleLogger;
import org.springframework.batch.item.file.transform.Range;

import com.redislabs.riot.cli.ManifestVersionProvider;
import com.redislabs.riot.cli.db.DatabaseExportCommand;
import com.redislabs.riot.cli.db.DatabaseImportCommand;
import com.redislabs.riot.cli.file.FileExportCommand;
import com.redislabs.riot.cli.file.FileImportCommand;
import com.redislabs.riot.cli.file.RangeConverter;
import com.redislabs.riot.cli.generator.GeneratorImportCommand;

import picocli.CommandLine;
import picocli.CommandLine.Command;

@Command(name = "riot", mixinStandardHelpOptions = true, subcommands = { FileImportCommand.class,
FileExportCommand.class, DatabaseExportCommand.class, DatabaseImportCommand.class,
GeneratorImportCommand.class }, versionProvider = ManifestVersionProvider.class)
public class Riot implements Runnable {

public static void main(String[] args) {
System.setProperty(SimpleLogger.LOG_KEY_PREFIX + "io.lettuce.core", "warn");
int exitCode = new CommandLine(new Riot()).registerConverter(Range.class, new RangeConverter())
.setCaseInsensitiveEnumValuesAllowed(true).execute(args);
System.exit(exitCode);
}

@Override
public void run() {
CommandLine.usage(this, System.out);
}

}
Loading

0 comments on commit 4fa84e0

Please sign in to comment.