Examples of newRecordId()


Examples of org.lilyproject.repository.impl.id.IdGeneratorImpl.newRecordId()

        assertEquals(1 /* vint length */ + 1 /* record id type byte */ + "foo".length(), bos.toByteArray().length);

        RecordIdWritable writable2 = new RecordIdWritable();
        writable2.readFields(new DataInputStream(new ByteArrayInputStream(bos.toByteArray())));

        assertEquals(idGenerator.newRecordId("foo"), writable2.getRecordId());
    }
}
View Full Code Here

Examples of org.lilyproject.repository.impl.id.IdGeneratorImpl.newRecordId()

        byte[] mapping1Data = IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream(BASE_PATH + "shardingconfig1.json"));
        ShardSelector selector = JsonShardSelectorBuilder.build(mapping1Data);

        IdGenerator idGenerator = new IdGeneratorImpl();

        String shardName = selector.getShard(idGenerator.newRecordId());
        assertNotNull(shardName);
    }

    @Test
    public void testStringFieldListMapping() throws Exception {
View Full Code Here

Examples of org.lilyproject.repository.impl.id.IdGeneratorImpl.newRecordId()

    public void testStringFieldListMapping() throws Exception {
        byte[] mappingData = IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream(BASE_PATH + "shardingconfig2.json"));
        ShardSelector selector = JsonShardSelectorBuilder.build(mappingData);

        IdGenerator idGenerator = new IdGeneratorImpl();
        RecordId recordId = idGenerator.newRecordId(Collections.singletonMap("transport", "car"));

        String shardName = selector.getShard(recordId);
        assertEquals("shard1", shardName);
    }
View Full Code Here

Examples of org.lilyproject.repository.impl.id.IdGeneratorImpl.newRecordId()

    public void testLongFieldRangeMapping() throws Exception {
        byte[] mappingData = IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream(BASE_PATH + "shardingconfig3.json"));
        ShardSelector selector = JsonShardSelectorBuilder.build(mappingData);

        IdGenerator idGenerator = new IdGeneratorImpl();
        RecordId recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "400"));

        String shardName = selector.getShard(recordId);
        assertEquals("shard1", shardName);

        recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "1000"));
View Full Code Here

Examples of org.lilyproject.repository.impl.id.IdGeneratorImpl.newRecordId()

        RecordId recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "400"));

        String shardName = selector.getShard(recordId);
        assertEquals("shard1", shardName);

        recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "1000"));
        shardName = selector.getShard(recordId);
        assertEquals("shard2", shardName);

        recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "1200"));
        shardName = selector.getShard(recordId);
View Full Code Here

Examples of org.lilyproject.repository.impl.id.IdGeneratorImpl.newRecordId()

        recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "1000"));
        shardName = selector.getShard(recordId);
        assertEquals("shard2", shardName);

        recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "1200"));
        shardName = selector.getShard(recordId);
        assertEquals("shard2", shardName);

        recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "341234123"));
        shardName = selector.getShard(recordId);
View Full Code Here

Examples of org.lilyproject.repository.impl.id.IdGeneratorImpl.newRecordId()

        recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "1200"));
        shardName = selector.getShard(recordId);
        assertEquals("shard2", shardName);

        recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "341234123"));
        shardName = selector.getShard(recordId);
        assertEquals("shard3", shardName);

        recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "abc"));
        try {
View Full Code Here

Examples of org.lilyproject.repository.impl.id.IdGeneratorImpl.newRecordId()

        recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "341234123"));
        shardName = selector.getShard(recordId);
        assertEquals("shard3", shardName);

        recordId = idGenerator.newRecordId(Collections.singletonMap("weight", "abc"));
        try {
            shardName = selector.getShard(recordId);
            fail("Expected an exception");
        } catch (ShardSelectorException e) {
            // expected
View Full Code Here

Examples of org.lilyproject.repository.impl.id.IdGeneratorImpl.newRecordId()

        boolean shard1Used = false;
        boolean shard2Used = false;
        boolean shard3Used = false;

        for (int i = 0; i < 50; i++) {
            String shardName = selector.getShard(idGenerator.newRecordId());
            assertTrue(shards.containsKey(shardName));

            if (shardName.equals("shard1")) {
                shard1Used = true;
            } else if (shardName.equals("shard2")) {
View Full Code Here

Examples of org.lilyproject.repository.impl.id.IdGeneratorImpl.newRecordId()

        // This is the failure scenario where creating the record fails after reserving the blob
        byte[] bytes = new byte[3000];
        random.nextBytes(bytes);
        Blob blob = writeBlob(bytes, "aMediaType", "testCreate");
        IdGeneratorImpl idGeneratorImpl = new IdGeneratorImpl();
        RecordId recordId = idGeneratorImpl.newRecordId();
        BlobReference blobReference = new BlobReference(blob, recordId, fieldType);
        Set<BlobReference> blobs = new HashSet<BlobReference>();
        blobs.add(blobReference);
        blobManager.reserveBlobs(blobs);
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.