Skip to content

Commit

Permalink
resolving TCK problems
Browse files Browse the repository at this point in the history
  • Loading branch information
satanatoly authored and Anatoly Satanovskiy committed Aug 23, 2017
1 parent 86552a6 commit 818b95e
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 31 deletions.
Expand Up @@ -98,8 +98,8 @@ public ActivityContextImpl(
this.activityContextHandle = activityContextHandle;
this.factory = factory;
this.cacheData = cacheData;
// ac creation, create cache data and set activity flags
this.cacheData.create(activityFlags);
// ac creation, create cache data and set activity flags
this.cacheData.create(activityFlags);
this.flags = activityFlags;
// set access time if needed
if (updateAccessTime) {
Expand Down
Expand Up @@ -2,7 +2,7 @@

public enum ActivityCacheType
{
ATTACHED_SBBS(1),ATTACHED_TIMERS(2),NAMES_BOUND(3),CMP_ATTRIBUTES(4),METADATA(5);
ATTACHED_SBBS(1),ATTACHED_TIMERS(2),NAMES_BOUND(3),CMP_ATTRIBUTES(4),METADATA(5),ENDING(6);

private final int value;

Expand Down
Expand Up @@ -21,6 +21,7 @@ public class ActivityContextCacheDataWrapper
private NameBoundsCacheData nameBoundsCacheData;
private CmpAttributesCacheData cmpAttributesCacheData;
private MetadataCacheData metadataCacheData;
private IsEndingCacheData isEndingCacheData;

public ActivityContextCacheDataWrapper(ActivityContextHandle activityContextHandle,
MobicentsCluster cluster) {
Expand All @@ -30,6 +31,7 @@ public ActivityContextCacheDataWrapper(ActivityContextHandle activityContextHand
this.nameBoundsCacheData=new NameBoundsCacheData(activityContextHandle, cluster.getMobicentsCache());
this.cmpAttributesCacheData=new CmpAttributesCacheData(activityContextHandle, cluster.getMobicentsCache());
this.metadataCacheData=new MetadataCacheData(activityContextHandle, cluster.getMobicentsCache());
this.isEndingCacheData=new IsEndingCacheData(activityContextHandle, cluster.getMobicentsCache());
}

public void create(Integer activityFlags) {
Expand Down Expand Up @@ -57,14 +59,14 @@ public Long getLastAccess() {
}

public boolean isEnding() {
return metadataCacheData.getObject(false, IS_ENDING_NODE_NAME)!=null;
return isEndingCacheData.get()!=null;
}


public boolean setEnding(boolean value) {
if (value) {
if (!isEnding()) {
metadataCacheData.setObject(true, IS_ENDING_NODE_NAME, true);
isEndingCacheData.set(true);
return true;
}
else {
Expand All @@ -73,7 +75,7 @@ public boolean setEnding(boolean value) {
}
else {
if (isEnding()) {
metadataCacheData.removeObject(true, IS_ENDING_NODE_NAME);
isEndingCacheData.remove();
return true;
}
else {
Expand Down Expand Up @@ -234,5 +236,6 @@ public void remove() {
nameBoundsCacheData.removeNode();
cmpAttributesCacheData.removeNode();
metadataCacheData.removeNode();
isEndingCacheData.remove();
}
}
@@ -0,0 +1,24 @@
package org.mobicents.slee.runtime.activity.cache;

import org.mobicents.slee.container.activity.ActivityContextHandle;
import org.restcomm.cache.CacheData;
import org.restcomm.cache.MobicentsCache;

public class IsEndingCacheData extends CacheData<ActivityCacheKey,Boolean>
{
public IsEndingCacheData(ActivityContextHandle handle, MobicentsCache cache) {
super(new ActivityCacheKey(handle, ActivityCacheType.ENDING), cache);
}

public void set(Boolean isEnding) {
super.put(isEnding);
}

public Boolean remove() {
return super.remove();
}

public Boolean get() {
return super.get();
}
}
Expand Up @@ -2,8 +2,6 @@

import java.util.HashMap;

import javax.slee.facilities.TimerID;

import org.mobicents.slee.container.activity.ActivityContextHandle;
import org.restcomm.cache.CacheData;
import org.restcomm.cache.MobicentsCache;
Expand Down
Expand Up @@ -145,7 +145,6 @@ private void routeQueuedEvent() {
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();

try {
System.out.println("PROCESSING EVENT:" + eventContext.getEvent());
final LocalActivityContext lac = eventContext.getLocalActivityContext();
final EventRoutingTask activityCurrentEventRoutingTask = lac.getCurrentEventRoutingTask();
EventContext activityCurrentEventContext = activityCurrentEventRoutingTask == null ? null : activityCurrentEventRoutingTask.getEventContext();
Expand Down
Expand Up @@ -307,7 +307,6 @@ public void remove() {
log.trace("remove()");
}

System.out.println("REMOVING ENTITY");
// removes the SBB entity from all Activity Contexts.
for (Iterator<ActivityContextHandle> i = this.getActivityContexts().iterator(); i.hasNext();) {
ActivityContextHandle ach = i.next();
Expand Down Expand Up @@ -355,7 +354,6 @@ public void remove() {
}
}

System.out.println("REMOVING CACHE DATA");
cacheData.remove();

if (log.isDebugEnabled()) {
Expand Down
Expand Up @@ -24,9 +24,28 @@ public Boolean setField(Boolean createIfNotExists,String name,Object value) {
else {
map=new HashMap<String, Object>(map);
map.put(name, value);
super.putNonTransactional(map);
return true;
}
}
else
return false;
}

public Boolean removeField(Boolean createIfNotExists,String name) {
HashMap<String, Object> map=super.get();
if(map==null && createIfNotExists)
map=new HashMap<String, Object>();

if(map!=null) {
if(map.containsKey(name)) {
map.remove(name);
super.put(map);
return true;
}
else {
return false;
}
}
else
return false;
Expand Down
Expand Up @@ -13,7 +13,7 @@
public class EventMasksCacheData extends CacheData<SbbEntityCacheKey,HashMap<ActivityContextHandle,Set<EventTypeID>>>
{
public EventMasksCacheData(SbbEntityID handle, MobicentsCache cache) {
super(new SbbEntityCacheKey(handle, SbbEntityCacheType.ATTACHED_CONTEXTS), cache);
super(new SbbEntityCacheKey(handle, SbbEntityCacheType.MASKED_EVENTS), cache);
}

public Boolean setEventMask(Boolean createIfNotExists,ActivityContextHandle handle,Set<EventTypeID> mask) {
Expand Down
@@ -1,7 +1,6 @@
package org.mobicents.slee.runtime.sbbentity.cache;

import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import javax.slee.EventTypeID;

Expand All @@ -21,8 +20,6 @@ public class SbbEntityCacheDataWrapper
private MetadataCacheData metadataCacheData;
private ParentEntityCacheData parentEntityCacheData;

private ConcurrentHashMap<String, Object> _cmpFieldsLocal = new ConcurrentHashMap<String, Object>();

public SbbEntityCacheDataWrapper(SbbEntityID sbbEntityID,
MobicentsCluster cluster) {

Expand Down Expand Up @@ -84,23 +81,16 @@ public void updateEventMask(ActivityContextHandle ac, Set<EventTypeID> maskedEve
}

public void setCmpField(String cmpField, Object cmpValue) {
cmpFieldsCacheData.setField(true, cmpField, cmpValue);

if (cmpField != null && cmpValue != null) {
_cmpFieldsLocal.put(cmpField, cmpValue);
}
System.out.println("Settings CMP Field:" + cmpField + ",Value:" + cmpValue);
if(cmpValue==null)
cmpFieldsCacheData.removeField(true, cmpField);
else
cmpFieldsCacheData.setField(true, cmpField, cmpValue);
}

public Object getCmpField(String cmpField) {
try {
return cmpFieldsCacheData.getField(false, cmpField);
}
catch (IllegalStateException stateException) {
// this happen when transaction is rollbackOnly and Infinispan throws exception:
// IllegalStateException (ActionStatus.ABORT_ONLY >
// is not in a valid state to be invoking cache operations on)
return _cmpFieldsLocal.get(cmpField);
}
System.out.println("Getting CMP Field:" + cmpField);
return cmpFieldsCacheData.getField(false, cmpField);
}

public Set<SbbEntityID> getChildRelationSbbEntities(String getChildRelationMethod) {
Expand All @@ -112,12 +102,10 @@ public Set<SbbEntityID> getAllChildSbbEntities() {
}

public void remove() {
System.out.println("REMOVING NODE");
attachedActivityContextsCacheData.removeNode();
cmpFieldsCacheData.removeNode();
eventMasksCacheData.removeNode();
metadataCacheData.removeNode();
parentEntityCacheData.removeNode();
_cmpFieldsLocal.clear();
}
}

0 comments on commit 818b95e

Please sign in to comment.