You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by "Jamie Goodyear (JIRA)" <ji...@apache.org> on 2008/12/10 16:00:05 UTC

[jira] Created: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Provide default jdbc lock impl for master/slave deployments
-----------------------------------------------------------

                 Key: SMX4KNL-163
                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
             Project: ServiceMix Kernel
          Issue Type: New Feature
         Environment: All
            Reporter: Jamie Goodyear
             Fix For: 1.1.0


Provide default jdbc lock impl for master/slave deployments.

>From note on SMX4KNL-106:
By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Jamie Goodyear (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48466#action_48466 ] 

Jamie Goodyear commented on SMX4KNL-163:
----------------------------------------

I'd lean towards making this part of the configuration, this would allow the user to choose if they want to re-use the instance names.

I'd update and retest with the extra configuration option, thanks for the feed back :)

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>         Attachments: for-discussion-only.txt, smx4knl-163.txt, smx4knl-163a.txt
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Jamie Goodyear (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jamie Goodyear updated SMX4KNL-163:
-----------------------------------

    Attachment: smx4knl-163a.txt

smx4knl-163a.txt

This patch includes a Default JDBC lock implementation. To use this feature the following must be set in your environment on each system in the master/slave setup:

 * Classpath updated to include JDBC driver.
 * system.properties file updated to reflect the below entries.

Entries for etc/system.properties:
{noformat} 
servicemix.lock=true
servicemix.lock.class=org.apache.servicemix.kernel.main.DefaultJDBCLock
servicemix.lock.jdbc.url=jdbc:derby://dbserver:1527/sample
servicemix.lock.jdbc.driver=org.apache.derby.jdbc.ClientDriver
servicemix.lock.jdbc.user=user
servicemix.lock.jdbc.password=password
servicemix.lock.jdbc.table=SERVICEMIX_LOCK
{noformat} 

Note: 
 * The database name "sample" will be created if it does not exist on the db.
 * First SMX4 instance to acquire the locking table is the master instance.
 * Will fail if jdbc driver is not on classpath. 

Testing notes:
Was tested with the following setup:

{noformat}
SMX instances on separate hosts:
host1 (SMX4 on AIX) 
host2 (SMX4 on Mac OSX)

Standalone Database Server:
dbserver (DerbyDB on Ubuntu)
{noformat}

Disconnecting the AIX machine allowed the Mac to pick up the SMX4 lock. When AIX servicemix instance was restarted it waited until the Mac instance lost its lock on the db table lock (Mac was shutdown). 

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>         Attachments: for-discussion-only.txt, smx4knl-163.txt, smx4knl-163a.txt
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Jamie Goodyear (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48121#action_48121 ] 

jgoodyear edited comment on SMX4KNL-163 at 12/11/08 9:55 AM:
------------------------------------------------------------------

I'm creating a DefaultJDBCLock class that can be extended for use with various databases, I'm posting the design below for comments.

To use the DefaultJDBCLock the following would have to be added to ${servicemix.base}/etc/system.properties:

{noformat}
# Servicemix Locking Configuration
servicemix.lock=true
#servicemix.lock.dir=/optional/user/defined/lock/directory
servicemix.lock.class=org.apache.servicemix.kernel.main.DefaultJDBCLock
{noformat}

The DefaultJDBCLock implements the Lock interface. Internally this JDBCLock makes use of an embedded instance of a Derby db. The user can specify where the Derby db will be located by setting the servicemix.lock.dir configuration entry.

{code:title=DefaultJDBCLock.java|borderStyle=solid}

public class DefaultJDBCLock implements Lock {

private static final String PROPERTY_LOCK_DIR = "servicemix.lock.dir";
private static final String PROP_SERVICEMIX_BASE = "servicemix.base";
private Connection lock;
private DataSource dataSource;

// Constructor
public DefaultJDBCLock (Properties props) {
    try {
        String lockDir = props.getProperty(PROPERTY_LOCK_DIR);
        if (lockDir != null) {
            File servicemixLock = getServiceMixLock(new File(lockDir), props);
            props.setProperty(PROPERTY_LOCK_DIR, servicemixLock.getPath());
        } else {
            props.setProperty(PROPERTY_LOCK_DIR, System.getProperty(PROP_SERVICEMIX_BASE));
        }
        dataSource = buildDataSource(props.getProperty(PROPERTY_LOCK_DIR));
    } catch (Exception e) {
        throw new RuntimeException("Could not create JDBC lock", e);
    }
}

// lock 
public boolean lock() throws Exception {
    if (lock == null) {
        lock = dataSource.getConnection();
    }
    return lock != null;
}

// release lock
public void release() throws Exception {
    if (lock != null && !lock.isClosed()) {
        lock.close();
    }
    lock = null;
}

// Creates embedded data source (Derby DB)
protected DataSource buildDataSource(String lockDir) throws IOException {}
// implementation omited here for brevity.
private static File getServiceMixLock(File lock,Properties props) {}
private static File validateDirectoryExists(String path, String errPrefix) {}

}
{code} 

      was (Author: jgoodyear):
    I'm creating a DefaultJDBCLock class that can be extended for use with various databases, I'm posting the design below for comments.

To use the DefaultJDBCLock the following would have to be added to ${servicemix.base}/etc/system.properties:

{noformat}
# Servicemix Locking Configuration
servicemix.lock=true
#servicemix.lock.dir=/optional/user/defined/lock/directory
servicemix.lock.class=org.apache.servicemix.kernel.main.DefaultJDBCLock.class
{noformat}

The DefaultJDBCLock implements the Lock interface. Internally this JDBCLock makes use of an embedded instance of a Derby db. The user can specify where the Derby db will be located by setting the servicemix.lock.dir configuration entry.

{code:title=DefaultJDBCLock.java|borderStyle=solid}

public class DefaultJDBCLock implements Lock {

private static final String PROPERTY_LOCK_DIR = "servicemix.lock.dir";
private static final String PROP_SERVICEMIX_BASE = "servicemix.base";
private Connection lock;
private DataSource dataSource;

// Constructor
public DefaultJDBCLock (Properties props) {
    try {
        String lockDir = props.getProperty(PROPERTY_LOCK_DIR);
        if (lockDir != null) {
            File servicemixLock = getServiceMixLock(new File(lockDir), props);
            props.setProperty(PROPERTY_LOCK_DIR, servicemixLock.getPath());
        } else {
            props.setProperty(PROPERTY_LOCK_DIR, System.getProperty(PROP_SERVICEMIX_BASE));
        }
        dataSource = buildDataSource(props.getProperty(PROPERTY_LOCK_DIR));
    } catch (Exception e) {
        throw new RuntimeException("Could not create JDBC lock", e);
    }
}

// lock 
public boolean lock() throws Exception {
    if (lock == null) {
        lock = dataSource.getConnection();
    }
    return lock != null;
}

// release lock
public void release() throws Exception {
    if (lock != null && !lock.isClosed()) {
        lock.close();
    }
    lock = null;
}

// Creates embedded data source (Derby DB)
protected DataSource buildDataSource(String lockDir) throws IOException {}
// implementation omited here for brevity.
private static File getServiceMixLock(File lock,Properties props) {}
private static File validateDirectoryExists(String path, String errPrefix) {}

}
{code} 
  
> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Guillaume Nodet (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48463#action_48463 ] 

Guillaume Nodet commented on SMX4KNL-163:
-----------------------------------------

The patch looks good, though I haven't tested it yet.
I'm a bit puzzled by the hardcoded "smx4" value that is used in the jdbc insert statement.
Should this value be also part of the configuration ?
Or maybe we should use the instance name which is now available through the "servicemix.name" system property ?

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>         Attachments: for-discussion-only.txt, smx4knl-163.txt, smx4knl-163a.txt
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Work started: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Jamie Goodyear (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Work on SMX4KNL-163 started by Jamie Goodyear.

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Jamie Goodyear (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48121#action_48121 ] 

Jamie Goodyear commented on SMX4KNL-163:
----------------------------------------

I'm creating a DefaultJDBCLock class that can be extended for use with various databases, I'm posting the design below for comments.

To use the DefaultJDBCLock the following would have to be added to ${servicemix.base}/etc/system.properties:

{noformat}
# Servicemix Locking Configuration
servicemix.lock=true
#servicemix.lock.dir=/optional/user/defined/lock/directory
servicemix.lock.class=org.apache.servicemix.kernel.main.DefaultJDBCLock.class
{noformat}

The DefaultJDBCLock implements the Lock interface. Internally this JDBCLock makes use of an embedded instance of a Derby db. The user can specify where the Derby db will be located by setting the servicemix.lock.dir configuration entry.

{code:title=DefaultJDBCLock.java|borderStyle=solid}

public class DefaultJDBCLock implements Lock {

private static final String PROPERTY_LOCK_DIR = "servicemix.lock.dir";
private static final String PROP_SERVICEMIX_BASE = "servicemix.base";
private Connection lock;
private DataSource dataSource;

// Constructor
public DefaultJDBCLock (Properties props) {
    try {
        String lockDir = props.getProperty(PROPERTY_LOCK_DIR);
        if (lockDir != null) {
            File servicemixLock = getServiceMixLock(new File(lockDir), props);
            props.setProperty(PROPERTY_LOCK_DIR, servicemixLock.getPath());
        } else {
            props.setProperty(PROPERTY_LOCK_DIR, System.getProperty(PROP_SERVICEMIX_BASE));
        }
        dataSource = buildDataSource(props.getProperty(PROPERTY_LOCK_DIR));
    } catch (Exception e) {
        throw new RuntimeException("Could not create JDBC lock", e);
    }
}

// lock 
public boolean lock() throws Exception {
    if (lock == null) {
        lock = dataSource.getConnection();
    }
    return lock != null;
}

// release lock
public void release() throws Exception {
    if (lock != null && !lock.isClosed()) {
        lock.close();
    }
    lock = null;
}

// Creates embedded data source (Derby DB)
protected DataSource buildDataSource(String lockDir) throws IOException {}
// implementation omited here for brevity.
private static File getServiceMixLock(File lock,Properties props) {}
private static File validateDirectoryExists(String path, String errPrefix) {}

}
{code} 

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Guillaume Nodet (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48280#action_48280 ] 

Guillaume Nodet commented on SMX4KNL-163:
-----------------------------------------

Good work! The configuration looks much better now :-)
For the JDBC statements to be sent to the database, wouldn't it be simpler to just allow them to be configured through the same mechanism, as properties.

Note that the polling is only necessary when the lock has not been acquired.   When the lock has been acquired, maintaining the connection alive should be sufficient, without committing it.  If the server crashes, the connection will be destroyed and the DB will automatically release the lock, which can then be acquired by another instance.  So the loop is necessary only when the lock can not be acquired.

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>         Attachments: for-discussion-only.txt, smx4knl-163.txt
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Jamie Goodyear (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jamie Goodyear updated SMX4KNL-163:
-----------------------------------

    Attachment:     (was: smx4knl-163a.txt)

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>         Attachments: for-discussion-only.txt, smx4knl-163.txt, smx4knl-163a.txt
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Adrian Trenaman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48183#action_48183 ] 

Adrian Trenaman commented on SMX4KNL-163:
-----------------------------------------

Hi Jamie, how are you getting on with this? 

I'm with Guillaume on the use of classname + Url, rather than using Derby:I have in mind an architecture where ActiveMQ is deployed in SMX4 in a master/slave scenario: I'd like the whole SMX4 kernel, including AMQ and all bundles etc - to wait until the lock is available before start-up. Have you thought about how your locking mechanism might interact with that of AMQ? 



> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>         Attachments: smx4knl-163.txt
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Guillaume Nodet (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48127#action_48127 ] 

Guillaume Nodet commented on SMX4KNL-163:
-----------------------------------------

Why would creating a connection do the DB lock the smx instance ?
I would have thought this involve at least a JDBC statement.
You may want to take a look at the way ActiveMQ does that:
  http://svn.apache.org/repos/asf/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java

Also, I think it should be possible to avoid the dependnecy on Derby by using the lower level JDBC driver classname + url maybe.

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>         Attachments: smx4knl-163.txt
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Jamie Goodyear (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48585#action_48585 ] 

Jamie Goodyear commented on SMX4KNL-163:
----------------------------------------

Will do :)

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>         Attachments: for-discussion-only.txt, smx4knl-163.txt, smx4knl-163a.txt, smx4knl-163b.txt
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Jamie Goodyear (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48187#action_48187 ] 

Jamie Goodyear commented on SMX4KNL-163:
----------------------------------------

Hi Adrian,

If we use the classname + Url approach, rather than an internal Derby instance, then we should be able to point SMX4 kernel lock at the AMQ database. Reusing the AMQ DB lock table or a second locking table just for SMX4 could be made into a configuration preference. 

The first scenario would make SMX4 wait upon gaining the AMQ lock, the later would allow SMX4 kernel to gain a lock independently of the AMQ instance.  This design & deployment scenario will need some testing on separate hosts to see if its feasible. 

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>         Attachments: smx4knl-163.txt
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Jamie Goodyear (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jamie Goodyear updated SMX4KNL-163:
-----------------------------------

    Attachment: smx4knl-163b.txt

smx4knl-163b.txt

This patch includes a Default JDBC lock implementation. To use this feature the following must be set in your environment on each system in the master/slave setup:

Classpath updated to include JDBC driver.
system.properties file updated to reflect the below entries.
Entries for etc/system.properties:

{noformat}
servicemix.lock=true
servicemix.lock.class=org.apache.servicemix.kernel.main.DefaultJDBCLock
servicemix.lock.jdbc.url=jdbc:derby://dbserver:1527/sample
servicemix.lock.jdbc.driver=org.apache.derby.jdbc.ClientDriver
servicemix.lock.jdbc.user=user
servicemix.lock.jdbc.password=password
servicemix.lock.jdbc.table=SERVICEMIX_LOCK
servicemix.lock.jdbc.clustername=smx4
servicemix.lock.jdbc.timeout=30
{noformat}

Note:

The database name "sample" will be created if it does not exist on the db.
First SMX4 instance to acquire the locking table is the master instance.
Will fail if jdbc driver is not on classpath.

Testing notes:
Was tested with the following setup:

{noformat}
SMX instances on separate hosts:
host1 (SMX4 on AIX) 
host2 (SMX4 on Mac OSX)

Standalone Database Server:
dbserver (DerbyDB on Ubuntu)
{noformat}

Disconnecting the AIX machine allowed the Mac to pick up the SMX4 lock. When AIX servicemix instance was restarted it waited until the Mac instance lost its lock on the db table lock (Mac was shutdown).

If the database was to go offline then the current master would discover this via the LockMonitor and shutdown the master instance of SMX. The former master instance will now require manual restart. The slaves will upon restoration of the database attempt to connect and start up as per normal. The rational behind this scenario is that if SMX is setup in a clustered environment then the DB hosting the lock table will most likely also be Highly Available, loss of the DB would probably warrant shutting down the currently running SMX instance leaving the slaves to await DB restoratiion. This feature helps avoid having a second SMX instance act as master while the original master is still running (unaware of the loss of  jdbc lock).

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>         Attachments: for-discussion-only.txt, smx4knl-163.txt, smx4knl-163a.txt, smx4knl-163b.txt
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Jamie Goodyear (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jamie Goodyear reassigned SMX4KNL-163:
--------------------------------------

    Assignee: Jamie Goodyear

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Jamie Goodyear (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jamie Goodyear updated SMX4KNL-163:
-----------------------------------

    Attachment: for-discussion-only.txt

Hi All,

  I've attached a file "for-discussion-only.txt" for the purposes of discussing the DefaultJDBCLock. 

  I used AMQ's DefaultDataLocker as a blue print for how to construct this class. In AMQ the keepAlive function perfoms a service similar to SMX's Lock interface lock(), I intend here for Main#lock() to call the DefaultJDBCLock#lock() method continuously thereby  maintaining a lock on the Servicemix locking table. 

  To use the jdbc lock a user would have to include the following in their system.properties file:

{noformat}
servicemix.lock=true
servicemix.lock.class=org.apache.servicemix.kernel.main.DefaultJDBCLock
servicemix.lock.jdbc.url=jdbc:derby://localhost:1527/sample
servicemix.lock.jdbc.driver=org.apache.derby.jdbc.ClientDriver
servicemix.lock.jdbc.user=user
servicemix.lock.jdbc.password=password
{noformat}

 The mechanism for creating a SMX4 locking table and/or re-using another application's locking table needs to be developed & tested. 

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>         Attachments: for-discussion-only.txt, smx4knl-163.txt
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Guillaume Nodet (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guillaume Nodet resolved SMX4KNL-163.
-------------------------------------

    Resolution: Fixed

Adding         main/src/main/java/org/apache/servicemix/kernel/main/DefaultJDBCLock.java
Sending        main/src/main/java/org/apache/servicemix/kernel/main/Lock.java
Adding         main/src/main/java/org/apache/servicemix/kernel/main/LockMonitor.java
Sending        main/src/main/java/org/apache/servicemix/kernel/main/Main.java
Sending        main/src/main/java/org/apache/servicemix/kernel/main/SimpleFileLock.java
Adding         main/src/main/java/org/apache/servicemix/kernel/main/Statements.java
Transmitting file data ......
Committed revision 732947.

Thanks a lot for this awesome patch, Jamie!
Would you mind taking a few minutes and add some documentation about that in the ServiceMix Kernel's User's Guide ?

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>         Attachments: for-discussion-only.txt, smx4knl-163.txt, smx4knl-163a.txt, smx4knl-163b.txt
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Jamie Goodyear (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jamie Goodyear updated SMX4KNL-163:
-----------------------------------

    Attachment: smx4knl-163.txt

First implementation of DefaultJDBCLock class.

Usage:
User must set in system.properties servicemix.lock to true, and servicemix.lock.class to org.apache.servicemix.kernel.main.DefaultJDBCLock.

User may optionally specify location for derby db creation.

Please note:
This patch would introduce a dependency on Apache Derby 10.1.3.1.

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>         Attachments: smx4knl-163.txt
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Jamie Goodyear (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48129#action_48129 ] 

Jamie Goodyear commented on SMX4KNL-163:
----------------------------------------

Thanks Guillaume,
Will update and repost.

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>         Attachments: smx4knl-163.txt
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SMX4KNL-163) Provide default jdbc lock impl for master/slave deployments

Posted by "Jamie Goodyear (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/SMX4KNL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jamie Goodyear updated SMX4KNL-163:
-----------------------------------

    Attachment: smx4knl-163a.txt

smx4knl-163a.txt

see above post for details.

> Provide default jdbc lock impl for master/slave deployments
> -----------------------------------------------------------
>
>                 Key: SMX4KNL-163
>                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-163
>             Project: ServiceMix Kernel
>          Issue Type: New Feature
>         Environment: All
>            Reporter: Jamie Goodyear
>            Assignee: Jamie Goodyear
>             Fix For: 1.1.0
>
>         Attachments: for-discussion-only.txt, smx4knl-163.txt, smx4knl-163a.txt
>
>
> Provide default jdbc lock impl for master/slave deployments.
> From note on SMX4KNL-106:
> By default, a file based locking mechanism is used. There is an interface that can be implemented to allow other locking mechanisms such as JDBC. This would require setting a system property for the class name of the lock (it can be done in etc/system.properties) and changing the shell script to add the needed jars to the boot classpath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.