Package com.comcast.cmb.common.util

Examples of com.comcast.cmb.common.util.PersistenceException


  @Override
  public Map<String, String> sendMessageBatch(CQSQueue queue,  int shard, List<CQSMessage> messages) throws PersistenceException,  IOException, InterruptedException, NoSuchAlgorithmException, JSONException {

    if (queue == null) {
      throw new PersistenceException(CQSErrorCodes.NonExistentQueue, "The supplied queue doesn't exist");
    }

    if (messages == null || messages.size() == 0) {
      throw new PersistenceException(CQSErrorCodes.InvalidQueryParameter,  "No messages are supplied.");
    }
   
    Map<CmbComposite, String> messageDataMap = new HashMap<CmbComposite, String>();
    Map<String, String> ret = new HashMap<String, String>();
    int ttl = queue.getMsgRetentionPeriod();
    String key = Util.hashQueueUrl(queue.getRelativeUrl()) + "_" + shard + "_" + rand.nextInt(queue.getNumberOfPartitions());
   
    for (CQSMessage message : messages) {

      if (message == null) {
        throw new PersistenceException(CQSErrorCodes.InvalidMessageContents, "The supplied message is invalid");
      }
     
      if (queue.isCompressed()) {
        message.setBody(Util.compress(message.getBody()));
      }
View Full Code Here


    public static int getShardFromReceiptHandle(String receiptHandle) throws PersistenceException {

      String handleParts[] = receiptHandle.split(":");
     
      if (handleParts.length < 3) {
        throw new PersistenceException(CMBErrorCodes.InternalError, "Invalid receipt handle " + receiptHandle);
      }
     
      String keyParts[] = handleParts[2].split("_");

      if (keyParts.length < 3) {
View Full Code Here

            }

            queue = getCachedQueue(queueUrl);

            if (queue == null) {
                throw new PersistenceException(CQSErrorCodes.NonExistentQueue, "The supplied queue with url " + request.getRequestURL().toString() + " doesn't exist");
            }
           
        } else {
            throw new PersistenceException(CQSErrorCodes.NonExistentQueue, "The supplied queue with url " + request.getRequestURL().toString() + " doesn't exist");
        }
       
        return queue;
    }
View Full Code Here

  @Override
  public void deleteQueue(String queueUrl) throws PersistenceException {

    if (getQueueByUrl(queueUrl) == null) {
      logger.error("event=delete_queue error_code=queue_does_not_exist queue_url=" + queueUrl);
      throw new PersistenceException (CQSErrorCodes.InvalidRequest, "No queue with the url " + queueUrl + " exists");
    }
   
    cassandraHandler.delete(AbstractDurablePersistence.CQS_KEYSPACE, COLUMN_FAMILY_QUEUES, queueUrl, null, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
    cassandraHandler.delete(AbstractDurablePersistence.CQS_KEYSPACE, COLUMN_FAMILY_QUEUES_BY_USER, Util.getUserIdForRelativeQueueUrl(queueUrl), Util.getArnForRelativeQueueUrl(queueUrl), CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
  }
View Full Code Here

  @Override
  public List<CQSQueue> listQueues(String userId, String queueNamePrefix, boolean containingMessagesOnly) throws PersistenceException {
   
    if (userId == null || userId.trim().length() == 0) {
      logger.error("event=list_queues error_code=invalid_user user_id=" + userId);
      throw new PersistenceException(CQSErrorCodes.InvalidParameterValue, "Invalid userId " + userId);
    }
     
    List<CQSQueue> queueList = new ArrayList<CQSQueue>();
    String lastArn = null;
    int counter;
View Full Code Here

  @Override
  public long getNumberOfQueuesByUser(String userId) throws PersistenceException {
   
    if (userId == null || userId.trim().length() == 0) {
      logger.error("event=list_queues error_code=invalid_user user_id=" + userId);
      throw new PersistenceException(CQSErrorCodes.InvalidParameterValue, "Invalid userId " + userId);
    }
     
    String lastArn = null;
    int sliceSize;
    long numQueues = 0;
View Full Code Here

      return CompositeSerializer.get();
    } else if (s instanceof CmbLongSerializer) {
      return LongSerializer.get();
    }
   
    throw new PersistenceException(CMBErrorCodes.InternalError, "Unknown serializer " + s);
  }
View Full Code Here

TOP

Related Classes of com.comcast.cmb.common.util.PersistenceException

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.