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

apache / iotdb / #9899

23 Aug 2023 02:10AM UTC coverage: 47.857% (-0.09%) from 47.943%
#9899

push

travis_ci

web-flow
[IOTDB-6121] Consensus layer interface and exception handling refactoring (#10896)

1249 of 1249 new or added lines in 50 files covered. (100.0%)

80064 of 167298 relevant lines covered (47.86%)

0.48 hits per line

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

0.0
/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/StatusUtils.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.commons.utils;
21

22
import org.apache.iotdb.common.rpc.thrift.TSStatus;
23
import org.apache.iotdb.rpc.RpcUtils;
24
import org.apache.iotdb.rpc.TSStatusCode;
25

26
import java.util.Arrays;
27
import java.util.Map;
28

29
public class StatusUtils {
30
  private StatusUtils() {}
31

32
  public static final TSStatus OK = getStatus(TSStatusCode.SUCCESS_STATUS);
×
33
  public static final TSStatus INTERNAL_ERROR = getStatus(TSStatusCode.INTERNAL_SERVER_ERROR);
×
34
  public static final TSStatus EXECUTE_STATEMENT_ERROR =
×
35
      getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
×
36

37
  /**
38
   * @param statusMap index -> status
39
   * @param size the total number of status to generate
40
   */
41
  public static TSStatus[] getFailingStatus(Map<Integer, TSStatus> statusMap, int size) {
42
    if (statusMap == null || statusMap.isEmpty()) {
×
43
      return new TSStatus[0];
×
44
    }
45
    TSStatus[] failingStatus = new TSStatus[size];
×
46
    Arrays.fill(failingStatus, RpcUtils.SUCCESS_STATUS);
×
47
    for (Map.Entry<Integer, TSStatus> status : statusMap.entrySet()) {
×
48
      failingStatus[status.getKey()] = status.getValue();
×
49
    }
×
50
    return failingStatus;
×
51
  }
52

53
  public static TSStatus getStatus(TSStatusCode statusCode) {
54
    TSStatus status = new TSStatus();
×
55
    status.setCode(statusCode.getStatusCode());
×
56
    switch (statusCode) {
×
57
      case SUCCESS_STATUS:
58
        status.setMessage("Executed successfully.");
×
59
        break;
×
60
      case INTERNAL_REQUEST_TIME_OUT:
61
        status.setMessage("Request timed out.");
×
62
        break;
×
63
      case INCOMPATIBLE_VERSION:
64
        status.setMessage("Incompatible version.");
×
65
        break;
×
66
      case REMOVE_DATANODE_ERROR:
67
        status.setMessage("Failed while removing DataNode.");
×
68
        break;
×
69
      case ALIAS_ALREADY_EXIST:
70
        status.setMessage("Alias already exists.");
×
71
        break;
×
72
      case PATH_ALREADY_EXIST:
73
        status.setMessage("Path already exist.");
×
74
        break;
×
75
      case PATH_NOT_EXIST:
76
        status.setMessage("Path does not exist.");
×
77
        break;
×
78
      case METADATA_ERROR:
79
        status.setMessage("Meet error when dealing with metadata.");
×
80
        break;
×
81
      case OUT_OF_TTL:
82
        status.setMessage("Insertion time is less than TTL time bound.");
×
83
        break;
×
84
      case COMPACTION_ERROR:
85
        status.setMessage("Meet error while merging.");
×
86
        break;
×
87
      case DISPATCH_ERROR:
88
        status.setMessage("Meet error while dispatching.");
×
89
        break;
×
90
      case DATAREGION_PROCESS_ERROR:
91
        status.setMessage("Database processor related error.");
×
92
        break;
×
93
      case STORAGE_ENGINE_ERROR:
94
        status.setMessage("Storage engine related error.");
×
95
        break;
×
96
      case TSFILE_PROCESSOR_ERROR:
97
        status.setMessage("TsFile processor related error.");
×
98
        break;
×
99
      case ILLEGAL_PATH:
100
        status.setMessage("Illegal path.");
×
101
        break;
×
102
      case LOAD_FILE_ERROR:
103
        status.setMessage("Meet error while loading file.");
×
104
        break;
×
105
      case EXECUTE_STATEMENT_ERROR:
106
        status.setMessage("Execute statement error.");
×
107
        break;
×
108
      case SQL_PARSE_ERROR:
109
        status.setMessage("Meet error while parsing SQL.");
×
110
        break;
×
111
      case GENERATE_TIME_ZONE_ERROR:
112
        status.setMessage("Meet error while generating time zone.");
×
113
        break;
×
114
      case SET_TIME_ZONE_ERROR:
115
        status.setMessage("Meet error while setting time zone.");
×
116
        break;
×
117
      case QUERY_NOT_ALLOWED:
118
        status.setMessage("Query statements are not allowed error.");
×
119
        break;
×
120
      case LOGICAL_OPERATOR_ERROR:
121
        status.setMessage("Logical operator related error.");
×
122
        break;
×
123
      case LOGICAL_OPTIMIZE_ERROR:
124
        status.setMessage("Logical optimize related error.");
×
125
        break;
×
126
      case UNSUPPORTED_FILL_TYPE:
127
        status.setMessage("Unsupported fill type related error.");
×
128
        break;
×
129
      case QUERY_PROCESS_ERROR:
130
        status.setMessage("Query process related error.");
×
131
        break;
×
132
      case WRITE_PROCESS_ERROR:
133
        status.setMessage("Writing data related error.");
×
134
        break;
×
135
      case INTERNAL_SERVER_ERROR:
136
        status.setMessage("Internal server error.");
×
137
        break;
×
138
      case CLOSE_OPERATION_ERROR:
139
        status.setMessage("Meet error in close operation.");
×
140
        break;
×
141
      case SYSTEM_READ_ONLY:
142
        status.setMessage("Fail to do non-query operations because system is read-only.");
×
143
        break;
×
144
      case DISK_SPACE_INSUFFICIENT:
145
        status.setMessage("Disk space is insufficient.");
×
146
        break;
×
147
      case START_UP_ERROR:
148
        status.setMessage("Meet error while starting up.");
×
149
        break;
×
150
      case WRONG_LOGIN_PASSWORD:
151
        status.setMessage("Username or password is wrong.");
×
152
        break;
×
153
      case NOT_LOGIN:
154
        status.setMessage("Has not logged in.");
×
155
        break;
×
156
      case NO_PERMISSION:
157
        status.setMessage("No permissions for this operation, please add privilege.");
×
158
        break;
×
159
      case INIT_AUTH_ERROR:
160
        status.setMessage("Failed to init authorizer.");
×
161
        break;
×
162
      case UNSUPPORTED_OPERATION:
163
        status.setMessage("Unsupported operation.");
×
164
        break;
×
165
      case CAN_NOT_CONNECT_DATANODE:
166
        status.setMessage("Node cannot be reached.");
×
167
        break;
×
168
      default:
169
        status.setMessage("");
×
170
        break;
171
    }
172
    return status;
×
173
  }
174
}
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