You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2022/04/08 12:11:46 UTC
[iotdb] branch master updated: [IOTDB-2857] Move methods in serviceProvider to sessionManager (#5440)
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 9d206f9568 [IOTDB-2857] Move methods in serviceProvider to sessionManager (#5440)
9d206f9568 is described below
commit 9d206f9568091f630a6413e643520088ea42ae87
Author: Xiangwei Wei <34...@users.noreply.github.com>
AuthorDate: Fri Apr 8 20:11:41 2022 +0800
[IOTDB-2857] Move methods in serviceProvider to sessionManager (#5440)
---
.../db/protocol/influxdb/handler/QueryHandler.java | 3 +-
.../iotdb/db/protocol/mqtt/PublishHandler.java | 12 +-
.../rest/handler/AuthorizationHandler.java | 12 +-
.../protocol/rest/impl/GrafanaApiServiceImpl.java | 2 +-
.../db/protocol/rest/impl/RestApiServiceImpl.java | 2 +-
.../iotdb/db/query/control/SessionManager.java | 118 +++++++++++---
.../iotdb/db/service/basic/ServiceProvider.java | 172 ---------------------
.../service/thrift/impl/InfluxDBServiceImpl.java | 18 +--
.../db/service/thrift/impl/TSServiceImpl.java | 131 +++++++---------
9 files changed, 177 insertions(+), 293 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/protocol/influxdb/handler/QueryHandler.java b/server/src/main/java/org/apache/iotdb/db/protocol/influxdb/handler/QueryHandler.java
index 3737e52719..98ebf5e7b8 100644
--- a/server/src/main/java/org/apache/iotdb/db/protocol/influxdb/handler/QueryHandler.java
+++ b/server/src/main/java/org/apache/iotdb/db/protocol/influxdb/handler/QueryHandler.java
@@ -43,6 +43,7 @@ import org.apache.iotdb.db.qp.logical.crud.FilterOperator;
import org.apache.iotdb.db.qp.physical.PhysicalPlan;
import org.apache.iotdb.db.qp.physical.crud.QueryPlan;
import org.apache.iotdb.db.query.context.QueryContext;
+import org.apache.iotdb.db.query.control.SessionManager;
import org.apache.iotdb.db.query.expression.Expression;
import org.apache.iotdb.db.query.expression.ResultColumn;
import org.apache.iotdb.db.query.expression.unary.FunctionExpression;
@@ -878,7 +879,7 @@ public class QueryHandler {
try {
QueryPlan queryPlan =
(QueryPlan) serviceProvider.getPlanner().parseSQLToPhysicalPlan(realQuerySql);
- TSStatus tsStatus = serviceProvider.checkAuthority(queryPlan, sessionId);
+ TSStatus tsStatus = SessionManager.getInstance().checkAuthority(queryPlan, sessionId);
if (tsStatus != null) {
throw new AuthException(tsStatus.getMessage());
}
diff --git a/server/src/main/java/org/apache/iotdb/db/protocol/mqtt/PublishHandler.java b/server/src/main/java/org/apache/iotdb/db/protocol/mqtt/PublishHandler.java
index 3bf7144e73..1818968ec2 100644
--- a/server/src/main/java/org/apache/iotdb/db/protocol/mqtt/PublishHandler.java
+++ b/server/src/main/java/org/apache/iotdb/db/protocol/mqtt/PublishHandler.java
@@ -20,9 +20,9 @@ package org.apache.iotdb.db.protocol.mqtt;
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.metadata.path.PartialPath;
import org.apache.iotdb.db.qp.physical.crud.InsertRowPlan;
+import org.apache.iotdb.db.query.control.SessionManager;
import org.apache.iotdb.db.service.IoTDB;
import org.apache.iotdb.db.service.basic.BasicOpenSessionResp;
-import org.apache.iotdb.db.service.basic.ServiceProvider;
import org.apache.iotdb.service.rpc.thrift.TSProtocolVersion;
import org.apache.iotdb.service.rpc.thrift.TSStatus;
@@ -42,7 +42,7 @@ import java.util.List;
/** PublishHandler handle the messages from MQTT clients. */
public class PublishHandler extends AbstractInterceptHandler {
- private final ServiceProvider serviceProvider = IoTDB.serviceProvider;
+ private final SessionManager SESSION_MANAGER = SessionManager.getInstance();
private long sessionId;
private static final Logger LOG = LoggerFactory.getLogger(PublishHandler.class);
@@ -66,7 +66,7 @@ public class PublishHandler extends AbstractInterceptHandler {
public void onConnect(InterceptConnectMessage msg) {
try {
BasicOpenSessionResp basicOpenSessionResp =
- serviceProvider.openSession(
+ SESSION_MANAGER.openSession(
msg.getUsername(),
new String(msg.getPassword()),
ZoneId.systemDefault().toString(),
@@ -79,7 +79,7 @@ public class PublishHandler extends AbstractInterceptHandler {
@Override
public void onDisconnect(InterceptDisconnectMessage msg) {
- serviceProvider.closeSession(sessionId);
+ SESSION_MANAGER.closeSession(sessionId);
}
@Override
@@ -119,11 +119,11 @@ public class PublishHandler extends AbstractInterceptHandler {
event.getTimestamp(),
event.getMeasurements().toArray(new String[0]),
event.getValues().toArray(new String[0]));
- TSStatus tsStatus = serviceProvider.checkAuthority(plan, sessionId);
+ TSStatus tsStatus = SESSION_MANAGER.checkAuthority(plan, sessionId);
if (tsStatus != null) {
LOG.warn(tsStatus.message);
} else {
- status = serviceProvider.executeNonQuery(plan);
+ status = IoTDB.serviceProvider.executeNonQuery(plan);
}
} catch (Exception e) {
LOG.warn(
diff --git a/server/src/main/java/org/apache/iotdb/db/protocol/rest/handler/AuthorizationHandler.java b/server/src/main/java/org/apache/iotdb/db/protocol/rest/handler/AuthorizationHandler.java
index a8310729d7..beb945683f 100644
--- a/server/src/main/java/org/apache/iotdb/db/protocol/rest/handler/AuthorizationHandler.java
+++ b/server/src/main/java/org/apache/iotdb/db/protocol/rest/handler/AuthorizationHandler.java
@@ -18,26 +18,20 @@
package org.apache.iotdb.db.protocol.rest.handler;
import org.apache.iotdb.db.auth.AuthException;
-import org.apache.iotdb.db.exception.query.QueryProcessException;
import org.apache.iotdb.db.protocol.rest.model.ExecutionStatus;
import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.db.service.basic.ServiceProvider;
+import org.apache.iotdb.db.query.control.SessionManager;
import org.apache.iotdb.rpc.TSStatusCode;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
public class AuthorizationHandler {
- private final ServiceProvider serviceProvider;
-
- public AuthorizationHandler(ServiceProvider serviceProvider) throws QueryProcessException {
- this.serviceProvider = serviceProvider;
- }
public Response checkAuthority(SecurityContext securityContext, PhysicalPlan physicalPlan) {
try {
- if (!this.serviceProvider.checkAuthorization(
- physicalPlan, securityContext.getUserPrincipal().getName())) {
+ if (!SessionManager.getInstance()
+ .checkAuthorization(physicalPlan, securityContext.getUserPrincipal().getName())) {
return Response.ok()
.entity(
new ExecutionStatus()
diff --git a/server/src/main/java/org/apache/iotdb/db/protocol/rest/impl/GrafanaApiServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/protocol/rest/impl/GrafanaApiServiceImpl.java
index 3a1b3dfe9e..ac024024c1 100644
--- a/server/src/main/java/org/apache/iotdb/db/protocol/rest/impl/GrafanaApiServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/protocol/rest/impl/GrafanaApiServiceImpl.java
@@ -55,7 +55,7 @@ public class GrafanaApiServiceImpl extends GrafanaApiService {
private final long timePrecision; // the default timestamp precision is ms
public GrafanaApiServiceImpl() throws QueryProcessException {
- authorizationHandler = new AuthorizationHandler(serviceProvider);
+ authorizationHandler = new AuthorizationHandler();
switch (IoTDBDescriptor.getInstance().getConfig().getTimestampPrecision()) {
case "ns":
diff --git a/server/src/main/java/org/apache/iotdb/db/protocol/rest/impl/RestApiServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/protocol/rest/impl/RestApiServiceImpl.java
index 781ea03d93..02ae5832f0 100644
--- a/server/src/main/java/org/apache/iotdb/db/protocol/rest/impl/RestApiServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/protocol/rest/impl/RestApiServiceImpl.java
@@ -57,7 +57,7 @@ public class RestApiServiceImpl extends RestApiService {
public RestApiServiceImpl() throws QueryProcessException {
planner = serviceProvider.getPlanner();
- authorizationHandler = new AuthorizationHandler(serviceProvider);
+ authorizationHandler = new AuthorizationHandler();
defaultQueryRowLimit =
IoTDBRestServiceDescriptor.getInstance().getConfig().getRestQueryDefaultRowSizeLimit();
diff --git a/server/src/main/java/org/apache/iotdb/db/query/control/SessionManager.java b/server/src/main/java/org/apache/iotdb/db/query/control/SessionManager.java
index 3d7a8f9213..a3193ede71 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/control/SessionManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/control/SessionManager.java
@@ -20,14 +20,20 @@ package org.apache.iotdb.db.query.control;
import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.db.auth.AuthException;
+import org.apache.iotdb.db.auth.AuthorityChecker;
import org.apache.iotdb.db.auth.authorizer.BasicAuthorizer;
import org.apache.iotdb.db.auth.authorizer.IAuthorizer;
+import org.apache.iotdb.db.conf.OperationType;
import org.apache.iotdb.db.exception.StorageEngineException;
import org.apache.iotdb.db.mpp.common.SessionInfo;
+import org.apache.iotdb.db.qp.physical.PhysicalPlan;
+import org.apache.iotdb.db.qp.physical.sys.AuthorPlan;
import org.apache.iotdb.db.query.dataset.UDTFDataSet;
import org.apache.iotdb.db.service.basic.BasicOpenSessionResp;
+import org.apache.iotdb.rpc.RpcUtils;
import org.apache.iotdb.rpc.TSStatusCode;
import org.apache.iotdb.service.rpc.thrift.TSProtocolVersion;
+import org.apache.iotdb.service.rpc.thrift.TSStatus;
import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
import org.apache.thrift.TException;
@@ -42,6 +48,8 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.atomic.AtomicLong;
+import static org.apache.iotdb.db.utils.ErrorHandlingUtils.onNPEOrUnexpectedException;
+
public class SessionManager {
private static final Logger LOGGER = LoggerFactory.getLogger(SessionManager.class);
public static final Logger AUDIT_LOGGER =
@@ -78,23 +86,6 @@ public class SessionManager {
// singleton
}
- public Long getCurrSessionId() {
- return currSessionId.get();
- }
-
- public void removeCurrSessionId() {
- currSessionId.remove();
- }
-
- public TimeZone getCurrSessionTimeZone() {
- if (getCurrSessionId() != null) {
- return TimeZone.getTimeZone(SessionManager.getInstance().getZoneId(getCurrSessionId()));
- } else {
- // only used for test
- return TimeZone.getTimeZone("+08:00");
- }
- }
-
public BasicOpenSessionResp openSession(
String username,
String password,
@@ -154,12 +145,54 @@ public class SessionManager {
return openSessionResp.sessionId(sessionId);
}
+ public BasicOpenSessionResp openSession(
+ String username, String password, String zoneId, TSProtocolVersion tsProtocolVersion)
+ throws TException {
+ return openSession(
+ username, password, zoneId, tsProtocolVersion, IoTDBConstant.ClientVersion.V_0_12);
+ }
+
public boolean closeSession(long sessionId) {
AUDIT_LOGGER.info("Session-{} is closing", sessionId);
+ currSessionId.remove();
+ return SessionTimeoutManager.getInstance().unregister(sessionId);
+ }
- removeCurrSessionId();
+ public TSStatus closeOperation(
+ long sessionId,
+ long queryId,
+ long statementId,
+ boolean haveStatementId,
+ boolean haveSetQueryId) {
+ if (!checkLogin(sessionId)) {
+ return RpcUtils.getStatus(
+ TSStatusCode.NOT_LOGIN_ERROR,
+ "Log in failed. Either you are not authorized or the session has timed out.");
+ }
- return SessionTimeoutManager.getInstance().unregister(sessionId);
+ if (AUDIT_LOGGER.isDebugEnabled()) {
+ AUDIT_LOGGER.debug(
+ "{}: receive close operation from Session {}",
+ IoTDBConstant.GLOBAL_DB_NAME,
+ currSessionId);
+ }
+
+ try {
+ if (haveStatementId) {
+ if (haveSetQueryId) {
+ this.closeDataset(statementId, queryId);
+ } else {
+ this.closeStatement(sessionId, statementId);
+ }
+ return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
+ } else {
+ return RpcUtils.getStatus(
+ TSStatusCode.CLOSE_OPERATION_ERROR, "statement id not set by client.");
+ }
+ } catch (Exception e) {
+ return onNPEOrUnexpectedException(
+ e, OperationType.CLOSE_OPERATION, TSStatusCode.CLOSE_OPERATION_ERROR);
+ }
}
/**
@@ -168,7 +201,7 @@ public class SessionManager {
* @return true: If logged in; false: If not logged in
*/
public boolean checkLogin(long sessionId) {
- boolean isLoggedIn = getUsername(sessionId) != null;
+ boolean isLoggedIn = sessionIdToUsername.get(sessionId) != null;
if (!isLoggedIn) {
LOGGER.info("{}: Not login. ", IoTDBConstant.GLOBAL_DB_NAME);
} else {
@@ -273,6 +306,51 @@ public class SessionManager {
}
}
+ /** Check whether specific user has the authorization to given plan. */
+ public boolean checkAuthorization(PhysicalPlan plan, String username) throws AuthException {
+ if (!plan.isAuthenticationRequired()) {
+ return true;
+ }
+
+ String targetUser = null;
+ if (plan instanceof AuthorPlan) {
+ targetUser = ((AuthorPlan) plan).getUserName();
+ }
+ return AuthorityChecker.check(
+ username, plan.getAuthPaths(), plan.getOperatorType(), targetUser);
+ }
+
+ /** Check whether specific Session has the authorization to given plan. */
+ public TSStatus checkAuthority(PhysicalPlan plan, long sessionId) {
+ try {
+ if (!checkAuthorization(plan, sessionIdToUsername.get(sessionId))) {
+ return RpcUtils.getStatus(
+ TSStatusCode.NO_PERMISSION_ERROR,
+ "No permissions for this operation " + plan.getOperatorType());
+ }
+ } catch (AuthException e) {
+ LOGGER.warn("meet error while checking authorization.", e);
+ return RpcUtils.getStatus(TSStatusCode.UNINITIALIZED_AUTH_ERROR, e.getMessage());
+ } catch (Exception e) {
+ return onNPEOrUnexpectedException(
+ e, OperationType.CHECK_AUTHORITY, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+ }
+ return null;
+ }
+
+ public Long getCurrSessionId() {
+ return currSessionId.get();
+ }
+
+ public TimeZone getCurrSessionTimeZone() {
+ if (getCurrSessionId() != null) {
+ return TimeZone.getTimeZone(SessionManager.getInstance().getZoneId(getCurrSessionId()));
+ } else {
+ // only used for test
+ return TimeZone.getTimeZone("+08:00");
+ }
+ }
+
public String getUsername(Long sessionId) {
return sessionIdToUsername.get(sessionId);
}
diff --git a/server/src/main/java/org/apache/iotdb/db/service/basic/ServiceProvider.java b/server/src/main/java/org/apache/iotdb/db/service/basic/ServiceProvider.java
index 924babfeb0..e7afa13bd5 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/basic/ServiceProvider.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/basic/ServiceProvider.java
@@ -20,13 +20,8 @@
package org.apache.iotdb.db.service.basic;
import org.apache.iotdb.commons.conf.IoTDBConstant;
-import org.apache.iotdb.db.auth.AuthException;
-import org.apache.iotdb.db.auth.AuthorityChecker;
-import org.apache.iotdb.db.auth.authorizer.BasicAuthorizer;
-import org.apache.iotdb.db.auth.authorizer.IAuthorizer;
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.conf.OperationType;
import org.apache.iotdb.db.exception.StorageEngineException;
import org.apache.iotdb.db.exception.metadata.MetadataException;
import org.apache.iotdb.db.exception.metadata.StorageGroupNotSetException;
@@ -35,16 +30,11 @@ import org.apache.iotdb.db.qp.Planner;
import org.apache.iotdb.db.qp.executor.IPlanExecutor;
import org.apache.iotdb.db.qp.executor.PlanExecutor;
import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.db.qp.physical.sys.AuthorPlan;
import org.apache.iotdb.db.query.context.QueryContext;
import org.apache.iotdb.db.query.control.QueryTimeManager;
import org.apache.iotdb.db.query.control.SessionManager;
-import org.apache.iotdb.db.query.control.SessionTimeoutManager;
import org.apache.iotdb.db.query.control.tracing.TracingManager;
-import org.apache.iotdb.rpc.RpcUtils;
-import org.apache.iotdb.rpc.TSStatusCode;
import org.apache.iotdb.service.rpc.thrift.TSProtocolVersion;
-import org.apache.iotdb.service.rpc.thrift.TSStatus;
import org.apache.iotdb.tsfile.exception.filter.QueryFilterOptimizationException;
import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
@@ -55,8 +45,6 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.sql.SQLException;
-import static org.apache.iotdb.db.utils.ErrorHandlingUtils.onNPEOrUnexpectedException;
-
public abstract class ServiceProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(ServiceProvider.class);
@@ -99,162 +87,6 @@ public abstract class ServiceProvider {
public abstract boolean executeNonQuery(PhysicalPlan plan)
throws QueryProcessException, StorageGroupNotSetException, StorageEngineException;
- /**
- * Check whether current user has logged in.
- *
- * @return true: If logged in; false: If not logged in
- */
- public boolean checkLogin(long sessionId) {
- boolean isLoggedIn = SESSION_MANAGER.getUsername(sessionId) != null;
- if (!isLoggedIn) {
- LOGGER.info("{}: Not login. ", IoTDBConstant.GLOBAL_DB_NAME);
- } else {
- SessionTimeoutManager.getInstance().refresh(sessionId);
- }
- return isLoggedIn;
- }
-
- public boolean checkAuthorization(PhysicalPlan plan, String username) throws AuthException {
- if (!plan.isAuthenticationRequired()) {
- return true;
- }
-
- String targetUser = null;
- if (plan instanceof AuthorPlan) {
- targetUser = ((AuthorPlan) plan).getUserName();
- }
- return AuthorityChecker.check(
- username, plan.getAuthPaths(), plan.getOperatorType(), targetUser);
- }
-
- public TSStatus checkAuthority(PhysicalPlan plan, long sessionId) {
- try {
- if (!checkAuthorization(plan, SESSION_MANAGER.getUsername(sessionId))) {
- return RpcUtils.getStatus(
- TSStatusCode.NO_PERMISSION_ERROR,
- "No permissions for this operation " + plan.getOperatorType());
- }
- } catch (AuthException e) {
- LOGGER.warn("meet error while checking authorization.", e);
- return RpcUtils.getStatus(TSStatusCode.UNINITIALIZED_AUTH_ERROR, e.getMessage());
- } catch (Exception e) {
- return onNPEOrUnexpectedException(
- e, OperationType.CHECK_AUTHORITY, TSStatusCode.EXECUTE_STATEMENT_ERROR);
- }
- return null;
- }
-
- public BasicOpenSessionResp openSession(
- String username,
- String password,
- String zoneId,
- TSProtocolVersion tsProtocolVersion,
- IoTDBConstant.ClientVersion clientVersion)
- throws TException {
- BasicOpenSessionResp openSessionResp = new BasicOpenSessionResp();
-
- boolean status;
- IAuthorizer authorizer;
- try {
- authorizer = BasicAuthorizer.getInstance();
- } catch (AuthException e) {
- throw new TException(e);
- }
- String loginMessage = null;
- try {
- status = authorizer.login(username, password);
- } catch (AuthException e) {
- LOGGER.info("meet error while logging in.", e);
- status = false;
- loginMessage = e.getMessage();
- }
-
- long sessionId = -1;
- if (status) {
- // check the version compatibility
- boolean compatible = checkCompatibility(tsProtocolVersion);
- if (!compatible) {
- openSessionResp.setCode(TSStatusCode.INCOMPATIBLE_VERSION.getStatusCode());
- openSessionResp.setMessage(
- "The version is incompatible, please upgrade to " + IoTDBConstant.VERSION);
- return openSessionResp.sessionId(sessionId);
- }
-
- openSessionResp.setCode(TSStatusCode.SUCCESS_STATUS.getStatusCode());
- openSessionResp.setMessage("Login successfully");
-
- sessionId = SESSION_MANAGER.requestSessionId(username, zoneId, clientVersion);
-
- LOGGER.info(
- "{}: Login status: {}. User : {}, opens Session-{}",
- IoTDBConstant.GLOBAL_DB_NAME,
- openSessionResp.getMessage(),
- username,
- sessionId);
- } else {
- openSessionResp.setMessage(loginMessage != null ? loginMessage : "Authentication failed.");
- openSessionResp.setCode(TSStatusCode.WRONG_LOGIN_PASSWORD_ERROR.getStatusCode());
-
- sessionId = SESSION_MANAGER.requestSessionId(username, zoneId, clientVersion);
- AUDIT_LOGGER.info("User {} opens Session failed with an incorrect password", username);
- }
-
- SessionTimeoutManager.getInstance().register(sessionId);
- return openSessionResp.sessionId(sessionId);
- }
-
- public BasicOpenSessionResp openSession(
- String username, String password, String zoneId, TSProtocolVersion tsProtocolVersion)
- throws TException {
- return openSession(
- username, password, zoneId, tsProtocolVersion, IoTDBConstant.ClientVersion.V_0_12);
- }
-
- public boolean closeSession(long sessionId) {
- AUDIT_LOGGER.info("Session-{} is closing", sessionId);
-
- SESSION_MANAGER.removeCurrSessionId();
-
- return SessionTimeoutManager.getInstance().unregister(sessionId);
- }
-
- public TSStatus closeOperation(
- long sessionId,
- long queryId,
- long statementId,
- boolean haveStatementId,
- boolean haveSetQueryId) {
- if (!checkLogin(sessionId)) {
- return RpcUtils.getStatus(
- TSStatusCode.NOT_LOGIN_ERROR,
- "Log in failed. Either you are not authorized or the session has timed out.");
- }
-
- if (AUDIT_LOGGER.isDebugEnabled()) {
- AUDIT_LOGGER.debug(
- "{}: receive close operation from Session {}",
- IoTDBConstant.GLOBAL_DB_NAME,
- SESSION_MANAGER.getCurrSessionId());
- }
-
- try {
- if (haveStatementId) {
- if (haveSetQueryId) {
- SESSION_MANAGER.closeDataset(statementId, queryId);
- } else {
- SESSION_MANAGER.closeStatement(sessionId, statementId);
- }
- return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
- } else {
- return RpcUtils.getStatus(
- TSStatusCode.CLOSE_OPERATION_ERROR, "statement id not set by client.");
- }
- } catch (Exception e) {
- return onNPEOrUnexpectedException(
- e, OperationType.CLOSE_OPERATION, TSStatusCode.CLOSE_OPERATION_ERROR);
- }
- }
-
/** create QueryDataSet and buffer it for fetchResults */
public QueryDataSet createQueryDataSet(
QueryContext context, PhysicalPlan physicalPlan, int fetchSize)
@@ -266,8 +98,4 @@ public abstract class ServiceProvider {
SESSION_MANAGER.setDataset(context.getQueryId(), queryDataSet);
return queryDataSet;
}
-
- private boolean checkCompatibility(TSProtocolVersion version) {
- return version.equals(CURRENT_RPC_VERSION);
- }
}
diff --git a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/InfluxDBServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/InfluxDBServiceImpl.java
index 8789142c59..3ceff40fd5 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/InfluxDBServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/InfluxDBServiceImpl.java
@@ -34,6 +34,7 @@ import org.apache.iotdb.db.qp.logical.Operator;
import org.apache.iotdb.db.qp.physical.PhysicalPlan;
import org.apache.iotdb.db.qp.physical.crud.InsertRowPlan;
import org.apache.iotdb.db.qp.physical.sys.SetStorageGroupPlan;
+import org.apache.iotdb.db.query.control.SessionManager;
import org.apache.iotdb.db.service.IoTDB;
import org.apache.iotdb.db.service.basic.BasicOpenSessionResp;
import org.apache.iotdb.db.service.basic.ServiceProvider;
@@ -61,19 +62,18 @@ import java.util.List;
public class InfluxDBServiceImpl implements InfluxDBService.Iface {
- private final ServiceProvider serviceProvider;
+ private final SessionManager SESSION_MANAGER = SessionManager.getInstance();
private final InfluxDBMetaManager metaManager;
public InfluxDBServiceImpl() {
- serviceProvider = IoTDB.serviceProvider;
metaManager = InfluxDBMetaManager.getInstance();
}
@Override
public TSOpenSessionResp openSession(TSOpenSessionReq req) throws TException {
BasicOpenSessionResp basicOpenSessionResp =
- serviceProvider.openSession(
+ SESSION_MANAGER.openSession(
req.username, req.password, req.zoneId, TSProtocolVersion.IOTDB_SERVICE_PROTOCOL_V3);
return new TSOpenSessionResp()
.setStatus(
@@ -85,14 +85,14 @@ public class InfluxDBServiceImpl implements InfluxDBService.Iface {
@Override
public TSStatus closeSession(TSCloseSessionReq req) {
return new TSStatus(
- !serviceProvider.closeSession(req.sessionId)
+ !SESSION_MANAGER.closeSession(req.sessionId)
? RpcUtils.getInfluxDBStatus(TSStatusCode.NOT_LOGIN_ERROR)
: RpcUtils.getInfluxDBStatus(TSStatusCode.SUCCESS_STATUS));
}
@Override
public TSStatus writePoints(TSWritePointsReq req) {
- if (!serviceProvider.checkLogin(req.sessionId)) {
+ if (!SESSION_MANAGER.checkLogin(req.sessionId)) {
return getNotLoggedInStatus();
}
@@ -122,7 +122,7 @@ public class InfluxDBServiceImpl implements InfluxDBService.Iface {
@Override
public TSStatus createDatabase(TSCreateDatabaseReq req) throws TException {
- if (!serviceProvider.checkLogin(req.sessionId)) {
+ if (!SESSION_MANAGER.checkLogin(req.sessionId)) {
return getNotLoggedInStatus();
}
try {
@@ -146,7 +146,7 @@ public class InfluxDBServiceImpl implements InfluxDBService.Iface {
Operator operator = InfluxDBLogicalGenerator.generate(req.command);
QueryHandler.checkInfluxDBQueryOperator(operator);
return QueryHandler.queryInfluxDB(
- req.database, (InfluxQueryOperator) operator, req.sessionId, serviceProvider);
+ req.database, (InfluxQueryOperator) operator, req.sessionId, IoTDB.serviceProvider);
}
public void handleClientExit() {
@@ -165,10 +165,10 @@ public class InfluxDBServiceImpl implements InfluxDBService.Iface {
private TSStatus executeNonQueryPlan(PhysicalPlan plan, long sessionId)
throws QueryProcessException, StorageGroupNotSetException, StorageEngineException {
org.apache.iotdb.service.rpc.thrift.TSStatus status =
- serviceProvider.checkAuthority(plan, sessionId);
+ SESSION_MANAGER.checkAuthority(plan, sessionId);
if (status == null) {
status =
- serviceProvider.executeNonQuery(plan)
+ IoTDB.serviceProvider.executeNonQuery(plan)
? RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS, "Execute successfully")
: RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
}
diff --git a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java
index 315620643e..3472c29ebf 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java
@@ -320,16 +320,6 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSOpenSessionResp openSession(TSOpenSessionReq req) throws TException {
- IoTDBConstant.ClientVersion clientVersion = parseClientVersion(req);
- BasicOpenSessionResp openSessionResp =
- serviceProvider.openSession(
- req.username, req.password, req.zoneId, req.client_protocol, clientVersion);
- TSStatus tsStatus = RpcUtils.getStatus(openSessionResp.getCode(), openSessionResp.getMessage());
- TSOpenSessionResp resp = new TSOpenSessionResp(tsStatus, CURRENT_RPC_VERSION);
- return resp.setSessionId(openSessionResp.getSessionId());
- }
-
- public TSOpenSessionResp openSessionV2(TSOpenSessionReq req) throws TException {
IoTDBConstant.ClientVersion clientVersion = parseClientVersion(req);
BasicOpenSessionResp openSessionResp =
SESSION_MANAGER.openSession(
@@ -349,13 +339,6 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus closeSession(TSCloseSessionReq req) {
- return new TSStatus(
- !serviceProvider.closeSession(req.sessionId)
- ? RpcUtils.getStatus(TSStatusCode.NOT_LOGIN_ERROR)
- : RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS));
- }
-
- public TSStatus closeSessionV2(TSCloseSessionReq req) {
return new TSStatus(
!SESSION_MANAGER.closeSession(req.sessionId)
? RpcUtils.getStatus(TSStatusCode.NOT_LOGIN_ERROR)
@@ -370,7 +353,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus closeOperation(TSCloseOperationReq req) {
- return serviceProvider.closeOperation(
+ return SESSION_MANAGER.closeOperation(
req.sessionId, req.queryId, req.statementId, req.isSetStatementId(), req.isSetQueryId());
}
@@ -378,7 +361,7 @@ public class TSServiceImpl implements TSIService.Iface {
public TSFetchMetadataResp fetchMetadata(TSFetchMetadataReq req) {
TSFetchMetadataResp resp = new TSFetchMetadataResp();
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return resp.setStatus(getNotLoggedInStatus());
}
@@ -524,7 +507,7 @@ public class TSServiceImpl implements TSIService.Iface {
long t1 = System.currentTimeMillis();
List<TSStatus> result = new ArrayList<>();
boolean isAllSuccessful = true;
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -556,7 +539,7 @@ public class TSServiceImpl implements TSIService.Iface {
index = 0;
}
- TSStatus status = serviceProvider.checkAuthority(physicalPlan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(physicalPlan, req.getSessionId());
if (status != null) {
insertRowsPlan.getResults().put(index, status);
isAllSuccessful = false;
@@ -578,7 +561,7 @@ public class TSServiceImpl implements TSIService.Iface {
multiPlan = new CreateMultiTimeSeriesPlan();
executeList.add(multiPlan);
}
- TSStatus status = serviceProvider.checkAuthority(physicalPlan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(physicalPlan, req.getSessionId());
if (status != null) {
multiPlan.getResults().put(i, status);
isAllSuccessful = false;
@@ -630,7 +613,7 @@ public class TSServiceImpl implements TSIService.Iface {
public TSExecuteStatementResp executeStatement(TSExecuteStatementReq req) {
String statement = req.getStatement();
try {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return RpcUtils.getTSExecuteStatementResp(getNotLoggedInStatus());
}
@@ -668,7 +651,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSExecuteStatementResp executeQueryStatement(TSExecuteStatementReq req) {
try {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return RpcUtils.getTSExecuteStatementResp(getNotLoggedInStatus());
}
@@ -704,7 +687,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSExecuteStatementResp executeRawDataQuery(TSRawDataQueryReq req) {
try {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return RpcUtils.getTSExecuteStatementResp(getNotLoggedInStatus());
}
@@ -750,7 +733,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSExecuteStatementResp executeLastDataQuery(TSLastDataQueryReq req) {
try {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return RpcUtils.getTSExecuteStatementResp(getNotLoggedInStatus());
}
@@ -824,7 +807,7 @@ public class TSServiceImpl implements TSIService.Iface {
List<? extends PartialPath> authPaths = plan.getAuthPaths();
if (authPaths != null
&& !authPaths.isEmpty()
- && !serviceProvider.checkAuthorization(plan, username)) {
+ && !SESSION_MANAGER.checkAuthorization(plan, username)) {
return RpcUtils.getTSExecuteStatementResp(
RpcUtils.getStatus(
TSStatusCode.NO_PERMISSION_ERROR,
@@ -946,7 +929,7 @@ public class TSServiceImpl implements TSIService.Iface {
long sessionId)
throws IoTDBException, TException, SQLException, IOException, InterruptedException,
QueryFilterOptimizationException {
- TSStatus status = serviceProvider.checkAuthority(physicalPlan, sessionId);
+ TSStatus status = SESSION_MANAGER.checkAuthority(physicalPlan, sessionId);
if (status != null) {
return new TSExecuteStatementResp(status);
}
@@ -1002,7 +985,7 @@ public class TSServiceImpl implements TSIService.Iface {
InsertMultiTabletPlan insertMultiTabletPlan = new InsertMultiTabletPlan();
for (int i = 0; i < insertTabletPlans.size(); i++) {
InsertTabletPlan insertTabletPlan = insertTabletPlans.get(i);
- TSStatus status = serviceProvider.checkAuthority(insertTabletPlan, sessionId);
+ TSStatus status = SESSION_MANAGER.checkAuthority(insertTabletPlan, sessionId);
if (status != null) {
// not authorized
@@ -1018,7 +1001,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSFetchResultsResp fetchResults(TSFetchResultsReq req) {
try {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return RpcUtils.getTSFetchResultsResp(getNotLoggedInStatus());
}
@@ -1084,7 +1067,7 @@ public class TSServiceImpl implements TSIService.Iface {
/** update statement can be: 1. select-into statement 2. non-query statement */
@Override
public TSExecuteStatementResp executeUpdateStatement(TSExecuteStatementReq req) {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return RpcUtils.getTSExecuteStatementResp(getNotLoggedInStatus());
}
@@ -1135,7 +1118,7 @@ public class TSServiceImpl implements TSIService.Iface {
}
private TSExecuteStatementResp executeNonQueryStatement(PhysicalPlan plan, long sessionId) {
- TSStatus status = serviceProvider.checkAuthority(plan, sessionId);
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, sessionId);
return status != null
? new TSExecuteStatementResp(status)
: RpcUtils.getTSExecuteStatementResp(executeNonQueryPlan(plan))
@@ -1204,7 +1187,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus insertRecords(TSInsertRecordsReq req) {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -1226,7 +1209,7 @@ public class TSServiceImpl implements TSIService.Iface {
req.getMeasurementsList().get(i).toArray(new String[0]),
req.valuesList.get(i),
req.isAligned);
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
if (status != null) {
insertRowsPlan.getResults().put(i, status);
allCheckSuccess = false;
@@ -1276,7 +1259,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus insertRecordsOfOneDevice(TSInsertRecordsOfOneDeviceReq req) {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -1297,7 +1280,7 @@ public class TSServiceImpl implements TSIService.Iface {
req.getMeasurementsList(),
req.getValuesList(),
req.isAligned);
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
statusList.add(status != null ? status : executeNonQueryPlan(plan));
} catch (IoTDBException e) {
statusList.add(
@@ -1322,7 +1305,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus insertStringRecordsOfOneDevice(TSInsertStringRecordsOfOneDeviceReq req) {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -1345,7 +1328,7 @@ public class TSServiceImpl implements TSIService.Iface {
plan.setDataTypes(new TSDataType[plan.getMeasurements().length]);
plan.setNeedInferType(true);
plan.setAligned(req.isAligned);
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
if (status != null) {
insertRowsPlan.getResults().put(i, status);
@@ -1380,7 +1363,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus insertStringRecords(TSInsertStringRecordsReq req) {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -1403,7 +1386,7 @@ public class TSServiceImpl implements TSIService.Iface {
plan.setDataTypes(new TSDataType[plan.getMeasurements().length]);
plan.setNeedInferType(true);
plan.setAligned(req.isAligned);
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
if (status != null) {
insertRowsPlan.getResults().put(i, status);
@@ -1494,7 +1477,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus insertRecord(TSInsertRecordReq req) {
try {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -1511,7 +1494,7 @@ public class TSServiceImpl implements TSIService.Iface {
req.getMeasurements().toArray(new String[0]),
req.values,
req.isAligned);
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
return status != null ? status : executeNonQueryPlan(plan);
} catch (IoTDBException e) {
return onIoTDBException(e, OperationType.INSERT_RECORD, e.getErrorCode());
@@ -1547,7 +1530,7 @@ public class TSServiceImpl implements TSIService.Iface {
"");
// TODO(INSERT) do this check in analyze
- // TSStatus status = serviceProvider.checkAuthority(insertTabletPlan,
+ // TSStatus status = SESSION_MANAGER.checkAuthority(insertTabletPlan,
// req.getSessionId());
return result.status;
} catch (Exception e) {
@@ -1561,7 +1544,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus insertStringRecord(TSInsertStringRecordReq req) {
try {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -1579,7 +1562,7 @@ public class TSServiceImpl implements TSIService.Iface {
plan.setValues(req.getValues().toArray(new Object[0]));
plan.setNeedInferType(true);
plan.setAligned(req.isAligned);
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
return status != null ? status : executeNonQueryPlan(plan);
} catch (IoTDBException e) {
return onIoTDBException(e, OperationType.INSERT_STRING_RECORD, e.getErrorCode());
@@ -1592,7 +1575,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus deleteData(TSDeleteDataReq req) {
try {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -1604,7 +1587,7 @@ public class TSServiceImpl implements TSIService.Iface {
paths.add(new PartialPath(path));
}
plan.addPaths(paths);
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
return status != null ? new TSStatus(status) : new TSStatus(executeNonQueryPlan(plan));
} catch (IoTDBException e) {
@@ -1619,7 +1602,7 @@ public class TSServiceImpl implements TSIService.Iface {
public TSStatus insertTablet(TSInsertTabletReq req) {
long t1 = System.currentTimeMillis();
try {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -1634,7 +1617,7 @@ public class TSServiceImpl implements TSIService.Iface {
insertTabletPlan.setRowCount(req.size);
insertTabletPlan.setDataTypes(req.types);
insertTabletPlan.setAligned(req.isAligned);
- TSStatus status = serviceProvider.checkAuthority(insertTabletPlan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(insertTabletPlan, req.getSessionId());
return status != null ? status : executeNonQueryPlan(insertTabletPlan);
} catch (IoTDBException e) {
@@ -1669,7 +1652,7 @@ public class TSServiceImpl implements TSIService.Iface {
"");
// TODO(INSERT) do this check in analyze
- // TSStatus status = serviceProvider.checkAuthority(insertTabletPlan,
+ // TSStatus status = SESSION_MANAGER.checkAuthority(insertTabletPlan,
// req.getSessionId());
return result.status;
} catch (Exception e) {
@@ -1684,7 +1667,7 @@ public class TSServiceImpl implements TSIService.Iface {
public TSStatus insertTablets(TSInsertTabletsReq req) {
long t1 = System.currentTimeMillis();
try {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -1729,7 +1712,7 @@ public class TSServiceImpl implements TSIService.Iface {
InsertMultiTabletPlan insertMultiTabletPlan = new InsertMultiTabletPlan();
for (int i = 0; i < req.prefixPaths.size(); i++) {
InsertTabletPlan insertTabletPlan = constructInsertTabletPlan(req, i);
- TSStatus status = serviceProvider.checkAuthority(insertTabletPlan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(insertTabletPlan, req.getSessionId());
if (status != null) {
// not authorized
insertMultiTabletPlan.getResults().put(i, status);
@@ -1744,12 +1727,12 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus setStorageGroup(long sessionId, String storageGroup) {
try {
- if (!serviceProvider.checkLogin(sessionId)) {
+ if (!SESSION_MANAGER.checkLogin(sessionId)) {
return getNotLoggedInStatus();
}
SetStorageGroupPlan plan = new SetStorageGroupPlan(new PartialPath(storageGroup));
- TSStatus status = serviceProvider.checkAuthority(plan, sessionId);
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, sessionId);
return status != null ? status : executeNonQueryPlan(plan);
} catch (IoTDBException e) {
@@ -1763,7 +1746,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus deleteStorageGroups(long sessionId, List<String> storageGroups) {
try {
- if (!serviceProvider.checkLogin(sessionId)) {
+ if (!SESSION_MANAGER.checkLogin(sessionId)) {
return getNotLoggedInStatus();
}
@@ -1772,7 +1755,7 @@ public class TSServiceImpl implements TSIService.Iface {
storageGroupList.add(new PartialPath(storageGroup));
}
DeleteStorageGroupPlan plan = new DeleteStorageGroupPlan(storageGroupList);
- TSStatus status = serviceProvider.checkAuthority(plan, sessionId);
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, sessionId);
return status != null ? status : executeNonQueryPlan(plan);
} catch (IoTDBException e) {
return onIoTDBException(e, OperationType.DELETE_STORAGE_GROUPS, e.getErrorCode());
@@ -1785,7 +1768,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus createTimeseries(TSCreateTimeseriesReq req) {
try {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -1804,7 +1787,7 @@ public class TSServiceImpl implements TSIService.Iface {
req.tags,
req.attributes,
req.measurementAlias);
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
return status != null ? status : executeNonQueryPlan(plan);
} catch (IoTDBException e) {
return onIoTDBException(e, OperationType.CREATE_TIMESERIES, e.getErrorCode());
@@ -1817,7 +1800,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus createAlignedTimeseries(TSCreateAlignedTimeseriesReq req) {
try {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -1863,7 +1846,7 @@ public class TSServiceImpl implements TSIService.Iface {
req.measurementAlias,
req.tagsList,
req.attributesList);
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
return status != null ? status : executeNonQueryPlan(plan);
} catch (IoTDBException e) {
return onIoTDBException(e, OperationType.CREATE_ALIGNED_TIMESERIES, e.getErrorCode());
@@ -1877,7 +1860,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus createMultiTimeseries(TSCreateMultiTimeseriesReq req) {
try {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -1915,7 +1898,7 @@ public class TSServiceImpl implements TSIService.Iface {
CreateTimeSeriesPlan plan = new CreateTimeSeriesPlan();
for (int i = 0; i < req.paths.size(); i++) {
plan.setPath(new PartialPath(req.paths.get(i)));
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
if (status != null) {
// not authorized
multiPlan.getResults().put(i, status);
@@ -1964,7 +1947,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus deleteTimeseries(long sessionId, List<String> paths) {
try {
- if (!serviceProvider.checkLogin(sessionId)) {
+ if (!SESSION_MANAGER.checkLogin(sessionId)) {
return getNotLoggedInStatus();
}
@@ -1973,7 +1956,7 @@ public class TSServiceImpl implements TSIService.Iface {
pathList.add(new PartialPath(path));
}
DeleteTimeSeriesPlan plan = new DeleteTimeSeriesPlan(pathList);
- TSStatus status = serviceProvider.checkAuthority(plan, sessionId);
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, sessionId);
return status != null ? status : executeNonQueryPlan(plan);
} catch (IoTDBException e) {
return onIoTDBException(e, OperationType.DELETE_TIMESERIES, e.getErrorCode());
@@ -1991,7 +1974,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus createSchemaTemplate(TSCreateSchemaTemplateReq req) throws TException {
try {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -2006,7 +1989,7 @@ public class TSServiceImpl implements TSIService.Iface {
// Construct plan from serialized request
ByteBuffer buffer = ByteBuffer.wrap(req.getSerializedTemplate());
plan = CreateTemplatePlan.deserializeFromReq(buffer);
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
return status != null ? status : executeNonQueryPlan(plan);
} catch (Exception e) {
@@ -2033,7 +2016,7 @@ public class TSServiceImpl implements TSIService.Iface {
AppendTemplatePlan plan =
new AppendTemplatePlan(
req.getName(), req.isAligned, measurements, dataTypes, encodings, compressionTypes);
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
return status != null ? status : executeNonQueryPlan(plan);
}
@@ -2041,7 +2024,7 @@ public class TSServiceImpl implements TSIService.Iface {
public TSStatus pruneSchemaTemplate(TSPruneSchemaTemplateReq req) {
PruneTemplatePlan plan =
new PruneTemplatePlan(req.getName(), Collections.singletonList(req.getPath()));
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
return status != null ? status : executeNonQueryPlan(plan);
}
@@ -2095,7 +2078,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus setSchemaTemplate(TSSetSchemaTemplateReq req) throws TException {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -2109,7 +2092,7 @@ public class TSServiceImpl implements TSIService.Iface {
try {
SetTemplatePlan plan = new SetTemplatePlan(req.templateName, req.prefixPath);
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
return status != null ? status : executeNonQueryPlan(plan);
} catch (IllegalPathException e) {
return onIoTDBException(e, OperationType.EXECUTE_STATEMENT, e.getErrorCode());
@@ -2118,7 +2101,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus unsetSchemaTemplate(TSUnsetSchemaTemplateReq req) throws TException {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -2132,7 +2115,7 @@ public class TSServiceImpl implements TSIService.Iface {
try {
UnsetTemplatePlan plan = new UnsetTemplatePlan(req.prefixPath, req.templateName);
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
return status != null ? status : executeNonQueryPlan(plan);
} catch (IllegalPathException e) {
return onIoTDBException(e, OperationType.EXECUTE_STATEMENT, e.getErrorCode());
@@ -2141,7 +2124,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSStatus dropSchemaTemplate(TSDropSchemaTemplateReq req) throws TException {
- if (!serviceProvider.checkLogin(req.getSessionId())) {
+ if (!SESSION_MANAGER.checkLogin(req.getSessionId())) {
return getNotLoggedInStatus();
}
@@ -2153,7 +2136,7 @@ public class TSServiceImpl implements TSIService.Iface {
}
DropTemplatePlan plan = new DropTemplatePlan(req.templateName);
- TSStatus status = serviceProvider.checkAuthority(plan, req.getSessionId());
+ TSStatus status = SESSION_MANAGER.checkAuthority(plan, req.getSessionId());
return status != null ? status : executeNonQueryPlan(plan);
}