Examples of CNSTopic


Examples of com.comcast.cns.model.CNSTopic

  }

  @Override
  public void updateTopicDisplayName(String arn, String displayName) throws Exception {

    CNSTopic topic = getTopic(arn);

    if (topic != null) {
      topic.setDisplayName(displayName);
      topic.checkIsValid();
      cassandraHandler.insertRow(AbstractDurablePersistence.CNS_KEYSPACE, topic.getArn(), columnFamilyTopics, getColumnValues(topic), CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, null);
    }
   
    CNSCache.removeTopic(arn);
  }
View Full Code Here

Examples of com.comcast.cns.model.CNSTopic

   
    // subscription is unique by protocol + endpoint + topic

    final CNSSubscription subscription = new CNSSubscription(endpoint, protocol, topicArn, userId);

    CNSTopic t = PersistenceFactory.getTopicPersistence().getTopic(topicArn);
   
    if (t == null) {
      throw new TopicNotFoundException("Resource not found.");
    }
   
View Full Code Here

Examples of com.comcast.cns.model.CNSTopic

        nextTokenComposite = cassandraHandler.getCmbComposite(endpoint, tokProtocol.name());
    }

    List<CNSSubscription> l = new ArrayList<CNSSubscription>();
   
    CNSTopic t = PersistenceFactory.getTopicPersistence().getTopic(topicArn);
   
    if (t == null) {
      throw new TopicNotFoundException("Resource not found.");
    }
   
View Full Code Here

Examples of com.comcast.cns.model.CNSTopic

      String topicName = "T" + rand.nextLong();

      String userId1 = user1.getUserId();
      String userId2 = user2.getUserId();

      CNSTopic t = topicHandler.createTopic(topicName, topicName, userId2);
      topicArn = t.getArn();
     
      try {
                topicHandler.deleteTopic(topicArn); //delete any pre-existing state
            } catch (Exception e) { }
           
            t = topicHandler.createTopic(topicName, topicName, userId2);
            topicArn = t.getArn();

      ICNSSubscriptionPersistence subscriptionHandler = new CNSSubscriptionCassandraPersistence();
      long beforeSubscribeCount = subscriptionHandler.getCountSubscription(t.getArn(), "subscriptionPending");

      CNSSubscription s = subscriptionHandler.subscribe(CMBTestingConstants.HTTP_ENDPOINT_BASE_URL + "recv/1234", CnsSubscriptionProtocol.http, t.getArn(), userId1);

      long afterSubscribeCount = subscriptionHandler.getCountSubscription(t.getArn(), "subscriptionPending");
     
      // check default delivery policy on topic1
     
      CNSSubscriptionAttributes attributes = attributeHandler.getSubscriptionAttributes(s.getArn());
     
      assertTrue("Expected 3 retries in healthy policy, instead found " + attributes.getEffectiveDeliveryPolicy().getHealthyRetryPolicy().getNumRetries(), attributes.getEffectiveDeliveryPolicy().getHealthyRetryPolicy().getNumRetries() == 3);
     
      List<CNSSubscription> l = subscriptionHandler.listSubscriptions(null, null, userId1);

      assertTrue("Could not verify PendingConfirmation state", l.size() == 1 && l.get(0).getArn().equals("PendingConfirmation"));

      s = subscriptionHandler.confirmSubscription(false, s.getToken(), t.getArn());

      l = subscriptionHandler.listSubscriptions(null, null, userId1);

      assertTrue("Expected 1 subscription, instead found " + l.size(), l.size() == 1);

      l = subscriptionHandler.listSubscriptionsByTopic(null, t.getArn(), null);

      assertTrue("Expected 1 subscription, instead found " + l.size(), l.size() == 1);

      l = subscriptionHandler.listSubscriptionsByTopic(null, t.getArn(), CnsSubscriptionProtocol.http);

      assertTrue("Expected 1 subscription, instead found " + l.size(), l.size() == 1);
     
      l = subscriptionHandler.listSubscriptionsByTopic(null, t.getArn(), CnsSubscriptionProtocol.email);

      assertTrue("Expected 0 subscription, instead found " + l.size(), l.size() == 0);
     
      assertTrue("Wrong number of subscribers", afterSubscribeCount == beforeSubscribeCount+1);

      try {
        l = subscriptionHandler.listSubscriptionsByTopic(null, com.comcast.cns.util.Util.generateCnsTopicArn("xyz", "east", userId1), null);
      } catch (CMBException ex) {
        assertTrue(ex.getCMBCode().equals(CMBErrorCodes.NotFound.getCMBCode()));
      }
     
      CNSSubscription sdup = subscriptionHandler.getSubscription(s.getArn());
     
      assertTrue("Subscriptions are not identical: " + s + "; " + sdup, s.equals(sdup));
     
      long beforeUnsubscribeCount = subscriptionHandler.getCountSubscription(t.getArn(), "subscriptionDeleted");

      subscriptionHandler.unsubscribe(s.getArn());
     
      long afterUnsubscribeCount = subscriptionHandler.getCountSubscription(t.getArn(), "subscriptionDeleted");

      l = subscriptionHandler.listSubscriptions(null, null, userId1);

      assertTrue("Expected 0 subscription, instead found " + l.size(), l.size() == 0);
     
