Package com.basho.riak.client.bucket

Examples of com.basho.riak.client.bucket.Bucket


    @Override
    public void storeIncomingStatistics(String guiPath, String accountName, Long timeperiod, String value, ValueType valueType, UnitType unitType, Long count) {
        Double valueDouble = LiveStatisticsUtil.parseDouble(value);
        long hoursSince1970 = timeperiod / 240;

        Bucket myBucket = null;
        try {
            myBucket = riakClient.fetchBucket(accountName + ";" + hoursSince1970).execute();
            BasicMetricHour storedMetricHour = myBucket.fetch("" + guiPath, BasicMetricHour.class).execute();
            if (storedMetricHour == null) {
                storedMetricHour = new BasicMetricHour(guiPath, accountName, hoursSince1970, valueType.toString(), unitType.toString());
            }

            storedMetricHour.addStatistic(new BasicLiveStatistics(guiPath, accountName, timeperiod, valueDouble, valueType.value(), unitType.value(), count));

            myBucket.store("" + guiPath, storedMetricHour).execute();
        } catch (RiakRetryFailedException e) {
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
        }
    }
View Full Code Here


    private BasicMetricHour getMetricHour(String accountName, String guiPath, long hoursSince1970) {
        //logger.info("getting Metric Hour for account: " + accountName + " guiPath: " + guiPath + " ts: " + hoursSince1970);
        BasicMetricHour metricHour = null;

        Bucket mhBucket = null;
        try {
            mhBucket = riakClient.fetchBucket(accountName + ";" + hoursSince1970).execute();
            metricHour = mhBucket.fetch("" + guiPath, BasicMetricHour.class).execute();
            logger.info("finding: " + accountName + ";" + hoursSince1970 + "/" + guiPath);
            if (metricHour != null) {
                metricHourCache.put(
                        metricHour.getAccountName() + ";" + metricHour.getGuiPath() + ";" + metricHour.getHoursSince1970(),
                        metricHour
View Full Code Here

        try {

            for (int index = fromHoursSince1970.intValue(); index <= toHoursSince1970.intValue(); index++) {
                int keys = 0;
                Bucket hourBucket = riakClient.fetchBucket(accountName + ";" + index).execute();
                try {
                    for (String key : hourBucket.keys()) {
                        hourBucket.delete(key);
                        keys++;
                    }
                } catch (RiakException e) {
                    e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
                }
View Full Code Here

    this.riakClient = riakClient;
  }

  @Override
  public void persistGroupInstrumentation(GroupedStatistics groupedStatistics) {
    Bucket myBucket = null;
        try {
            myBucket = riakClient.fetchBucket("Grouped Statistics;" + groupedStatistics.getAccountName()).execute();
            myBucket.store(groupedStatistics.getName(), groupedStatistics).execute();
        } catch (RiakRetryFailedException rrfe) {
            rrfe.printStackTrace();
        }

  }
View Full Code Here

  @Override
  public GroupedStatistics getGroupedStatistics(String name, String accountName) {
    BasicGroupedStatistics groupedStatistics = null;

        Bucket myBucket = null;
        try {
            myBucket = riakClient.fetchBucket("Grouped Statistics;" + accountName).execute();
            groupedStatistics = myBucket.fetch(name, BasicGroupedStatistics.class).execute();
        } catch (RiakRetryFailedException rrfe) {
            rrfe.printStackTrace();
        }

        return groupedStatistics;
View Full Code Here

  @Override
  public List<GroupedStatistics> getGroupedStatistics(String accountName) {
    List<GroupedStatistics> gsList = new ArrayList<GroupedStatistics>();

        Bucket myBucket = null;
        try {
            myBucket = riakClient.fetchBucket("Grouped Statistics;" + accountName).execute();

            for (String key : myBucket.fetchIndex(BucketIndex.index).withValue("$key").execute()) {
                gsList.add(myBucket.fetch(key, BasicGroupedStatistics.class).execute());
            }
        } catch (RiakRetryFailedException rrfe) {
            rrfe.printStackTrace();
        } catch (RiakException e) {
            e.printStackTrace();
View Full Code Here

        return gsList;
  }

  @Override
  public void deleteGroupedChart(String groupName, String accountName) {
    Bucket myBucket = null;
        try {
            myBucket = riakClient.fetchBucket("Grouped Statistics;" + accountName).execute();
            myBucket.delete(groupName).execute();
        } catch (RiakRetryFailedException rrfe) {
            rrfe.printStackTrace();
        } catch (RiakException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

  private static Logger logger = Logger.getLogger(RiakAbstractDao.class.getName());
 
  public static <E> List<E> getListFromRiakBucket(IRiakClient riakClient, String bucketName, E type, Class<E> clazz) {
    List<E> resultList = new ArrayList<>();
   
    Bucket bucket = null;
    try {
      bucket = riakClient.fetchBucket(bucketName).execute();
     
      for (String key : bucket.fetchIndex(BucketIndex.index).withValue("$key").execute()) {
        resultList.add(bucket.fetch(key, clazz).execute());
      }
    } catch (RiakRetryFailedException rrfe) {
            rrfe.printStackTrace();
        } catch (RiakException e) {
            e.printStackTrace();
View Full Code Here

  }
 
  public static <E> E getObjectFromBucket(IRiakClient riakClient, String bucketName, String key, E type, Class<E> clazz) {
    E returnObject = null;
   
    Bucket bucket = null;
    try {
      bucket = riakClient.fetchBucket(bucketName).execute();
      returnObject = bucket.fetch(key, clazz).execute();
    } catch (RiakRetryFailedException rrfe) {
            rrfe.printStackTrace();
        }  
   
    return returnObject;
View Full Code Here

   
    return returnObject;
  }
 
  public static <E> void persistObjectInBucket(IRiakClient riakClient, String bucketName, String key, E type) {
    Bucket bucket = null;
    try {
      bucket = riakClient.fetchBucket(bucketName).execute();
      bucket.store(key, type).execute();
    } catch (RiakRetryFailedException rrfe) {
            rrfe.printStackTrace();
        }
  }
View Full Code Here

TOP

Related Classes of com.basho.riak.client.bucket.Bucket

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.