Package com.comcast.cmb.common.persistence.AbstractDurablePersistence

Examples of com.comcast.cmb.common.persistence.AbstractDurablePersistence.CmbComposite


        return CnsSubscriptionProtocol.valueOf(arr[0]);
    }
 
    private void insertOrUpdateSubsAndIndexes(final CNSSubscription subscription, Integer ttl) throws Exception {
        subscription.checkIsValid();
        CmbComposite columnName = cassandraHandler.getCmbComposite(subscription.getEndpoint(), subscription.getProtocol().name());
        cassandraHandler.update(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilySubscriptions, subscription.getTopicArn(), columnName, getColumnValuesJSON(subscription), CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.COMPOSITE_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, ttl);
        cassandraHandler.insertRow(AbstractDurablePersistence.CNS_KEYSPACE, subscription.getArn(), columnFamilySubscriptionsIndex, getIndexColumnValues(subscription.getEndpoint(), subscription.getProtocol()), CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, ttl);
        cassandraHandler.insertRow(AbstractDurablePersistence.CNS_KEYSPACE, subscription.getUserId(), columnFamilySubscriptionsUserIndex, new HashMap<String, String>() {{ put(subscription.getArn(), "");}}, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, ttl);
        cassandraHandler.insertRow(AbstractDurablePersistence.CNS_KEYSPACE, subscription.getToken(), columnFamilySubscriptionsTokenIndex, new HashMap<String, String>() {{ put(subscription.getArn(), "");}}, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, ttl);
  }
