• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apache / iotdb / #10006

06 Sep 2023 05:15AM CUT coverage: 47.697% (+0.006%) from 47.691%
#10006

push

travis_ci

web-flow
[RatisConsensus] retry cache expiration time should be longer than retriable-client wait duration (#11045) (#11052)

13 of 13 new or added lines in 1 file covered. (100.0%)

80213 of 168172 relevant lines covered (47.7%)

0.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/AbstractTsFileTool.java
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19

20
package org.apache.iotdb.tool;
21

22
import org.apache.iotdb.cli.utils.IoTPrinter;
23
import org.apache.iotdb.exception.ArgsErrorException;
24
import org.apache.iotdb.session.Session;
25

26
import org.apache.commons.cli.CommandLine;
27
import org.apache.commons.cli.Option;
28
import org.apache.commons.cli.Options;
29

30
public abstract class AbstractTsFileTool {
31

32
  protected static final String HOST_ARGS = "h";
33
  protected static final String HOST_NAME = "host";
34

35
  protected static final String HELP_ARGS = "help";
36

37
  protected static final String PORT_ARGS = "p";
38
  protected static final String PORT_NAME = "port";
39

40
  protected static final String PW_ARGS = "pw";
41
  protected static final String PW_NAME = "password";
42

43
  protected static final String USERNAME_ARGS = "u";
44
  protected static final String USERNAME_NAME = "username";
45

46
  protected static final String TIMEOUT_ARGS = "t";
47
  protected static final String TIMEOUT_NAME = "timeout";
48
  protected static final int MAX_HELP_CONSOLE_WIDTH = 92;
49
  protected static final int CODE_OK = 0;
50
  protected static final int CODE_ERROR = 1;
51

52
  protected static String host;
53
  protected static String port;
54
  protected static String username;
55
  protected static String password;
56
  protected static Session session;
57

58
  protected AbstractTsFileTool() {}
×
59

60
  protected static String checkRequiredArg(String arg, String name, CommandLine commandLine)
61
      throws ArgsErrorException {
62
    String str = commandLine.getOptionValue(arg);
×
63
    if (str == null) {
×
64
      String msg = String.format("Required values for option '%s' not provided", name);
×
65
      IoTPrinter.println(msg);
×
66
      IoTPrinter.println("Use -help for more information");
×
67
      throw new ArgsErrorException(msg);
×
68
    }
69
    return str;
×
70
  }
71

72
  protected static void parseBasicParams(CommandLine commandLine) throws ArgsErrorException {
73
    host = checkRequiredArg(HOST_ARGS, HOST_NAME, commandLine);
×
74
    port = checkRequiredArg(PORT_ARGS, PORT_NAME, commandLine);
×
75
    username = checkRequiredArg(USERNAME_ARGS, USERNAME_NAME, commandLine);
×
76
    password = commandLine.getOptionValue(PW_ARGS);
×
77
  }
×
78

79
  protected static Options createNewOptions() {
80
    Options options = new Options();
×
81

82
    Option opHost =
×
83
        Option.builder(HOST_ARGS)
×
84
            .longOpt(HOST_NAME)
×
85
            .required()
×
86
            .argName(HOST_NAME)
×
87
            .hasArg()
×
88
            .desc("Host Name (required)")
×
89
            .build();
×
90
    options.addOption(opHost);
×
91

92
    Option opPort =
×
93
        Option.builder(PORT_ARGS)
×
94
            .longOpt(PORT_NAME)
×
95
            .required()
×
96
            .argName(PORT_NAME)
×
97
            .hasArg()
×
98
            .desc("Port (required)")
×
99
            .build();
×
100
    options.addOption(opPort);
×
101

102
    Option opUsername =
×
103
        Option.builder(USERNAME_ARGS)
×
104
            .longOpt(USERNAME_NAME)
×
105
            .required()
×
106
            .argName(USERNAME_NAME)
×
107
            .hasArg()
×
108
            .desc("Username (required)")
×
109
            .build();
×
110
    options.addOption(opUsername);
×
111

112
    Option opPassword =
×
113
        Option.builder(PW_ARGS)
×
114
            .longOpt(PW_NAME)
×
115
            .optionalArg(true)
×
116
            .argName(PW_NAME)
×
117
            .hasArg()
×
118
            .desc("Password (required)")
×
119
            .build();
×
120
    options.addOption(opPassword);
×
121
    return options;
×
122
  }
123
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc