Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.Blob


        recordType.addFieldTypeEntry(fieldTypeEntry);
        recordType = typeManager.createRecordType(recordType);

        byte[] bytes = new byte[3000];
        random.nextBytes(bytes);
        Blob blob = writeBlob(bytes, "aMediaType", "testCreate");
        Record record = repository.newRecord();
        record.setRecordType(recordType.getName());
        record.setField(fieldName, blob);
        record = repository.create(record);
View Full Code Here


        recordType.addFieldTypeEntry(fieldTypeEntry);
        recordType = typeManager.createRecordType(recordType);

        byte[] bytes = new byte[size];
        random.nextBytes(bytes);
        Blob blob = writeBlob(bytes, "aMediaType", "testUpdateMutableMultivalueHierarchyBlob");

        byte[] bytes2 = new byte[size];
        random.nextBytes(bytes);
        Blob blob2 = writeBlob(bytes2, "aMediaType", "testUpdateMutableMultivalueHierarchyBlob2");

        byte[] bytes3 = new byte[size];
        random.nextBytes(bytes3);
        Blob blob3 = writeBlob(bytes3, "aMediaType", "testUpdateMutableMultivalueHierarchyBlob3");

        byte[] bytes4 = new byte[size];
        random.nextBytes(bytes4);
        Blob blob4 = writeBlob(bytes4, "aMediaType", "testUpdateMutableMultivalueHierarchyBlob4");

        Record record = repository.newRecord();
        record.setRecordType(recordType.getName(), null);
        record.setField(fieldName, Arrays.asList(new HierarchyPath(blob, blob2), new HierarchyPath(blob3)));
        record = repository.create(record);
View Full Code Here

        recordType = typeManager.createRecordType(recordType);

        // Incubate blob but never use it
        byte[] bytes = new byte[3000];
        random.nextBytes(bytes);
        Blob blob = writeBlob(bytes, "aMediaType", "testCreate");

        // Give time for the blob to expire
        Thread.sleep(60);

        BlobIncubatorMonitor monitor = new BlobIncubatorMonitor(repoSetup.getZk(), repoSetup.getHbaseTableFactory(),
View Full Code Here

        recordType = typeManager.createRecordType(recordType);

        // 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);
View Full Code Here

        recordType = typeManager.createRecordType(recordType);

        // 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);
        repository.newRecord();
        Record record = repository.newRecord();
        record.setRecordType(recordType.getName());
        record.setField(fieldName, blob);
        record = repository.create(record);

        // Faking failure
        HTableInterface blobIncubatorTable = LilyHBaseSchema.getBlobIncubatorTable(repoSetup.getHbaseTableFactory(), true);
        Put put = new Put(blob.getValue());
        put.add(LilyHBaseSchema.BlobIncubatorCf.REF.bytes, LilyHBaseSchema.BlobIncubatorColumn.RECORD.bytes, record.getId().toBytes());
        put.add(LilyHBaseSchema.BlobIncubatorCf.REF.bytes, LilyHBaseSchema.BlobIncubatorColumn.FIELD.bytes, fieldType.getId().getBytes());
        blobIncubatorTable.put(put);

        // Give time for the blob to expire
        Thread.sleep(60);

        BlobIncubatorMonitor monitor = new BlobIncubatorMonitor(repoSetup.getZk(), repoSetup.getHbaseTableFactory(),
                                            repoSetup.getTableManager(), blobManager, typeManager, 50, 0, 0);
        monitor.runMonitorOnce();

        assertBlobDelete(false, blob);
        Get get = new Get(blob.getValue());
        Result result = blobIncubatorTable.get(get);
        assertTrue(result == null || result.isEmpty());
    }
View Full Code Here

        }
    }

    @Test
    public void testBadEncoding() throws Exception {
        Blob blob = new Blob("aMediaType", (long) 10, "aName");
        blob.setValue(new byte[0]);
        try {
            testBlobStoreAccessRegistry.getBlobAccess(blob).getInputStream();
            fail();
        } catch (BlobException expected) {
        }
View Full Code Here

     * @param length The blob site to be used when constructing the blob
     * (this can be used to control how the blob will be stored)
     */
    private Blob writeBlob(byte[] bytes, String mediaType, String name, long length) throws RepositoryException, InterruptedException,
IOException {
        Blob blob = new Blob(mediaType, length, name);
        OutputStream outputStream = repository.getOutputStream(blob);
        outputStream.write(bytes);
        outputStream.close();
        return blob;
    }
View Full Code Here

        FieldTypeEntry fieldTypeEntry = typeManager.newFieldTypeEntry(fieldType.getId(), true);
        recordType.addFieldTypeEntry(fieldTypeEntry);
        recordType = typeManager.createRecordType(recordType);

        byte[] bytes = Bytes.toBytes("someBytes");
        Blob blob = writeBlob(bytes, "aMediaType", "testCreate");
        Record record = repository.newRecord();
        record.setRecordType(recordType.getName());
        record.setField(fieldName, blob);
        record = repository.create(record);
View Full Code Here

        byte[] medium = new byte[100];
        random.nextBytes(medium);
        byte[] large = new byte[2048];
        random.nextBytes(large);

        Blob smallBlob = writeBlob(small, "mime/small", "small");
        Blob mediumBlob = writeBlob(medium, "mime/medium", "medium");
        Blob largeBlob = writeBlob(large, "mime/large", "large");

        Record record = repository.newRecord();
        record.setRecordType(recordType.getName());
        record.setField(fieldName1, smallBlob);
        record.setField(fieldName2, mediumBlob);
View Full Code Here

        Random rg = new Random();
        byte[] bytes = new byte[size];
        rg.nextBytes(bytes);

        // create BLOB object
        Blob blob = new Blob("application/pdf", 0L, "Document");
        // create a stream to write the BLOB
        OutputStream bos = repository.getOutputStream(blob);
        // write the data
        bos.write(bytes);
        bos.close();
        blob.setSize(5L);
        // create a new record ID
        RecordId rid = repository.getIdGenerator().newRecordId();
        // create a new record
        Record record = repository.newRecord(rid);
        record.setRecordType(new QName(namespace, "testForceInlineRT"));
View Full Code Here

TOP

Related Classes of org.lilyproject.repository.api.Blob

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.