mgaido91 commented on a change in pull request #284: [LIVY-752][THRIFT] Fix implementation
of limits on connections.
URL: https://github.com/apache/incubator-livy/pull/284#discussion_r389981352
##########
File path: thriftserver/server/src/main/scala/org/apache/livy/thriftserver/LivyThriftSessionManager.scala
##########
@@ -412,37 +413,24 @@ class LivyThriftSessionManager(val server: LivyThriftServer, val livyConf:
LivyC
}
}
- // Taken from Hive
- @throws[HiveSQLException]
- private def incrementConnections(
- username: String,
- ipAddress: String,
- forwardedAddresses: util.List[String]): Unit = {
- val clientIpAddress: String = getOriginClientIpAddress(ipAddress, forwardedAddresses)
- val violation = anyViolations(username, clientIpAddress)
- // increment the counters only when there are no violations
- if (violation.isEmpty) {
- if (trackConnectionsPerUser(username)) incrementConnectionsCount(username)
- if (trackConnectionsPerIpAddress(clientIpAddress)) incrementConnectionsCount(clientIpAddress)
- if (trackConnectionsPerUserIpAddress(username, clientIpAddress)) {
- incrementConnectionsCount(username + ":" + clientIpAddress)
- }
- } else {
- error(violation.get)
- throw new HiveSQLException(violation.get)
- }
+ private def incrementConnectionsCount(key: String): Long = {
+ // Increment the count, returning the new value.
+ val count = connectionsCount.putIfAbsent(key, new AtomicLong(1L))
+ if (count != null) count.incrementAndGet()
Review comment:
nit: we usually always put the `{`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
|