View Full Code Here

Examples of com.comcast.cns.model.CNSTopic

    try {

      String userId1 = user1.getUserId();

      String topicName = "T" + rand.nextLong();
      CNSTopic t = topicHandler.createTopic(topicName, topicName, userId1);
      topicArn = t.getArn();

      ICNSSubscriptionPersistence subscriptionHandler = new CNSSubscriptionCassandraPersistence();

      for (int i=1; i<=96; i++) {
        subscriptionHandler.subscribe(CMBTestingConstants.HTTP_ENDPOINT_BASE_URL + "recv/" + i, CnsSubscriptionProtocol.http, t.getArn(), userId1);
      }
     
      CNSTestingUtils.confirmPendingSubscriptionsByTopic(t.getArn(), userId1, CnsSubscriptionProtocol.http);
     
      for (int i=97; i<=103; i++) {
     
        subscriptionHandler.subscribe(CMBTestingConstants.HTTP_ENDPOINT_BASE_URL + "recv/" + i, CnsSubscriptionProtocol.http, t.getArn(), userId1);
        CNSTestingUtils.confirmPendingSubscriptionsByTopic(t.getArn(), userId1, CnsSubscriptionProtocol.http);
        Set<String> keys = new TreeSet<String>();
       
        List<CNSSubscription> l = subscriptionHandler.listSubscriptions(null, null, userId1);
        List<CNSSubscription> a = new ArrayList<CNSSubscription>();
       
View Full Code Here

Examples of com.comcast.cns.model.CNSTopic

        try {

            String userId1 = user1.getUserId();

            String topicName = "T" + rand.nextLong();
            CNSTopic t = topicHandler.createTopic(topicName, topicName, userId1);
            topicArn = t.getArn();

            ICNSSubscriptionPersistence subscriptionHandler = new CNSSubscriptionCassandraPersistence();

            for (int i=1; i<=200; i++) {
                subscriptionHandler.subscribe(CMBTestingConstants.HTTP_ENDPOINT_BASE_URL + "recv/" + i, CnsSubscriptionProtocol.http, t.getArn(), userId1);
            }
           
            CNSTestingUtils.confirmPendingSubscriptionsByTopic(t.getArn(), userId1, CnsSubscriptionProtocol.http);
            ts1 = System.currentTimeMillis();
            List<CNSSubscription> l = subscriptionHandler.listSubscriptionsByTopic(null, t.getArn(), null, 1000);
            int totalSize = 0;
       
            while (totalSize != 200 && l.size() > 0) {
                totalSize += l.size();
                logger.info("Number of subscriptions is " + totalSize);
                l = subscriptionHandler.listSubscriptionsByTopic(l.get(l.size() - 1).getArn(), t.getArn(), null, 1000);
            }
           
            if (totalSize != 200) {
                fail("Expected 200 subscriptions, instead found " + totalSize);
            }
View Full Code Here

Examples of com.comcast.cns.model.CNSTopic

            String topicName = "T" + rand.nextLong();

            String userId1 = user1.getUserId();
            String userId2 = user2.getUserId();

            CNSTopic t = topicHandler.createTopic(topicName, topicName, userId2);
            topicArn = t.getArn();

            ICNSSubscriptionPersistence subscriptionHandler = new CNSSubscriptionCassandraPersistence();
            subscriptionHandler.subscribe(CMBTestingConstants.HTTP_ENDPOINT_BASE_URL + "recv/1234", CnsSubscriptionProtocol.http, t.getArn(), userId1);
           
        } catch (Exception ex) {
           
            fail(ex.toString());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.