Package org.json_voltpatches

Examples of org.json_voltpatches.JSONObject$Null


    private void processSnapshotData(byte data[]) throws Exception {
        if (data == null) {
            return;
        }
        JSONObject jsonObj = new JSONObject(new String(data, "UTF-8"));
        long txnId = jsonObj.getLong("txnId");
        int hostCount = jsonObj.getInt("hostCount");
        String path = jsonObj.getString("path");
        String nonce = jsonObj.getString("nonce");
        boolean truncation = jsonObj.getBoolean("isTruncation");
        boolean didSucceed = jsonObj.getBoolean("didSucceed");
        // A truncation request ID is not always provided. It's used for
        // snapshots triggered indirectly via ZooKeeper so that the
        // triggerer can recognize the snapshot when it finishes.
        String truncReqId = jsonObj.optString("truncReqId");

        if (hostCount == 0) {
            /*
             * Convert the JSON object containing the export sequence numbers for each
             * table and partition to a regular map
             */
            Map<String, Map<Integer, Pair<Long, Long>>> exportSequenceNumbers = null;
            final JSONObject exportSequenceJSON = jsonObj.getJSONObject("exportSequenceNumbers");
            final ImmutableMap.Builder<String, Map<Integer, Pair<Long, Long>>> builder =
                    ImmutableMap.builder();
            @SuppressWarnings("unchecked")
            final Iterator<String> tableKeys = exportSequenceJSON.keys();
            while (tableKeys.hasNext()) {
                final String tableName = tableKeys.next();
                final JSONObject tableSequenceNumbers = exportSequenceJSON.getJSONObject(tableName);
                ImmutableMap.Builder<Integer, Pair<Long, Long>> tableBuilder = ImmutableMap.builder();
                @SuppressWarnings("unchecked")
                final Iterator<String> partitionKeys = tableSequenceNumbers.keys();
                while (partitionKeys.hasNext()) {
                    final String partitionString = partitionKeys.next();
                    final Integer partitionId = Integer.valueOf(partitionString);
                    JSONObject sequenceNumbers = tableSequenceNumbers.getJSONObject(partitionString);
                    final Long ackOffset = sequenceNumbers.getLong("ackOffset");
                    final Long sequenceNumber = sequenceNumbers.getLong("sequenceNumber");
                    tableBuilder.put(partitionId, Pair.of(ackOffset, sequenceNumber));
                }
                builder.put(tableName, tableBuilder.build());
            }
            exportSequenceNumbers = builder.build();
View Full Code Here


        System.out.println( collected.size() );
        for( AbstractPlanNode n : collected ) {
            System.out.println( n.toExplainPlanString() );
        }
        assertTrue( collected.size() == 1 );
        JSONObject j;
        try {
            j = new JSONObject( collected.get(0).toJSONString() );
            System.out.println(j.getString("PLAN_NODE_TYPE"));
            assertTrue( j.getString("PLAN_NODE_TYPE").equalsIgnoreCase("INDEXSCAN")  );
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
View Full Code Here

            stringer.key("path").value(path);
            stringer.key("nonce").value(nonce);
            stringer.key("truncReqId").value(truncReqId);
            stringer.key("exportSequenceNumbers").object().endObject();
            stringer.endObject();
            JSONObject jsonObj = new JSONObject(stringer.toString());
            nodeBytes = jsonObj.toString(4).getBytes(Charsets.UTF_8);
        } catch (Exception e) {
            VoltDB.crashLocalVoltDB("Error serializing snapshot completion node JSON", true, e);
        }

        ZKUtil.StringCallback cb = new ZKUtil.StringCallback();
View Full Code Here

            if (data == null) {
                VoltDB.crashLocalVoltDB("Data should not be null if the node exists", false, null);
            }

            try {
                JSONObject jsonObj = new JSONObject(new String(data, Charsets.UTF_8));
                if (jsonObj.getLong("txnId") != txnId) {
                    VoltDB.crashLocalVoltDB("TxnId should match", false, null);
                }

                int hostCount = jsonObj.getInt("hostCount");
                // +1 because hostCount was initialized to -1
                jsonObj.put("hostCount", hostCount + participantCount + 1);
                zk.setData(snapshotPath, jsonObj.toString(4).getBytes(Charsets.UTF_8),
                        stat.getVersion());
            } catch (KeeperException.BadVersionException e) {
                continue;
            } catch (Exception e) {
                VoltDB.crashLocalVoltDB("This ZK call should never fail", true, e);
View Full Code Here

            Map<String, Map<Integer, Pair<Long, Long>>> exportSequenceNumbers,
            SiteTracker tracker,
            HashinatorSnapshotData hashinatorData,
            long timestamp)
    {
        JSONObject jsData = null;
        if (data != null && !data.isEmpty()) {
            try {
                jsData = new JSONObject(data);
            }
            catch (JSONException e) {
                SNAP_LOG.error(String.format("JSON exception on snapshot data \"%s\".", data),
                        e);
            }
View Full Code Here

        // try to get the external interface first, if none was set, use local addresses
        InetAddress addr = null;
        int clientPort = VoltDB.DEFAULT_PORT;
        try {
            String localMetadata = VoltDB.instance().getLocalMetadata();
            JSONObject jsObj = new JSONObject(localMetadata);
            JSONArray interfaces = jsObj.getJSONArray("interfaces");
            String iface = interfaces.getString(0);
            addr = InetAddress.getByName(iface);
            clientPort = jsObj.getInt("clientPort");
        } catch (JSONException e) {
            hostLog.info("Failed to get local metadata, falling back to first resolvable IP address.");
        } catch (UnknownHostException e) {
            hostLog.info("Failed to determine hostname, falling back to first resolvable IP address.");
        }
View Full Code Here

                prettyJson += line;
            }
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        JSONObject jobj;
        try {
            jobj = new JSONObject( prettyJson );
            JSONArray jarray =  jobj.getJSONArray("PLAN_NODES");
            Database db = s_singleton.getDatabase();
            pnt.loadFromJSONArray(jarray, db);
        } catch (JSONException e) {
            e.printStackTrace();
        }
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", selector.name());
        String err = null;
        if (selector == OpsSelector.SYSTEMCATALOG) {
            err = parseParamsForSystemCatalog(params, obj);
        }
        else {
            err = "SystemCatalogAgent received a non-SYSTEMCATALOG OPS selector: " + selector.name();
        }
        if (err != null) {
            sendErrorResponse(c, ClientResponse.GRACEFUL_FAILURE, err, clientHandle);
            return;
        }
        String subselector = obj.getString("subselector");

        // All system catalog selectors are currently local, can all get serviced here
        PendingOpsRequest psr = new PendingOpsRequest(
                selector,
                subselector,
View Full Code Here

     */
    public static List<MailboxNodeContent> parseMailboxContents(List<String> jsons) throws JSONException {
        ArrayList<MailboxNodeContent> objects = new ArrayList<MailboxNodeContent>(jsons.size());
        for (String json : jsons) {
            MailboxNodeContent content = null;
            JSONObject jsObj = new JSONObject(json);
            long HSId = jsObj.getLong("HSId");
            Integer partitionId = null;
            if (jsObj.has("partitionId")) {
                partitionId = jsObj.getInt("partitionId");
            }
            content = new MailboxNodeContent(HSId, partitionId);
            objects.add(content);
        }
        return objects;
View Full Code Here

            if (data == null) {
                VoltDB.crashLocalVoltDB("Data should not be null if the node exists", false, null);
            }

            try {
                JSONObject jsonObj = new JSONObject(new String(data, "UTF-8"));
                if (jsonObj.getLong("txnId") != txnId) {
                    VoltDB.crashLocalVoltDB("TxnId should match", false, null);
                }
                int remainingHosts = jsonObj.getInt("hostCount") - 1;
                jsonObj.put("hostCount", remainingHosts);
                jsonObj.put("didSucceed", snapshotSuccess);
                if (!snapshotSuccess) {
                    jsonObj.put("isTruncation", false);
                }
                mergeExportSequenceNumbers(jsonObj, exportSequenceNumbers);
                zk.setData(snapshotPath, jsonObj.toString(4).getBytes("UTF-8"), stat.getVersion());
            } catch (KeeperException.BadVersionException e) {
                continue;
            } catch (Exception e) {
                VoltDB.crashLocalVoltDB("This ZK call should never fail", true, e);
            }
View Full Code Here

TOP

Related Classes of org.json_voltpatches.JSONObject$Null

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.