in backend/src/main/java/org/apache/iotdb/admin/service/impl/IotDBServiceImpl.java [463:491]
public void saveStorageGroup(Connection connection, String groupName) throws BaseException {
SessionPool sessionPool = getSessionPool(connection);
try {
String iotdbVersion = executeQueryOneValue(sessionPool, "show version");
int versionFlag = 0;
if (iotdbVersion.contains("0.12.")) {
sessionPool.executeNonQueryStatement("set storage group " + groupName);
} else if (iotdbVersion.contains("0.13.") || iotdbVersion.contains("0.14.")) {
sessionPool.executeNonQueryStatement("create storage group " + groupName);
}
// sessionPool.setStorageGroup(groupName);
} catch (StatementExecutionException e) {
if (e.getStatusCode() == 602) {
throw new BaseException(ErrorCode.NO_PRI_SET_GROUP, ErrorCode.NO_PRI_SET_GROUP_MSG);
}
// 300 indicates that the storage group is repeated or there is already a storage group on its
// front or back path
if (e.getStatusCode() == 300) {
throw new BaseException(ErrorCode.SET_GROUP_FAIL, ErrorCode.SET_GROUP_FAIL_MSG);
}
logger.error(e.getMessage());
} catch (IoTDBConnectionException e) {
logger.error(e.getMessage());
throw new BaseException(
ErrorCode.SET_GROUP_FAIL_EXISTS, ErrorCode.SET_GROUP_FAIL__EXISTS_MSG);
} finally {
closeSessionPool(sessionPool);
}
}