Package java.util

Examples of java.util.Random.nextBytes()


        // do some requests and test the load balancing
        Multiset<Integer> masters = HashMultiset.create();
        Multiset<Integer> counts = HashMultiset.create();
        byte[] key = new byte[16];
        for(int i = 0; i < numRequests; i++) {
            random.nextBytes(key);
            List<Node> routed = router.routeRequest(key);
            assertEquals(replicationFactor, routed.size());
            masters.add(routed.get(0).getId());
            for(Node n: routed)
                counts.add(n.getId());
View Full Code Here


        int l = rnd.nextInt( 40 ) + 20;

        byte[] buf = new byte[l];

        rnd.nextBytes( buf );

        return buf;
    }

View Full Code Here

        for(int iter = 0; iter < 10; iter++) {
            byte[][] keys = new byte[size][];
            int[] values = new int[size];
            for(int i = 0; i < size; i++) {
                byte[] key = new byte[keyHashSize];
                rand.nextBytes(key);
                values[i] = rand.nextInt(1000000);
                keys[i] = key;
            }
            ByteBuffer index = makeIndex(keys, values);
            // test finding keys
View Full Code Here

        final Store<ByteArray, byte[], byte[]> store = getStore();
        byte[] biggie = new byte[1 * 1024 * 1024];
        ByteArray key = new ByteArray(biggie);
        Random rand = new Random();
        for(int i = 0; i < 10; i++) {
            rand.nextBytes(biggie);
            Versioned<byte[]> versioned = new Versioned<byte[]>(biggie);
            store.put(key, versioned, null);
            assertNotNull(store.get(key, null));
            assertTrue(store.delete(key, versioned.getVersion()));
        }
View Full Code Here

            File tmp = tmpFile.newFile();
            while (true) {
                RandomAccessFile randomAccessFile = new RandomAccessFile(tmp, "rw");
                try {
                    FileChannel channel = randomAccessFile.getChannel();
                    rnd.nextBytes(data);
                    ByteBuffer buffer = ByteBuffer.wrap(data);
                    // Interrupted thread closes channel and throws ClosedByInterruptException.
                    channel.write(buffer);
                } finally {
                    randomAccessFile.close();
View Full Code Here

                ng = new Random();
            }
        }

        byte[] randomBytes = new byte[16];
        ng.nextBytes( randomBytes );
        randomBytes[6] &= 0x0f; /* clear version */
        randomBytes[6] |= 0x40; /* set to version 4 */
        randomBytes[8] &= 0x3f; /* clear variant */
        randomBytes[8] |= 0x80; /* set to IETF variant */

 
View Full Code Here

    writer.addUserMetadata("my.meta", byteBuf(1, 2, 3, 4, 5, 6, 7, -1, -2, 127, -128));
    writer.addUserMetadata("clobber", byteBuf(1,2,3));
    writer.addUserMetadata("clobber", byteBuf(4,3,2,1));
    ByteBuffer bigBuf = ByteBuffer.allocate(40000);
    Random random = new Random(0);
    random.nextBytes(bigBuf.array());
    writer.addUserMetadata("big", bigBuf);
    bigBuf.position(0);
    writer.addRow(new BigRow(true, (byte) 127, (short) 1024, 42,
        42L * 1024 * 1024 * 1024, (float) 3.1415, -2.713, null,
        null, null, null, null));
View Full Code Here

      stringValues[2*i+1] = words[rand.nextInt(words.length)];
    }
    for(int i=0; i < count; ++i) {
      doubleValues[i] = rand.nextDouble();
      byte[] buf = new byte[20];
      rand.nextBytes(buf);
      byteValues[i] = new BytesWritable(buf);
    }
    for(int i=0; i < count; ++i) {
      ReallyBigRow bigrow = createRandomRow(intValues, doubleValues, stringValues,
          byteValues, words, i);
View Full Code Here

      stringValues[2*i+1] = words[rand.nextInt(words.length)];
    }
    for(int i=0; i < count; ++i) {
      doubleValues[i] = rand.nextDouble();
      byte[] buf = new byte[20];
      rand.nextBytes(buf);
      byteValues[i] = new BytesWritable(buf);
    }
    for(int i=0; i < count; ++i) {
      ReallyBigRow bigrow = createRandomRowWithNulls(intValues, doubleValues, stringValues,
          byteValues, words, i, numNulls);
View Full Code Here

    assertTrue(dba.compare(val, 254, 1, 0, 1) > 0);
    assertTrue(dba.compare(val, 120, 1, 64, 1) > 0);
    val = new byte[1024];
    Random rand = new Random(1701);
    for(int i = 0; i < val.length; ++i) {
      rand.nextBytes(val);
    }
    dba.add(val, 0, 1024);
    assertEquals(1285, dba.size());
    assertEquals(0, dba.compare(val, 0, 1024, 261, 1024));
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.