Package org.voltcore.utils

Examples of org.voltcore.utils.InstanceId


            try
            {
                byte[] data =
                    m_zk.getData(CoreZK.instance_id, false, null);
                JSONObject idJSON = new JSONObject(new String(data, "UTF-8"));
                m_instanceId = new InstanceId(idJSON.getInt("coord"),
                        idJSON.getLong("timestamp"));

            }
            catch (Exception e)
            {
View Full Code Here


        ElasticHashinator h1 = new ElasticHashinator(
                ElasticHashinator.getConfigureBytes(3,
                ElasticHashinator.DEFAULT_TOTAL_TOKENS), false);
        byte[] bytes = h1.getConfigBytes();
        HashinatorSnapshotData d1 = new HashinatorSnapshotData(bytes, 1234);
        InstanceId iid1 = new InstanceId(111, 222);
        ByteBuffer b1 = d1.saveToBuffer(iid1);
        ByteBuffer b2 = ByteBuffer.wrap(b1.array());
        HashinatorSnapshotData d2 = new HashinatorSnapshotData();
        InstanceId iid2 = d2.restoreFromBuffer(b2);
        assertEquals(iid1, iid2);
        assertTrue(Arrays.equals(d1.m_serData, d2.m_serData));
        ElasticHashinator h2 = new ElasticHashinator(d2.m_serData, false);
        assertEquals(h1.getTokens(), h2.getTokens());
    }
View Full Code Here

                    if (digest == null) continue;
                    Long snapshotTxnId = digest.getLong("txnId");
                    String nonce = parseNonceFromSnapshotFilename(f.getName());
                    Snapshot named_s = namedSnapshots.get(nonce);
                    named_s.setTxnId(snapshotTxnId);
                    InstanceId iid = new InstanceId(0,0);
                    if (digest.has("instanceId")) {
                        iid = new InstanceId(digest.getJSONObject("instanceId"));
                    }
                    named_s.setInstanceId(iid);
                    TreeSet<String> tableSet = new TreeSet<String>();
                    JSONArray tables = digest.getJSONArray("tables");
                    for (int ii = 0; ii < tables.length(); ii++) {
View Full Code Here

        }

        // Slurp the data.
        int coord = buf.getInt(OFFSET_INSTID_COORD);
        long timestamp = buf.getLong(OFFSET_INSTID_TIMESTAMP);
        InstanceId instId = new InstanceId(coord, timestamp);
        m_version = buf.getLong(OFFSET_VERSION);
        m_serData = new byte[dataSize];
        buf.position(OFFSET_DATA);
        buf.get(m_serData);
View Full Code Here

            Map<String, Map<Integer, Pair<Long, Long>>> exportSequenceNumbers,
            HashinatorSnapshotData hashinatorData,
            long timestamp, int newPartitionCount) throws IOException
    {
        final List<Table> tables = SnapshotUtil.getTablesToSave(context.getDatabase());
        InstanceId instId = VoltDB.instance().getHostMessenger().getInstanceId();
        Runnable completionTask = SnapshotUtil.writeSnapshotDigest(
                txnId,
                context.getCatalogCRC(),
                file_path,
                file_nonce,
View Full Code Here

        File digest = s.m_digests.get(0);
        Long catalog_crc = null;
        Map<Integer,Long> pidToTxnMap = new TreeMap<Integer,Long>();
        Set<String> digestTableNames = new HashSet<String>();
        // Create a valid but meaningless InstanceId to support pre-instanceId checking versions
        InstanceId instanceId = new InstanceId(0, 0);
        int newParitionCount = -1;
        try
        {
            JSONObject digest_detail = SnapshotUtil.CRCCheck(digest, LOG);
            if (digest_detail == null) throw new IOException();
            catalog_crc = digest_detail.getLong("catalogCRC");

            if (digest_detail.has("partitionTransactionIds")) {
                JSONObject pidToTxnId = digest_detail.getJSONObject("partitionTransactionIds");
                @SuppressWarnings("unchecked")
                Iterator<String> it = pidToTxnId.keys();
                while (it.hasNext()) {
                    String pidkey = it.next();
                    Long txnidval = pidToTxnId.getLong(pidkey);
                    pidToTxnMap.put(Integer.valueOf(pidkey), txnidval);
                }
            }

            if (digest_detail.has("instanceId")) {
                instanceId = new InstanceId(digest_detail.getJSONObject("instanceId"));
            }

            if (digest_detail.has("newPartitionCount")) {
                newParitionCount = digest_detail.getInt("newPartitionCount");
            }
View Full Code Here

            nonce = jo.getString("nonce");
            partitionCount = jo.getInt("partitionCount");
            newPartitionCount = jo.getInt("newPartitionCount");
            catalogCrc = jo.getLong("catalogCrc");
            hostId = jo.getInt("hostId");
            instanceId = new InstanceId(jo.getJSONObject("instanceId"));

            JSONArray tables = jo.getJSONArray("tables");
            int cnt = tables.length();
            for (int i=0; i < cnt; i++) {
                JSONObject tableEntry = tables.getJSONObject(i);
View Full Code Here

TOP

Related Classes of org.voltcore.utils.InstanceId

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.