Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Oracle databas supports #387

Closed
wants to merge 8 commits into from
Closed

Conversation

liningalex
Copy link

This pull request is to supports Oracle database. please review. thanks.

val settings = ConnectionPoolSettings(maxSize = maxSize)

ConnectionPool.singleton(
config.properties("URL"),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be do use conts for "URL", "USERNAME", "USERNAME" etc? for avoid problems about copy-paste

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to extends JDBC StorageClient to avoid code copy.

init.invoke(instance)
}
catch {
case e: NoSuchMethodException => None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the return value of try expression is not used, Unit is suitable than None for ignoring an exception as following:

case _: NoSuchMethodException => ()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, good point.

@@ -29,14 +29,15 @@ class JDBCChannels(client: String, config: StorageClientConfig, prefix: String)
extends Channels with Logging {
/** Database table name for this data access object */
val tableName = JDBCUtils.prefixTableName(prefix, "channels")
DB autoCommit { implicit session =>
sql"""
def init() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use the deperecated procedure syntax. See: https://issues.scala-lang.org/browse/SI-7605

It should be:

def init() = {
  DB autoCommit { implicit session =>
    ...
  }
}

or

def init() = DB autoCommit { implicit session =>
  ...
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, done

@@ -29,8 +29,9 @@ class JDBCEngineInstances(client: String, config: StorageClientConfig, prefix: S
extends EngineInstances with Logging {
/** Database table name for this data access object */
val tableName = JDBCUtils.prefixTableName(prefix, "engineinstances")
DB autoCommit { implicit session =>
sql"""
def init() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@@ -29,8 +29,9 @@ class JDBCEvaluationInstances(client: String, config: StorageClientConfig, prefi
extends EvaluationInstances with Logging {
/** Database table name for this data access object */
val tableName = JDBCUtils.prefixTableName(prefix, "evaluationinstances")
DB autoCommit { implicit session =>
sql"""
def init() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

val binaryColumnType = JDBCUtils.binaryColumnType(client)
DB autoCommit { implicit session =>
sql"""
def init() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

/** JDBC implementation of [[EngineInstances]] */
class OJDBCEngineInstances(client: String, config: StorageClientConfig, prefix: String)
extends JDBCEngineInstances(client, config, prefix) {
override def init() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/** JDBC implementations of [[EvaluationInstances]] */
class OJDBCEvaluationInstances(client: String, config: StorageClientConfig, prefix: String)
extends JDBCEvaluationInstances(client, config, prefix) {
override def init() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/** JDBC implementation of [[Models]] */
class OJDBCModels(client: String, config: StorageClientConfig, prefix: String)
extends JDBCModels(client, config, prefix) {
override def init() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

asInstanceOf[T]
try {
val init = instance.getClass.getMethod("init")
init.invoke(instance)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, if init() method is necessary for data objects, we should define a trait (e.g. Initializable) which has a init() method and cast by pattern match here to call init() method.

But since this is just my thought, we need opinion from other committers as well.

@@ -198,7 +198,7 @@ object CreateServer extends Logging {
kryo.invert(modeldata.get(engineInstance.id).get.models).get.
asInstanceOf[Seq[Any]]

val batch = if (engineInstance.batch.nonEmpty) {
val batch = if (engineInstance.batch != null && engineInstance.batch.nonEmpty) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this null check necessary?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not so, pio deploy crashes.

@takezoe
Copy link
Member

takezoe commented Jun 5, 2017

@dszeto As our concern, is it possible to test with Oracle database on Travis-CI or ASF's Jenkins? If no, it might be difficult to guarantee this Oracle support works correctly over the future.

@dszeto
Copy link
Contributor

dszeto commented Jun 8, 2017

@takezoe A quick search reveals https://hub.docker.com/r/wnameless/oracle-xe-11g/, but this limits the guarantee to whatever Oracle XE 11g supports. @liningalex would you mind taking a look at this option? Let us know if you need help adding integration test.

@dszeto
Copy link
Contributor

dszeto commented Jun 8, 2017

@liningalex could you also please open a ticket on our Apache JIRA to help with tracking? Thanks!

I will conduct a more thorough review ASAP.

@dszeto
Copy link
Contributor

dszeto commented Jun 16, 2017

@liningalex Is the main motivation for a separate OJDBC set of classes due to Oracle requiring different column types?

@liningalex
Copy link
Author

liningalex commented Jun 16, 2017 via email

@dszeto
Copy link
Contributor

dszeto commented Jun 20, 2017

Hey @liningalex, if you don't have a chance adding integration test yet, I would like to merge this to a feature branch so that we can join forces on that.

@liningalex
Copy link
Author

liningalex commented Jun 21, 2017 via email

@dszeto
Copy link
Contributor

dszeto commented Jul 7, 2017

We don't have any documentation (which we should add later) on how that's done, but basically, it would be adding a new combination in the test matrix (https://github.com/apache/incubator-predictionio/blob/develop/.travis.yml), and setting up https://github.com/apache/incubator-predictionio/blob/develop/tests/docker-compose.yml to bring up a container running Oracle.

@dszeto
Copy link
Contributor

dszeto commented Jul 26, 2017

@liningalex Let us know how we can help. This is a great PR and we would like to get it in.

@liningalex
Copy link
Author

@dszeto is ./run_docker.sh ELASTICSEARCH HBASE LOCALFS ~/Documents/github/incubator-predictionio "echo 'All tests passed...'" right command to run tests? i got

Starting tests_postgres_1 ... done
Starting tests_elasticsearch_1 ... done
Sleeping 30 seconds for all services to be ready...
/init.sh: line 23: ~/Documents/github/incubator-predictionio: No such file or directory

@dszeto
Copy link
Contributor

dszeto commented Jul 27, 2017

Should be

  tests/run_docker.sh $METADATA_REP $EVENTDATA_REP $MODELDATA_REP \
    "python3 /PredictionIO/tests/pio_tests/tests.py"

where you replace those variables with ORACLE where applicable. This is assuming you have built the Docker image using tests/build_docker.sh.

@liningalex
Copy link
Author

@dszeto in the end, it says 'Generating XML reports...'. where are the reports?

@dszeto
Copy link
Contributor

dszeto commented Jul 28, 2017

These reports are generated by XMLTestRunner in tests/pio_tests/tests.py, which are generated inside the container.

@liningalex
Copy link
Author

@dszeto how do I get the copy?

@dszeto
Copy link
Contributor

dszeto commented Aug 4, 2017

You will need to use docker commands to either read volumes that were attached to running containers. The test is designed to return non-zero exit code if any tests fail, so if you can run to the end with a zero exit code that would mean tests are passing.

@liningalex liningalex closed this Oct 4, 2017
@liningalex
Copy link
Author

will reopen when integration test is added.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants