[ https://issues.apache.org/jira/browse/PHOENIX-3663?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15883451#comment-15883451 ]
James Taylor commented on PHOENIX-3663: --------------------------------------- Patch looks good, [~gjacoby]. One minor issue: - Instead of instantiating a SQLException directly, create a new enum in SQLExceptionCode and use SQLExceptionInfo.Builder to create it: {code} @Override public void addConnection(PhoenixConnection connection) throws SQLException { - connectionQueues.get(getQueueIndex(connection)).add(new WeakReference<PhoenixConnection>(connection)); - if (returnSequenceValues) { + if (returnSequenceValues || shouldThrottleNumConnections) { synchronized (connectionCountLock) { + if (shouldThrottleNumConnections && connectionCount + 1 > maxConnectionsAllowed){ + GLOBAL_PHOENIX_CONNECTIONS_THROTTLED_COUNTER.increment(); + throw new SQLException(String.format("Could not create connection " + + "because this client already has the maximum number" + + " of %d connections to the target cluster.", maxConnectionsAllowed)); + } + {code} Something like this: {code} throw new SQLExceptionInfo.Builder(SQLExceptionCode.MAX_CONNECTIONS_EXCEEDED) .setMessage("Maximum connections = " + maxConnectionsAllowed) .build().buildException(); {code} That way it'll have a unique error code that clients can match against. You could optionally create a new class derived from SQLException if we think it's likely that clients might catch this exception. You'd then instantiate the class in SQLExceptionCode (see other examples there). > Implement resource controls in Phoenix JDBC driver > -------------------------------------------------- > > Key: PHOENIX-3663 > URL: https://issues.apache.org/jira/browse/PHOENIX-3663 > Project: Phoenix > Issue Type: New Feature > Affects Versions: 4.9.0 > Reporter: Geoffrey Jacoby > Assignee: Geoffrey Jacoby > Attachments: PHOENIX-3663.patch > > > It would be very useful for service protection to be able to limit how many > Phoenix connections a particular client machine can request at one time. > This feature should be optional, and default to off for backwards > compatibility. -- This message was sent by Atlassian JIRA (v6.3.15#6346)