Skip to content

Commit

Permalink
Merge 15c2dcb into a28d17e
Browse files Browse the repository at this point in the history
  • Loading branch information
mmolimar committed Jan 20, 2020
2 parents a28d17e + 15c2dcb commit 846f8d1
Show file tree
Hide file tree
Showing 34 changed files with 1,210 additions and 546 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
language: scala
scala:
- 2.12.10
jdk:
- openjdk8
script:
- sbt clean coverage test it:test coverageReport && sbt coverageAggregate
after_success:
- sbt coveralls
- sbt coveralls
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# KSQL JDBC Driver [![Build Status](https://travis-ci.org/mmolimar/ksql-jdbc-driver.svg?branch=master)](https://travis-ci.org/mmolimar/ksql-jdbc-driver)[![Coverage Status](https://coveralls.io/repos/github/mmolimar/ksql-jdbc-driver/badge.svg?branch=master)](https://coveralls.io/github/mmolimar/ksql-jdbc-driver?branch=master)
# ksqlDB JDBC Driver [![Build Status](https://travis-ci.org/mmolimar/ksql-jdbc-driver.svg?branch=master)](https://travis-ci.org/mmolimar/ksql-jdbc-driver)[![Coverage Status](https://coveralls.io/repos/github/mmolimar/ksql-jdbc-driver/badge.svg?branch=master)](https://coveralls.io/github/mmolimar/ksql-jdbc-driver?branch=master)

**ksql-jdbc-driver** is a Type 3 Java Database Connectivity (JDBC) driver that provides standard access to
**ksql-jdbc-driver** is a Type 4 Java Database Connectivity (JDBC) driver that provides standard access to
Apache Kafka via JDBC API.

