RestComm / jain-slee

The World's #1 Open Source JAIN-SLEE (JSLEE) 1.1 Implementation
http://www.restcomm.com/
GNU Affero General Public License v3.0
25 stars 50 forks source link

[SBB Life cycle] Store and passivate SBB Entities #53

Closed SergeyLee closed 7 years ago

SergeyLee commented 8 years ago

This issue is a new feature for SBB passivation in some use cases.

Now SBB passivation works only for sbbEntity when it is not null and its sbbObject is not null:

https://github.com/RestComm/jain-slee/blob/2.x/container/router/src/main/java/org/mobicents/slee/runtime/eventrouter/routingtask/EventRoutingTaskImpl.java#L540-L543

The solution is passivation of all SBB Entities in the transaction context if the sbbObject is not null.

...
sbbEntity.passivateAndReleaseSbbObject();

final Collection coll = txMgr.getTransactionContext().getData().keySet();
final SbbEntityID ongoingEntID = sbbEntity.getSbbEntityId();
TransactionalAction removeLoadedSBBAction = new TransactionalAction() {
    @Override
    public void execute() {
        for (Object obj : coll) {
            if (obj instanceof SbbEntityID) {
                if (!obj.equals(ongoingEntID)) {
                    SbbEntity currentEntity = (SbbEntity) txMgr.getTransactionContext().getData().get(obj);
                    if (currentEntity.getSbbObject() != null) {
                        currentEntity.passivateAndReleaseSbbObject();
                    }
                }
            }
        }
    }
};
txMgr.getTransactionContext().getBeforeCommitPriorityActions().add(removeLoadedSBBAction);
...
SergeyLee commented 8 years ago

This issue is related to issue #41.

baranowb commented 8 years ago

Why: "if (!obj.equals(ongoingEntID)) {" ?

SergeyLee commented 8 years ago

Because ongoingEntID is

final SbbEntityID ongoingEntID = sbbEntity.getSbbEntityId();

and we already passivate sbbEntity.