Examples of CQSQueue


Examples of com.comcast.cqs.model.CQSQueue

   
    long ts1 = System.currentTimeMillis();
   
    List<CQSMessage> messages = null;

    CQSQueue queue = CQSCache.getCachedQueue(relativeQueueUrl);

      if (queue == null) {
        throw new CMBException(CMBErrorCodes.InternalError, "Unknown queue " + relativeQueueUrl);
      }
       
View Full Code Here

Examples of com.comcast.cqs.model.CQSQueue

       
        if (!m.matches()) {
            throw new CMBException(CMBErrorCodes.InvalidParameterValue, "QueueName " + queueName + " is invalid. Only alphanumeric and hyphen and underscore allowed.");
        }

        String relativeQueueUrl = new CQSQueue(queueName, userId).getRelativeUrl();
        CQSQueue queue = PersistenceFactory.getQueuePersistence().getQueue(relativeQueueUrl);
       
        if (queue != null) {
          return queue;
        }
       
        queue = new CQSQueue(queueName, userId);
       
        if (visibilityTimeout != null) {
        if (visibilityTimeout < 0 || visibilityTimeout > CMBProperties.getInstance().getCQSMaxVisibilityTimeOut()) {
                throw new CMBException(CMBErrorCodes.InvalidParameterValue, CQSConstants.VISIBILITY_TIMEOUT + " should be between 0 and " + CMBProperties.getInstance().getCQSMaxVisibilityTimeOut());
        }
        queue.setVisibilityTO(visibilityTimeout);
        }
       
        if (policy != null) {
          //TODO: validate policy
          queue.setPolicy(policy);
        }
       
        if (messageRetentionPeriod != null) {
        if (messageRetentionPeriod < 0 || messageRetentionPeriod > CMBProperties.getInstance().getCQSMaxMessageRetentionPeriod()) {
                throw new CMBException(CMBErrorCodes.InvalidParameterValue, CQSConstants.MESSAGE_RETENTION_PERIOD + " should be between 0 and " + CMBProperties.getInstance().getCQSMaxMessageRetentionPeriod());
        }
        queue.setMsgRetentionPeriod(messageRetentionPeriod);
        }
       
        if (delaySeconds != null) {
        if (delaySeconds < 0 || delaySeconds > CMBProperties.getInstance().getCQSMaxMessageDelaySeconds()) {
                throw new CMBException(CMBErrorCodes.InvalidParameterValue, CQSConstants.DELAY_SECONDS + " should be between 0 and " + CMBProperties.getInstance().getCQSMaxMessageDelaySeconds());
        }
        queue.setDelaySeconds(delaySeconds);
        }
       
        if (receiveMessageWaitTimeSeconds != null) {
        if (receiveMessageWaitTimeSeconds < 0 || receiveMessageWaitTimeSeconds > CMBProperties.getInstance().getCMBRequestTimeoutSec()) {
                throw new CMBException(CMBErrorCodes.InvalidParameterValue, CQSConstants.RECEIVE_MESSAGE_WAIT_TIME_SECONDS + " should be between 0 and " + CMBProperties.getInstance().getCQSMaxMessageDelaySeconds());
        }
        queue.setReceiveMessageWaitTimeSeconds(receiveMessageWaitTimeSeconds);
        }
       
        if (numberOfPartitions != null) {
        if (numberOfPartitions < 1) {
                throw new CMBException(CMBErrorCodes.InvalidParameterValue, CQSConstants.NUMBER_OF_PARTITIONS + " should be at least 1");
        }
          queue.setNumberOfPartitions(numberOfPartitions);
        }
       
        if (numberOfShards != null) {
        if (numberOfShards < 1 || numberOfShards > 100) {
                throw new CMBException(CMBErrorCodes.InvalidParameterValue, CQSConstants.NUMBER_OF_SHARDS + " should be between 1 and 100");
        }
            queue.setNumberOfShards(numberOfShards);
        }
       
        if (isCompressed != null) {
          queue.setCompressed(isCompressed);
        }
   
    PersistenceFactory.getQueuePersistence().createQueue(queue);
    for (int shard = 0; shard < numberOfShards; shard++) {
      PersistenceFactory.getCQSMessagePersistence().checkCacheConsistency(queue.getRelativeUrl(), shard, false);
    }

    long ts2 = System.currentTimeMillis();
   
    emitLogLine(userId, "SendMessage", relativeQueueUrl, null, ts2-ts1);
View Full Code Here

Examples of com.comcast.cqs.model.CQSQueue

 
  public static void deleteQueue(String userId, String relativeQueueUrl) throws Exception {
   
    long ts1 = System.currentTimeMillis();
   
      CQSQueue queue = CQSCache.getCachedQueue(relativeQueueUrl);
     
      if (queue == null) {
        throw new CMBException(CMBErrorCodes.InternalError, "Unknown queue " + relativeQueueUrl);
      }
     
      int numberOfShards = queue.getNumberOfShards();
      PersistenceFactory.getQueuePersistence().deleteQueue(queue.getRelativeUrl());
     
        for (int shard=0; shard<numberOfShards; shard++) {
          PersistenceFactory.getCQSMessagePersistence().clearQueue(queue.getRelativeUrl(), shard);
        }

        long ts2 = System.currentTimeMillis();
       
    emitLogLine(userId, "SendMessage", relativeQueueUrl, null, ts2-ts1);
View Full Code Here

Examples of com.comcast.cqs.model.CQSQueue

   
        if (queueName == null) {
            throw new CMBException(CMBErrorCodes.MissingParameter, "Missing parameter QueueName");
        }

        CQSQueue queue = PersistenceFactory.getQueuePersistence().getQueue(userId, queueName);

        if (queue == null) {
            throw new CMBException(CQSErrorCodes.NonExistentQueue, "Queue not found with name " + queueName + " for user " + userId);
        }
       
    long ts2 = System.currentTimeMillis();
   
    emitLogLine(userId, "SendMessage", queue.getRelativeUrl(), null, ts2-ts1);
       
        return queue;
  }
View Full Code Here

Examples of com.comcast.cqs.model.CQSQueue

 
  public static void changeMessageVisibility(String userId, String relativeQueueUrl, String receiptHandle, Integer visibilityTimeout) throws Exception {

    long ts1 = System.currentTimeMillis();
   
      CQSQueue queue = CQSCache.getCachedQueue(relativeQueueUrl);
     
      if (queue == null) {
        throw new CMBException(CMBErrorCodes.InternalError, "Unknown queue " + relativeQueueUrl);
      }
     
        if (receiptHandle == null) {
            throw new CMBException(CMBErrorCodes.MissingParameter, "ReceiptHandle not found");
        }

        if (visibilityTimeout == null) {
            throw new CMBException(CMBErrorCodes.MissingParameter, "VisibilityTimeout not found");
        }

        if (visibilityTimeout < 0 || visibilityTimeout > CMBProperties.getInstance().getCQSMaxVisibilityTimeOut()) {
            throw new CMBException(CMBErrorCodes.InvalidParameterValue, "VisibilityTimeout is limited from 0 to " + CMBProperties.getInstance().getCQSMaxVisibilityTimeOut() + " seconds");
        }
       
        PersistenceFactory.getCQSMessagePersistence().changeMessageVisibility(queue, receiptHandle, visibilityTimeout);
     
    long ts2 = System.currentTimeMillis();
   
    emitLogLine(userId, "ChangeMessageVisibility", queue.getRelativeUrl(), null, ts2-ts1);
  }
View Full Code Here

Examples of com.comcast.cqs.model.CQSQueue

  public boolean doAction(User user, AsyncContext asyncContext) throws Exception {

    HttpServletRequest request = (HttpServletRequest)asyncContext.getRequest();
        HttpServletResponse response = (HttpServletResponse)asyncContext.getResponse();

    CQSQueue queue = CQSCache.getCachedQueue(user, request);
   
        for (int shard=0; shard<queue.getNumberOfShards(); shard++) {
            PersistenceFactory.getCQSMessagePersistence().clearQueue(queue.getRelativeUrl(), shard);
        }
   
    String out = CQSMessagePopulator.getClearQueueResponse();
        writeResponse(out, response);
   
View Full Code Here

Examples of com.comcast.cqs.model.CQSQueue

     * @throws Exception
     */
    public static CQSQueue getCachedQueue(User user, HttpServletRequest request) throws Exception {
     
        String queueUrl = null;
        CQSQueue queue = null;

        queueUrl = request.getRequestURL().toString();

        if (queueUrl != null && !queueUrl.equals("") && !queueUrl.equals("/")) {

View Full Code Here

Examples of com.comcast.cqs.model.CQSQueue

            this.queueUrl = key;
        }
       
      @Override
        public CQSQueue call() throws Exception {
            CQSQueue queue = queuePersistence.getQueue(queueUrl);
            return queue;
        }
View Full Code Here

Examples of com.comcast.cqs.model.CQSQueue

    public boolean doAction(User user, AsyncContext asyncContext) throws Exception {
     
        HttpServletRequest request = (HttpServletRequest)asyncContext.getRequest();
        HttpServletResponse response = (HttpServletResponse)asyncContext.getResponse();

        CQSQueue queue = CQSCache.getCachedQueue(user, request);
        String label = request.getParameter(CQSConstants.LABEL);

        if (!Util.isValidId(label)) {
            throw new CMBException(CQSErrorCodes.InvalidBatchEntryId, "Label " + label + " is invalid. Only alphanumeric, hyphen, and underscore are allowed. It can be at most " + CMBProperties.getInstance().getCQSMaxMessageSuppliedIdLength() + " letters long.");
        }
       
        CMBPolicy policy = new CMBPolicy(queue.getPolicy());
       
        if (policy.removeStatement(label)) {
            String policyStr = policy.toString();
            PersistenceFactory.getQueuePersistence().updatePolicy(queue.getRelativeUrl(), policyStr);
            queue.setPolicy(policyStr);
        }
       
        String out = CQSQueuePopulator.getRemovePermissionResponse();
        writeResponse(out, response);
View Full Code Here

Examples of com.comcast.cqs.model.CQSQueue

       
        if (messagePersistence == null || actionMap == null) {
            init();
        }
             
        CQSQueue queue = null;
       
        if (!action.equals("CreateQueue") && !action.equals("healthCheckShallow") && !action.equals("HealthCheck") && !action.equals("ManageService") && !action.equals("GetQueueUrl") && !action.equals("ListQueues") && !action.equals("GetAPIStats")) {
            queue = CQSCache.getCachedQueue(user, request);
      }

        if (isAuthenticationRequired(action)) {
       
            CMBPolicy policy = new CMBPolicy();
           
            if (queue != null) {
              policy.fromString(queue.getPolicy());
            }
           
            if (!actionMap.get(action).isActionAllowed(user, request, "CQS", policy)) {
                throw new CMBException(CMBErrorCodes.AccessDenied, "You don't have permission for " + actionMap.get(action).getName());
            }
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.