Skip to content

Commit

Permalink
Reverted code reformat. Deencoded URLs. Reformatted log messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
estherbuchwalter committed Mar 10, 2022
1 parent 4ba4ebb commit b69bcb4
Show file tree
Hide file tree
Showing 8 changed files with 1,244 additions and 980 deletions.
42 changes: 24 additions & 18 deletions exec/java-exec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>exec-parent</artifactId>
Expand Down Expand Up @@ -422,12 +423,12 @@
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
Expand Down Expand Up @@ -810,7 +811,9 @@
<execution> <!-- copy all templates/data in the same location to compile them at once -->
<id>copy-fmpp-resources</id>
<phase>initialize</phase>
<goals><goal>copy-resources</goal></goals>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/codegen</outputDirectory>
<resources>
Expand All @@ -827,8 +830,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<!-- Extract parser grammar template from calcite-core.jar and put
it under ${project.build.directory}/codegen/templates where all freemarker templates are. -->
<!-- Extract parser grammar template from calcite-core.jar and put
it under ${project.build.directory}/codegen/templates where all freemarker templates are. -->
<execution>
<id>unpack-parser-template</id>
<phase>initialize</phase>
Expand All @@ -849,8 +852,8 @@
</configuration>
</execution>

<!-- Extract ValueVectorTypes.tdd from drill-vector.jar and put
it under ${project.build.directory}/codegen/data where all freemarker data files are. -->
<!-- Extract ValueVectorTypes.tdd from drill-vector.jar and put
it under ${project.build.directory}/codegen/data where all freemarker data files are. -->
<execution>
<id>unpack-vector-types</id>
<phase>initialize</phase>
Expand Down Expand Up @@ -881,7 +884,9 @@
<execution>
<id>generate-fmpp</id>
<phase>generate-sources</phase>
<goals><goal>generate</goal></goals>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<config>${project.build.directory}/codegen/config.fmpp</config>
<output>${project.build.directory}/generated-sources</output>
Expand All @@ -898,7 +903,9 @@
<execution>
<id>javacc</id>
<phase>generate-sources</phase>
<goals><goal>javacc</goal></goals>
<goals>
<goal>javacc</goal>
</goals>
<configuration>
<sourceDirectory>${project.build.directory}/generated-sources/</sourceDirectory>
<includes>
Expand All @@ -907,11 +914,11 @@
<lookAhead>2</lookAhead>
<isStatic>false</isStatic>
<outputDirectory>${project.build.directory}/generated-sources/</outputDirectory>
<!--
<debugParser>true</debugParser>
<debugLookAhead>true</debugLookAhead>
<debugTokenManager>true</debugTokenManager>
-->
<!--
<debugParser>true</debugParser>
<debugLookAhead>true</debugLookAhead>
<debugTokenManager>true</debugTokenManager>
-->
</configuration>
</execution>
</executions>
Expand Down Expand Up @@ -998,5 +1005,4 @@
</build>



</project>
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,9 @@
import java.util.ArrayList;
import java.util.List;

@OpenAPIDefinition(info = @Info(
title = "Apache Drill REST API", description = "OpenAPI Specification", license = @License(name = "Apache Software Foundation (ASF)", url = "http://www.apache" +
".org/licenses/LICENSE-2.0"),
contact = @Contact(name = "Apache Drill", url = "https://drill.apache.org/")
))/*,
tags = {
@Tag(name = "My Tag 1", description = "Tag 1's Description", externalDocs = @ExternalDocumentation(description = "docs description1")),
@Tag(name = "My Tag 2", description = "Tag 2's Description", externalDocs = @ExternalDocumentation(description = "docs description2"))})*/
@OpenAPIDefinition(info = @Info(title = "Apache Drill REST API", description = "OpenAPI Specification",
license = @License(name = "Apache Software Foundation (ASF)", url = "http://www.apache" + ".org/licenses/LICENSE-2.0"),
contact = @Contact(name = "Apache Drill", url = "https://drill.apache.org/")))

