Skip to content

Commit 0512da0

Browse files
Import from Hoodie private repo: Part 1
0 parents  commit 0512da0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+8868
-0
lines changed

hoodie-cli/hoodie-cli.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
HOODIE_JAR=`ls $DIR/target/hoodie-cli-*-SNAPSHOT.jar`
4+
java -cp /etc/hadoop/conf:/etc/spark/conf:$DIR/target/lib/*:$HOODIE_JAR org.springframework.shell.Bootstrap
Binary file not shown.

hoodie-cli/pom.xml

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright (c) 2016 Uber Technologies, Inc. (hoodie-dev-group@uber.com)
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
19+
<parent>
20+
<artifactId>hoodie</artifactId>
21+
<groupId>com.uber.hoodie</groupId>
22+
<version>0.2.5-SNAPSHOT</version>
23+
</parent>
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<artifactId>hoodie-cli</artifactId>
27+
<packaging>jar</packaging>
28+
29+
<properties>
30+
<spring.shell.version>1.2.0.RELEASE</spring.shell.version>
31+
<jar.mainclass>org.springframework.shell.Bootstrap</jar.mainclass>
32+
<log4j.version>1.2.17</log4j.version>
33+
<junit.version>4.10</junit.version>
34+
</properties>
35+
36+
<repositories>
37+
<repository>
38+
<id>libs-milestone</id>
39+
<url>http://repo.spring.io/libs-milestone/</url>
40+
</repository>
41+
<repository>
42+
<id>libs-release</id>
43+
<url>http://repo.spring.io/libs-release/</url>
44+
</repository>
45+
<repository>
46+
<id>scala-tools.org</id>
47+
<name>Scala-tools Maven2 Repository</name>
48+
<url>http://scala-tools.org/repo-releases</url>
49+
</repository>
50+
</repositories>
51+
52+
<build>
53+
<pluginManagement>
54+
<plugins>
55+
<plugin>
56+
<groupId>net.alchim31.maven</groupId>
57+
<artifactId>scala-maven-plugin</artifactId>
58+
<version>3.2.1</version>
59+
</plugin>
60+
</plugins>
61+
</pluginManagement>
62+
63+
<plugins>
64+
<plugin>
65+
<groupId>org.apache.maven.plugins</groupId>
66+
<artifactId>maven-compiler-plugin</artifactId>
67+
<configuration>
68+
<source>1.5</source>
69+
<target>1.5</target>
70+
</configuration>
71+
</plugin>
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-dependency-plugin</artifactId>
75+
<executions>
76+
<execution>
77+
<id>copy-dependencies</id>
78+
<phase>prepare-package</phase>
79+
<goals>
80+
<goal>copy-dependencies</goal>
81+
</goals>
82+
<configuration>
83+
<outputDirectory>${project.build.directory}/lib</outputDirectory>
84+
<overWriteReleases>true</overWriteReleases>
85+
<overWriteSnapshots>true</overWriteSnapshots>
86+
<overWriteIfNewer>true</overWriteIfNewer>
87+
</configuration>
88+
</execution>
89+
</executions>
90+
</plugin>
91+
<plugin>
92+
<groupId>org.apache.maven.plugins</groupId>
93+
<artifactId>maven-jar-plugin</artifactId>
94+
<configuration>
95+
<archive>
96+
<manifest>
97+
<addClasspath>true</addClasspath>
98+
<useUniqueVersions>false</useUniqueVersions>
99+
<classpathPrefix>lib/</classpathPrefix>
100+
<mainClass>${jar.mainclass}</mainClass>
101+
</manifest>
102+
<manifestEntries>
103+
<version>${project.version}</version>
104+
</manifestEntries>
105+
</archive>
106+
</configuration>
107+
</plugin>
108+
<plugin>
109+
<groupId>net.alchim31.maven</groupId>
110+
<artifactId>scala-maven-plugin</artifactId>
111+
<executions>
112+
<execution>
113+
<id>scala-compile-first</id>
114+
<phase>process-resources</phase>
115+
<goals>
116+
<goal>add-source</goal>
117+
<goal>compile</goal>
118+
</goals>
119+
</execution>
120+
<execution>
121+
<id>scala-test-compile</id>
122+
<phase>process-test-resources</phase>
123+
<goals>
124+
<goal>testCompile</goal>
125+
</goals>
126+
</execution>
127+
</executions>
128+
</plugin>
129+
<plugin>
130+
<groupId>org.apache.rat</groupId>
131+
<artifactId>apache-rat-plugin</artifactId>
132+
</plugin>
133+
</plugins>
134+
</build>
135+
136+
137+
<dependencies>
138+
139+
<dependency>
140+
<groupId>org.scala-lang</groupId>
141+
<artifactId>scala-library</artifactId>
142+
<version>2.10.5</version>
143+
</dependency>
144+
145+
<dependency>
146+
<groupId>org.springframework.shell</groupId>
147+
<artifactId>spring-shell</artifactId>
148+
<version>${spring.shell.version}</version>
149+
</dependency>
150+
<dependency>
151+
<groupId>de.vandermeer</groupId>
152+
<artifactId>asciitable</artifactId>
153+
<version>0.2.5</version>
154+
</dependency>
155+
<dependency>
156+
<groupId>org.apache.spark</groupId>
157+
<artifactId>spark-core_2.10</artifactId>
158+
</dependency>
159+
<dependency>
160+
<groupId>org.apache.spark</groupId>
161+
<artifactId>spark-sql_2.10</artifactId>
162+
<version>${spark.version}</version>
163+
<scope>provided</scope>
164+
</dependency>
165+
166+
167+
<dependency>
168+
<groupId>dnl.utils</groupId>
169+
<artifactId>textutils</artifactId>
170+
<version>0.3.3</version>
171+
<scope>system</scope>
172+
<systemPath>${basedir}/lib/dnl/utils/textutils/0.3.3/textutils-0.3.3.jar</systemPath>
173+
</dependency>
174+
175+
<dependency>
176+
<groupId>log4j</groupId>
177+
<artifactId>log4j</artifactId>
178+
<version>${log4j.version}</version>
179+
</dependency>
180+
<dependency>
181+
<groupId>com.uber.hoodie</groupId>
182+
<artifactId>hoodie-client</artifactId>
183+
<version>${project.version}</version>
184+
</dependency>
185+
<dependency>
186+
<groupId>com.uber.hoodie</groupId>
187+
<artifactId>hoodie-common</artifactId>
188+
<version>${project.version}</version>
189+
</dependency>
190+
<dependency>
191+
<groupId>com.uber.hoodie</groupId>
192+
<artifactId>hoodie-mr</artifactId>
193+
<version>${project.version}</version>
194+
</dependency>
195+
<dependency>
196+
<groupId>com.uber.hoodie</groupId>
197+
<artifactId>hoodie-tools</artifactId>
198+
<version>${project.version}</version>
199+
</dependency>
200+
<dependency>
201+
<groupId>junit</groupId>
202+
<artifactId>junit-dep</artifactId>
203+
<version>${junit.version}</version>
204+
<scope>test</scope>
205+
</dependency>
206+
</dependencies>
207+
208+
</project>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2016 Uber Technologies, Inc. (hoodie-dev-group@uber.com)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.uber.hoodie.cli;
18+
19+
import com.uber.hoodie.common.model.HoodieTableMetadata;
20+
import org.apache.hadoop.conf.Configuration;
21+
import org.apache.hadoop.fs.FileSystem;
22+
23+
import java.io.IOException;
24+
25+
public class HoodieCLI {
26+
public static Configuration conf;
27+
public static FileSystem fs;
28+
public static CLIState state = CLIState.INIT;
29+
public static HoodieTableMetadata tableMetadata;
30+
public static HoodieTableMetadata syncTableMetadata;
31+
32+
33+
public enum CLIState {
34+
INIT, DATASET, SYNC
35+
}
36+
37+
public static boolean initConf() {
38+
if (HoodieCLI.conf == null) {
39+
HoodieCLI.conf = new Configuration();
40+
return true;
41+
}
42+
return false;
43+
}
44+
45+
public static void initFS(boolean force) throws IOException {
46+
if(fs == null || force) {
47+
fs = FileSystem.get(conf);
48+
}
49+
}
50+
51+
public static void setTableMetadata(HoodieTableMetadata tableMetadata) {
52+
HoodieCLI.tableMetadata = tableMetadata;
53+
}
54+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2016 Uber Technologies, Inc. (hoodie-dev-group@uber.com)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.uber.hoodie.cli;
18+
19+
import org.springframework.core.Ordered;
20+
import org.springframework.core.annotation.Order;
21+
import org.springframework.shell.plugin.support.DefaultHistoryFileNameProvider;
22+
import org.springframework.stereotype.Component;
23+
24+
@Component
25+
@Order(Ordered.HIGHEST_PRECEDENCE)
26+
public class HoodieHistoryFileNameProvider extends DefaultHistoryFileNameProvider {
27+
28+
public String getHistoryFileName() {
29+
return "hoodie-cmd.log";
30+
}
31+
32+
@Override
33+
public String getProviderName() {
34+
return "Hoodie file name provider";
35+
}
36+
37+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2016 Uber Technologies, Inc. (hoodie-dev-group@uber.com)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.uber.hoodie.cli;
18+
19+
import dnl.utils.text.table.TextTable;
20+
21+
import java.io.ByteArrayOutputStream;
22+
import java.io.PrintStream;
23+
import java.nio.charset.Charset;
24+
25+
public class HoodiePrintHelper {
26+
27+
public static String print(String[] header, String[][] rows) {
28+
TextTable textTable = new TextTable(header, rows);
29+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
30+
PrintStream ps = new PrintStream(baos);
31+
textTable.printTable(ps, 4);
32+
return new String(baos.toByteArray(), Charset.forName("utf-8"));
33+
}
34+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2016 Uber Technologies, Inc. (hoodie-dev-group@uber.com)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.uber.hoodie.cli;
18+
19+
import org.springframework.core.Ordered;
20+
import org.springframework.core.annotation.Order;
21+
import org.springframework.shell.plugin.support.DefaultPromptProvider;
22+
import org.springframework.stereotype.Component;
23+
24+
@Component
25+
@Order(Ordered.HIGHEST_PRECEDENCE)
26+
public class HoodiePrompt extends DefaultPromptProvider {
27+
28+
@Override
29+
public String getPrompt() {
30+
switch (HoodieCLI.state) {
31+
case INIT:
32+
return "hoodie->";
33+
case DATASET:
34+
return "hoodie:" + HoodieCLI.tableMetadata.getTableName() + "->";
35+
case SYNC:
36+
return "hoodie:" + HoodieCLI.tableMetadata.getTableName() + " <==> "
37+
+ HoodieCLI.syncTableMetadata.getTableName() + "->";
38+
}
39+
if (HoodieCLI.tableMetadata != null)
40+
return "hoodie:" + HoodieCLI.tableMetadata.getTableName() + "->";
41+
return "hoodie->";
42+
}
43+
44+
@Override
45+
public String getProviderName() {
46+
return "Hoodie provider";
47+
}
48+
49+
}

0 commit comments

Comments
 (0)