Package org.json_voltpatches

Examples of org.json_voltpatches.JSONObject


                    }
                }
                stringer.endArray();

                stringer.endObject();
                JSONObject jsObj = new JSONObject(stringer.toString());
                jsonBytes = jsObj.toString(4).getBytes(Charsets.UTF_8);
            } catch (JSONException e) {
                Throwables.propagate(e);
            } catch (IOException e) {
                e.printStackTrace();
            }
View Full Code Here


        try {
            String crunchJson = nodeList.toJSONString();
            //System.out.println(crunchJson);
            //System.out.flush();
            JSONObject jobj = new JSONObject(crunchJson);
            json = jobj.toString(4);
        } catch (JSONException e2) {
            // Any plan that can't be serialized to JSON to
            // write to debugging output is also going to fail
            // to get written to the catalog, to sysprocs, etc.
            // Just bail.
View Full Code Here

    @Override
    protected void collectStatsImpl(Connection c, long clientHandle, OpsSelector selector,
            ParameterSet params) throws Exception
    {
        JSONObject obj = new JSONObject();
        obj.put("selector", "SNAPSHOTSCAN");
        String err = null;
        if (selector == OpsSelector.SNAPSHOTSCAN) {
            err = parseParams(params, obj);
        }
        else {
            err = "SnapshotScanAgent received non-SNAPSHOTSCAN selector: " + selector.name();
        }
        if (err != null) {
            // Maintain old @SnapshotScan behavior.
            ColumnInfo[] result_columns = new ColumnInfo[1];
            result_columns[0] = new ColumnInfo("ERR_MSG", VoltType.STRING);
            VoltTable results[] = new VoltTable[] { new VoltTable(result_columns) };
            results[0].addRow(err);
            ClientResponseImpl errorResponse = new ClientResponseImpl(ClientResponse.SUCCESS,
                    ClientResponse.UNINITIALIZED_APP_STATUS_CODE, null, results, err);
            errorResponse.setClientHandle(clientHandle);
            ByteBuffer buf = ByteBuffer.allocate(errorResponse.getSerializedSize() + 4);
            buf.putInt(buf.capacity() - 4);
            errorResponse.flattenToBuffer(buf).flip();
            c.writeStream().enqueue(buf);
            return;
        }
        String subselector = obj.getString("subselector");

        PendingOpsRequest psr =
            new PendingOpsRequest(
                    selector,
                    subselector,
View Full Code Here

                    continue;
                }
                if (f.canRead()) {
                    try {
                        Set<String> tableNames = new HashSet<String>();
                        JSONObject digest = SnapshotUtil.CRCCheck(f, SNAP_LOG);
                        if (digest == null) continue;
                        JSONArray tables = digest.getJSONArray("tables");
                        for (int ii = 0; ii < tables.length(); ii++) {
                            tableNames.add(tables.getString(ii));
                        }
                        final StringWriter sw = new StringWriter();
                        int ii = 0;
View Full Code Here

        tearDownZK();
    }

    void configure(String root, ZooKeeper zk) throws Exception
    {
        JSONObject aa = new JSONObject("{key:aaval}");
        JSONObject bb = new JSONObject("{key:bbval}");
        JSONObject cc = new JSONObject("{key:ccval}");
        zk.create(root, new byte[]{}, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        zk.create(root + "/aa", aa.toString().getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        zk.create(root + "/bb", bb.toString().getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        zk.create(root + "/cc", cc.toString().getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    }
View Full Code Here

        Map<String, JSONObject> cache = dut.pointInTimeCache();

        assertEquals("3 items cached.", 3, cache.size());
        assertEquals("aaval", cache.get("/cache03/aa").get("key"));

        JSONObject aa = new JSONObject("{key:aaval2}");
        zk.setData("/cache03/aa", aa.toString().getBytes(), -1);
        while(true) {
            cache = dut.pointInTimeCache();
            if (cache.get("/cache03/aa").get("key").equals("aaval2")) {
                break;
            }
View Full Code Here

        Map<String, JSONObject> cache = cb.m_cache;

        assertEquals("3 items cached.", 3, cache.size());
        assertEquals("aaval", cache.get("/cache03/aa").get("key"));

        JSONObject aa = new JSONObject("{key:aaval2}");
        zk.setData("/cache03/aa", aa.toString().getBytes(), -1);
        while(true) {
            cache = cb.m_cache;
            if (cache.get("/cache03/aa").get("key").equals("aaval2")) {
                break;
            }
View Full Code Here

        MapCache dut = new MapCache(zk, "/cache04");
        dut.start(true);
        Map<String, JSONObject> cache = dut.pointInTimeCache();

        JSONObject dd = new JSONObject("{key:ddval}");
        dut.put("dd", dd);

        while(true) {
            cache = dut.pointInTimeCache();
            if (cache.size() == 3) {
                Thread.sleep(1);
            }
            else {
                break;
            }
        }
        assertEquals("Item added", 4, cache.size());
        assertEquals("aaval", cache.get("/cache04/aa").get("key"));
        assertEquals("bbval", cache.get("/cache04/bb").get("key"));
        assertEquals("ccval", cache.get("/cache04/cc").get("key"));
        assertEquals("ddval", cache.get("/cache04/dd").get("key"));

        // modify the new child and make sure it has a watch set.
        JSONObject dd2 = new JSONObject("{key:ddval2}");
        dut.put("dd", dd2);
        while(true) {
            cache = dut.pointInTimeCache();
            if (cache.get("/cache04/dd").get("key").equals("ddval2")) {
                break;
View Full Code Here

        TestCallback cb = new TestCallback();
        MapCache dut = new MapCache(zk, "/cache04", cb);
        dut.start(true);
        Map<String, JSONObject> cache = cb.m_cache;

        JSONObject dd = new JSONObject("{key:ddval}");
        dut.put("dd", dd);

        while(true) {
            cache = cb.m_cache;
            if (cache.size() == 3) {
                Thread.sleep(1);
            }
            else {
                break;
            }
        }
        assertEquals("Item added", 4, cache.size());
        assertEquals("aaval", cache.get("/cache04/aa").get("key"));
        assertEquals("bbval", cache.get("/cache04/bb").get("key"));
        assertEquals("ccval", cache.get("/cache04/cc").get("key"));
        assertEquals("ddval", cache.get("/cache04/dd").get("key"));

        // modify the new child and make sure it has a watch set.
        JSONObject dd2 = new JSONObject("{key:ddval2}");
        dut.put("dd", dd2);
        while(true) {
            cache = cb.m_cache;
            if (cache.get("/cache04/dd").get("key").equals("ddval2")) {
                break;
View Full Code Here

        String str = "";
        AdHocPlannedStatement plannedStatement = plannedStatements.get(i);
        String aggplan = new String(plannedStatement.core.aggregatorFragment, Constants.UTF8ENCODING);
        PlanNodeTree pnt = new PlanNodeTree();
        try {
            JSONObject jobj = new JSONObject( aggplan );
            JSONArray jarray =  jobj.getJSONArray(PlanNodeTree.Members.PLAN_NODES.name());
            pnt.loadFromJSONArray(jarray, db);

            if( plannedStatement.core.collectorFragment != null ) {
                //multi-partition query plan
                String collplan = new String(plannedStatement.core.collectorFragment, Constants.UTF8ENCODING);
                PlanNodeTree collpnt = new PlanNodeTree();
                //reattach plan fragments
                jobj = new JSONObject( collplan );
                jarray =  jobj.getJSONArray(PlanNodeTree.Members.PLAN_NODES.name());
                collpnt.loadFromJSONArray(jarray, db);
                assert( collpnt.getRootPlanNode() instanceof SendPlanNode);
                pnt.getRootPlanNode().reattachFragment( (SendPlanNode) collpnt.getRootPlanNode() );
            }
            str = pnt.getRootPlanNode().toExplainPlanString();
View Full Code Here

TOP

Related Classes of org.json_voltpatches.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.