Revision: 16079
Author: baranowb
Date: Tue Dec 28 04:06:40 2010
Log: [SLEE] Update publication enabler and doc.
http://code.google.com/p/mobicents/source/detail?r=16079
Modified:
/trunk/servers/jain-slee/enablers/sip-publication-client/docs/sources/src/main/resources/en-US/Chapter-Integrating_The_Enabler.xml
/trunk/servers/jain-slee/enablers/sip-publication-client/docs/sources/src/main/resources/en-US/Chapter-Using_The_Enabler.xml
/trunk/servers/jain-slee/enablers/sip-publication-client/example/sbb/src/main/java/org/mobicents/slee/enabler/sip/example/PublicationClientParentSbb.java
/trunk/servers/jain-slee/enablers/sip-publication-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/PublicationClientChildActivityContextInterface.java
/trunk/servers/jain-slee/enablers/sip-publication-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/PublicationClientChildSbb.java
/trunk/servers/jain-slee/enablers/sip-publication-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/PublicationClientParent.java
=======================================
---
/trunk/servers/jain-slee/enablers/sip-publication-client/docs/sources/src/main/resources/en-US/Chapter-Integrating_The_Enabler.xml
Fri Dec 17 06:32:44 2010
+++
/trunk/servers/jain-slee/enablers/sip-publication-client/docs/sources/src/main/resources/en-US/Chapter-Integrating_The_Enabler.xml
Tue Dec 28 04:06:40 2010
@@ -77,6 +77,11 @@
public void afterRemovePublication(Result result,
PublicationClientChildLocalInterface child);
+ void newPublicationFailed(PublicationClientChildLocalObject
sbbLocalObject);
+
+ void refreshPublicationFailed(PublicationClientChildLocalObject
sbbLocalObject);
+
+ void removePublicationFailed(PublicationClientChildLocalObject
sbbLocalObject);
}
]]>
</programlisting>
@@ -132,6 +137,38 @@
publication request.</para>
</listitem>
</varlistentry>
+
+
+ <varlistentry>
+ <term>
+ The
+ <literal>newPublicationFailed(PublicationClientChildLocalObject
sbbLocalObject);</literal>
+ method:
+ </term>
+ <listitem>
+ <para>Callback from the Enabler, indicating communication failure.
Enabler must be discarded.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ The
+ <literal>refreshPublicationFailed(PublicationClientChildLocalObject
sbbLocalObject);</literal>
+ method:
+ </term>
+ <listitem>
+ <para>Callback from the Enabler, indicating communication failure.
Enabler must be discarded.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ The
+ <literal>removePublicationFailed(PublicationClientChildLocalObject
sbbLocalObject);</literal>
+ method:
+ </term>
+ <listitem>
+ <para>Callback from the Enabler, indicating communication failure.
Enabler must be discarded.</para>
+ </listitem>
+ </varlistentry>
</variablelist>
=======================================
---
/trunk/servers/jain-slee/enablers/sip-publication-client/docs/sources/src/main/resources/en-US/Chapter-Using_The_Enabler.xml
Fri Dec 17 06:32:44 2010
+++
/trunk/servers/jain-slee/enablers/sip-publication-client/docs/sources/src/main/resources/en-US/Chapter-Using_The_Enabler.xml
Tue Dec 28 04:06:40 2010
@@ -70,9 +70,12 @@
public interface PublicationClientChild {
- public void newPublication(String entity, String eventPackage, String
document, String contentType, String contentSubType, int expires) throws
PublicationException;
-
- public void updatePublication(String document, String contentType, String
contentSubType, int expires) throws PublicationException;
+ public void newPublication(String entity, String eventPackage, String
document
+ , String contentType, String contentSubType
+ , int expires) throws PublicationException;
+
+ public void updatePublication(String document, String contentType, String
contentSubType
+ , int expires) throws PublicationException;
public void removePublication() throws PublicationException;
@@ -297,7 +300,7 @@
</entry>
<entry>
<para>Specifies time drift, in seconds, between value of
Expires/Min-Expires values and automatic refresh performed by enabler. For
instance if Expires value passed(and accepted by ECS/PA)
- is 3600, time drift set to 10, Enabler will refresh publication
after 3590
+ is 3600, time drift set to 10, Enabler will refresh publication
after 3590 seconds
</para>
</entry>
</row>
=======================================
---
/trunk/servers/jain-slee/enablers/sip-publication-client/example/sbb/src/main/java/org/mobicents/slee/enabler/sip/example/PublicationClientParentSbb.java
Fri Dec 17 06:32:44 2010
+++
/trunk/servers/jain-slee/enablers/sip-publication-client/example/sbb/src/main/java/org/mobicents/slee/enabler/sip/example/PublicationClientParentSbb.java
Tue Dec 28 04:06:40 2010
@@ -151,13 +151,22 @@
public void afterNewPublication(Result result,
PublicationClientChildLocalObject child) {
tracer.info("GOT AFTER NEW PUB!: "+result);
-
+ if(result.getStatusCode()>299)
+ {
+ //ie.
+ child.remove();
+ }
}
public void afterRefreshPublication(Result result,
PublicationClientChildLocalObject child) {
tracer.info("GOT AFTER REF PUB!: "+result);
-
+ if(result.getStatusCode()>299)
+ {
+ //ie.
+ child.remove();
+ }else
+ {
//lets update. just to see more flow.
try {
child.updatePublication(fancyXML, "application",
"pidf+xml", 61);
@@ -165,17 +174,43 @@
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+ }
}
public void afterUpdatePublication(Result result,
PublicationClientChildLocalObject child) {
tracer.info("GOT AFTER UPD PUB!: "+result);
+ if(result.getStatusCode()>299)
+ {
+ //ie.
+ child.remove();
+ }
}
public void afterRemovePublication(Result result,
PublicationClientChildLocalObject child) {
tracer.info("GOT AFTER REM PUB!: "+result);
+ child.remove();
}
+
+ @Override
+ public void newPublicationFailed(PublicationClientChildLocalObject
sbbLocalObject) {
+ tracer.info("GOT NEW PUB FAILURE!");
+ sbbLocalObject.remove();
+ }
+
+ @Override
+ public void refreshPublicationFailed(PublicationClientChildLocalObject
sbbLocalObject) {
+ tracer.info("GOT REFRESH PUB FAILURE!");
+ sbbLocalObject.remove();
+
+ }
+
+ @Override
+ public void removePublicationFailed(PublicationClientChildLocalObject
sbbLocalObject) {
+ tracer.info("GOT REMOVE PUB FAILURE!");
+ sbbLocalObject.remove();
+
+ }
}
=======================================
---
/trunk/servers/jain-slee/enablers/sip-publication-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/PublicationClientChildActivityContextInterface.java
Fri Dec 17 06:32:44 2010
+++
/trunk/servers/jain-slee/enablers/sip-publication-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/PublicationClientChildActivityContextInterface.java
Tue Dec 28 04:06:40 2010
@@ -16,7 +16,4 @@
public TimerID getExpiresTimerID();
- public void setPublishRequestType(PublishRequestType t);
-
- public PublishRequestType getPublishRequestType();
-}
+}
=======================================
---
/trunk/servers/jain-slee/enablers/sip-publication-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/PublicationClientChildSbb.java
Fri Dec 17 06:32:44 2010
+++
/trunk/servers/jain-slee/enablers/sip-publication-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/PublicationClientChildSbb.java
Tue Dec 28 04:06:40 2010
@@ -59,7 +59,7 @@
*/
public abstract class PublicationClientChildSbb implements Sbb,
PublicationClientChild {
- private static final int DEFAULT_EXPIRES_DRIFT = 5;
+ private static final int DEFAULT_EXPIRES_DRIFT = 15;
private static Tracer tracer;
protected SbbContext sbbContext;
@@ -100,7 +100,7 @@
@Override
public boolean isRefreshing()
{
- return this.getRefreshCMP();
+ return this.getPublishRequestTypeCMP() ==
PublishRequestType.REFRESH;
}
//FIXME: should xxxPulication methods throw exception to indicate failure
and not clean state? boolean return value is ambiguous.
@Override
@@ -143,7 +143,7 @@
try {
String[] ents = entity.split("@");
SipURI test = addressFactory.createSipURI(ents[0],
ents[1]);
- } catch (ParseException e1) {
+ } catch (Exception e1) {
throw new IllegalArgumentException("Failed to parse
entity!",e1);
}
//otherwise lets kick off.
@@ -172,7 +172,7 @@
//Dont start timer here, since we don't have ETag!
//startExpiresTimer();
-
asSbbActivityContextInterface(ctxAci).setPublishRequestType(PublishRequestType.NEW);
+ setPublishRequestTypeCMP(PublishRequestType.NEW);
ctx.sendRequest();
clear = false;
} catch (TransactionUnavailableException e) {
@@ -232,9 +232,9 @@
{
throw new IllegalArgumentException("expires must be greater
than 0.");
}
- if(getRefreshCMP())
- {
- throw new PublicationException("Enabler is refreshing, cannot send
another PUBLISH!");
+ if(getPublishRequestTypeCMP() != null)
+ {
+ throw new PublicationException("Enabler
is "+getPublishRequestTypeCMP()+", cannot update publication!");
}
cancelExpiresTimer();
//update expire
@@ -257,8 +257,9 @@
//start timer here, if ECS/PA return something else, we
will reschedule.
startExpiresTimer();
-
asSbbActivityContextInterface(ctxAci).setPublishRequestType(PublishRequestType.UPDATE);
+
ctx.sendRequest();
+ setPublishRequestTypeCMP(PublishRequestType.UPDATE);
} catch (TransactionUnavailableException e) {
if(tracer.isSevereEnabled())
{
@@ -298,9 +299,9 @@
{
throw new IllegalStateException("Enabler does not handle any
publication, cannot remove!");
}
- if(getRefreshCMP())
- {
- throw new PublicationException("Enabler is refreshing, cannot send
another PUBLISH!");
+ if(getPublishRequestTypeCMP() != null)
+ {
+ throw new PublicationException("Enabler
is "+getPublishRequestTypeCMP()+", cannot remove publication!");
}else
{
cancelExpiresTimer(); // so no refresh is created.
@@ -318,13 +319,11 @@
ctx =
this.sleeSipProvider.getNewClientTransaction(r);
ctxAci =
this.sipActivityContextInterfaceFactory.getActivityContextInterface(ctx);
ctxAci.attach(this.sbbContext.getSbbLocalObject());
-
-
- //start timer here, if ECS/PA return something else, we will
reschedule.
- startExpiresTimer();
-
-
asSbbActivityContextInterface(ctxAci).setPublishRequestType(PublishRequestType.REMOVE);
+ //cancel timer here, if ECS/PA return something else, we will
reschedule.
+ cancelExpiresTimer();
+
ctx.sendRequest();
+
setPublishRequestTypeCMP(PublishRequestType.REMOVE);
} catch (TransactionUnavailableException e) {
if(tracer.isSevereEnabled())
{
@@ -373,9 +372,9 @@
public abstract int getExpiresCMP();
public abstract void setETagCMP(String d);
public abstract String getETagCMP();
- //flags for simple concurrency control, since SBB is REENTRANT
- public abstract boolean getRefreshCMP();
- public abstract void setRefreshCMP(boolean b);
+ //type of ongoing request.
+ public abstract void setPublishRequestTypeCMP(PublishRequestType t);
+ public abstract PublishRequestType getPublishRequestTypeCMP();
@@ -397,8 +396,8 @@
}
public void onSuccessRespEvent(ResponseEvent event,
ActivityContextInterface ac) {
- //if (tracer.isFineEnabled())
- tracer.info("Received 2xx (SUCCESS)
response:\n"+event.getResponse());
+ if (tracer.isFineEnabled())
+ tracer.fine("Received 2xx (SUCCESS)
response:\n"+event.getResponse());
//2xx, great, lets see...
Response response = event.getResponse();
//get ETag
@@ -413,11 +412,9 @@
}
Result result = new
Result(response.getStatusCode(),SIP_ETag.getETag(),expiresHeader.getExpires(),getEntityCMP());
-
-
-
- PublicationClientChildActivityContextInterface pccAci =
asSbbActivityContextInterface(ac);
- switch (pccAci.getPublishRequestType()) {
+ PublishRequestType type = getPublishRequestTypeCMP();
+ setPublishRequestTypeCMP(null);
+ switch (type) {
case NEW:
cancelExpiresTimer();
startExpiresTimer();
@@ -449,7 +446,6 @@
tracer.severe("Exception in publication
parent!", e);
}
}
- setRefreshCMP(false);
break;
case UPDATE:
cancelExpiresTimer();
@@ -480,8 +476,7 @@
tracer.severe("Exception in publication
parent!", e);
}
}
-
- this.clear();
+ //this.clear();
break;
}
}
@@ -511,10 +506,11 @@
// 423 (Interval Too Brief) response.
//in this case, we may issue another command, let
- PublicationClientChildActivityContextInterface pccAci =
asSbbActivityContextInterface(ac);
- switch (pccAci.getPublishRequestType()) {
+ PublishRequestType type = getPublishRequestTypeCMP();
+ setPublishRequestTypeCMP(null);
+ switch (type) {
case NEW:
- this.clear();
+
try{
this.getParentSbbCMP().afterNewPublication(result,
(PublicationClientChildLocalObject) this.sbbContext.getSbbLocalObject());
}catch(Exception e)
@@ -552,7 +548,7 @@
{
tracer.severe("Received 423 on REMOVE
request!");
}
- this.clear();
+
try{
this.getParentSbbCMP().afterRemovePublication(result,
(PublicationClientChildLocalObject) this.sbbContext.getSbbLocalObject());
}catch(Exception e)
@@ -614,7 +610,14 @@
public void onTimerEvent(TimerEvent event, ActivityContextInterface
aci) {
// refresh time?
- setRefreshCMP(true);
+ if(getPublishRequestTypeCMP() != null)
+ {
+ if(tracer.isSevereEnabled())
+ {
+ tracer.severe("Performing "+getPublishRequestTypeCMP()+", skipping
refresh.");
+ }
+ return;
+ }
PublicationClientChildActivityContextInterface naAci =
asSbbActivityContextInterface(aci);
naAci.setExpiresTimerID(null);
@@ -623,7 +626,46 @@
}
public void onTransactionTimeoutEvent(TimeoutEvent
event,ActivityContextInterface ac) {
- //TODO: add 5xx/4xx ?
+ //bad, failed to communicate
+ PublishRequestType type = getPublishRequestTypeCMP();
+ setPublishRequestTypeCMP(null);
+ //add clear, and pass more as arg to identify culprit?
+ switch (type) {
+ case NEW:
+
+ try {
+
getParentSbbCMP().newPublicationFailed((PublicationClientChildLocalObject)
sbbContext.getSbbLocalObject());
+ } catch (Exception e) {
+ if (tracer.isSevereEnabled()) {
+ tracer.severe("Received exception from parent on subscribe callback",
e);
+ }
+ }
+ //this.clear();
+ break;
+ case REFRESH:
+ //failed to refresh, we should get notify when it times
out.
+
+ try {
+
getParentSbbCMP().refreshPublicationFailed((PublicationClientChildLocalObject)
sbbContext.getSbbLocalObject());
+ } catch (Exception e) {
+ if (tracer.isSevereEnabled()) {
+ tracer.severe("Received exception from parent on subscribe callback",
e);
+ }
+ }
+ //this.clear();
+ break;
+ case REMOVE:
+ //failed to remove, we will receive notify.
+ try {
+
getParentSbbCMP().removePublicationFailed((PublicationClientChildLocalObject)
sbbContext.getSbbLocalObject());
+ } catch (Exception e) {
+ if (tracer.isSevereEnabled()) {
+ tracer.severe("Received exception from parent on subscribe callback",
e);
+ }
+ }
+ //this.clear();
+ break;
+ }
}
public void onActivityEndEvent(javax.slee.ActivityEndEvent event,
ActivityContextInterface aci) {
@@ -647,7 +689,7 @@
setETagCMP(null);
setEventPackageCMP(null);
setExpiresCMP(0);//?
- setRefreshCMP(false);
+ setPublishRequestTypeCMP(null);
//kill null ac
for(ActivityContextInterface aci:
this.sbbContext.getActivities())
{
@@ -903,8 +945,10 @@
//fill data we have.
Result result = new
Result(statusCode,getETagCMP(),getExpiresCMP(),getEntityCMP());
PublicationClientChildActivityContextInterface pccAci =
asSbbActivityContextInterface(ac);
- this.clear();
- switch (pccAci.getPublishRequestType()) {
+ this.clear(); //FIXME: ok to clear?
+ PublishRequestType type = getPublishRequestTypeCMP();
+ setPublishRequestTypeCMP(null);
+ switch (type) {
case NEW:
try{
@@ -982,7 +1026,7 @@
//start timer here, if ECS/PA return something else, we
will reschedule.
startExpiresTimer();
-
asSbbActivityContextInterface(ctxAci).setPublishRequestType(PublishRequestType.REFRESH);
+ setPublishRequestTypeCMP(PublishRequestType.REFRESH);
ctx.sendRequest();
clear = false;
@@ -1017,9 +1061,10 @@
}finally
{
if(clear)
- {
+ {
//something went wrong, clear publication state.
this.clear();
+ //TODO: remove?
}
}
}
@@ -1090,6 +1135,7 @@
*/
@Override
public void sbbRemove() {
+ this.clear();
}
/*
=======================================
---
/trunk/servers/jain-slee/enablers/sip-publication-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/PublicationClientParent.java
Fri Dec 17 06:32:44 2010
+++
/trunk/servers/jain-slee/enablers/sip-publication-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/PublicationClientParent.java
Tue Dec 28 04:06:40 2010
@@ -17,18 +17,81 @@
*/
package org.mobicents.slee.enabler.sip;
-
/**
* @author baranowb
*/
public interface PublicationClientParent {
+ /**
+ * This method is called when publication enabler receives answer for
+ * publication creating request. If answer indicates success, it can be
used
+ * to manage publication, otherwise it must be discarded.
+ *
+ * @param result
+ * - object holding information about operation
+ * @param child
+ * - enabler, which handles publication
+ */
public void afterNewPublication(Result result,
PublicationClientChildLocalObject child);
+ /**
+ * Callback indicating state of publication refresh. Its behaviour is
+ * similar to
+ * {...@link #afterNewPublication(Result,
PublicationClientChildLocalObject)}.
+ *
+ * @param result
+ * - object holding information about operation
+ * @param child
+ * - enabler, which handles publication
+ */
public void afterRefreshPublication(Result result,
PublicationClientChildLocalObject child);
+ /**
+ * Callback method indicating state of publication update. Its behaviour
is
+ * similar to
+ * {...@link #afterNewPublication(Result,
PublicationClientChildLocalObject)}.
+ *
+ * @param result
+ * - object holding information about operation
+ * @param child
+ * - enabler, which handles publication
+ */
public void afterUpdatePublication(Result result,
PublicationClientChildLocalObject child);
+ /**
+ * Callback method indicating state of publication remove. Its behaviour
is
+ * similar to
+ * {...@link #afterNewPublication(Result,
PublicationClientChildLocalObject)}.
+ *
+ * @param result
+ * - object holding information about operation
+ * @param child
+ * - enabler, which handles publication
+ */
public void afterRemovePublication(Result result,
PublicationClientChildLocalObject child);
-}
+ /**
+ * Callback method indicating that communication failed. Enabler must be
+ * discarded
+ *
+ * @param sbbLocalObject
+ */
+ void newPublicationFailed(PublicationClientChildLocalObject
sbbLocalObject);
+
+ /**
+ * Callback method indicating that communication failed. Enabler must be
+ * discarded
+ *
+ * @param sbbLocalObject
+ */
+ void refreshPublicationFailed(PublicationClientChildLocalObject
sbbLocalObject);
+
+ /**
+ * Callback method indicating that communication failed. Enabler must be
+ * discarded
+ *
+ * @param sbbLocalObject
+ */
+ void removePublicationFailed(PublicationClientChildLocalObject
sbbLocalObject);
+
+}