From c319c9f7b43d34b1c5e8bd74e47c8dae4f848100 Mon Sep 17 00:00:00 2001 From: Kent Yao Date: Wed, 21 Oct 2020 18:19:33 +0800 Subject: [PATCH] noops --- .../kyuubi/operation/NoopOperation.scala | 42 +++++++++++ .../operation/NoopOperationManager.scala | 73 +++++++++++++++++++ .../kyuubi/session/NoopSessionImpl.scala | 34 +++++++++ .../kyuubi/session/NoopSessionManager.scala | 35 +++++++++ 4 files changed, 184 insertions(+) create mode 100644 kyuubi-common/src/test/scala/org/apache/kyuubi/operation/NoopOperation.scala create mode 100644 kyuubi-common/src/test/scala/org/apache/kyuubi/operation/NoopOperationManager.scala create mode 100644 kyuubi-common/src/test/scala/org/apache/kyuubi/session/NoopSessionImpl.scala create mode 100644 kyuubi-common/src/test/scala/org/apache/kyuubi/session/NoopSessionManager.scala diff --git a/kyuubi-common/src/test/scala/org/apache/kyuubi/operation/NoopOperation.scala b/kyuubi-common/src/test/scala/org/apache/kyuubi/operation/NoopOperation.scala new file mode 100644 index 000000000..30f57031e --- /dev/null +++ b/kyuubi-common/src/test/scala/org/apache/kyuubi/operation/NoopOperation.scala @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.kyuubi.operation + +import org.apache.hive.service.rpc.thrift.{TRowSet, TTableSchema} + +import org.apache.kyuubi.operation.FetchOrientation.FetchOrientation +import org.apache.kyuubi.session.Session + +class NoopOperation(session: Session) + extends AbstractOperation(OperationType.UNKNOWN_OPERATION, session) { + override protected def runInternal(): Unit = {} + + override protected def beforeRun(): Unit = {} + + override protected def afterRun(): Unit = {} + + override def cancel(): Unit = {} + + override def close(): Unit = {} + + override def getResultSetSchema: TTableSchema = new TTableSchema() + + override def getNextRowSet(order: FetchOrientation, rowSetSize: Int): TRowSet = new TRowSet() + + override def shouldRunAsync: Boolean = false +} diff --git a/kyuubi-common/src/test/scala/org/apache/kyuubi/operation/NoopOperationManager.scala b/kyuubi-common/src/test/scala/org/apache/kyuubi/operation/NoopOperationManager.scala new file mode 100644 index 000000000..bb61b6dfe --- /dev/null +++ b/kyuubi-common/src/test/scala/org/apache/kyuubi/operation/NoopOperationManager.scala @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.kyuubi.operation + +import org.apache.hive.service.rpc.thrift.TRowSet + +import org.apache.kyuubi.operation.FetchOrientation.FetchOrientation +import org.apache.kyuubi.session.Session + +class NoopOperationManager extends OperationManager("noop") { + override def newExecuteStatementOperation( + session: Session, + statement: String, + runAsync: Boolean, + queryTimeout: Long): Operation = new NoopOperation(session) + + override def newGetTypeInfoOperation(session: Session): Operation = new NoopOperation(session) + + override def newGetCatalogsOperation(session: Session): Operation = new NoopOperation(session) + + override def newGetSchemasOperation( + session: Session, + catalog: String, + schema: String): Operation = { + new NoopOperation(session) + } + + override def newGetTablesOperation( + session: Session, + catalogName: String, + schemaName: String, + tableName: String, + tableTypes: java.util.List[String]): Operation = { + new NoopOperation(session) + } + + override def newGetTableTypesOperation(session: Session): Operation = { + new NoopOperation(session) + } + + override def newGetColumnsOperation( + session: Session, + catalogName: String, + schemaName: String, + tableName: String, + columnName: String): Operation = new NoopOperation(session) + + override def newGetFunctionsOperation( + session: Session, + catalogName: String, + schemaName: String, + functionName: String): Operation = new NoopOperation(session) + + override def getOperationLogRowSet( + opHandle: OperationHandle, + order: FetchOrientation, + maxRows: Int): TRowSet = new TRowSet() +} diff --git a/kyuubi-common/src/test/scala/org/apache/kyuubi/session/NoopSessionImpl.scala b/kyuubi-common/src/test/scala/org/apache/kyuubi/session/NoopSessionImpl.scala new file mode 100644 index 000000000..a8b47e287 --- /dev/null +++ b/kyuubi-common/src/test/scala/org/apache/kyuubi/session/NoopSessionImpl.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.kyuubi.session + +import org.apache.hive.service.rpc.thrift.TProtocolVersion + +class NoopSessionImpl( + protocol: TProtocolVersion, + user: String, + password: String, + ipAddress: String, + conf: Map[String, String], + sessionManager: SessionManager) + extends AbstractSession(protocol, user, password, ipAddress, conf, sessionManager) { + + override def handle: SessionHandle = SessionHandle(protocol) + + override def open(): Unit = {} +} diff --git a/kyuubi-common/src/test/scala/org/apache/kyuubi/session/NoopSessionManager.scala b/kyuubi-common/src/test/scala/org/apache/kyuubi/session/NoopSessionManager.scala new file mode 100644 index 000000000..5f1756a25 --- /dev/null +++ b/kyuubi-common/src/test/scala/org/apache/kyuubi/session/NoopSessionManager.scala @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.kyuubi.session + +import org.apache.hive.service.rpc.thrift.TProtocolVersion + +import org.apache.kyuubi.operation.{NoopOperationManager, OperationManager} + +class NoopSessionManager extends SessionManager("noop") { + override val operationManager: OperationManager = new NoopOperationManager() + + override def openSession( + protocol: TProtocolVersion, + user: String, + password: String, + ipAddress: String, + conf: Map[String, String]): SessionHandle = { + new NoopSessionImpl(protocol, user, password, ipAddress, conf, this).handle + } +}