Package com.netflix.staash.json

Examples of com.netflix.staash.json.JsonObject


        return obj.toString();
    }

    public String listTablesInSchema(String db) {
        List<String> tables = getTableNames(db);
        JsonObject obj = new JsonObject();
        JsonArray arr = new JsonArray();
        for (String table : tables) {
            arr.addString(table);
        }
        obj.putArray(db, arr);
        return obj.toString();
    }
View Full Code Here


        return obj.toString();
    }

    public String listTimeseriesInSchema(String db) {
        List<String> tables = getSeriesNames(db);
        JsonObject obj = new JsonObject();
        JsonArray arr = new JsonArray();
        obj.putArray(db, arr);
        if (tables != null) {
            for (String table : tables) {
                arr.addString(table);
            }
            obj.putArray(db, arr);
        }
        return obj.toString();
    }
View Full Code Here

        this.meta = meta;
        this.fac = fac;
    }

    public String writeRow(String db, String table, JsonObject rowObj) {
        JsonObject storageConf = meta.getStorageForTable(db+"."+table);
        PaasConnection conn = fac.createConnection(storageConf, db);
        return conn.insert(db,table,rowObj);
    }
View Full Code Here

        JsonObject storageConf = meta.getStorageForTable(db+"."+table);
        PaasConnection conn = fac.createConnection(storageConf, db);
        return conn.insert(db,table,rowObj);
    }
    public String writeToKVStore(String db, String table, JsonObject rowObj) {
      JsonObject storageConf = meta.getStorageForTable(db+"."+table);
        PaasConnection conn = fac.createConnection(storageConf, db);
        rowObj.putString("type", "kv");
    return conn.insert(db, table, rowObj);
    }
View Full Code Here

        rowObj.putString("type", "kv");
    return conn.insert(db, table, rowObj);
    }

    public String listRow(String db, String table, String keycol, String key) {
        JsonObject storageConf = meta.getStorageForTable(db+"."+table);
        if (storageConf == null) return "{\"msg\":\"the requested table does not exist in paas\"}";
        PaasConnection conn = fac.createConnection(storageConf,db);
        return conn.read(db,table,keycol,key);
    }
View Full Code Here

        PaasConnection conn = fac.createConnection(storageConf,db);
        return conn.read(db,table,keycol,key);
    }
    public String writeEvents(String db, String table, JsonArray events) {     
        for (Object event: events) {
          JsonObject obj = (JsonObject) event;
          writeEvent(db, table, obj);
        }
    return "{\"msg\":\"ok\"}";
    }
View Full Code Here

        }
    return "{\"msg\":\"ok\"}";
    }

    public String writeEvent(String db, String table, JsonObject rowObj) {
        JsonObject tbl = meta.runQuery(EntityType.SERIES, db+"."+table);
        if (tbl == null) throw new RuntimeException("Table "+table+" does not exist");
        JsonObject storageConf = meta.getStorageForTable(db+"."+table);
        if (storageConf == null) throw new RuntimeException("Storage for  "+table+" does not exist");
        PaasConnection conn = fac.createConnection(storageConf,db);
        String periodicity = tbl.getString("periodicity");
        Long time = rowObj.getLong("timestamp");
        if (time == null || time <= 0) {
View Full Code Here

        rowObj.putString("values","'"+prefix+String.valueOf(rowkey)+"',"+time+",'"+rowObj.getString("event")+"'");
        return conn.insert(db,table,rowObj);
    }

    public String readEvent(String db, String table, String eventTime) {
        JsonObject tbl = meta.runQuery(EntityType.SERIES, db+"."+table);
        if (tbl == null) throw new RuntimeException("Table "+table+" does not exist");
        JsonObject storageConf = meta.getStorageForTable(db+"."+table);
        if (storageConf == null) throw new RuntimeException("Storage for  "+table+" does not exist");
        PaasConnection conn = fac.createConnection(storageConf,db);
        String periodicity = tbl.getString("periodicity");
        Long time = Long.parseLong(eventTime);
        Long rowkey = (time/Long.parseLong(periodicity))*Long.parseLong(periodicity);
 
View Full Code Here

        Long rowkey = (time/Long.parseLong(periodicity))*Long.parseLong(periodicity);
        return conn.read(db,table,"key",String.valueOf(rowkey),"column1",String.valueOf(eventTime));
    }
   
    public String readEvent(String db, String table, String prefix,String eventTime) {
        JsonObject tbl = meta.runQuery(EntityType.SERIES, db+"."+table);
        if (tbl == null) throw new RuntimeException("Table "+table+" does not exist");
        JsonObject storageConf = meta.getStorageForTable(db+"."+table);
        if (storageConf == null) throw new RuntimeException("Storage for  "+table+" does not exist");
        PaasConnection conn = fac.createConnection(storageConf,db);
        String periodicity = tbl.getString("periodicity");
        Long time = Long.parseLong(eventTime);
        Long rowkey = (time/Long.parseLong(periodicity))*Long.parseLong(periodicity);
 
View Full Code Here

        if (prefix !=  null && !prefix.equals("")) prefix = prefix+":"; else prefix = "";
        return conn.read(db,table,"key",prefix+String.valueOf(rowkey),"column1",String.valueOf(eventTime));
    }

    public String readEvent(String db, String table, String prefix,String startTime, String endTime) {
        JsonObject tbl = meta.runQuery(EntityType.SERIES, db+"."+table);
        if (tbl == null) throw new RuntimeException("Table "+table+" does not exist");
        JsonObject storageConf = meta.getStorageForTable(db+"."+table);
        if (storageConf == null) throw new RuntimeException("Storage for  "+table+" does not exist");
        PaasConnection conn = fac.createConnection(storageConf,db);
        String periodicity = tbl.getString("periodicity");
        Long time = Long.parseLong(startTime);
        Long startTimekey = (time/Long.parseLong(periodicity))*Long.parseLong(periodicity);
        Long endTimeL = Long.parseLong(endTime);
        Long endTimeKey = (endTimeL/Long.parseLong(periodicity))*Long.parseLong(periodicity);
        if (prefix !=  null && !prefix.equals("")) prefix = prefix+":"; else prefix = "";
        JsonObject response = new JsonObject();
        for (Long current = startTimekey; current < endTimeKey;current = current+Long.parseLong(periodicity) ) {
            JsonObject  slice = new JsonObject(conn.read(db,table,"key",prefix+String.valueOf(current)));
          for (String field:slice.getFieldNames()) {
            response.putString(field, slice.getString(field));
          }
        }
        return response.toString();
    }
View Full Code Here

TOP

Related Classes of com.netflix.staash.json.JsonObject

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.