Package com.comcast.cmb.common.util

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


  @Override
  public long getNumberOfTopicsByUser(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 numTopics = 0;
View Full Code Here


         retention = queue.getMsgRetentionPeriod();
       } else {
         retention = CMBProperties.getInstance().getCQSMessageRetentionPeriod();
       }
     } catch (Exception e) {
       throw new PersistenceException (e);
     }

     List<String> memIdsRet = new LinkedList<String>();
     Set <String> memIds = null;
     boolean brokenJedis = false;
View Full Code Here

  public User createUser(String userName, String password, Boolean isAdmin, String description) throws PersistenceException {
    User user = null;
   
    if (userName == null || userName.length() < 0 || userName.length() > 25) {
      logger.error("event=create_user error_code=invalid_user_name user_name=" + userName);
      throw new PersistenceException(CQSErrorCodes.InvalidRequest, "Invalid user name " + userName);
    }
   
    if (password == null || password.length() < 0 || password.length() > 25) {
      logger.error("event=create_user error_code=invalid_password");
      throw new PersistenceException(CQSErrorCodes.InvalidRequest, "Invalid password");
    }

    if (getUserByName(userName) != null) {
      logger.error("event=create_user error_code=user_already_exists user_name=" + userName);
      throw new PersistenceException(CQSErrorCodes.InvalidRequest, "User with user name " + userName + " already exists");
    }
   
    try {

      String userId = Long.toString(System.currentTimeMillis()).substring(1);
           
            String hashedPassword = AuthUtil.hashPassword(password);
            String accessSecret = AuthUtil.generateRandomAccessSecret();
            String accessKey = AuthUtil.generateRandomAccessKey();

      user = new User(userId, userName, hashedPassword, accessKey, accessSecret, isAdmin, description);
     
      Map<String, String> userDataMap = new HashMap<String, String>();
     
      userDataMap.put(USER_ID, user.getUserId());
      //userDataMap.put(USER_NAME, user.getUserName());
      userDataMap.put(HASH_PASSWORD, user.getHashPassword());
      userDataMap.put(ACCESS_SECRET, user.getAccessSecret());   
      userDataMap.put(ACCESS_KEY, user.getAccessKey());
      userDataMap.put(IS_ADMIN, user.getIsAdmin().toString());
      userDataMap.put(USER_DESC, user.getDescription());
     
      cassandraHandler.insertRow(AbstractDurablePersistence.CMB_KEYSPACE, user.getUserName(), COLUMN_FAMILY_USERS, userDataMap, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, null);
     
    } catch (Exception e) {
      logger.error("event=create_user", e);
      throw new PersistenceException(CQSErrorCodes.InvalidRequest, e.getMessage());
    }
   
    return user;
   
  }
View Full Code Here

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

          prepareMutationBatch();
      m.withRow((ColumnFamily)getColumnFamily(columnFamily), key).
        putColumn(getComposite(column), value, getSerializer(valueSerializer), ttl);
      m.execute();
    } catch (ConnectionException ex) {
      throw new PersistenceException(ex);
    } finally {
      long ts2 = System.currentTimeMillis();
      CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraTime, (ts2 - ts1));
      CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraWrite, 1L);
    }
View Full Code Here

    } catch (NotFoundException ex){
        //ignore.
        return null;
    } catch (ConnectionException ex) {
   
      throw new PersistenceException(ex);

    } finally {

      long ts2 = System.currentTimeMillis();
      CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraTime, (ts2 - ts1));     
View Full Code Here

    } catch (NotFoundException ex){
      //ignore.
      return null;
    } catch (ConnectionException ex) {
   
      throw new PersistenceException(ex);

    } finally {

      long ts2 = System.currentTimeMillis();
      CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraTime, (ts2 - ts1));     
View Full Code Here

    } catch (NotFoundException ex){
      //ignore.
      return null;
    } catch (ConnectionException ex) {
   
      throw new PersistenceException(ex);

    } finally {

      long ts2 = System.currentTimeMillis();
      CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraTime, (ts2 - ts1));     
View Full Code Here

    } catch (NotFoundException ex){
      //ignore.
      return null;
    } catch (ConnectionException ex) {
   
      throw new PersistenceException(ex);

    } finally {

      long ts2 = System.currentTimeMillis();
      CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraTime, (ts2 - ts1));     
View Full Code Here

        clm.putColumn((N)getComposite(columnName), columnValues.get(columnName), getSerializer(valueSerializer), ttl);
        CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraWrite, 1L);
      }
      OperationResult<Void> result = m.execute();
    } catch (ConnectionException ex) {
      throw new PersistenceException(ex);
    } finally {
      long ts2 = System.currentTimeMillis();
      CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraTime, (ts2 - ts1));
    }
  }
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.