You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by ks...@apache.org on 2011/05/20 15:33:59 UTC
svn commit: r1125378 - in /juddi/trunk:
juddi-core/src/main/java/org/apache/juddi/subscription/
uddi-tck-base/src/main/java/org/apache/juddi/v3/tck/
uddi-tck/src/test/java/org/apache/juddi/v3/tck/
Author: kstam
Date: Fri May 20 13:33:58 2011
New Revision: 1125378
URL: http://svn.apache.org/viewvc?rev=1125378&view=rev
Log:
JUDDI-483, Taking out the write lock. it is unlikely we would see multiple notifications being sent out.
Modified:
juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java
juddi/trunk/uddi-tck-base/src/main/java/org/apache/juddi/v3/tck/TckBusiness.java
juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerIntegrationTest.java
Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java?rev=1125378&r1=1125377&r2=1125378&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java (original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java Fri May 20 13:33:58 2011
@@ -25,7 +25,6 @@ import java.util.TimerTask;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
-import javax.persistence.LockModeType;
import javax.persistence.Query;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
@@ -118,7 +117,7 @@ public class SubscriptionNotifier extend
{
if ((firedOnTime(scheduledExecutionTime()) || alwaysNotify) && registryMayContainUpdates()) {
long startTime = System.currentTimeMillis();
- log.debug("Start Notification background task; checking if subscription notifications need to be send out..");
+ log.info("Start Notification background task; checking if subscription notifications need to be send out..");
Collection<Subscription> subscriptions = getAllAsyncSubscriptions();
for (Subscription subscription : subscriptions) {
@@ -170,7 +169,7 @@ public class SubscriptionNotifier extend
} else {
log.warn("NotificationTimer is lagging " + lagTime + " milli seconds behind. A lag time "
+ "which exceeds an acceptable lagtime of " + acceptableLagTime + "ms indicates "
- + "that the registry server is under stress. We are therefore skipping this notification "
+ + "that the registry server is under load or was in sleep mode. We are therefore skipping this notification "
+ "cycle.");
return false;
}
@@ -240,24 +239,34 @@ public class SubscriptionNotifier extend
* @throws MalformedURLException
* @throws DispositionReportFaultMessage
*/
- protected void notify(GetSubscriptionResults getSubscriptionResults, SubscriptionResultsList resultList)
+ protected synchronized void notify(GetSubscriptionResults getSubscriptionResults, SubscriptionResultsList resultList)
{
EntityManager em = PersistenceManager.getEntityManager();
EntityTransaction tx = em.getTransaction();
try {
- tx.begin();
+
org.apache.juddi.model.Subscription modelSubscription = em.find(org.apache.juddi.model.Subscription.class, resultList.getSubscription().getSubscriptionKey());
- log.debug("Taking out a write lock on this subscription, and bail if we can't get it since that would mean"
- + " another jUDDI instance is in the process of sending out the notification.");
- em.lock(modelSubscription, LockModeType.WRITE);
+ //log.debug("Taking out a write lock on this subscription, and bail if we can't get it since that would mean"
+ // + " another jUDDI instance is in the process of sending out the notification.");
+ //em.lock(modelSubscription, LockModeType.WRITE);
+ Date notificationDate = new Date();
Date startPoint = resultList.getCoveragePeriod().getStartPoint().toGregorianCalendar().getTime();
Date endPoint = resultList.getCoveragePeriod().getEndPoint().toGregorianCalendar().getTime();
+
+
if (modelSubscription.getLastNotified()!=null
&& startPoint.before(modelSubscription.getLastNotified())
&& endPoint.after(modelSubscription.getLastNotified())) {
log.info("We already send out a notification within this coverage period, no need to send another one.");
return;
}
+
+ //now log to the db that we completed sending the notification.
+ tx.begin();
+ modelSubscription.setLastNotified(notificationDate);
+ em.persist(modelSubscription);
+ tx.commit();
+
org.apache.juddi.model.BindingTemplate bindingTemplate= em.find(org.apache.juddi.model.BindingTemplate.class, modelSubscription.getBindingKey());
NotifySubscriptionListener body = new NotifySubscriptionListener();
if (resultList.getServiceList()!=null && resultList.getServiceList().getServiceInfos()!=null &&
@@ -267,13 +276,16 @@ public class SubscriptionNotifier extend
body.setSubscriptionResultsList(resultList);
String authorizedName = modelSubscription.getAuthorizedName();
UDDISecurityImpl security = new UDDISecurityImpl();
- try {
- //obtain a token for this publisher
- org.uddi.api_v3.AuthToken token = security.getAuthToken(authorizedName);
- body.setAuthInfo(token.getAuthInfo());
- } catch (DispositionReportFaultMessage e) {
- body.setAuthInfo("Failed to generate token, please contact UDDI admin");
- log.error(e.getMessage(),e);
+
+ if (authorizedName != null) { // add a security token if needed
+ try {
+ //obtain a token for this publisher
+ org.uddi.api_v3.AuthToken token = security.getAuthToken(authorizedName);
+ body.setAuthInfo(token.getAuthInfo());
+ } catch (DispositionReportFaultMessage e) {
+ body.setAuthInfo("Failed to generate token, please contact UDDI admin");
+ log.error(e.getMessage(),e);
+ }
}
if (bindingTemplate!=null) {
@@ -295,10 +307,7 @@ public class SubscriptionNotifier extend
notifier.notifySubscriptionListener(body);
chunkToken=body.getSubscriptionResultsList().getChunkToken();
}
- //now log to the db that we completed sending the notification.
- Date notificationDate = new Date();
- modelSubscription.setLastNotified(notificationDate);
- em.persist(modelSubscription);
+
} catch (Exception e) {
log.error(e.getMessage(),e);
}
@@ -308,7 +317,7 @@ public class SubscriptionNotifier extend
} else {
log.error("There is no valid binding template defined for this subscription: " + modelSubscription.getBindingKey());
}
- tx.commit();
+
} finally {
if (tx.isActive()) {
tx.rollback();
Modified: juddi/trunk/uddi-tck-base/src/main/java/org/apache/juddi/v3/tck/TckBusiness.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck-base/src/main/java/org/apache/juddi/v3/tck/TckBusiness.java?rev=1125378&r1=1125377&r2=1125378&view=diff
==============================================================================
--- juddi/trunk/uddi-tck-base/src/main/java/org/apache/juddi/v3/tck/TckBusiness.java (original)
+++ juddi/trunk/uddi-tck-base/src/main/java/org/apache/juddi/v3/tck/TckBusiness.java Fri May 20 13:33:58 2011
@@ -50,7 +50,7 @@ public class TckBusiness
final static String SAM_BUSINESS_KEY = "uddi:www.samco.com:samco";
final static String COMBINE_CATBAGS_BIZ_XML = "uddi_data/joepublisher/combineCatBagsBusinessServices.xml";
final static String COMBINE_CATBAGS_BIZ_KEY = "uddi:uddi.joepublisher.com:business01";
- public final static String RIFTSAW_BUSINESS_KEY = "uddi:riftsaw.jboss.org:redhat-jboss";
+ public final static String RIFTSAW_BUSINESS_KEY = "uddi:riftsaw.jboss.org:business_redhat-jboss";
public final static String RIFTSAW_BUSINESS_XML = "uddi_data/bpel/riftsaw/businessEntity.xml";
Modified: juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerIntegrationTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerIntegrationTest.java?rev=1125378&r1=1125377&r2=1125378&view=diff
==============================================================================
--- juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerIntegrationTest.java (original)
+++ juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerIntegrationTest.java Fri May 20 13:33:58 2011
@@ -14,6 +14,8 @@ package org.apache.juddi.v3.tck;
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import java.util.Date;
+
import javax.xml.ws.Endpoint;
import org.apache.commons.configuration.ConfigurationException;
@@ -52,6 +54,7 @@ public class UDDI_090_SubscriptionListen
manager.stop();
//shutting down the TCK SubscriptionListener
endPoint.stop();
+ endPoint = null;
}
@BeforeClass
@@ -96,8 +99,9 @@ public class UDDI_090_SubscriptionListen
//Saving the Subscription
tckSubscriptionListener.saveNotifierSubscription(authInfoJoe);
//Changing the service we subscribed to "JoePublisherService"
+ Thread.sleep(1000);
logger.info("Updating Service ********** ");
- tckBusinessService.updateJoePublisherService(authInfoJoe, "foo");
+ tckBusinessService.updateJoePublisherService(authInfoJoe, "foo" + new Date());
//tckSubscriptionListener.changeSubscribedObject(authInfoJoe);
//waiting up to 100 seconds for the listener to notice the change.
@@ -106,6 +110,7 @@ public class UDDI_090_SubscriptionListen
Thread.sleep(500);
System.out.print(".");
if (UDDISubscriptionListenerImpl.notificationCount > 0) {
+ logger.info("Received Notification");
break;
} else {
System.out.print(test);
@@ -119,21 +124,15 @@ public class UDDI_090_SubscriptionListen
}
} catch (Exception e) {
+ logger.error("No exceptions please.");
e.printStackTrace();
Assert.fail();
} finally {
- endPoint.stop();
- endPoint = null;
- //do a best effort to remove these artifacts
- try {
tckSubscriptionListener.deleteNotifierSubscription(authInfoJoe);
tckBusinessService.deleteJoePublisherService(authInfoJoe);
tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
tckTModel.deleteJoePublisherTmodel(authInfoJoe);
- } catch (Exception e) {
- e.printStackTrace();
- }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org