[infinispan-issues] [JBoss JIRA] (ISPN-3664) Improve write command processing

Pedro Ruivo (JIRA) jira-events at lists.jboss.org
Fri Oct 25 14:09:01 EDT 2013


Pedro Ruivo created ISPN-3664:
---------------------------------

             Summary: Improve write command processing
                 Key: ISPN-3664
                 URL: https://issues.jboss.org/browse/ISPN-3664
             Project: Infinispan
          Issue Type: Enhancement
    Affects Versions: 6.0.0.CR1
            Reporter: Pedro Ruivo
            Assignee: Pedro Ruivo
             Fix For: 7.0.0.Final


Major refactorization of the write command with the following goals:
-> Base WriteCommand: all the write command has the same workflow through the interceptor chain
-> Create a concrete WriteCommand for each operation (put, remove, replace, replaceIfEquals, removeIfEquals, putIfAbsent)
-> Extend the interceptor chain to process each one of the command and add a new "visitWriteCommand", that is invoked by the default visitX methods.
-> (minor) change the GetKeyValueCommand to ReadCommand to make name "compatible" with WriteCommand.

The above it is safe and it would make the code simple. The basic flow of the write commands are: (non-tx) lock, fetch value (cachestore/remote), check condition and apply change

Suggested implementation

class abstract WriteCommand
Object key, Object newValue
boolen match(Object currentValue) //true by default
boolean needsRemoteGetBeforeWrite() //true by default
object perform() //common implementation like: if (match(entry.getValue()) then entry.setValue(newValue); entry.setChanged(true); entry.setRemoved(newValue == null)}

* Concrete implementations*
{PutCommand|RemoveCommand} extends WriteCommand
ovewrite needsRemoteGetBeforeWrite() {return !flags.contains(IGNORE_RETURN_VALUE)}

ReplaceIfPresentCommand extends WriteCommand
ovewrite match(Object currentValue) {return currentValue != null}

PutIfAbsentCommand extends WriteCommand
ovewrite match(Object currentValue) {return currentValue == null}

* Special base class for operation with expected value to compare*
class abstract AdvancedWriteCommand extends WriteCommand
Object expectedValue
match(Object currentValue) {return currentValue.equals(expectedValue)}

{RemoveIfEquals|ReplaceIfEquals} extends AdvancedWriteCommand //no different implementation needed.

ps: I'm going to open the discussion in the dev mailing list...

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the infinispan-issues mailing list