Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed tsfile tools do not output logs #183

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions java/tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
<artifactId>tsfile</artifactId>
<version>1.0.1-tsfilev4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand All @@ -60,6 +64,17 @@
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<usedDependencies combine.children="append">
<!-- We just need this dependency to prevent the compiler from freaking out on unused imports -->
<usedDependency>ch.qos.logback:logback-classic</usedDependency>
<usedDependency>junit:junit</usedDependency>
</usedDependencies>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
under the License.
-->
<configuration scan="true" scanPeriod="60 seconds">
<statusListener class="ch.qos.logback.core.status.NopStatusListener"/>
<appender class="ch.qos.logback.core.ConsoleAppender" name="stdout">
<Target>System.out</Target>
<encoder>
<pattern>%d [%t] %-5p %C{25}:%L - %m %n</pattern>
<charset>utf-8</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
<level>INFO</level>
</filter>
</appender>
<appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="tools">
Expand All @@ -46,4 +47,6 @@
<appender-ref ref="stdout"/>
<appender-ref ref="tools"/>
</root>
<logger name="org.apache.tsfile.common.conf.TSFileDescriptor" level="OFF"/>
<logger name="org.apache.tsfile.write.TsFileWriter" level="OFF"/>
</configuration>
4 changes: 2 additions & 2 deletions java/tools/src/assembly/resources/tools/csv2tsfile.bat
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ set CLASSPATH="%TSFILE_HOME%\lib\*"
if NOT DEFINED MAIN_CLASS set MAIN_CLASS=org.apache.tsfile.tools.TsFileTool

set TSFILE_CONF=%TSFILE_HOME%\conf
set "tsfile_params=-Dlogback.configurationFile=!IOTDB_CLI_CONF!\logback-cvs2tsfile.xml"
start /B "" cmd /C "("%JAVA_HOME%\bin\java" -DTSFILE_HOME=!TSFILE_HOME! !tsfile_params! !JAVA_OPTS! -cp !CLASSPATH! !MAIN_CLASS! %*) > nul 2>&1"
set "tsfile_params=-Dlogback.configurationFile=!TSFILE_CONF!\logback-cvs2tsfile.xml"
start /B "" cmd /C "("%JAVA_HOME%\bin\java" -DTSFILE_HOME=!TSFILE_HOME! !tsfile_params! !JAVA_OPTS! -cp !CLASSPATH! !MAIN_CLASS! %*)"
exit /b


Expand Down
3 changes: 2 additions & 1 deletion java/tools/src/assembly/tools.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<format>dir</format>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<includeBaseDirectory>true</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
Expand All @@ -45,6 +45,7 @@
<file>
<source>${maven.multiModuleProjectDirectory}/java/tools/src/assembly/resources/tools/csv2tsfile.sh</source>
<destName>tools/csv2tsfile.sh</destName>
<fileMode>0755</fileMode>
</file>
<file>
<source>${maven.multiModuleProjectDirectory}/java/tools/src/assembly/resources/tools/csv2tsfile.bat</source>
Expand Down
35 changes: 26 additions & 9 deletions java/tools/src/main/java/org/apache/tsfile/tools/SchemaParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
public class SchemaParser {

public static class Schema {
String tableName;
String timePrecision;
String tableName = "";
String timePrecision = "ms";
boolean hasHeader = true;
String separator;
String separator = ",";
String nullFormat;
String timeColumn;
String timeColumn = "";
int timeColumnIndex = -1;
List<IDColumns> idColumns = new ArrayList<>();
List<Column> csvColumns = new ArrayList<>();
Expand Down Expand Up @@ -155,7 +155,12 @@ public static Schema parseSchema(String filePath) throws IOException {
} else if (line.startsWith("time_precision=")) {
schema.timePrecision = extractValue(line);
} else if (line.startsWith("has_header=")) {
schema.hasHeader = Boolean.parseBoolean(extractValue(line));
String has_header = extractValue(line);
if (has_header.equals("true") || has_header.equals("false")) {
schema.hasHeader = Boolean.parseBoolean(has_header);
} else {
throw new IllegalArgumentException("The data format of has_header is incorrect");
}
} else if (line.startsWith("separator=")) {
schema.separator = extractValue(line);
} else if (line.startsWith("null_format=")) {
Expand Down Expand Up @@ -244,21 +249,33 @@ private static void validateParams(SchemaParser.Schema schema) {
if (!schema.timePrecision.equals("us")
&& !schema.timePrecision.equals("ms")
&& !schema.timePrecision.equals("ns")) {
throw new IllegalArgumentException("timePrecision must be us,ms or ns");
throw new IllegalArgumentException("The time_precision parameter only supports ms,us,ns");
}
if (!schema.separator.equals(",")
&& !schema.separator.equals("tab")
&& !schema.separator.equals(";")) {
throw new IllegalArgumentException("separator must be \",\", tab, or \";\"");
}
if (schema.timeColumnIndex < 0) {
throw new IllegalArgumentException("time_column is required");
}
if (schema.tableName.isEmpty()) {
throw new IllegalArgumentException("table_name is required");
}
if (schema.idColumns.isEmpty()) {
throw new IllegalArgumentException("id_columns is required");
}
if (schema.csvColumns.isEmpty()) {
throw new IllegalArgumentException("csv_columns is required");
}
if (schema.timeColumn.isEmpty()) {
throw new IllegalArgumentException("time_column is required");
} else if (schema.timeColumnIndex < 0) {
throw new IllegalArgumentException(
"The value " + schema.timeColumn + " of time_column is not in csv_columns");
}
for (IDColumns idColumn : schema.idColumns) {
if (idColumn.csvColumnIndex < 0 && !idColumn.isDefault) {
throw new IllegalArgumentException(
"The value " + idColumn.name + " of id_columns is not in csv_columns");
}
}
}
}
Loading