Logo Search packages:      
Sourcecode: libjgroups-java version File versions

boolean org::jgroups::blocks::DistributedLockManager::processResponses ( RspList  responses,
int  consensusType,
Object  decree 
) throws ChannelException [inline]

Processes the response list and votes like the default processResponses method with the consensusType VOTE_ALL If the result of the voting is false, but this DistributedLockManager owns the lock, the result is changed to true and the lock is released, but marked as multiple locked. (only in the prepare state to reduce traffic)

Note: we do not support voting in case of Byzantine failures, i.e. when the node responds with the fault message.

Implements org::jgroups::blocks::VoteResponseProcessor.

Definition at line 512 of file DistributedLockManager.java.

References checkResponse(), org::jgroups::blocks::DistributedLockManager::LockDecree::getKey(), org::jgroups::blocks::VotingAdapter::VoteResult::getNegativeVotes(), org::jgroups::blocks::VotingAdapter::VoteResult::getPositiveVotes(), org::jgroups::util::Rsp::getValue(), org::jgroups::blocks::DistributedLockManager::LockDecree::isMultipleLocked(), lock(), and org::jgroups::blocks::DistributedLockManager::LockDecree::setMultipleLocked().

        if (responses == null) {
            return false;

        int totalPositiveVotes = 0;
        int totalNegativeVotes = 0;

        for (int i = 0; i < responses.size(); i++) {
            Rsp response = (Rsp) responses.elementAt(i);

            switch (checkResponse(response)) {
                case PROCESS_SKIP:
                case PROCESS_BREAK:
                    return false;

            VoteResult result = (VoteResult) response.getValue();

            totalPositiveVotes += result.getPositiveVotes();
            totalNegativeVotes += result.getNegativeVotes();

        boolean voteResult = (totalNegativeVotes == 0 && totalPositiveVotes > 0);

        if (decree instanceof TwoPhaseVotingAdapter.TwoPhaseWrapper) {
            TwoPhaseVotingAdapter.TwoPhaseWrapper wrappedDecree = (TwoPhaseVotingAdapter.TwoPhaseWrapper)decree;
            if (wrappedDecree.isPrepare()) {
                Object unwrappedDecree = wrappedDecree.getDecree();
                if (unwrappedDecree instanceof ReleaseLockDecree) {
                    ReleaseLockDecree releaseLockDecree = (ReleaseLockDecree)unwrappedDecree;
                    LockDecree lock = null;
                    if ((lock = (LockDecree)heldLocks.get(releaseLockDecree.getKey())) != null) {
                        // If there is a local lock...
                        if (!voteResult) {
                            // ... and another DLM voted negatively, but this DLM owns the lock
                            // we inform the other node, that it's lock is multiple locked
                            if (informLockingNodes(releaseLockDecree)) {

                                // we set the local lock to multiple locked

                                voteResult = true;
                        if (lock.isMultipleLocked()) {
                            //... and the local lock is marked as multilocked
                            // we mark the releaseLockDecree als multiple locked for evaluation when unlock returns

        return voteResult;

Generated by  Doxygen 1.6.0   Back to index