DRILL-5485: Remove WebServer dependency on DrillClient#829
DRILL-5485: Remove WebServer dependency on DrillClient#829sohami wants to merge 4 commits intoapache:masterfrom
Conversation
d90af9e to
503f861
Compare
| import java.util.concurrent.CountDownLatch; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| public abstract class AbstractUserClientConnectionWrapper implements UserClientConnection { |
There was a problem hiding this comment.
Add some doc about how instances of sub-classes can only be used once.
And this classes itself doesn't wrap.. How about AbstractDisposableUserClientConnection?
| * @param listener | ||
| * @param result | ||
| */ | ||
| void sendResult(RpcOutcomeListener<GeneralRPCProtos.Ack> listener, UserBitShared.QueryResult result); |
There was a problem hiding this comment.
Add imports for inner classes, here and everywhere else.
| .setUserName(sessionUserPrincipal.getName()) | ||
| .build()) | ||
| .withOptionManager(drillbitContext.getOptionManager()) | ||
| .setSupportComplexTypes(drillbitContext.getConfig().getBoolean(ExecConstants.CLIENT_SUPPORT_COMPLEX_TYPES)) |
There was a problem hiding this comment.
This is used to check if client can handle complex types, which is not based on config. Can the web client handle complex types?
Similar call below.
There was a problem hiding this comment.
For DrillClient by default this is set as true based on the config only. I looked into the usage and based on this property in session, if false planner will introduce a project node to convert complex types to JSON string. On WebServer when data batch is received we convert each data type to it's string format (even the complex types). Hence it does support complex types since WebClient now will see all the data in Json string format and should be fine.
| public UserBitShared.QueryType getType() { | ||
| UserBitShared.QueryType type = UserBitShared.QueryType.SQL; | ||
| public QueryType getType() { | ||
| QueryType type = QueryType.SQL; |
There was a problem hiding this comment.
return QueryType.valueOf(queryType);
| } | ||
| public QueryResult run(final WorkManager workManager, final WebUserConnection webUserConnection) throws Exception { | ||
|
|
||
| final UserProtos.RunQuery runQuery = UserProtos.RunQuery.getDefaultInstance().newBuilderForType() |
There was a problem hiding this comment.
RunQuery.newBuilder().setType(...)...
| try { | ||
| // This can be slow as the underlying library will try to resolve the address | ||
| remoteAddress = new InetSocketAddress(InetAddress.getByName(request.getRemoteAddr()), request.getRemotePort()); | ||
| session.setAttribute(SocketAddress.class.getSimpleName(), remoteAddress); |
There was a problem hiding this comment.
Attributes names too generic. Maybe use: "drill-user-session", "drill-socket-address", ...?
|
|
||
| /** | ||
| * For anonymous WebUserSession it is called after each query request whereas for Authenticated WebUserSession | ||
| * it is never called. |
There was a problem hiding this comment.
Comment does not seem right. Looks to me that cleanupSession() is called after every query request, and the session resources are closed iff the user is anonymous.
| import io.netty.buffer.ByteBuf; | ||
| import io.netty.channel.ChannelFuture; | ||
| import static org.apache.drill.exec.ExecConstants.CREATE_PREPARE_STATEMENT_TIMEOUT_MILLIS; | ||
| import static org.apache.drill.exec.proto.UserProtos.RequestStatus.*; |
| return new SessionHandler(sessionManager); | ||
| } | ||
|
|
||
| private void clearSessionCustomAttributes(HttpSession session) { |
There was a problem hiding this comment.
How about encapsulating all the resources in one class (DrillWebSession)?
- Only that instance would be an attribute on a http session.
- This logic could be captured in
DrillWebSession#closemethod.
There was a problem hiding this comment.
WebUserConnection is a class which is encapsulating all the resources. I had the logic of close and cleanup in it earlier. But I Didn't set that as attribute of Http session object since in that case it will be reset for each request. Since there are not many resources which we are setting inside HttpSession and each of them are really a separate property for the session in itself, I guess keeping them separated should be fine.
There was a problem hiding this comment.
(I somehow managed to delete this in my comment..) The life cycle of those resources could be placed together in one class, as resources are being initialized in one place but closed in different places.
There was a problem hiding this comment.
Moved all the resources inside another class WebSessionResources which now manages their lifecycle.
| public class WebUserConnection extends AbstractUserClientConnectionWrapper implements ConnectionThrottle { | ||
| private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(WebUserConnection.class); | ||
|
|
||
| /** |
…roviders for Authenticated and Anonymous web users.
NOTE: Updated to store the UserSession, BufferAllocator and other session states inside the HttpSession of Jetty instead
of storing in DrillUserPrincipal. For each request now a new instance of WebUserConnection will be created. However
for authenticated users the UserSession and other states will be re-used whereas for Anonymous Users it will created
for each request and later re-cycled after query execution.
|
Seems @sohami has addressed @sudheeshkatkam 's comments. I'm going to merge this PR. +1 |
1. Added WebUserConnection/AnonWebUserConnection and their providers for Authenticated and Anonymous web users. 2. Updated to store the UserSession, BufferAllocator and other session states inside the HttpSession of Jetty instead of storing in DrillUserPrincipal. For each request now a new instance of WebUserConnection will be created. However for authenticated users the UserSession and other states will be re-used whereas for Anonymous Users it will created for each request and later re-cycled after query execution. close apache#829
No description provided.