Skip to content

Commit 4911447

Browse files
NIFI-14615 Added Parquet Content Viewer (#10013)
- Moved shared classes to `nifi-parquet-shared` - Reduced size of `nifi-parquet-nar` with provided scope for Hadoop libraries Co-authored-by: David Handermann <[email protected]> Signed-off-by: David Handermann <[email protected]>
1 parent a9a4338 commit 4911447

File tree

15 files changed

+786
-20
lines changed

15 files changed

+786
-20
lines changed
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<project xmlns="http://maven.apache.org/POM/4.0.0"
17+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<modelVersion>4.0.0</modelVersion>
20+
<parent>
21+
<groupId>org.apache.nifi</groupId>
22+
<artifactId>nifi-parquet-bundle</artifactId>
23+
<version>2.7.0-SNAPSHOT</version>
24+
</parent>
25+
<artifactId>nifi-parquet-content-viewer</artifactId>
26+
<packaging>war</packaging>
27+
<properties>
28+
<source.skip>true</source.skip>
29+
<standard-content-viewer.ui.working.dir>${project.build.directory}/standard-content-viewer-ui-working-directory</standard-content-viewer.ui.working.dir>
30+
</properties>
31+
<dependencies>
32+
<dependency>
33+
<groupId>org.apache.nifi</groupId>
34+
<artifactId>nifi-framework-api</artifactId>
35+
<version>2.7.0-SNAPSHOT</version>
36+
<scope>provided</scope> <!-- expected to be provided by parent classloader -->
37+
</dependency>
38+
<dependency>
39+
<groupId>org.apache.nifi</groupId>
40+
<artifactId>nifi-content-viewer-utils</artifactId>
41+
<version>2.7.0-SNAPSHOT</version>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.apache.nifi</groupId>
45+
<artifactId>nifi-web-servlet-shared</artifactId>
46+
<version>2.7.0-SNAPSHOT</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.apache.nifi</groupId>
50+
<artifactId>nifi-frontend</artifactId>
51+
<version>2.7.0-SNAPSHOT</version>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.glassfish.jersey.core</groupId>
55+
<artifactId>jersey-common</artifactId>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.apache.parquet</groupId>
59+
<artifactId>parquet-common</artifactId>
60+
<version>${parquet.version}</version>
61+
<scope>provided</scope>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.apache.parquet</groupId>
65+
<artifactId>parquet-hadoop</artifactId>
66+
<version>${parquet.version}</version>
67+
<scope>provided</scope>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.apache.parquet</groupId>
71+
<artifactId>parquet-avro</artifactId>
72+
<version>${parquet.version}</version>
73+
<scope>provided</scope>
74+
</dependency>
75+
<dependency>
76+
<groupId>org.apache.hadoop</groupId>
77+
<artifactId>hadoop-common</artifactId>
78+
<version>${hadoop.version}</version>
79+
<scope>provided</scope>
80+
<exclusions>
81+
<exclusion>
82+
<groupId>log4j</groupId>
83+
<artifactId>log4j</artifactId>
84+
</exclusion>
85+
<exclusion>
86+
<groupId>org.slf4j</groupId>
87+
<artifactId>slf4j-reload4j</artifactId>
88+
</exclusion>
89+
<exclusion>
90+
<groupId>org.slf4j</groupId>
91+
<artifactId>slf4j-log4j12</artifactId>
92+
</exclusion>
93+
<exclusion>
94+
<groupId>commons-logging</groupId>
95+
<artifactId>commons-logging</artifactId>
96+
</exclusion>
97+
</exclusions>
98+
</dependency>
99+
<dependency>
100+
<groupId>org.apache.nifi</groupId>
101+
<artifactId>nifi-parquet-shared</artifactId>
102+
<version>2.7.0-SNAPSHOT</version>
103+
<scope>provided</scope>
104+
</dependency>
105+
</dependencies>
106+
<build>
107+
<plugins>
108+
<!--
109+
Unpack the built standard content viewer front end application
110+
-->
111+
<plugin>
112+
<groupId>org.apache.maven.plugins</groupId>
113+
<artifactId>maven-dependency-plugin</artifactId>
114+
<executions>
115+
<execution>
116+
<id>unpack-standard-content-viewer-ui</id>
117+
<phase>prepare-package</phase>
118+
<goals>
119+
<goal>unpack-dependencies</goal>
120+
</goals>
121+
<configuration>
122+
<includeGroupIds>org.apache.nifi</includeGroupIds>
123+
<includeArtifactIds>nifi-frontend</includeArtifactIds>
124+
<excludeTransitive>true</excludeTransitive>
125+
<silent>false</silent>
126+
<outputDirectory>${standard-content-viewer.ui.working.dir}</outputDirectory>
127+
<includes>standard-content-viewer/**/*</includes>
128+
</configuration>
129+
</execution>
130+
</executions>
131+
</plugin>
132+
<!--
133+
Include the Standard Content Viewer UI and exclude the JAR dependency
134+
-->
135+
<plugin>
136+
<artifactId>maven-war-plugin</artifactId>
137+
<configuration>
138+
<webResources>
139+
<resource>
140+
<directory>${standard-content-viewer.ui.working.dir}/standard-content-viewer</directory>
141+
<includes>**/*</includes>
142+
<targetPath>WEB-INF/classes/static</targetPath>
143+
</resource>
144+
<resource>
145+
<directory>src/main/webapp/META-INF</directory>
146+
<targetPath>META-INF</targetPath>
147+
<includes>
148+
<include>nifi-content-viewer</include>
149+
</includes>
150+
<filtering>false</filtering>
151+
</resource>
152+
</webResources>
153+
<packagingExcludes>WEB-INF/lib/nifi-frontend*.jar</packagingExcludes>
154+
</configuration>
155+
</plugin>
156+
</plugins>
157+
</build>
158+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.nifi.parquet.web.content.viewer;
18+
19+
import jakarta.servlet.DispatcherType;
20+
import jakarta.servlet.FilterRegistration;
21+
import jakarta.servlet.ServletContext;
22+
import jakarta.servlet.ServletContextEvent;
23+
import jakarta.servlet.ServletContextListener;
24+
import jakarta.servlet.ServletRegistration;
25+
import jakarta.servlet.annotation.WebListener;
26+
import org.apache.nifi.web.servlet.filter.QueryStringToFragmentFilter;
27+
import org.apache.nifi.parquet.web.controller.ParquetContentViewerController;
28+
import org.eclipse.jetty.ee11.servlet.DefaultServlet;
29+
import org.slf4j.Logger;
30+
import org.slf4j.LoggerFactory;
31+
32+
import java.util.EnumSet;
33+
34+
/**
35+
* Servlet Context Listener supporting registration of Filters
36+
*/
37+
@WebListener
38+
public class ParquetServletContextListener implements ServletContextListener {
39+
private static final String API_CONTENT_MAPPING = "/api/content";
40+
41+
private static final int LOAD_ON_STARTUP_ENABLED = 1;
42+
43+
private static final String DIR_ALLOWED_PARAMETER = "dirAllowed";
44+
45+
private static final String BASE_RESOURCE_PARAMETER = "baseResource";
46+
47+
private static final String BASE_RESOURCE_DIRECTORY = "WEB-INF/classes/static";
48+
49+
private static final String DEFAULT_MAPPING = "/";
50+
51+
private static final Logger logger = LoggerFactory.getLogger(ParquetServletContextListener.class);
52+
53+
@Override
54+
public void contextInitialized(final ServletContextEvent sce) {
55+
final ServletContext servletContext = sce.getServletContext();
56+
final FilterRegistration.Dynamic filter = servletContext.addFilter(QueryStringToFragmentFilter.class.getSimpleName(), QueryStringToFragmentFilter.class);
57+
filter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, DEFAULT_MAPPING);
58+
59+
final ServletRegistration.Dynamic servlet = servletContext.addServlet(ParquetContentViewerController.class.getSimpleName(), ParquetContentViewerController.class);
60+
servlet.addMapping(API_CONTENT_MAPPING);
61+
servlet.setLoadOnStartup(LOAD_ON_STARTUP_ENABLED);
62+
63+
final ServletRegistration.Dynamic defaultServlet = servletContext.addServlet(DefaultServlet.class.getSimpleName(), DefaultServlet.class);
64+
defaultServlet.addMapping(DEFAULT_MAPPING);
65+
defaultServlet.setInitParameter(DIR_ALLOWED_PARAMETER, Boolean.FALSE.toString());
66+
defaultServlet.setInitParameter(BASE_RESOURCE_PARAMETER, BASE_RESOURCE_DIRECTORY);
67+
defaultServlet.setLoadOnStartup(LOAD_ON_STARTUP_ENABLED);
68+
69+
logger.info("Parquet Content Viewer Initialized");
70+
}
71+
}

0 commit comments

Comments
 (0)