未验证 提交 4fb606f9 编写于 作者: C chaow 提交者: GitHub

[IOTDB-628] rename package client to cli (#1122)

Co-authored-by: Nmychaow <941210239@qq.com>
上级 03c2305a
......@@ -27,8 +27,8 @@
<version>0.10.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>iotdb-client</artifactId>
<name>IoTDB Client</name>
<artifactId>iotdb-cli</artifactId>
<name>IoTDB Cli</name>
<properties>
<cli.test.skip>false</cli.test.skip>
<cli.it.skip>${cli.test.skip}</cli.it.skip>
......@@ -99,7 +99,7 @@
</goals>
<configuration>
<descriptors>
<descriptor>src/assembly/client.xml</descriptor>
<descriptor>src/assembly/cli.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
......
......@@ -20,7 +20,7 @@
-->
<assembly>
<id>client</id>
<id>cli</id>
<formats>
<format>dir</format>
<format>zip</format>
......
......@@ -19,7 +19,7 @@
@echo off
echo ````````````````````````
echo Starting IoTDB Client
echo Starting IoTDB Cli
echo ````````````````````````
@REM You can put your env variable here
......@@ -31,7 +31,7 @@ pushd %~dp0..
if NOT DEFINED IOTDB_CLI_HOME set IOTDB_CLI_HOME=%CD%
popd
if NOT DEFINED MAIN_CLASS set MAIN_CLASS=org.apache.iotdb.client.WinClient
if NOT DEFINED MAIN_CLASS set MAIN_CLASS=org.apache.iotdb.cli.WinCli
if NOT DEFINED JAVA_HOME goto :err
@REM -----------------------------------------------------------------------------
......
......@@ -26,7 +26,7 @@ if [ -z "${IOTDB_CLI_HOME}" ]; then
fi
MAIN_CLASS=org.apache.iotdb.client.Client
MAIN_CLASS=org.apache.iotdb.cli.Cli
CLASSPATH=""
......
......@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.iotdb.client;
package org.apache.iotdb.cli;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
......@@ -25,7 +25,6 @@ import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.iotdb.exception.ArgsErrorException;
import org.apache.iotdb.jdbc.IoTDBConnection;
import org.apache.iotdb.jdbc.IoTDBNonAlignQueryResultSet;
import org.apache.iotdb.jdbc.IoTDBQueryResultSet;
import org.apache.iotdb.service.rpc.thrift.ServerProperties;
import org.apache.iotdb.tool.ImportCsv;
......@@ -46,7 +45,7 @@ import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
public abstract class AbstractClient {
public abstract class AbstractCli {
static final String HOST_ARGS = "h";
static final String HOST_NAME = "host";
......@@ -81,7 +80,7 @@ public abstract class AbstractClient {
static final String SHOW_FETCH_SIZE = "show fetch_size";
private static final String HELP = "help";
static final String IOTDB_CLI_PREFIX = "IoTDB";
static final String SCRIPT_HINT = "./start-client.sh(start-client.bat if Windows)";
static final String SCRIPT_HINT = "./start-cli.sh(start-cli.bat if Windows)";
static final String QUIT_COMMAND = "quit";
static final String EXIT_COMMAND = "exit";
private static final String SHOW_METADATA_COMMAND = "show timeseries";
......@@ -362,7 +361,7 @@ public abstract class AbstractClient {
static void echoStarting() {
println("---------------------");
println("Starting IoTDB Client");
println("Starting IoTDB Cli");
println("---------------------");
}
......
......@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.iotdb.client;
package org.apache.iotdb.cli;
import java.io.IOException;
import java.sql.DriverManager;
......@@ -36,7 +36,7 @@ import org.apache.thrift.TException;
/**
* args[]: -h 127.0.0.1 -p 6667 -u root -pw root
*/
public class Client extends AbstractClient {
public class Cli extends AbstractCli {
private static CommandLine commandLine;
......@@ -58,7 +58,7 @@ public class Client extends AbstractClient {
if (args == null || args.length == 0) {
println(
"Require more params input, eg. ./start-client.sh(start-client.bat if Windows) "
"Require more params input, eg. ./start-cli.sh(start-cli.bat if Windows) "
+ "-h xxx.xxx.xxx.xxx -p xxxx -u xxx.");
println("For more information, please check the following hint.");
hf.printHelp(SCRIPT_HINT, options, true);
......@@ -94,7 +94,7 @@ public class Client extends AbstractClient {
}
} catch (ParseException e) {
println(
"Require more params input, eg. ./start-client.sh(start-client.bat if Windows) "
"Require more params input, eg. ./start-cli.sh(start-cli.bat if Windows) "
+ "-h xxx.xxx.xxx.xxx -p xxxx -u xxx.");
println("For more information, please check the following hint.");
hf.printHelp(IOTDB_CLI_PREFIX, options, true);
......@@ -135,7 +135,7 @@ public class Client extends AbstractClient {
} catch (ArgsErrorException e) {
println(IOTDB_CLI_PREFIX + "> input params error because" + e.getMessage());
} catch (Exception e) {
println(IOTDB_CLI_PREFIX + "> exit client with error " + e.getMessage());
println(IOTDB_CLI_PREFIX + "> exit cli with error " + e.getMessage());
}
}
......
......@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.iotdb.client;
package org.apache.iotdb.cli;
import java.io.Console;
import java.sql.DriverManager;
......@@ -36,7 +36,7 @@ import org.apache.thrift.TException;
/**
* args[]: -h 127.0.0.1 -p 6667 -u root -pw root
*/
public class WinClient extends AbstractClient {
public class WinCli extends AbstractCli {
private static CommandLine commandLine;
......@@ -128,7 +128,7 @@ public class WinClient extends AbstractClient {
} catch (ArgsErrorException e) {
println(IOTDB_CLI_PREFIX + "> input params error because" + e.getMessage());
} catch (Exception e) {
println(IOTDB_CLI_PREFIX + "> exit client with error " + e.getMessage());
println(IOTDB_CLI_PREFIX + "> exit cli with error " + e.getMessage());
}
}
......
......@@ -44,7 +44,7 @@ import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.iotdb.client.AbstractClient;
import org.apache.iotdb.cli.AbstractCli;
import org.apache.iotdb.exception.ArgsErrorException;
import org.apache.iotdb.jdbc.Config;
import org.apache.iotdb.jdbc.IoTDBConnection;
......@@ -327,7 +327,7 @@ public class ExportCsv extends AbstractCsvTool {
switch (timeFormat) {
case "default":
long timestamp = rs.getLong(1);
String str = AbstractClient
String str = AbstractCli
.parseLongToDateWithPrecision(DateTimeFormatter.ISO_OFFSET_DATE_TIME, timestamp, zoneId,
TIMESTAMP_PRECISION);
bw.write(str + ",");
......
......@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.iotdb.client;
package org.apache.iotdb.cli;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
......@@ -27,7 +27,7 @@ import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.iotdb.client.AbstractClient.OperationResult;
import org.apache.iotdb.cli.AbstractCli.OperationResult;
import org.apache.iotdb.exception.ArgsErrorException;
import org.apache.iotdb.jdbc.IoTDBConnection;
import org.apache.iotdb.jdbc.IoTDBDatabaseMetadata;
......@@ -39,8 +39,8 @@ import org.mockito.MockitoAnnotations;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AbstractClientIT {
private static Logger logger = LoggerFactory.getLogger(AbstractClientIT.class);
public class AbstractCliIT {
private static Logger logger = LoggerFactory.getLogger(AbstractCliIT.class);
@Mock
private IoTDBConnection connection;
......@@ -60,13 +60,13 @@ public class AbstractClientIT {
@Test
public void testInit() {
AbstractClient.init();
String[] keywords = {AbstractClient.HOST_ARGS, AbstractClient.HELP_ARGS,
AbstractClient.PORT_ARGS,
AbstractClient.PASSWORD_ARGS, AbstractClient.USERNAME_ARGS, AbstractClient.ISO8601_ARGS,
AbstractClient.MAX_PRINT_ROW_COUNT_ARGS,};
AbstractCli.init();
String[] keywords = {AbstractCli.HOST_ARGS, AbstractCli.HELP_ARGS,
AbstractCli.PORT_ARGS,
AbstractCli.PASSWORD_ARGS, AbstractCli.USERNAME_ARGS, AbstractCli.ISO8601_ARGS,
AbstractCli.MAX_PRINT_ROW_COUNT_ARGS,};
for (String keyword : keywords) {
if (!AbstractClient.keywordSet.contains("-" + keyword)) {
if (!AbstractCli.keywordSet.contains("-" + keyword)) {
logger.error(keyword);
fail();
}
......@@ -75,31 +75,31 @@ public class AbstractClientIT {
@Test
public void testCheckRequiredArg() throws ParseException, ArgsErrorException {
Options options = AbstractClient.createOptions();
Options options = AbstractCli.createOptions();
CommandLineParser parser = new DefaultParser();
String[] args = new String[]{"-u", "user1"};
CommandLine commandLine = parser.parse(options, args);
String str = AbstractClient
.checkRequiredArg(AbstractClient.USERNAME_ARGS, AbstractClient.USERNAME_NAME,
String str = AbstractCli
.checkRequiredArg(AbstractCli.USERNAME_ARGS, AbstractCli.USERNAME_NAME,
commandLine, true, "root");
assertEquals("user1", str);
args = new String[]{"-u", "root",};
commandLine = parser.parse(options, args);
str = AbstractClient
.checkRequiredArg(AbstractClient.HOST_ARGS, AbstractClient.HOST_NAME, commandLine, false,
str = AbstractCli
.checkRequiredArg(AbstractCli.HOST_ARGS, AbstractCli.HOST_NAME, commandLine, false,
"127.0.0.1");
assertEquals("127.0.0.1", str);
try {
str = AbstractClient
.checkRequiredArg(AbstractClient.HOST_ARGS, AbstractClient.HOST_NAME, commandLine, true,
str = AbstractCli
.checkRequiredArg(AbstractCli.HOST_ARGS, AbstractCli.HOST_NAME, commandLine, true,
"127.0.0.1");
} catch (ArgsErrorException e) {
assertEquals("IoTDB: Required values for option 'host' not provided", e.getMessage());
}
try {
str = AbstractClient
.checkRequiredArg(AbstractClient.HOST_ARGS, AbstractClient.HOST_NAME, commandLine,
str = AbstractCli
.checkRequiredArg(AbstractCli.HOST_ARGS, AbstractCli.HOST_NAME, commandLine,
false, null);
} catch (ArgsErrorException e) {
assertEquals("IoTDB: Required values for option 'host' is null.", e.getMessage());
......@@ -108,30 +108,30 @@ public class AbstractClientIT {
@Test
public void testRemovePasswordArgs() {
AbstractClient.init();
AbstractCli.init();
String[] input = new String[]{"-h", "127.0.0.1", "-p", "6667", "-u", "root", "-pw", "root"};
String[] res = new String[]{"-h", "127.0.0.1", "-p", "6667", "-u", "root", "-pw", "root"};
isTwoStringArrayEqual(res, AbstractClient.removePasswordArgs(input));
isTwoStringArrayEqual(res, AbstractCli.removePasswordArgs(input));
input = new String[]{"-h", "127.0.0.1", "-p", "6667", "-pw", "root", "-u", "root"};
res = new String[]{"-h", "127.0.0.1", "-p", "6667", "-pw", "root", "-u", "root"};
isTwoStringArrayEqual(res, AbstractClient.removePasswordArgs(input));
isTwoStringArrayEqual(res, AbstractCli.removePasswordArgs(input));
input = new String[]{"-h", "127.0.0.1", "-p", "6667", "root", "-u", "root", "-pw"};
res = new String[]{"-h", "127.0.0.1", "-p", "6667", "root", "-u", "root"};
isTwoStringArrayEqual(res, AbstractClient.removePasswordArgs(input));
isTwoStringArrayEqual(res, AbstractCli.removePasswordArgs(input));
input = new String[]{"-h", "127.0.0.1", "-p", "6667", "-pw", "-u", "root"};
res = new String[]{"-h", "127.0.0.1", "-p", "6667", "-u", "root"};
isTwoStringArrayEqual(res, AbstractClient.removePasswordArgs(input));
isTwoStringArrayEqual(res, AbstractCli.removePasswordArgs(input));
input = new String[]{"-pw", "-h", "127.0.0.1", "-p", "6667", "root", "-u", "root"};
res = new String[]{"-h", "127.0.0.1", "-p", "6667", "root", "-u", "root"};
isTwoStringArrayEqual(res, AbstractClient.removePasswordArgs(input));
isTwoStringArrayEqual(res, AbstractCli.removePasswordArgs(input));
input = new String[]{};
res = new String[]{};
isTwoStringArrayEqual(res, AbstractClient.removePasswordArgs(input));
isTwoStringArrayEqual(res, AbstractCli.removePasswordArgs(input));
}
private void isTwoStringArrayEqual(String[] expected, String[] actual) {
......@@ -142,77 +142,77 @@ public class AbstractClientIT {
@Test
public void testHandleInputInputCmd() {
assertEquals(OperationResult.STOP_OPER, AbstractClient
.handleInputCmd(AbstractClient.EXIT_COMMAND, connection));
assertEquals(OperationResult.STOP_OPER, AbstractClient
.handleInputCmd(AbstractClient.QUIT_COMMAND, connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
.handleInputCmd(String.format("%s=", AbstractClient.SET_TIMESTAMP_DISPLAY), connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
.handleInputCmd(String.format("%s=xxx", AbstractClient.SET_TIMESTAMP_DISPLAY), connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
.handleInputCmd(String.format("%s=default", AbstractClient.SET_TIMESTAMP_DISPLAY), connection));
assertEquals(OperationResult.STOP_OPER, AbstractCli
.handleInputCmd(AbstractCli.EXIT_COMMAND, connection));
assertEquals(OperationResult.STOP_OPER, AbstractCli
.handleInputCmd(AbstractCli.QUIT_COMMAND, connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractCli
.handleInputCmd(String.format("%s=", AbstractCli.SET_TIMESTAMP_DISPLAY), connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractCli
.handleInputCmd(String.format("%s=xxx", AbstractCli.SET_TIMESTAMP_DISPLAY), connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractCli
.handleInputCmd(String.format("%s=default", AbstractCli.SET_TIMESTAMP_DISPLAY), connection));
testSetTimeFormat();
assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
.handleInputCmd(String.format("%s=", AbstractClient.SET_MAX_DISPLAY_NUM), connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
.handleInputCmd(String.format("%s=xxx", AbstractClient.SET_MAX_DISPLAY_NUM),connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
.handleInputCmd(String.format("%s=1", AbstractClient.SET_MAX_DISPLAY_NUM), connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractCli
.handleInputCmd(String.format("%s=", AbstractCli.SET_MAX_DISPLAY_NUM), connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractCli
.handleInputCmd(String.format("%s=xxx", AbstractCli.SET_MAX_DISPLAY_NUM),connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractCli
.handleInputCmd(String.format("%s=1", AbstractCli.SET_MAX_DISPLAY_NUM), connection));
testSetMaxDisplayNumber();
assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
.handleInputCmd(AbstractClient.SHOW_TIMEZONE, connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
.handleInputCmd(AbstractClient.SHOW_TIMESTAMP_DISPLAY, connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
.handleInputCmd(AbstractClient.SHOW_FETCH_SIZE, connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
.handleInputCmd(String.format("%s=", AbstractClient.SET_TIME_ZONE), connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
.handleInputCmd(String.format("%s=+08:00", AbstractClient.SET_TIME_ZONE), connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
.handleInputCmd(String.format("%s=", AbstractClient.SET_FETCH_SIZE), connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractClient
.handleInputCmd(String.format("%s=111", AbstractClient.SET_FETCH_SIZE), connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractCli
.handleInputCmd(AbstractCli.SHOW_TIMEZONE, connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractCli
.handleInputCmd(AbstractCli.SHOW_TIMESTAMP_DISPLAY, connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractCli
.handleInputCmd(AbstractCli.SHOW_FETCH_SIZE, connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractCli
.handleInputCmd(String.format("%s=", AbstractCli.SET_TIME_ZONE), connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractCli
.handleInputCmd(String.format("%s=+08:00", AbstractCli.SET_TIME_ZONE), connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractCli
.handleInputCmd(String.format("%s=", AbstractCli.SET_FETCH_SIZE), connection));
assertEquals(OperationResult.CONTINUE_OPER, AbstractCli
.handleInputCmd(String.format("%s=111", AbstractCli.SET_FETCH_SIZE), connection));
}
private void testSetTimeFormat() {
AbstractClient.setTimeFormat("long");
assertEquals(AbstractClient.maxTimeLength, AbstractClient.maxValueLength);
assertEquals(AbstractClient.formatTime, "%" + AbstractClient.maxTimeLength + "s|");
AbstractCli.setTimeFormat("long");
assertEquals(AbstractCli.maxTimeLength, AbstractCli.maxValueLength);
assertEquals(AbstractCli.formatTime, "%" + AbstractCli.maxTimeLength + "s|");
AbstractClient.setTimeFormat("number");
assertEquals(AbstractClient.maxTimeLength, AbstractClient.maxValueLength);
assertEquals(AbstractClient.formatTime, "%" + AbstractClient.maxTimeLength + "s|");
AbstractCli.setTimeFormat("number");
assertEquals(AbstractCli.maxTimeLength, AbstractCli.maxValueLength);
assertEquals(AbstractCli.formatTime, "%" + AbstractCli.maxTimeLength + "s|");
AbstractClient.setTimeFormat("default");
assertEquals(AbstractClient.ISO_DATETIME_LEN, AbstractClient.maxTimeLength);
assertEquals(AbstractClient.formatTime, "%" + AbstractClient.maxTimeLength + "s|");
AbstractCli.setTimeFormat("default");
assertEquals(AbstractCli.ISO_DATETIME_LEN, AbstractCli.maxTimeLength);
assertEquals(AbstractCli.formatTime, "%" + AbstractCli.maxTimeLength + "s|");
AbstractClient.setTimeFormat("iso8601");
assertEquals(AbstractClient.ISO_DATETIME_LEN, AbstractClient.maxTimeLength);
assertEquals(AbstractClient.formatTime, "%" + AbstractClient.maxTimeLength + "s|");
AbstractCli.setTimeFormat("iso8601");
assertEquals(AbstractCli.ISO_DATETIME_LEN, AbstractCli.maxTimeLength);
assertEquals(AbstractCli.formatTime, "%" + AbstractCli.maxTimeLength + "s|");
AbstractClient.setTimeFormat("yyyy-MM-dd HH:mm:ssZZ");
assertEquals(AbstractClient.maxTimeLength, "yyyy-MM-dd HH:mm:ssZZ".length());
assertEquals(AbstractClient.formatTime, "%" + AbstractClient.maxTimeLength + "s|");
AbstractCli.setTimeFormat("yyyy-MM-dd HH:mm:ssZZ");
assertEquals(AbstractCli.maxTimeLength, "yyyy-MM-dd HH:mm:ssZZ".length());
assertEquals(AbstractCli.formatTime, "%" + AbstractCli.maxTimeLength + "s|");
AbstractClient.setTimeFormat("dd");
assertEquals(AbstractClient.maxTimeLength, AbstractClient.TIMESTAMP_STR.length());
assertEquals(AbstractClient.formatTime, "%" + AbstractClient.maxTimeLength + "s|");
AbstractCli.setTimeFormat("dd");
assertEquals(AbstractCli.maxTimeLength, AbstractCli.TIMESTAMP_STR.length());
assertEquals(AbstractCli.formatTime, "%" + AbstractCli.maxTimeLength + "s|");
}
private void testSetMaxDisplayNumber() {
AbstractClient.setMaxDisplayNumber("10");
assertEquals(10, AbstractClient.maxPrintRowCount);
AbstractClient.setMaxDisplayNumber("111111111111111");
assertEquals(Integer.MAX_VALUE, AbstractClient.maxPrintRowCount);
AbstractClient.setMaxDisplayNumber("-10");
assertEquals(Integer.MAX_VALUE, AbstractClient.maxPrintRowCount);
AbstractCli.setMaxDisplayNumber("10");
assertEquals(10, AbstractCli.maxPrintRowCount);
AbstractCli.setMaxDisplayNumber("111111111111111");
assertEquals(Integer.MAX_VALUE, AbstractCli.maxPrintRowCount);
AbstractCli.setMaxDisplayNumber("-10");
assertEquals(Integer.MAX_VALUE, AbstractCli.maxPrintRowCount);
}
}
......@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.iotdb.client;
package org.apache.iotdb.cli;
import static org.junit.Assert.assertEquals;
......@@ -61,7 +61,7 @@ public abstract class AbstractScript {
try {
properties.load(new FileReader(target));
} catch (IOException e) {
return "target/iotdb-client-";
return "target/iotdb-cli-";
}
return new File(userDir, String.format("target/%s-%s", properties.getProperty("artifactId"), properties.getProperty("version"))).getAbsolutePath();
}
......
......@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.iotdb.client;
package org.apache.iotdb.cli;
import java.io.File;
import java.io.IOException;
......@@ -47,12 +47,12 @@ public class StartClientScriptIT extends AbstractScript {
@Override
protected void testOnWindows() throws IOException {
final String[] output = {"````````````````````````", "Starting IoTDB Client",
final String[] output = {"````````````````````````", "Starting IoTDB Cli",
"````````````````````````",
"IoTDB> Connection Error, please check whether the network is available or the server has started. Host is 127.0.0.1, port is 6668."};
String dir = getCliPath();
ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c",
dir + File.separator + "sbin" + File.separator + "start-client.bat",
dir + File.separator + "sbin" + File.separator + "start-cli.bat",
"-h",
"127.0.0.1", "-p", "6668", "-u", "root", "-pw", "root");
testOutput(builder, output);
......@@ -64,7 +64,7 @@ public class StartClientScriptIT extends AbstractScript {
"IoTDB> Connection Error, please check whether the network is available or the server has started. Host is 127.0.0.1, port is 6668."};
String dir = getCliPath();
ProcessBuilder builder = new ProcessBuilder("sh",
dir + File.separator + "sbin" + File.separator + "start-client.sh",
dir + File.separator + "sbin" + File.separator + "start-cli.sh",
"-h",
"127.0.0.1", "-p", "6668", "-u", "root", "-pw", "root");
testOutput(builder, output);
......
......@@ -20,7 +20,7 @@ package org.apache.iotdb.tool;
import java.io.File;
import java.io.IOException;
import org.apache.iotdb.client.AbstractScript;
import org.apache.iotdb.cli.AbstractScript;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
......
......@@ -20,7 +20,7 @@ package org.apache.iotdb.tool;
import java.io.File;
import java.io.IOException;
import org.apache.iotdb.client.AbstractScript;
import org.apache.iotdb.cli.AbstractScript;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
......
......@@ -105,7 +105,7 @@
</dependency>
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>iotdb-client</artifactId>
<artifactId>iotdb-cli</artifactId>
<version>${project.version}</version>
<type>zip</type>
</dependency>
......
......@@ -35,7 +35,7 @@
- Basic commands for IoTDB
- Stop IoTDB
- Only build server
- Only build client
- Only build cli
<!-- /TOC -->
......@@ -110,17 +110,17 @@ to $IOTDB_JMX_OPTS in iotdb-env.sh. or iotdb-env.bat
IoTDB offers different ways to interact with server, here we introduce basic steps of using Cli tool to insert and query data.
After installing IoTDB, there is a default user 'root', its default password is also 'root'. Users can use this
default user to login Cli to use IoTDB. The startup script of Cli is the start-client script in the folder sbin. When executing the script, user should assign
default user to login Cli to use IoTDB. The startup script of Cli is the start-cli script in the folder sbin. When executing the script, user should assign
IP, PORT, USER_NAME and PASSWORD. The default parameters are "-h 127.0.0.1 -p 6667 -u root -pw -root".
Here is the command for starting the Cli:
```
# Unix/OS X
> sbin/start-client.sh -h 127.0.0.1 -p 6667 -u root -pw root
> sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root
# Windows
> sbin\start-client.bat -h 127.0.0.1 -p 6667 -u root -pw root
> sbin\start-cli.bat -h 127.0.0.1 -p 6667 -u root -pw root
```
The command line client is interactive so if everything is ready you should see the welcome logo and statements:
......@@ -250,12 +250,12 @@ The server can be stopped with ctrl-C or the following script:
```
## Only build client
## Only build cli
Under the root path of incubator-iotdb:
```
> mvn clean package -pl client -am -DskipTests
> mvn clean package -pl cli -am -DskipTests
```
After build, the IoTDB client will be at the folder "client/target/iotdb-client-{project.version}".
\ No newline at end of file
......@@ -34,7 +34,7 @@
- Can I use Hadoop and Spark to read TsFile in IoTDB?
- How does IoTDB handle duplicate points?
- How can I tell what type of the specific timeseries?
- How can I change IoTDB's Client time display format?
- How can I change IoTDB's Cli time display format?
## How can I identify my version of IoTDB?
......@@ -43,7 +43,7 @@ There are several ways to identify the version of IoTDB that you are using:
* Launch IoTDB's Command Line Interface:
```
> ./start-client.sh -p 6667 -pw root -u root -h localhost
> ./start-cli.sh -p 6667 -pw root -u root -h localhost
_____ _________ ______ ______
|_ _| | _ _ ||_ _ `.|_ _ \
| | .--.|_/ | | \_| | | `. \ | |_) |
......@@ -88,7 +88,7 @@ $ pwd
$ ls -l
server/
client/
cli/
pom.xml
Readme.md
...
......@@ -96,7 +96,7 @@ Readme.md
Let `$IOTDB_HOME = /workspace/incubator-iotdb/server/target/iotdb-server-{project.version}`
Let `$IOTDB_CLI_HOME = /workspace/incubator-iotdb/client/target/iotdb-client-{project.version}`
Let `$IOTDB_CLI_HOME = /workspace/incubator-iotdb/cli/target/iotdb-cli-{project.version}`
By default settings, the logs are stored under ```IOTDB_HOME/logs```. You can change log level and storage path by configuring ```logback.xml``` under ```IOTDB_HOME/conf```.
......@@ -157,11 +157,11 @@ Otherwise, you can also use wildcard in timeseries path:
IoTDB> show timeseries root.fit.d1.*
```
## How can I change IoTDB's Client time display format?
## How can I change IoTDB's Cli time display format?
The default IoTDB's Client time display format is human readable (e.g. ```1970-01-01T08:00:00.001```), if you want to display time in timestamp type or other readable format, add parameter ```-disableIS08601``` in start command:
The default IoTDB's Cli time display format is human readable (e.g. ```1970-01-01T08:00:00.001```), if you want to display time in timestamp type or other readable format, add parameter ```-disableIS08601``` in start command:
```
> $IOTDB_CLI_HOME/sbin/start-client.sh -h 127.0.0.1 -p 6667 -u root -pw root -disableIS08601
> $IOTDB_CLI_HOME/sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root -disableIS08601
```
......@@ -32,38 +32,38 @@ IoTDB provides Cli/shell tools for users to interact with IoTDB server in comman
> Note: In this document, \$IOTDB\_HOME represents the path of the IoTDB installation directory.
## Build client from source code
## Build cli from source code
Under the root path of incubator-iotdb:
```
> mvn clean package -pl client -am -DskipTests
> mvn clean package -pl cli -am -DskipTests
```
After build, the IoTDB client will be at the folder "client/target/iotdb-client-{project.version}".
After build, the IoTDB cli will be at the folder "cli/target/iotdb-cli-{project.version}".
## Running Cli/Shell
After installation, there is a default user in IoTDB: `root`, and the
default password is `root`. Users can use this username to try IoTDB Cli/Shell tool. The client startup script is the `start-client` file under the \$IOTDB\_HOME/bin folder. When starting the script, you need to specify the IP and PORT. (Make sure the IoTDB server is running properly when you use Cli/Shell tool to connect it.)
default password is `root`. Users can use this username to try IoTDB Cli/Shell tool. The cli startup script is the `start-cli` file under the \$IOTDB\_HOME/bin folder. When starting the script, you need to specify the IP and PORT. (Make sure the IoTDB server is running properly when you use Cli/Shell tool to connect it.)
Here is an example where the server is started locally and the user has not changed the running port. The default port is
6667 </br>
If you need to connect to the remote server or changes
the port number of the server running, set the specific IP and PORT at -h and -p.</br>
You also can set your own environment variable at the front of the start script ("/sbin/start-client.sh" for linux and "/sbin/start-client.bat" for windows)
You also can set your own environment variable at the front of the start script ("/sbin/start-cli.sh" for linux and "/sbin/start-cli.bat" for windows)
The Linux and MacOS system startup commands are as follows:
```
Shell > sbin/start-client.sh -h 127.0.0.1 -p 6667 -u root -pw root
Shell > sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root
```
The Windows system startup commands are as follows:
```
Shell > sbin\start-client.bat -h 127.0.0.1 -p 6667 -u root -pw root
Shell > sbin\start-cli.bat -h 127.0.0.1 -p 6667 -u root -pw root
```
After using these commands, the client can be started successfully. The successful status will be as follows:
After using these commands, the cli can be started successfully. The successful status will be as follows:
```
_____ _________ ______ ______
......@@ -77,7 +77,7 @@ After using these commands, the client can be started successfully. The successf
IoTDB> login successfully
IoTDB>
```
Enter ```quit``` or `exit` can exit Client. The client will shows `quit normally`
Enter ```quit``` or `exit` can exit Cli. The cli will shows `quit normally`
## Cli/Shell Parameters
......@@ -90,31 +90,31 @@ Enter ```quit``` or `exit` can exit Client. The client will shows `quit normally
|-pw <`password`>|string, no quotation marks|No|The password used for IoTDB to connect to the server. If no password is entered, IoTDB will ask for password in Cli command|-pw root|
|-u <`username`>|string, no quotation marks|Yes|User name used for IoTDB to connect the server|-u root|
|-maxPRC <`maxPrintRowCount`>|int|No|Set the maximum number of rows that IoTDB returns|-maxPRC 10|
|-e <`execute`> |string|No|manipulate IoTDB in batches without entering client input mode|-e "show storage group"|
|-e <`execute`> |string|No|manipulate IoTDB in batches without entering cli input mode|-e "show storage group"|
Following is a client command which connects the host with IP
Following is a cli command which connects the host with IP
10.129.187.21, port 6667, username "root", password "root", and prints the timestamp in digital form. The maximum number of lines displayed on the IoTDB command line is 10.
The Linux and MacOS system startup commands are as follows:
```
Shell > sbin/start-client.sh -h 10.129.187.21 -p 6667 -u root -pw root -disableIS08601 -maxPRC 10
Shell > sbin/start-cli.sh -h 10.129.187.21 -p 6667 -u root -pw root -disableIS08601 -maxPRC 10
```
The Windows system startup commands are as follows:
```
Shell > sbin\start-client.bat -h 10.129.187.21 -p 6667 -u root -pw root -disableIS08601 -maxPRC 10
Shell > sbin\start-cli.bat -h 10.129.187.21 -p 6667 -u root -pw root -disableIS08601 -maxPRC 10
```
## Cli/shell tool with -e parameter
-e parameter is designed for the Cli/shell tool in the situation where you would like to manipulate IoTDB in batches through scripts. By using the -e parameter, you can operate IoTDB without entering the client's input mode.
-e parameter is designed for the Cli/shell tool in the situation where you would like to manipulate IoTDB in batches through scripts. By using the -e parameter, you can operate IoTDB without entering the cli's input mode.
In order to avoid confusion between statements and other parameters, the current situation only supports the -e parameter as the last parameter.
The usage of -e parameter for Cli/shell is as follows:
```
Shell > sbin/start-client.sh -h {host} -p {port} -u {user} -pw {password} -e {sql for iotdb}
Shell > sbin/start-cli.sh -h {host} -p {port} -u {user} -pw {password} -e {sql for iotdb}
```
In order to better explain the use of -e parameter, take following as an example.
......@@ -129,15 +129,15 @@ port=6667
user=root
pass=root
./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "set storage group to root.demo"
./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "create timeseries root.demo.s1 WITH DATATYPE=INT32, ENCODING=RLE"
./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(1,10)"
./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(2,11)"
./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(3,12)"
./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "select s1 from root.demo"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "set storage group to root.demo"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "create timeseries root.demo.s1 WITH DATATYPE=INT32, ENCODING=RLE"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(1,10)"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(2,11)"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(3,12)"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "select s1 from root.demo"
```
The print results are shown in the figure, which are consistent with the client and jdbc operations.
The print results are shown in the figure, which are consistent with the cli and jdbc operations.
![img](https://issues.apache.org/jira/secure/attachment/12976042/12976042_image-2019-07-27-15-47-12-045.png)
......
......@@ -106,20 +106,20 @@ Windows系统启动命令如下:
IoTDB为用户提供多种与服务器交互的方式,在此我们介绍使用Cli工具进行写入、查询数据的基本步骤。
初始安装后的IoTDB中有一个默认用户:root,默认密码为root。用户可以使用该用户运行Cli工具操作IoTDB。Cli工具启动脚本为sbin文件夹下的start-client脚本。启动脚本时需要指定运行ip、port、username和password。若脚本未给定对应参数,则默认参数为"-h 127.0.0.1 -p 6667 -u root -pw -root"
初始安装后的IoTDB中有一个默认用户:root,默认密码为root。用户可以使用该用户运行Cli工具操作IoTDB。Cli工具启动脚本为sbin文件夹下的start-cli脚本。启动脚本时需要指定运行ip、port、username和password。若脚本未给定对应参数,则默认参数为"-h 127.0.0.1 -p 6667 -u root -pw -root"
以下启动语句为服务器在本机运行,且用户未更改运行端口号的示例。
Linux系统与MacOS系统启动命令如下:
```
> sbin/start-client.sh -h 127.0.0.1 -p 6667 -u root -pw root
> sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root
```
Windows系统启动命令如下:
```
> sbin\start-client.bat -h 127.0.0.1 -p 6667 -u root -pw root
> sbin\start-cli.bat -h 127.0.0.1 -p 6667 -u root -pw root
```
启动后出现如图提示即为启动成功。
......@@ -291,7 +291,7 @@ Windows系统停止命令如下:
在incubator-iotdb的根路径下:
```
> mvn clean package -pl client -am -DskipTests
> mvn clean package -pl cli -am -DskipTests
```
构建后,IoTDB客户端将位于文件夹“ client / target / iotdb-client- {project.version}”下。
构建后,IoTDB客户端将位于文件夹“ cli / target / iotdb-cli- {project.version}”下。
......@@ -44,7 +44,7 @@
*启动 IoTDB 的命令行界面:
```
> ./start-client.sh -p 6667 -pw root -u root -h localhost
> ./start-cli.sh -p 6667 -pw root -u root -h localhost
_____ _________ ______ ______
|_ _| | _ _ ||_ _ `.|_ _ \
| | .--.|_/ | | \_| | | `. \ | |_) |
......@@ -89,7 +89,7 @@ $ pwd
$ ls -l
server/
client/
cli/
pom.xml
Readme.md
...
......@@ -97,7 +97,7 @@ Readme.md
假如 `$IOTDB_HOME = /workspace/incubator-iotdb/server/target/iotdb-server-{project.version}`
假如 `$IOTDB_CLI_HOME = /workspace/incubator-iotdb/client/target/iotdb-client-{project.version}`
假如 `$IOTDB_CLI_HOME = /workspace/incubator-iotdb/cli/target/iotdb-cli-{project.version}`
在默认的设置里,logs 文件夹会被存储在```IOTDB_HOME/logs```。您可以在```IOTDB_HOME/conf```目录下的```logback.xml```文件中修改日志的级别和日志的存储路径。
......@@ -163,5 +163,5 @@ IoTDB> show timeseries root.fit.d1.*
IoTDB 客户端默认显示的时间是人类可读的(比如:```1970-01-01T08:00:00.001```),如果您想显示是时间戳或者其他可读格式, 请在启动命令上添加参数```-disableIS08601```:
```
> $IOTDB_CLI_HOME/sbin/start-client.sh -h 127.0.0.1 -p 6667 -u root -pw root -disableIS08601
> $IOTDB_CLI_HOME/sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root -disableIS08601
```
......@@ -33,33 +33,33 @@
<!-- /TOC -->
IOTDB为用户提供Client/Shell工具用于启动客户端和服务端程序。下面介绍每个Client/Shell工具的运行方式和相关参数。
IOTDB为用户提供cli/Shell工具用于启动客户端和服务端程序。下面介绍每个cli/Shell工具的运行方式和相关参数。
> \$IOTDB\_HOME表示IoTDB的安装目录所在路径。
## Cli / Shell安装
在incubator-iotdb的根目录下执行
```
> mvn clean package -pl client -am -DskipTests
> mvn clean package -pl cli -am -DskipTests
```
在生成完毕之后,IoTDB的cli工具位于文件夹"client/target/iotdb-client-{project.version}"中。
在生成完毕之后,IoTDB的cli工具位于文件夹"cli/target/iotdb-cli-{project.version}"中。
## Cli / Shell运行方式
安装后的IoTDB中有一个默认用户:`root`,默认密码为`root`。用户可以使用该用户尝试运行IoTDB客户端以测试服务器是否正常启动。客户端启动脚本为$IOTDB_HOME/bin文件夹下的`start-client`脚本。启动脚本时需要指定运行IP和PORT。以下为服务器在本机启动,且用户未更改运行端口号的示例,默认端口为6667。若用户尝试连接远程服务器或更改了服务器运行的端口号,请在-h和-p项处使用服务器的IP和PORT。</br>
用户也可以在启动脚本的最前方设置自己的环境变量,如JAVA_HOME等 (对于linux用户,脚本路径为:"/sbin/start-client.sh"; 对于windows用户,脚本路径为:"/sbin/start-client.bat")
安装后的IoTDB中有一个默认用户:`root`,默认密码为`root`。用户可以使用该用户尝试运行IoTDB客户端以测试服务器是否正常启动。客户端启动脚本为$IOTDB_HOME/bin文件夹下的`start-cli`脚本。启动脚本时需要指定运行IP和PORT。以下为服务器在本机启动,且用户未更改运行端口号的示例,默认端口为6667。若用户尝试连接远程服务器或更改了服务器运行的端口号,请在-h和-p项处使用服务器的IP和PORT。</br>
用户也可以在启动脚本的最前方设置自己的环境变量,如JAVA_HOME等 (对于linux用户,脚本路径为:"/sbin/start-cli.sh"; 对于windows用户,脚本路径为:"/sbin/start-cli.bat")
Linux系统与MacOS系统启动命令如下:
```
Shell > sbin/start-client.sh -h 127.0.0.1 -p 6667 -u root -pw root
Shell > sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root
```
Windows系统启动命令如下:
```
Shell > sbin\start-client.bat -h 127.0.0.1 -p 6667 -u root -pw root
Shell > sbin\start-cli.bat -h 127.0.0.1 -p 6667 -u root -pw root
```
回车后即可成功启动客户端。启动后出现如图提示即为启动成功。
```
......@@ -74,7 +74,7 @@ Windows系统启动命令如下:
IoTDB> login successfully
IoTDB>
```
输入`quit``exit`可退出Client结束本次会话,Client输出`quit normally`表示退出成功。
输入`quit``exit`可退出cli结束本次会话,cli输出`quit normally`表示退出成功。
## Cli / Shell运行参数
......@@ -95,22 +95,22 @@ IoTDB>
Linux系统与MacOS系统启动命令如下:
```
Shell > sbin/start-client.sh -h 10.129.187.21 -p 6667 -u root -pw root -disableIS08601 -maxPRC 10
Shell > sbin/start-cli.sh -h 10.129.187.21 -p 6667 -u root -pw root -disableIS08601 -maxPRC 10
```
Windows系统启动命令如下:
```
Shell > sbin\start-client.bat -h 10.129.187.21 -p 6667 -u root -pw root -disableIS08601 -maxPRC 10
Shell > sbin\start-cli.bat -h 10.129.187.21 -p 6667 -u root -pw root -disableIS08601 -maxPRC 10
```
## Cli / Shell的-e参数
当您想要通过脚本的方式通过Cli / Shell对IoTDB进行批量操作时,可以使用-e参数。通过使用该参数,您可以在不进入客户端输入模式的情况下操作IoTDB。
为了避免SQL语句和其他参数混淆,现在只支持-e参数作为最后的参数使用。
针对Client/Shell工具的-e参数用法如下:
针对cli/Shell工具的-e参数用法如下:
```
Shell > sbin/start-client.sh -h {host} -p {port} -u {user} -pw {password} -e {sql for iotdb}
Shell > sbin/start-cli.sh -h {host} -p {port} -u {user} -pw {password} -e {sql for iotdb}
```
为了更好的解释-e参数的使用,可以参考下面的例子。
......@@ -125,7 +125,7 @@ Windows系统启动命令如下:
4.查询验证数据是否插入成功
那么通过使用Client/Shell工具的-e参数,可以采用如下的脚本:
那么通过使用cli/Shell工具的-e参数,可以采用如下的脚本:
```
# !/bin/bash
......@@ -135,12 +135,12 @@ port=6667
user=root
pass=root
./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "set storage group to root.demo"
./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "create timeseries root.demo.s1 WITH DATATYPE=INT32, ENCODING=RLE"
./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(1,10)"
./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(2,11)"
./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(3,12)"
./sbin/start-client.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "select s1 from root.demo"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "set storage group to root.demo"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "create timeseries root.demo.s1 WITH DATATYPE=INT32, ENCODING=RLE"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(1,10)"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(2,11)"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "insert into root.demo(timestamp,s1) values(3,12)"
./sbin/start-cli.sh -h ${host} -p ${port} -u ${user} -pw ${pass} -e "select s1 from root.demo"
```
打印出来的结果显示在下图,通过这种方式进行的操作与客户端的输入模式以及通过JDBC进行操作结果是一致的。
......
......@@ -83,7 +83,7 @@
<module>service-rpc</module>
<module>jdbc</module>
<module>session</module>
<module>client</module>
<module>cli</module>
<module>server</module>
<module>example</module>
<module>grafana</module>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册