[
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.