public class DrillRestServer extends ResourceConfig {
static final Logger logger = LoggerFactory.getLogger(DrillRestServer.class);
Expand All @@ -106,8 +101,7 @@ public DrillRestServer(final WorkManager workManager, final ServletContext servl
register(MultiPartFeature.class);
property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);

final boolean isAuthEnabled =
workManager.getContext().getConfig().getBoolean(ExecConstants.USER_AUTHENTICATION_ENABLED);
final boolean isAuthEnabled = workManager.getContext().getConfig().getBoolean(ExecConstants.USER_AUTHENTICATION_ENABLED);

if (isAuthEnabled) {
register(LogInLogOutResources.class);
Expand All @@ -116,8 +110,7 @@ public DrillRestServer(final WorkManager workManager, final ServletContext servl
}

//disable moxy so it doesn't conflict with jackson.
final String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(CommonProperties.MOXY_JSON_FEATURE_DISABLE,
getConfiguration().getRuntimeType());
final String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(CommonProperties.MOXY_JSON_FEATURE_DISABLE, getConfiguration().getRuntimeType());
property(disableMoxy, true);

register(JsonParseExceptionMapper.class);
Expand Down Expand Up @@ -204,20 +197,15 @@ public WebUserConnection provide() {
}

// User is logged in, get/set the WebSessionResources attribute
WebSessionResources webSessionResources =
(WebSessionResources) session.getAttribute(WebSessionResources.class.getSimpleName());
WebSessionResources webSessionResources = (WebSessionResources) session.getAttribute(WebSessionResources.class.getSimpleName());

if (webSessionResources == null) {
// User is login in for the first time
final DrillbitContext drillbitContext = workManager.getContext();
final DrillConfig config = drillbitContext.getConfig();
final UserSession drillUserSession = UserSession.Builder.newBuilder()
.withCredentials(UserBitShared.UserCredentials.newBuilder()
.setUserName(sessionUserPrincipal.getName())
.build())
.withOptionManager(drillbitContext.getOptionManager())
.setSupportComplexTypes(config.getBoolean(ExecConstants.CLIENT_SUPPORT_COMPLEX_TYPES))
.build();
final UserSession drillUserSession = UserSession.Builder.newBuilder().withCredentials(UserBitShared.UserCredentials.newBuilder()
.setUserName(sessionUserPrincipal.getName()).build()).withOptionManager(drillbitContext.getOptionManager())
.setSupportComplexTypes(config.getBoolean(ExecConstants.CLIENT_SUPPORT_COMPLEX_TYPES)).build();

// Only try getting remote address in first login since it's a costly operation.
SocketAddress remoteAddress = null;
Expand All @@ -232,10 +220,9 @@ public WebUserConnection provide() {

// Create per session BufferAllocator and set it in session
final String sessionAllocatorName = String.format("WebServer:AuthUserSession:%s", session.getId());
final BufferAllocator sessionAllocator = workManager.getContext().getAllocator().newChildAllocator(
sessionAllocatorName,
config.getLong(ExecConstants.HTTP_SESSION_MEMORY_RESERVATION),
config.getLong(ExecConstants.HTTP_SESSION_MEMORY_MAXIMUM));
final BufferAllocator sessionAllocator = workManager.getContext().getAllocator()
.newChildAllocator(sessionAllocatorName, config.getLong(ExecConstants.HTTP_SESSION_MEMORY_RESERVATION),
config.getLong(ExecConstants.HTTP_SESSION_MEMORY_MAXIMUM));

// Create a future which is needed by Foreman only. Foreman uses this future to add a close
// listener to known about channel close event from underlying layer. We use this future to notify Foreman
Expand All @@ -253,7 +240,8 @@ public WebUserConnection provide() {
}

@Override
public void dispose(WebUserConnection instance) { }
public void dispose(WebUserConnection instance) {
}
}

public static class AnonWebUserConnectionProvider implements Factory<WebUserConnection> {
Expand All @@ -273,21 +261,15 @@ public WebUserConnection provide() {
final DrillConfig config = drillbitContext.getConfig();

// Create an allocator here for each request
final BufferAllocator sessionAllocator = drillbitContext.getAllocator()
.newChildAllocator("WebServer:AnonUserSession",
config.getLong(ExecConstants.HTTP_SESSION_MEMORY_RESERVATION),
config.getLong(ExecConstants.HTTP_SESSION_MEMORY_MAXIMUM));
final BufferAllocator sessionAllocator = drillbitContext.getAllocator().newChildAllocator("WebServer:AnonUserSession",
config.getLong(ExecConstants.HTTP_SESSION_MEMORY_RESERVATION), config.getLong(ExecConstants.HTTP_SESSION_MEMORY_MAXIMUM));

final Principal sessionUserPrincipal = createSessionUserPrincipal(config, request);

// Create new UserSession for each request from non-authenticated user
final UserSession drillUserSession = UserSession.Builder.newBuilder()
.withCredentials(UserBitShared.UserCredentials.newBuilder()
.setUserName(sessionUserPrincipal.getName())
.build())
.withOptionManager(drillbitContext.getOptionManager())
.setSupportComplexTypes(drillbitContext.getConfig().getBoolean(ExecConstants.CLIENT_SUPPORT_COMPLEX_TYPES))
.build();
final UserSession drillUserSession = UserSession.Builder.newBuilder().withCredentials(UserBitShared.UserCredentials.newBuilder()
.setUserName(sessionUserPrincipal.getName()).build()).withOptionManager(drillbitContext.getOptionManager())
.setSupportComplexTypes(drillbitContext.getConfig().getBoolean(ExecConstants.CLIENT_SUPPORT_COMPLEX_TYPES)).build();

// Try to get the remote Address but set it to null in case of failure.
SocketAddress remoteAddress = null;
Expand All @@ -306,15 +288,15 @@ public WebUserConnection provide() {
// But we need this close future as it's expected by Foreman.
final Promise<Void> closeFuture = new DefaultPromise(executor);

final WebSessionResources webSessionResources = new WebSessionResources(sessionAllocator, remoteAddress,
drillUserSession, closeFuture);
final WebSessionResources webSessionResources = new WebSessionResources(sessionAllocator, remoteAddress, drillUserSession, closeFuture);

// Create a AnonWenUserConnection for this request
return new AnonWebUserConnection(webSessionResources);
}

@Override
public void dispose(WebUserConnection instance) { }
public void dispose(WebUserConnection instance) {
}

/**
* Creates session user principal. If impersonation is enabled without
Expand All @@ -323,7 +305,7 @@ public void dispose(WebUserConnection instance) { }
* name will be used. In both cases session user principal will have admin
* rights.
*
* @param config drill config
* @param config drill config
* @param request client request
* @return session user principal
*/
Expand All @@ -344,15 +326,17 @@ private Principal createSessionUserPrincipal(DrillConfig config, HttpServletRequ
*/
public static class DrillUserPrincipalProvider implements Factory<DrillUserPrincipal> {

@Inject HttpServletRequest request;
@Inject
HttpServletRequest request;

@Override
public DrillUserPrincipal provide() {
return (DrillUserPrincipal) request.getUserPrincipal();
}

@Override
public void dispose(DrillUserPrincipal principal) { }
public void dispose(DrillUserPrincipal principal) {
}
}

// Provider which creates and cleanups DrillUserPrincipal for anonymous (auth disabled) mode
Expand Down

0 comments on commit b69bcb4

Please sign in to comment.