[KYUUBI #1780] Log error message on REST endpoints
### _Why are the changes needed?_ closes #1780 Add error log in Rest be ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [ ] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1781 from simon824/printerror. Closes #1780 5dfaafad [simon] style 17a2a3b0 [simon] logging 2abc9c8b [simon] print error log Authored-by: simon <zhangshiming@cvte.com> Signed-off-by: Cheng Pan <chengpan@apache.org>
This commit is contained in:
parent
a4de0e67f6
commit
dd4c2fa7fc
@ -29,6 +29,7 @@ import io.swagger.v3.oas.annotations.tags.Tag
|
||||
import org.apache.hive.service.rpc.thrift._
|
||||
|
||||
import org.apache.kyuubi.KyuubiSQLException
|
||||
import org.apache.kyuubi.Logging
|
||||
import org.apache.kyuubi.events.KyuubiOperationEvent
|
||||
import org.apache.kyuubi.operation.{FetchOrientation, KyuubiOperation}
|
||||
import org.apache.kyuubi.operation.OperationHandle.parseOperationHandle
|
||||
@ -36,7 +37,7 @@ import org.apache.kyuubi.server.api.ApiRequestContext
|
||||
|
||||
@Tag(name = "Operation")
|
||||
@Produces(Array(MediaType.APPLICATION_JSON))
|
||||
private[v1] class OperationsResource extends ApiRequestContext {
|
||||
private[v1] class OperationsResource extends ApiRequestContext with Logging {
|
||||
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
@ -53,8 +54,10 @@ private[v1] class OperationsResource extends ApiRequestContext {
|
||||
val operation = fe.be.sessionManager.operationManager.getOperation(opHandle)
|
||||
KyuubiOperationEvent(operation.asInstanceOf[KyuubiOperation])
|
||||
} catch {
|
||||
case NonFatal(_) =>
|
||||
throw new NotFoundException(s"Error getting an operation event")
|
||||
case NonFatal(e) =>
|
||||
val errorMsg = "Error getting an operation event"
|
||||
error(errorMsg, e)
|
||||
throw new NotFoundException(errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,9 +81,10 @@ private[v1] class OperationsResource extends ApiRequestContext {
|
||||
}
|
||||
Response.ok().build()
|
||||
} catch {
|
||||
case NonFatal(_) =>
|
||||
throw new NotFoundException(s"Error applying ${request.action} " +
|
||||
s"for operation handle $operationHandleStr")
|
||||
case NonFatal(e) =>
|
||||
val errorMsg = s"Error applying ${request.action} for operation handle $operationHandleStr"
|
||||
error(errorMsg, e)
|
||||
throw new NotFoundException(errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,9 +120,10 @@ private[v1] class OperationsResource extends ApiRequestContext {
|
||||
c.getComment)
|
||||
}))
|
||||
} catch {
|
||||
case NonFatal(_) =>
|
||||
throw new NotFoundException(
|
||||
s"Error getting result set metadata for operation handle $operationHandleStr")
|
||||
case NonFatal(e) =>
|
||||
val errorMsg = s"Error getting result set metadata for operation handle $operationHandleStr"
|
||||
error(errorMsg, e)
|
||||
throw new NotFoundException(errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,9 +146,10 @@ private[v1] class OperationsResource extends ApiRequestContext {
|
||||
val logRowSet = rowSet.getColumns.get(0).getStringVal.getValues.asScala
|
||||
OperationLog(logRowSet, logRowSet.size)
|
||||
} catch {
|
||||
case NonFatal(_) =>
|
||||
throw new NotFoundException(
|
||||
s"Error getting operation log for operation handle $operationHandleStr")
|
||||
case NonFatal(e) =>
|
||||
val errorMsg = s"Error getting operation log for operation handle $operationHandleStr"
|
||||
error(errorMsg, e)
|
||||
throw new NotFoundException(errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,9 +194,10 @@ private[v1] class OperationsResource extends ApiRequestContext {
|
||||
})
|
||||
ResultRowSet(rows, rows.size)
|
||||
} catch {
|
||||
case NonFatal(_) =>
|
||||
throw new NotFoundException(
|
||||
s"Error getting result row set for operation handle $operationHandleStr")
|
||||
case NonFatal(e) =>
|
||||
val errorMsg = s"Error getting result row set for operation handle $operationHandleStr"
|
||||
error(errorMsg, e)
|
||||
throw new NotFoundException(errorMsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse
|
||||
import io.swagger.v3.oas.annotations.tags.Tag
|
||||
import org.apache.hive.service.rpc.thrift.{TGetInfoType, TProtocolVersion}
|
||||
|
||||
import org.apache.kyuubi.Utils.error
|
||||
import org.apache.kyuubi.Logging
|
||||
import org.apache.kyuubi.events.KyuubiEvent
|
||||
import org.apache.kyuubi.operation.OperationHandle
|
||||
import org.apache.kyuubi.server.api.ApiRequestContext
|
||||
@ -37,7 +37,7 @@ import org.apache.kyuubi.session.SessionHandle.parseSessionHandle
|
||||
|
||||
@Tag(name = "Session")
|
||||
@Produces(Array(MediaType.APPLICATION_JSON))
|
||||
private[v1] class SessionsResource extends ApiRequestContext {
|
||||
private[v1] class SessionsResource extends ApiRequestContext with Logging {
|
||||
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
@ -162,8 +162,10 @@ private[v1] class SessionsResource extends ApiRequestContext {
|
||||
request.runAsync,
|
||||
request.queryTimeout)
|
||||
} catch {
|
||||
case NonFatal(_) =>
|
||||
throw new NotFoundException(s"Error executing statement")
|
||||
case NonFatal(e) =>
|
||||
val errorMsg = "Error executing statement"
|
||||
error(errorMsg, e)
|
||||
throw new NotFoundException(errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,8 +180,10 @@ private[v1] class SessionsResource extends ApiRequestContext {
|
||||
try {
|
||||
fe.be.getTypeInfo(parseSessionHandle(sessionHandleStr))
|
||||
} catch {
|
||||
case NonFatal(_) =>
|
||||
throw new NotFoundException(s"Error getting type information")
|
||||
case NonFatal(e) =>
|
||||
val errorMsg = "Error getting type information"
|
||||
error(errorMsg, e)
|
||||
throw new NotFoundException(errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,8 +198,10 @@ private[v1] class SessionsResource extends ApiRequestContext {
|
||||
try {
|
||||
fe.be.getCatalogs(parseSessionHandle(sessionHandleStr))
|
||||
} catch {
|
||||
case NonFatal(_) =>
|
||||
throw new NotFoundException(s"Error getting catalogs")
|
||||
case NonFatal(e) =>
|
||||
val errorMsg = "Error getting catalogs"
|
||||
error(errorMsg, e)
|
||||
throw new NotFoundException(errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,7 +224,9 @@ private[v1] class SessionsResource extends ApiRequestContext {
|
||||
operationHandle
|
||||
} catch {
|
||||
case NonFatal(e) =>
|
||||
throw new NotFoundException(s"Error getting schemas", e)
|
||||
val errorMsg = "Error getting schemas"
|
||||
error(errorMsg, e)
|
||||
throw new NotFoundException(errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,8 +248,10 @@ private[v1] class SessionsResource extends ApiRequestContext {
|
||||
request.tableName,
|
||||
request.tableTypes)
|
||||
} catch {
|
||||
case NonFatal(_) =>
|
||||
throw new NotFoundException(s"Error getting tables")
|
||||
case NonFatal(e) =>
|
||||
val errorMsg = "Error getting tables"
|
||||
error(errorMsg, e)
|
||||
throw new NotFoundException(errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,8 +266,10 @@ private[v1] class SessionsResource extends ApiRequestContext {
|
||||
try {
|
||||
fe.be.getTableTypes(parseSessionHandle(sessionHandleStr))
|
||||
} catch {
|
||||
case NonFatal(_) =>
|
||||
throw new NotFoundException(s"Error getting table types")
|
||||
case NonFatal(e) =>
|
||||
val errorMsg = "Error getting table types"
|
||||
error(errorMsg, e)
|
||||
throw new NotFoundException(errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,8 +291,10 @@ private[v1] class SessionsResource extends ApiRequestContext {
|
||||
request.tableName,
|
||||
request.columnName)
|
||||
} catch {
|
||||
case NonFatal(_) =>
|
||||
throw new NotFoundException(s"Error getting columns")
|
||||
case NonFatal(e) =>
|
||||
val errorMsg = "Error getting columns"
|
||||
error(errorMsg, e)
|
||||
throw new NotFoundException(errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,8 +315,10 @@ private[v1] class SessionsResource extends ApiRequestContext {
|
||||
request.schemaName,
|
||||
request.functionName)
|
||||
} catch {
|
||||
case NonFatal(_) =>
|
||||
throw new NotFoundException(s"Error getting functions")
|
||||
case NonFatal(e) =>
|
||||
val errorMsg = "Error getting functions"
|
||||
error(errorMsg, e)
|
||||
throw new NotFoundException(errorMsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user