Package voldemort.utils

Examples of voldemort.utils.ByteArray


    @Override
    @Test
    public void testFetchedEqualsPut() throws Exception {
        System.out.println("                    Testing Fetchhed equals put                    ");
        ByteArray key = getKey();
        Store<ByteArray, byte[], byte[]> store = getStore();
        VectorClock clock = getClock(1, 1, 2, 3, 3, 4);
        byte[] value = getValue();
        System.out.println("Value chosen : " + value);
        List<Versioned<byte[]>> resultList = store.get(key, null);
View Full Code Here


    @Override
    @Test
    public void testGetVersions() throws Exception {
        List<ByteArray> keys = getKeys(2);
        ByteArray key = keys.get(0);
        byte[] value = getValue();
        VectorClock vc = getClock(0, 0);
        Store<ByteArray, byte[], byte[]> store = getStore();
        store.put(key, Versioned.value(value, vc), null);
        List<Versioned<byte[]>> versioneds = store.get(key, null);
View Full Code Here

        // MimeBodyPart it gets converted to 0xc2 and 0x8c
        // This thread tracks this question
        // http://stackoverflow.com/questions/23023583/mimebodypart-getcontent-corrupts-binary-data

        byte[] interestingByte = new byte[] { (byte) 0x8c };
        ByteArray interestingKey = new ByteArray(interestingByte);

        keys.add(interestingKey);
        values.add(interestingByte);

        // Add all possible byte values
        byte[] allPossibleBytes = getAllPossibleBytes();
        ByteArray allPossibleKey = new ByteArray(allPossibleBytes);
        keys.add(allPossibleKey);
        values.add(allPossibleBytes);

        assertEquals(keys.size(), values.size());
        int count = keys.size();
View Full Code Here

    @Test
    public void testGetWithBinaryData() throws Exception {
        Store<ByteArray, byte[], byte[]> store = getStore();

        byte[] allPossibleBytes = getAllPossibleBytes();
        ByteArray key = new ByteArray(allPossibleBytes);
        VectorClock vc = getClock(0, 0);
        Versioned<byte[]> versioned = new Versioned<byte[]>(allPossibleBytes, vc);
        store.put(key, versioned, null);

        List<Versioned<byte[]>> found = store.get(key, null);
View Full Code Here

                runner.submit(new Runnable() {

                    public void run() {

                        for(int i = 0; i < numKeys; i++) {
                            ByteArray key = new ByteArray(("test-key-" + i).getBytes());
                            try {
                                routedStore.get(key, null);
                            } catch(VoldemortException e) {
                                //
                            }
View Full Code Here

        try {
            Iterator<ByteArray> it = keys.iterator();
            StringBuilder keyArgs = null;

            while(it.hasNext()) {
                ByteArray key = it.next();
                String base64Key = RestUtils.encodeVoldemortKey(key.get());
                if(keyArgs == null) {
                    keyArgs = new StringBuilder();
                    keyArgs.append(base64Key);
                } else {
                    keyArgs.append("," + base64Key);
                }
                numberOfKeys++;
            }

            // Rerouting getall() requests with single key to get(). This is a
            // temporary fix to handle the NPE when getAll requests are made
            // with single key.
            // TODO a common way to handle getAll with any number of keys
            if(numberOfKeys == 1) {
                List<Versioned<byte[]>> resultList = new ArrayList<Versioned<byte[]>>();
                it = keys.iterator();
                ByteArray key = it.next();
                byte[] singleKeyTransforms = null;
                if(transforms != null) {
                    singleKeyTransforms = transforms.get(key);
                }
                resultList = this.get(key, singleKeyTransforms);
View Full Code Here

                MimeBodyPart part = (MimeBodyPart) mp.getBodyPart(i);

                // Get the key
                String contentLocation = part.getHeader("Content-Location")[0];
                String base64Key = contentLocation.split("/")[2];
                ByteArray key = new ByteArray(RestUtils.decodeVoldemortKey(base64Key));

                if(logger.isDebugEnabled()) {
                    logger.debug("Content-Location : " + contentLocation);
                    logger.debug("Base 64 key : " + base64Key);
                }
View Full Code Here

    private static VectorClock vectorClock;

    @BeforeClass
    public static void oneTimeSetUp() {
        voldemortConfig = VoldemortConfig.loadFromVoldemortHome("config/single_node_rest_server/");
        key = new ByteArray("key1".getBytes());
        vectorClock = new VectorClock();
        vectorClock.incrementVersion(voldemortConfig.getNodeId(), System.currentTimeMillis());
        value = new Versioned<byte[]>("value1".getBytes(), vectorClock);
        server = new VoldemortServer(voldemortConfig);
        if(!server.isStarted())
View Full Code Here

    public void testGetAll() {

        logger.info("\n\n********************  Testing Get All *******************\n\n");
        VectorClock vectorClock1 = new VectorClock();
        vectorClock1.incrementVersion(voldemortConfig.getNodeId(), System.currentTimeMillis());
        ByteArray key2 = new ByteArray("key2".getBytes());
        Versioned<byte[]> value2 = new Versioned<byte[]>("value2".getBytes(), vectorClock1);
        store.put(key2, value2, null);

        vectorClock1 = new VectorClock();
        vectorClock1.incrementVersion(voldemortConfig.getNodeId(), System.currentTimeMillis());
        ByteArray key3 = new ByteArray("key3".getBytes());
        Versioned<byte[]> value3 = new Versioned<byte[]>("value3".getBytes(), vectorClock1);
        store.put(key3, value3, null);

        Map<ByteArray, List<Versioned<byte[]>>> input = new HashMap<ByteArray, List<Versioned<byte[]>>>();
        List<Versioned<byte[]>> valuesList2 = new ArrayList<Versioned<byte[]>>();
View Full Code Here

        Map<ByteArray, List<Versioned<byte[]>>> input = new HashMap<ByteArray, List<Versioned<byte[]>>>();
        List<Versioned<byte[]>> valuesList2 = new ArrayList<Versioned<byte[]>>();

        VectorClock vectorClock1 = new VectorClock();
        vectorClock1.incrementVersion(voldemortConfig.getNodeId(), System.currentTimeMillis());
        ByteArray key2 = new ByteArray("key22".getBytes());
        Versioned<byte[]> value1 = new Versioned<byte[]>("value22".getBytes(), vectorClock1);
        store.put(key2, value1, null);
        valuesList2.add(value1);

        VectorClock vectorClock2 = new VectorClock();
        vectorClock2.incrementVersion(1, System.currentTimeMillis());
        Versioned<byte[]> value2 = new Versioned<byte[]>("value23".getBytes(), vectorClock2);
        store.put(key2, value2, null);
        valuesList2.add(value2);
        input.put(key2, valuesList2);

        List<Versioned<byte[]>> valuesList3 = new ArrayList<Versioned<byte[]>>();
        VectorClock vectorClock3 = new VectorClock();
        vectorClock3.incrementVersion(voldemortConfig.getNodeId(), System.currentTimeMillis());
        ByteArray key3 = new ByteArray("key23".getBytes());
        Versioned<byte[]> value3 = new Versioned<byte[]>("value43".getBytes(), vectorClock3);
        store.put(key3, value3, null);
        valuesList3.add(value3);
        input.put(key3, valuesList3);
View Full Code Here

TOP

Related Classes of voldemort.utils.ByteArray

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.