Skip to content

Commit

Permalink
Enable Cassandra for JDK11
Browse files Browse the repository at this point in the history
  • Loading branch information
Reamer committed Oct 13, 2022
1 parent bf5c666 commit 4ba0dbc
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 67 deletions.
97 changes: 56 additions & 41 deletions cassandra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,20 @@
<description>Zeppelin cassandra support</description>

<properties>
<cassandra.driver.version>4.8.0</cassandra.driver.version>
<snappy.version>1.1.7.3</snappy.version>
<lz4.version>1.7.0</lz4.version>
<scalate.version>1.7.1</scalate.version>
<cassandra.driver.version>4.14.1</cassandra.driver.version>
<snappy.version>1.1.8.4</snappy.version>
<lz4.version>1.8.0</lz4.version>
<scalate.version>1.9.8</scalate.version>

<!-- test library versions -->
<jna.version>4.2.0</jna.version>
<jna.version>5.12.1</jna.version>
<cassandra.unit.version>4.3.1.0</cassandra.unit.version>
<scalecheck.version>1.17.0</scalecheck.version>

<scala.version>${scala.2.12.version}</scala.version>
<scala.binary.version>2.12</scala.binary.version>
<scala.parser.combinators>1.1.2</scala.parser.combinators>
<cassandra.scalatest.version>3.2.0-SNAP10</cassandra.scalatest.version>

<interpreter.name>cassandra</interpreter.name>
</properties>
Expand Down Expand Up @@ -100,13 +106,6 @@
<scope>runtime</scope>
</dependency>

<!-- we'll switch back to it after removing support for Scala 2.10
<dependency>
<groupId>org.scala-lang.modules</groupId>
<artifactId>scala-java8-compat_${scala.binary.version}</artifactId>
<version>${scala.java8.compat.version}</version>
</dependency> -->

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand All @@ -118,11 +117,24 @@
<version>${scalate.version}</version>
</dependency>

<dependency>
<groupId>org.scala-lang.modules</groupId>
<artifactId>scala-parser-combinators_${scala.binary.version}</artifactId>
<version>${scala.parser.combinators}</version>
</dependency>

<!-- test libraries -->
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.binary.version}</artifactId>
<version>${scalatest.version}</version>
<version>${cassandra.scalatest.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.scalacheck</groupId>
<artifactId>scalacheck_${scala.binary.version}</artifactId>
<version>${scalecheck.version}</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -158,6 +170,7 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand All @@ -174,30 +187,50 @@
<plugins>
<!-- Plugin to compile Scala code -->
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<id>eclipse-add-source</id>
<goals>
<goal>compile</goal>
<goal>add-source</goal>
</goals>
<phase>compile</phase>
</execution>
<execution>
<id>test-compile</id>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>testCompile</goal>
<goal>compile</goal>
</goals>
<phase>test-compile</phase>
</execution>
<execution>
<phase>process-resources</phase>
<id>scala-test-compile-first</id>
<phase>process-test-resources</phase>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<args>
<arg>-unchecked</arg>
<arg>-deprecation</arg>
<arg>-feature</arg>
<arg>-nobootcp</arg>
</args>
<jvmArgs>
<jvmArg>-Xms1024m</jvmArg>
<jvmArg>-Xmx1024m</jvmArg>
<jvmArg>-XX:MaxMetaspaceSize=${MaxMetaspace}</jvmArg>
</jvmArgs>
<javacArgs>
<javacArg>-source</javacArg>
<javacArg>${java.version}</javacArg>
<javacArg>-target</javacArg>
<javacArg>${java.version}</javacArg>
<javacArg>-Xlint:all,-serial,-path,-options</javacArg>
</javacArgs>
</configuration>
</plugin>

<plugin>
Expand All @@ -213,24 +246,6 @@
</executions>
</plugin>

<plugin>
<groupId>org.scalatra.scalate</groupId>
<artifactId>maven-scalate-plugin_${scala.binary.version}</artifactId>
<executions>
<execution>
<id>compile</id>
<phase>process-classes</phase>
<goals>
<goal>precompile</goal>
</goals>
<configuration>
<resourcesSourceDirectory>${basedir}/src/main/resources/scalate</resourcesSourceDirectory>
<contextClass>org.fusesource.scalate.DefaultRenderContext</contextClass>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class InterpreterLogic(val session: CqlSession, val properties: Properties) {
findInAngularRepository(variable) match {
case Some(value) => statement.replaceAll(escapedExp,value.toString)
case None =>
val value = context.getGui.input(variable, defaultVal)
val value = context.getGui.textbox(variable, defaultVal)
statement.replaceAll(escapedExp, value.toString)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;

import org.apache.commons.io.IOUtils;
import org.apache.zeppelin.display.AngularObjectRegistry;
import org.apache.zeppelin.display.GUI;
import org.apache.zeppelin.interpreter.Interpreter;
Expand All @@ -33,10 +35,8 @@
import org.junit.Ignore;
import org.junit.Test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Properties;

Expand Down Expand Up @@ -264,7 +264,7 @@ public void should_interpret_multiple_statements_with_single_line_logged_batch()
"The Way You Are\tTears for Fears\t1983\n" +
"Primitive\tSoulfly\t2003\n");
}

@Test
public void should_throw_statement_not_having_semi_colon() {
//Given
Expand Down Expand Up @@ -834,18 +834,12 @@ private static String reformatHtml(String rawHtml) {
}

private static String readTestResource(String testResource) {
StringBuilder builder = new StringBuilder();
InputStream stream = testResource.getClass().getResourceAsStream(testResource);

try (BufferedReader br = new BufferedReader(new InputStreamReader(stream))) {
String line;
while ((line = br.readLine()) != null) {
builder.append(line).append("\n");
}
} catch (Exception ex) {
throw new RuntimeException(ex);
try {
return IOUtils.toString(
CassandraInterpreterTest.class.getResourceAsStream(testResource),
StandardCharsets.UTF_8);
} catch (IOException ex) {
throw new RuntimeException(ex);
}

return builder.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ public void should_extract_variable_and_default_value() {
//Given
AngularObjectRegistry angularObjectRegistry = new AngularObjectRegistry("cassandra", null);
when(intrContext.getAngularObjectRegistry()).thenReturn(angularObjectRegistry);
when(intrContext.getGui().input("table", "zeppelin.demo")).thenReturn("zeppelin.demo");
when(intrContext.getGui().input("id", "'John'")).thenReturn("'John'");
when(intrContext.getGui().textbox("table", "zeppelin.demo")).thenReturn("zeppelin.demo");
when(intrContext.getGui().textbox("id", "'John'")).thenReturn("'John'");

//When
final String actual = helper.maybeExtractVariables(
Expand Down
Loading

0 comments on commit 4ba0dbc

Please sign in to comment.