[
https://issues.jboss.org/browse/ISPN-1131?page=com.atlassian.jira.plugin....
]
Mircea Markus edited comment on ISPN-1131 at 5/23/11 4:15 PM:
--------------------------------------------------------------
Suggested design.
On first release this is an experimental feature disabled by default.
In ordert to enable it use the following configuration element:
{code:xml}
<locking
isolationLevel="READ_COMMITTED"
lockAtPrepareTime="true" />
{code}
In order to preserve the existing functionality and also support *lockAtPrepareTime* a new
interceptor is added: {{PrepareTimeLockingInterceptor}}:
* it extends {{LockingInterceptor}}
* when *lockAtPrepareTime* is enabled it takes {{LockingInterceptor}}'s place is the
interceptor chain
* it overrides all {{LockingInterceptor}}'s {{visit<WriteCommand>}} methods
(e.g. visitpPutKeyValueCommand) and does not acquire write locks on these invocations but
read locks
* read locks are acquired similar to {{LockingInterceptor.visitGetKeyValueCommand()}}:
{code:java}
public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand
command) throws Throwable {
try {
entryFactory.wrapEntryForReading(ctx, command.getKey());
return invokeNextInterceptor(ctx, command);
} finally {
doAfterCall(ctx);
}
}
{code}
* {{PrepareTimeLockingInterceptor.visitPrepareCommand}} overrides
{{LockingInterceptor.visitPrepareCommand}}:
{code:java}
@Override
public Object visitPrepareCommand(TxInvocationContext ctx, PrepareCommand command)
throws Throwable {
super.visitPrepareCommand(ctx, command);
if (ctx.isOriginLocal()) {
for (WriteCommand wc : command.getModifications()) {
acquireLock(wc);
}
}
return invokeNextInterceptor(ctx, command);
}
{code}
* {{acquireLock()}} in the code above acquires locks *exactly* the same way
{{LockingInterceptor}} would do for a given command.
** E.g. {{acquireLock(PutKeyValueCommand)}} is equivalent with
{{LockingInterceptor.visitPutKeyValueCommand(..)}}
** if in distributed mode, the acquire lock *only* acquires a lock if the key(s) within
{{WriteCommand}} map to the local node
was (Author: mircea.markus):
Suggested design.
When first released, this will be an experimental feature disabled by default.
It will be possible to enable it by using the following configuration element:
{code:xml}
<locking
isolationLevel="READ_COMMITTED"
lockAtPrepareTime="true" />
{code}
In order to preserve the existing functionality and also support *lockAtPrepareTime* a new
interceptor will be added: {{PrepareTimeLockingInterceptor}}:
* it extends {{LockingInterceptor}}
* when *lockAtPrepareTime* is enabled it takes {{LockingInterceptor}}'s place is the
interceptor chain
* it overrides the all {{LockingInterceptor}}'s {{visit<WriteCommand>}} methods
(e.g. visitpPutKeyValueCommand) and does not acquire write locks on these invocations but
read locks
* read locks are acquired similar to {{LockingInterceptor.visitGetKeyValueCommand()}}:
{code:java}
public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand
command) throws Throwable {
try {
entryFactory.wrapEntryForReading(ctx, command.getKey());
return invokeNextInterceptor(ctx, command);
} finally {
doAfterCall(ctx);
}
}
{code}
* {{PrepareTimeLockingInterceptor.visitPrepareCommand}} also overrides the same method
from {{LockingInterceptor}}:
{code:java}
@Override
public Object visitPrepareCommand(TxInvocationContext ctx, PrepareCommand command)
throws Throwable {
super.visitPrepareCommand(ctx, command);
if (ctx.isOriginLocal()) {
for (WriteCommand wc : command.getModifications()) {
acquireLock(wc);
}
}
return invokeNextInterceptor(ctx, command);
}
{code}
* {{acquireLock()}} in the code above acquires locks *exactly* the same way
{{LockingInterceptor}} would do for a given command.
** E.g. {{acquireLock(PutKeyValueCommand}} is equivalent with
{{LockingInterceptor.visitPutKeyValueCommand(..)}}
** if in distributed mode, the acquire lock *only* acquires a lock if the key(s) within
{{WriteCommand}} map to the local node
Locking optimization: acquire (write) locks at prepare time
-----------------------------------------------------------
Key: ISPN-1131
URL:
https://issues.jboss.org/browse/ISPN-1131
Project: Infinispan
Issue Type: Feature Request
Reporter: Mircea Markus
Assignee: Manik Surtani
Labels: locking, optimization
Fix For: 5.1.0.Final
Detailed here, as the 1st improvement:
http://community.jboss.org/wiki/PossibleLockingImprovements
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira