Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring maha dependencies into current decade. #1078

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions api-example/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM jetty:9.4.18-jre8-alpine
FROM jetty:12-jdk21

ADD target/maha-api-example-*.war /var/lib/jetty/webapps/mahademo.war
EXPOSE 8080
ENTRYPOINT java -jar $JETTY_HOME/start.jar
COPY --chown=jetty:jetty target/maha-api-example-*.war /var/lib/jetty/webapps/ROOT.war
COPY jetty-logging.properties /var/lib/jetty/resources/
RUN java -jar /usr/local/jetty/start.jar --add-modules=server,http,ee10-deploy
11 changes: 11 additions & 0 deletions api-example/jetty-logging.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Set logging levels from: ALL, TRACE, DEBUG, INFO, WARN, ERROR, OFF
org.eclipse.jetty.LEVEL=DEBUG
## Configure a level for an arbitrary logger tree
#com.example.LEVEL=INFO
## Configure a level for specific logger
#com.example.MyComponent.LEVEL=INFO
## Configure JMX Context Name
# org.eclipse.jetty.logging.jmx.context=JettyServer
## Hide stacks traces in an arbitrary logger tree
#com.example.STACKS=false
com.LEVEL=DEBUG
90 changes: 26 additions & 64 deletions api-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
<url>http://maven.apache.org</url>

<properties>
<jersey.version>2.27</jersey.version>
<jetty.version>9.4.48.v20220622</jetty.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -105,11 +103,6 @@
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
Expand Down Expand Up @@ -162,7 +155,7 @@
<!-- Spring dependencies.. -->
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring4</artifactId>
<artifactId>jersey-spring6</artifactId>
<version>${jersey.version}</version>
<exclusions>
<exclusion>
Expand Down Expand Up @@ -221,37 +214,6 @@
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<version>${jetty.version}</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
Expand Down Expand Up @@ -290,33 +252,33 @@

<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<scanIntervalSeconds>1</scanIntervalSeconds>
<webApp>
<contextPath>/mahademo</contextPath>
</webApp>
<systemProperties>
<systemProperty>
<name>org.slf4j.simpleLogger.defaultLogLevel</name>
<value>debug</value>
</systemProperty>
</systemProperties>
</configuration>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.191</version>
</dependency>
</dependencies>
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.eclipse.jetty</groupId>-->
<!-- <artifactId>jetty-maven-plugin</artifactId>-->
<!-- <version>${jetty.version}</version>-->
<!-- <configuration>-->
<!-- <scanIntervalSeconds>1</scanIntervalSeconds>-->
<!-- <webApp>-->
<!-- <contextPath>/mahademo</contextPath>-->
<!-- </webApp>-->
<!-- <systemProperties>-->
<!-- <systemProperty>-->
<!-- <name>org.slf4j.simpleLogger.defaultLogLevel</name>-->
<!-- <value>debug</value>-->
<!-- </systemProperty>-->
<!-- </systemProperties>-->
<!-- </configuration>-->
<!-- <dependencies>-->
<!-- <dependency>-->
<!-- <groupId>com.h2database</groupId>-->
<!-- <artifactId>h2</artifactId>-->
<!-- <version>${h2.version}</version>-->
<!-- </dependency>-->
<!-- </dependencies>-->
<!-- </plugin>-->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<version>3.4.0</version>
<configuration>
<attachClasses>true</attachClasses>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ object ExampleMahaService extends Logging {

val insertSql =
"""
INSERT INTO student_grade_sheet (year, section_id, student_id, class_id, total_marks, date, comment)
INSERT INTO student_grade_sheet (myyear, section_id, student_id, class_id, total_marks, mydate, mycomment)
VALUES (?, ?, ?, ?, ?, ?, ?)
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class SampleFactSchemaRegistrationFactory extends FactRegistrationFactory {
DimCol("class_id", IntType(), annotations = Set(PrimaryKey))
, DimCol("student_id", IntType(), annotations = Set(ForeignKey("student")))
, DimCol("section_id", IntType(3))
, DimCol("year", IntType(3, (Map(1 -> "Freshman", 2 -> "Sophomore", 3 -> "Junior", 4 -> "Senior"), "Other")))
, DimCol("comment", StrType(), annotations = Set(EscapingRequired))
, DimCol("date", DateType())
, DimCol("myyear", IntType(3, (Map(1 -> "Freshman", 2 -> "Sophomore", 3 -> "Junior", 4 -> "Senior"), "Other")))
, DimCol("mycomment", StrType(), annotations = Set(EscapingRequired))
, DimCol("mydate", DateType())
),
Set(
FactCol("total_marks", IntType())
Expand All @@ -54,9 +54,9 @@ class SampleFactSchemaRegistrationFactory extends FactRegistrationFactory {
PubCol("class_id", "Class ID", InNotInEqualityNotEquals),
PubCol("student_id", "Student ID", InNotInEqualityNotEquals),
PubCol("section_id", "Section ID", InNotInEqualityNotEquals),
PubCol("date", "Day", InNotInBetweenEqualityNotEqualsGreaterLesser),
PubCol("year", "Year", InNotInBetweenEqualityNotEqualsGreaterLesser),
PubCol("comment", "Remarks", InEqualityLike)
PubCol("mydate", "Day", InNotInBetweenEqualityNotEqualsGreaterLesser),
PubCol("myyear", "Year", InNotInBetweenEqualityNotEqualsGreaterLesser),
PubCol("mycomment", "Remarks", InEqualityLike)
),
Set(
PublicFactCol("total_marks", "Total Marks", InNotInBetweenEqualityNotEqualsGreaterLesser),
Expand Down
2 changes: 1 addition & 1 deletion api-example/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<servlet-name>jersey-servlet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-name>jakarta.ws.rs.Application</param-name>
<param-value>com.yahoo.maha.api.jersey.MahaResourceConfig</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
Expand Down
2 changes: 1 addition & 1 deletion api-example/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<logger name="com.yahoo.maha.core" level="ERROR"/>
<logger name="com.yahoo.maha.executor" level="ERROR"/>

<root level="INFO">
<root level="DEBUG">
<appender-ref ref="ASYNCFILE" />
<appender-ref ref="ASYNCSTDOUT" />
</root>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.yahoo.maha.api.example

import com.yahoo.maha.service.calcite.avatica.MahaAvaticaService
import jakarta.ws.rs.core.MediaType
import com.yahoo.maha.service.utils.MahaConstants
import junit.framework.TestCase.assertNotNull
import org.apache.calcite.avatica.proto.Common.WireMessage
import org.apache.http.client.methods.{HttpGet, HttpPost}
import org.apache.http.entity.{ByteArrayEntity, StringEntity}
import org.apache.http.impl.client.{CloseableHttpClient, HttpClientBuilder}
import org.apache.http.util.EntityUtils
import org.apache.http.{HttpEntity, HttpHeaders, HttpResponse}
import org.apache.log4j.MDC
import org.eclipse.jetty.ee10.webapp.WebAppContext
import org.eclipse.jetty.server.Server
import org.junit.Assert.assertEquals
import org.junit._
class ExampleResourceTest {
@Test
def successfulCubesEndpoint() {
assertNotNull("jetty must be initialised", ExampleResourceTest.server)
val httpClient: CloseableHttpClient = HttpClientBuilder.create().build()
val httpGet: HttpGet = new HttpGet("http://localhost:7875/appName/registry/student/cubes")
val httpResponse: HttpResponse = httpClient.execute(httpGet)
assertEquals("should return status 200", 200, httpResponse.getStatusLine.getStatusCode)
val cubesJson: String = EntityUtils.toString(httpResponse.getEntity)
assert(cubesJson.equals("""["student_performance"]"""))

}

@Test
def successfulDomainEndpoint() {
assertNotNull("jetty must be initialised", ExampleResourceTest.server)
val httpClient: CloseableHttpClient = HttpClientBuilder.create().build()
val httpGet: HttpGet = new HttpGet("http://localhost:7875/appName/registry/student/domain")
val httpResponse: HttpResponse = httpClient.execute(httpGet)
assertEquals("should return status 200", 200, httpResponse.getStatusLine.getStatusCode)
val domainJson: String = EntityUtils.toString(httpResponse.getEntity)
val expected: String = """{"dimensions":[{"name":"student","fields":["Student ID","Student Name","Student Status"],"fieldsWithSchemas":[{"name":"Student ID","allowedSchemas":[]},{"name":"Student Name","allowedSchemas":[]},{"name":"Student Status","allowedSchemas":[]}]}],"schemas":{"student":["student_performance"]},"cubes":[{"name":"student_performance","mainEntityIds":{"student":"Student ID"},"maxDaysLookBack":[{"requestType":"SyncRequest","grain":"DailyGrain","days":9999},{"requestType":"AsyncRequest","grain":"DailyGrain","days":9999}],"maxDaysWindow":[{"requestType":"SyncRequest","grain":"DailyGrain","days":20},{"requestType":"AsyncRequest","grain":"DailyGrain","days":20},{"requestType":"SyncRequest","grain":"HourlyGrain","days":20},{"requestType":"AsyncRequest","grain":"HourlyGrain","days":20}],"fields":[{"field":"Class ID","type":"Dimension","dataType":{"type":"Number","constraint":null},"dimensionName":null,"filterable":true,"filterOperations":["IN","NOT IN","=","<>"],"required":false,"filteringRequired":false,"incompatibleColumns":null,"isImageColumn":false,"allowedSchemas":null},{"field":"Day","type":"Dimension","dataType":{"type":"Date","constraint":null},"dimensionName":null,"filterable":true,"filterOperations":["IN","<>","=","<","BETWEEN",">","NOT IN"],"required":false,"filteringRequired":false,"incompatibleColumns":null,"isImageColumn":false,"allowedSchemas":null},{"field":"Remarks","type":"Dimension","dataType":{"type":"String","constraint":null},"dimensionName":null,"filterable":true,"filterOperations":["IN","=","LIKE"],"required":false,"filteringRequired":false,"incompatibleColumns":null,"isImageColumn":false,"allowedSchemas":null},{"field":"Section ID","type":"Dimension","dataType":{"type":"Number","constraint":"3"},"dimensionName":null,"filterable":true,"filterOperations":["IN","NOT IN","=","<>"],"required":false,"filteringRequired":false,"incompatibleColumns":null,"isImageColumn":false,"allowedSchemas":null},{"field":"Student ID","type":"Dimension","dataType":{"type":"Number","constraint":null},"dimensionName":"student","filterable":true,"filterOperations":["IN","NOT IN","=","<>"],"required":false,"filteringRequired":false,"incompatibleColumns":null,"isImageColumn":false,"allowedSchemas":null},{"field":"Year","type":"Dimension","dataType":{"type":"Enum","constraint":"Freshman|Junior|Senior|Sophomore"},"dimensionName":null,"filterable":true,"filterOperations":["IN","<>","=","<","BETWEEN",">","NOT IN"],"required":false,"filteringRequired":false,"incompatibleColumns":null,"isImageColumn":false,"allowedSchemas":null},{"field":"Marks Obtained","type":"Fact","dataType":{"type":"Number","constraint":null},"dimensionName":null,"filterable":true,"filterOperations":["IN","<>","=","<","BETWEEN",">","NOT IN"],"required":false,"filteringRequired":false,"rollupExpression":"SumRollup","incompatibleColumns":null,"allowedSchemas":null},{"field":"Performance Factor","type":"Fact","dataType":{"type":"Number","constraint":"10"},"dimensionName":null,"filterable":true,"filterOperations":["IN","<>","=","<","BETWEEN",">","NOT IN"],"required":false,"filteringRequired":false,"rollupExpression":"SumRollup","incompatibleColumns":null,"allowedSchemas":null},{"field":"Total Marks","type":"Fact","dataType":{"type":"Number","constraint":null},"dimensionName":null,"filterable":true,"filterOperations":["IN","<>","=","<","BETWEEN",">","NOT IN"],"required":false,"filteringRequired":false,"rollupExpression":"SumRollup","incompatibleColumns":null,"allowedSchemas":null}]}]}"""
println(domainJson)
println(expected)
assert(domainJson.contains(expected))
}
}

object ExampleResourceTest {
var server: Server = null

@BeforeClass
def startJetty() {
// user params for kafka logging and bucketing
MDC.put(MahaConstants.REQUEST_ID, "123Request")
MDC.put(MahaConstants.USER_ID, "abc")

server = new Server(7875)
server.setStopAtShutdown(true)
val webAppContext: WebAppContext = new WebAppContext()
webAppContext.setContextPath("/appName")
webAppContext.setBaseResourceAsString("src/main/webapp")
webAppContext.setClassLoader(getClass().getClassLoader())
server.setHandler(webAppContext)
server.start()
}

@AfterClass
def stopJetty() {
server.stop()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ExampleTest extends AnyFunSuite {
test("Test for Example Test") {
val mahaService = ExampleMahaService.getMahaService
val baseRequest = ExampleRequest.getRequest
assert(mahaService.getDomain("wiki").isDefined)
//assert(mahaService.getDomain("wiki").isDefined)
assert(mahaService.getDomain("student").isDefined)
}

Expand Down
74 changes: 46 additions & 28 deletions api-jersey/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
<url>http://maven.apache.org</url>

<properties>
<jersey.version>2.27</jersey.version>
<jetty.version>9.4.35.v20201120</jetty.version>

</properties>

<dependencies>
Expand Down Expand Up @@ -109,6 +108,25 @@
<artifactId>grizzled-slf4j_${scala.major.version}</artifactId>
</dependency>

<!-- https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>${jakarta.servlet.api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>${jakarta.ws.rs-api.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jetty-servlet</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
Expand Down Expand Up @@ -146,7 +164,7 @@
<!-- Spring dependencies.. -->
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring4</artifactId>
<artifactId>jersey-spring6</artifactId>
<version>${jersey.version}</version>
<exclusions>
<exclusion>
Expand Down Expand Up @@ -210,31 +228,31 @@
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<version>${jetty.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.eclipse.jetty</groupId>-->
<!-- <artifactId>jetty-webapp</artifactId>-->
<!-- <version>${jetty.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.eclipse.jetty</groupId>-->
<!-- <artifactId>jetty-servlet</artifactId>-->
<!-- <version>${jetty.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.eclipse.jetty</groupId>-->
<!-- <artifactId>jetty-util</artifactId>-->
<!-- <version>${jetty.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.eclipse.jetty</groupId>-->
<!-- <artifactId>jetty-servlets</artifactId>-->
<!-- <version>${jetty.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.eclipse.jetty</groupId>-->
<!-- <artifactId>jetty-http</artifactId>-->
<!-- <version>${jetty.version}</version>-->
<!-- </dependency>-->

<dependency>
<groupId>ch.qos.logback</groupId>
Expand Down
Loading