felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Müller (JIRA) <j...@apache.org>
Subject [jira] Commented: (FELIX-2280) To much code duplication in DefaultJDBCLock, OracleJDBCLock and MySQLJDBCLock
Date Fri, 16 Apr 2010 17:14:24 GMT

    [ https://issues.apache.org/jira/browse/FELIX-2280?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12857888#action_12857888
] 

Christian Müller commented on FELIX-2280:
-----------------------------------------

What I dislike on the current solution and what I like to change with my patch is:
- provide java doc for the interface org.apache.felix.karaf.main.Lock
- provide unit tests for org.apache.felix.karaf.main.DefaultJDBCLock, org.apache.felix.karaf.main.MySQLJDBCLock,
and org.apache.felix.karaf.main.OracleJDBCLock
- remove the duplicated code in org.apache.felix.karaf.main.DefaultJDBCLock, org.apache.felix.karaf.main.MySQLJDBCLock,
and org.apache.felix.karaf.main.OracleJDBCLock
- all implementations should use the same column names
- all implementations should work in the same way (what the currently not do in my opinion)
    - OracleJDBCLock never checks in the alive method, if it holds the lock
    - OracleJDBCLock checks also whether the lock tabe exists or not in its constructor
    - OracleJDBCLock dosn't update the lock table in the lock() method

Detailed description of the current implementations:

DefaultJDBCLock:
creation of DefaultJDBCLock
lock
 -> checks whether the lock tabe exists or not
     -> if table exists
         -> SELECT * FROM LOCK_TABLE FOR UPDATE
         -> UPDATE LOCK_TABLE SET TIME=1 WHERE CLUSTER = 'cluster'
     -> if table not exists
         -> create table LOCK_TABLE (TIME bigint, CLUSTER varchar(20))
         -> insert into LOCK_TABLE (TIME, CLUSTER) values (1, 'cluster')
         -> SELECT * FROM LOCK_TABLE FOR UPDATE
         -> UPDATE LOCK_TABLE SET TIME=1 WHERE CLUSTER = 'cluster'
release
 -> checks whether connection is open
     -> if its open
         -> rollback connection
         -> close connection
isAlive
 -> checks whether connection is open
     -> if its open
         -> UPDATE LOCK_TABLE SET TIME=timestamp WHERE CLUSTER = 'cluster'
         -> checks the updated row count
             -> if is lower then 1
                 -> return false
             -> otherwise
                 -> return true
     -> if its closed
         -> return false



OracleJDBCLock:
creation of OracleJDBCLock
 -> checks whether the lock tabe exists or not
     -> if table not exists
         -> create table LOCK_TABLE (MOMENT number(20), NODE varchar2(20))
         -> insert into LOCK_TABLE (MOMENT, NODE) values (timestamp, 'cluster')
lock
 -> checks whether the lock tabe exists or not
     -> if table exists
         -> SELECT * FROM LOCK_TABLE FOR UPDATE NOWAIT
         -> SELECT * FROM LOCK_TABLE
release
 -> checks whether connection is open
     -> if its open
         -> rollback connection
         -> close connection
isAlive
 -> checks whether connection is open
     -> if its open
         -> return true
     -> if its closed
         -> return false
 
 

MySQLJDBCLock:
creation of MySQLJDBCLock
 -> create database if not exists karaf
lock
 -> checks whether the lock tabe exists or not
     -> if table exists
         -> LOCK TABLES karaf.LOCK_TABLE WRITE
         -> UPDATE LOCK_TABLE SET TIME=timestamp WHERE CLUSTER = 'cluster'
     -> if table not exists
         -> create table LOCK_TABLE (TIME bigint, CLUSTER varchar(20)) ENGINE = INNODB
         -> insert into LOCK_TABLE (TIME, CLUSTER) values (timestamp, 'cluster')
         -> LOCK TABLES karaf.LOCK_TABLE WRITE
         -> UPDATE LOCK_TABLE SET TIME=timestamp WHERE CLUSTER = 'cluster'
release
 -> checks whether connection is open
     -> if its open
         -> rollback connection
         -> close connection
isAlive
 -> checks whether connection is open
     -> if its open
         -> UPDATE LOCK_TABLE SET TIME=timestamp WHERE CLUSTER = 'cluster'
         -> checks the updated row count
             -> if is lower then 1
                 -> return false
             -> otherwise
                 -> return true
     -> if its closed
         -> return false

> To much code duplication in DefaultJDBCLock, OracleJDBCLock and MySQLJDBCLock
> -----------------------------------------------------------------------------
>
>                 Key: FELIX-2280
>                 URL: https://issues.apache.org/jira/browse/FELIX-2280
>             Project: Felix
>          Issue Type: Improvement
>          Components: Karaf
>    Affects Versions: karaf-1.4.0
>         Environment: All
>            Reporter: Christian Müller
>
> org.apache.felix.karaf.main.DefaultJDBCLock, org.apache.felix.karaf.main.MySQLJDBCLock
and org.apache.felix.karaf.main.OracleJDBCLock has to much code duplications. I propose a
solution like in ActiveMQ [package org.apache.activemq.store.jdbc.adapter|http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/].
> And we should implement some unit tests for it.
> If it's fine for you, I will try to improve this part of karaf and provide a patch for
it.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message