View Full Code Here


      //get Column from main table
       
      String colName = slice.getColumns().get(0).getName();
        CnsSubscriptionProtocol protocol = getEndpointAndProtoIndexValProtocol(colName);
        String endpoint = getEndpointAndProtoIndexValEndpoint(colName);
        CmbComposite columnName = cassandraHandler.getCmbComposite(endpoint, protocol.name());
        CmbColumn<CmbComposite, String> column = cassandraHandler.readColumn(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilySubscriptions, Util.getCnsTopicArn(arn), columnName, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.COMPOSITE_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
       
        if (column != null) {
            CNSSubscription s = extractSubscriptionFromColumn(column, Util.getCnsTopicArn(arn));
            s.checkIsValid();
View Full Code Here

                throw new SubscriberNotFoundException("Subscriber not found for arn " + nextToken);
            }
        }
     
    //read from index to get composite-col-name corresponding to nextToken
    CmbComposite nextTokenComposite = null;
   
    if (nextToken != null) {
        CmbColumnSlice<String, String> slice = cassandraHandler.readColumnSlice(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilySubscriptionsIndex, nextToken, null, null, 1, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
        if (slice == null) {
          throw new IllegalArgumentException("Could not find any subscription with arn " + nextToken);
View Full Code Here

    CNSSubscription s = getSubscription(arn);
   
    if (s != null) {

      deleteIndexes(arn, s.getUserId(), s.getToken());
      CmbComposite columnName = cassandraHandler.getCmbComposite(s.getEndpoint(), s.getProtocol().name());
      cassandraHandler.delete(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilySubscriptions, Util.getCnsTopicArn(arn), columnName, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.COMPOSITE_SERIALIZER);
     
      if (s.isConfirmed()) {
        cassandraHandler.decrementCounter(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilyTopicStats, s.getTopicArn(), "subscriptionConfirmed", 1, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
      } else {
View Full Code Here

    if (message.getAttributes().containsKey(CQSConstants.DELAY_SECONDS)) {
      delaySeconds = Integer.parseInt(message.getAttributes().get(CQSConstants.DELAY_SECONDS));
    }
   
    long ts = System.currentTimeMillis() + delaySeconds*1000;
    CmbComposite columnName = cassandraHandler.getCmbComposite(AbstractDurablePersistence.newTime(ts, false), UUIDGen.getClockSeqAndNode());
    int ttl = queue.getMsgRetentionPeriod();
    int partition = rand.nextInt(queue.getNumberOfPartitions());
    String key = Util.hashQueueUrl(queue.getRelativeUrl()) + "_" + shard + "_" + partition;
   
    if (queue.isCompressed()) {
      message.setBody(Util.compress(message.getBody()));
    }

    message.setMessageId(key + ":" + columnName.get(0) + ":" + columnName.get(1));

    logger.debug("event=send_message ttl=" + ttl + " delay_sec=" + delaySeconds + " msg_id=" + message.getMessageId() + " key=" + key + " col=" + columnName);
   
    cassandraHandler.update(AbstractDurablePersistence.CQS_KEYSPACE, COLUMN_FAMILY_PARTITIONED_QUEUE_MESSAGES, key, columnName, getMessageJSON(message),
        CMB_SERIALIZER.STRING_SERIALIZER,
View Full Code Here

     
      boolean noMatch = true;
     
      for (CmbColumn<CmbComposite, String> column : columnSlice.getColumns()) {
       
        CmbComposite columnName = column.getName();
       
        if (ignoreFirstLastColumn && (previousHandle != null && columnName.compareTo(previousHandle) == 0) || (nextHandle != null && columnName.compareTo(nextHandle) == 0)) {
          noMatch = false;
          continue;
        } else if (column.getValue() == null || column.getValue().length() == 0) {
          continue;
        }
View Full Code Here

      if (message.getAttributes().containsKey(CQSConstants.DELAY_SECONDS)) {
        delaySeconds = Integer.parseInt(message.getAttributes().get(CQSConstants.DELAY_SECONDS));
      }
     
      long ts = System.currentTimeMillis() + delaySeconds*1000;
      CmbComposite columnName = cassandraHandler.getCmbComposite(AbstractDurablePersistence.newTime(ts, false), UUIDGen.getClockSeqAndNode());

      message.setMessageId(key + ":" + columnName.get(0) + ":" + columnName.get(1));
     
      logger.debug("event=send_message_batch msg_id=" + message.getMessageId() + " ttl=" + ttl + " delay_sec=" + delaySeconds + " key=" + key + " col=" + columnName);
     
      String messageJson = getMessageJSON(message);
      messageDataMap.put(columnName, messageJson);
View Full Code Here

    if (receiptHandleParts.length != 3) {
      logger.error("event=delete_message event=invalid_receipt_handle queue_url=" + queueUrl + " receipt_handle=" + receiptHandle);
      return;
    }
   
    CmbComposite columnName = cassandraHandler.getCmbComposite(Arrays.asList(Long.parseLong(receiptHandleParts[1]), Long.parseLong(receiptHandleParts[2])));
   
    if (columnName != null) {
      logger.debug("event=delete_message receipt_handle=" + receiptHandle + " col=" + columnName + " key=" + receiptHandleParts[0]);
      cassandraHandler.delete(AbstractDurablePersistence.CQS_KEYSPACE, COLUMN_FAMILY_PARTITIONED_QUEUE_MESSAGES, receiptHandleParts[0], columnName, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.COMPOSITE_SERIALIZER);
    }
View Full Code Here

   
    String queueHash = Util.hashQueueUrl(queueUrl);
    String key =  queueHash + "_" + shard + "_0";
    String handle = null;
    List<CQSMessage> messageList = new ArrayList<CQSMessage>();
    CmbComposite previousHandle = null;
    CmbComposite nextHandle = null;
   
    int numberPartitions = getNumberOfPartitions(queueUrl);
    int numberShards = getNumberOfShards(queueUrl);
   
    logger.debug("event=peek_queue queue_url=" + queueUrl + " prev_receipt_handle=" + previousReceiptHandle + " next_receipt_handle=" + nextReceiptHandle + " length=" + length + " num_partitions=" + numberPartitions);
View Full Code Here

      if (idParts.length != 3) {
        logger.error("event=get_messages error_code=invalid_message_id id=" + id);
        throw new IllegalArgumentException("Invalid message id " + id);
      }
     
      CmbComposite columnName = cassandraHandler.getCmbComposite(Arrays.asList(Long.parseLong(idParts[1]), Long.parseLong(idParts[2])));
     
      CmbColumn<CmbComposite, String> column = cassandraHandler.readColumn(AbstractDurablePersistence.CQS_KEYSPACE, COLUMN_FAMILY_PARTITIONED_QUEUE_MESSAGES,
          idParts[0], columnName, CMB_SERIALIZER.STRING_SERIALIZER,
          CMB_SERIALIZER.COMPOSITE_SERIALIZER,
          CMB_SERIALIZER.STRING_SERIALIZER);
View Full Code Here

TOP

Related Classes of com.comcast.cmb.common.persistence.AbstractDurablePersistence.CmbComposite

Copyright © 2018 www.massapicom. 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.