In the current version, the driver connects to the [KSQL engine](https://www.confluent.io/product/ksql/) to
perform queries to Kafka and then, the engine translates those requests to Kafka requests.
The driver connects to the [ksqlDB engine](https://ksqldb.io/) then, the engine translates those requests
to Kafka requests.

## Getting started

### Building from source ###

Just clone the ksql-jdbc-driver repo and package it:
Just clone the ``ksql-jdbc-driver`` repo and package it:

``git clone https://github.com/mmolimar/ksql-jdbc-driver.git && cd ksql-jdbc-driver``

``sbt clean package``
Expand All @@ -37,7 +37,7 @@ To know the test coverage of the driver:

As expected, the driver can be used as we are used to. So, in your application, register the driver (depending on
your JVM), for example:

* ``java.sql.DriverManager.registerDriver(new com.github.mmolimar.ksql.jdbc.KsqlDriver)``

or
Expand All @@ -46,16 +46,17 @@ or

### Connection URL

The URL has the form ``jdbc:ksql://<ksql-engine>:<port>[?<property1>=<value>&<property2>=<value>...]``
The URL has the form ``jdbc:ksql://[<username>:<password>@]<ksql-engine>:<port>[?<property1>=<value>&<property2>=<value>...]``

where:

* **\<ksql-engine>**: represents the KSQL engine host.
* **\<port>**: is the KSQL engine port.
* **\<username>:\<password>**: optional username and password to log into ksqlDB.
* **\<ksql-engine>**: represents the ksqlDB engine host.
* **\<port>**: ksqlDB engine port.
* **\<propertyN>**: are the custom client properties (optionals). Available properties:
* ``secured``: sets if the KSQL connection is secured or not. It's a boolean (``true``|``false``) and its default
* ``secured``: sets if the ksqlDB connection is secured or not. It's a boolean (``true``|``false``) and its default
value is ``false``.
* ``properties``: enables to set in KSQL extra properties from the JDBC URL. It's a boolean (``true``|``false``)
* ``properties``: enables to set in ksqlDB extra properties from the JDBC URL. It's a boolean (``true``|``false``)
and its default value is ``false``.
* ``timeout``: sets the max wait time between each message when receiving them. It's a long and its default
value is ``0`` which means that is infinite.
Expand Down
53 changes: 37 additions & 16 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
name := "ksql-jdbc-driver"
val projectVersion = "1.2.0"
val projectScalaVersion = "2.12.10"
val ksqlVersion = "5.4.0"
val kafkaVersion = "2.4.0"
val scalaTestVersion = "3.1.0"
val scalaMockVersion = "3.6.0"
val wsApiVersion = "2.1.1"

version := "1.1"
val repos = Seq(
"Confluent Maven Repo" at "https://packages.confluent.io/maven/",
"Confluent Snapshots Maven Repo" at "https://s3-us-west-2.amazonaws.com/confluent-snapshots/",
Resolver.mavenLocal
)

initialize := {
assert(Integer.parseInt(sys.props("java.specification.version").split("\\.")(1)) >= 8, "Java 8 or above required")
}

scalaVersion := "2.11.11"
val dependencies = Seq(
"io.confluent.ksql" % "ksql-rest-app" % ksqlVersion,
"org.apache.kafka" %% "kafka" % kafkaVersion % "test",
"org.scalatest" %% "scalatest" % scalaTestVersion % "test",
"org.scalamock" %% "scalamock-scalatest-support" % scalaMockVersion % "test",
"javax.ws.rs" % "javax.ws.rs-api" % wsApiVersion artifacts Artifact("javax.ws.rs-api", "jar", "jar")
)

resolvers += "Confluent Maven Repo" at "http://packages.confluent.io/maven/"
resolvers += "Confluent Snapshots Maven Repo" at "https://s3-us-west-2.amazonaws.com/confluent-snapshots/"
resolvers += Resolver.mavenLocal
val common = Seq(
organization := "com.github.mmolimar",
name := "ksql-jdbc-driver",
version := projectVersion,
scalaVersion := projectScalaVersion,
crossScalaVersions := Seq("2.11.12", projectScalaVersion),
resolvers ++= repos,
libraryDependencies ++= dependencies
)

libraryDependencies += "io.confluent.ksql" % "ksql-rest-app" % "5.3.0"
libraryDependencies += "org.apache.kafka" %% "kafka" % "2.3.0" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8" % "test"
libraryDependencies += "org.scalamock" %% "scalamock-scalatest-support" % "3.6.0" % "test"
libraryDependencies += "javax.ws.rs" % "javax.ws.rs-api" % "2.1.1" artifacts Artifact("javax.ws.rs-api", "jar", "jar")
lazy val root = project.in(file("."))
.configs(Configs.all: _*)
.settings(
common,
Tests.settings
)
.enablePlugins(ScoverageSbtPlugin, CoverallsPlugin, AssemblyPlugin)

assemblyMergeStrategy in assembly := {
case PathList("javax", "inject", xs@_*) => MergeStrategy.first
case PathList("javax", "inject", _*) => MergeStrategy.first
case PathList("javax", "annotation", _*) => MergeStrategy.first
case "module-info.class" => MergeStrategy.discard
case "log4j.properties" => MergeStrategy.discard
case x =>
Expand Down
7 changes: 0 additions & 7 deletions project/Build.scala

This file was deleted.

2 changes: 1 addition & 1 deletion project/Configs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import sbt._

object Configs {
val IntegrationTest = config("it") extend (Test)
val all = Seq(IntegrationTest)
val all: Seq[Configuration] = Seq(IntegrationTest)
}
14 changes: 5 additions & 9 deletions project/Testing.scala → project/Tests.scala
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
import sbt.Keys._
import sbt._
import sbt.{Def, _}

object Testing {
object Tests {

import Configs._

private lazy val testSettings = Seq(
fork in Test := false,
parallelExecution in Test := false
)

lazy val testAll = TaskKey[Unit]("test-all")

private lazy val itSettings = inConfig(IntegrationTest)(Defaults.testSettings) ++ Seq(
fork in IntegrationTest := false,
parallelExecution in IntegrationTest := false,
scalaSource in IntegrationTest := baseDirectory.value / "src/it/scala"
)
private lazy val testAll = TaskKey[Unit]("testAll", "Executes unit and integration tests.")

lazy val settings = testSettings ++ itSettings ++ Seq(
testAll := (),
testAll <<= testAll.dependsOn(test in IntegrationTest),
testAll <<= testAll.dependsOn(test in Test)
lazy val settings: Seq[Def.Setting[_]] = testSettings ++ itSettings ++ Seq(
testAll := (test in Test).dependsOn(test in IntegrationTest).value
)
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 0.13.9
sbt.version = 1.3.6
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
logLevel := Level.Warn

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.2")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
11 changes: 11 additions & 0 deletions src/it/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
log4j.rootLogger=INFO, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d] %p %c{1}:%L - %m%n

log4j.logger.kafka=ERROR, stdout
log4j.logger.org.apache.zookeeper=ERROR, stdout
log4j.logger.org.apache.kafka=ERROR, stdout
log4j.logger.org.I0Itec.zkclient=ERROR, stdout
log4j.logger.org.reflections=ERROR, stdout

0 comments on commit 846f8d1

Please sign in to comment.