Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.IdGenerator


        shards.put("shard2", "http://solr2");
        shards.put("shard3", "http://solr3");

        ShardSelector selector = DefaultShardSelectorBuilder.createDefaultSelector(shards);

        IdGenerator idGenerator = new IdGeneratorImpl();

        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


    public static Repository wrap(Repository repository) {
        TypeManager typeManager = (TypeManager) Proxy.newProxyInstance(TypeManager.class.getClassLoader(),
                new Class[]{TypeManager.class}, new TracingTypeManagerIH(repository.getTypeManager()));

        IdGenerator idGenerator = (IdGenerator) Proxy.newProxyInstance(IdGenerator.class.getClassLoader(),
                new Class[]{IdGenerator.class}, new TracingIdGeneratorIH(repository.getIdGenerator()));

        return (Repository) Proxy.newProxyInstance(Repository.class.getClassLoader(),
                new Class[]{Repository.class}, new TracingRepositoryIH(repository, typeManager, idGenerator));
    }
View Full Code Here

        if (currentDimensions.containsAll(dimensions.keySet())) {
            // the record already contains all of the new dimensions -> stop here
            //return;
        } else {
            IdGenerator idGenerator = indexUpdateBuilder.getRepository().getIdGenerator();
            Dep newDep = ctx.dep.plus(idGenerator, dimensions);
            // now find all the records of this newly defined variant
            final ArrayList<Record> result = IndexerUtils.getVariantsAsRecords(indexUpdateBuilder, newDep);
            if (result == null || result.size() == 0) {
                //if there are no records, we must continue with evalDeref with a 'null' record!
View Full Code Here

    public void testRecord() throws Exception {
        converter = new AvroConverter();
        FieldType fieldType = control.createMock(FieldType.class);
        FieldTypes fieldTypesSnapshot = control.createMock(FieldTypes.class);
        ValueType valueType = new StringValueType();
        IdGenerator idGenerator = new IdGeneratorImpl();

        recordFactory.newRecord();
        expectLastCall().andReturn(new RecordImpl()).anyTimes();
        repository.getIdGenerator();
        expectLastCall().andReturn(idGenerator).anyTimes();
View Full Code Here

    @Override
    public void follow(IndexUpdateBuilder indexUpdateBuilder, FollowCallback callback)
            throws RepositoryException, IOException, InterruptedException {
        LRepository repository = indexUpdateBuilder.getRepository();
        LTable table = repository.getTable(indexUpdateBuilder.getTable());
        IdGenerator idGenerator = repository.getIdGenerator();
        RecordContext ctx = indexUpdateBuilder.getRecordContext();

        Set<String> currentDimensions = Sets.newHashSet(ctx.dep.id.getVariantProperties().keySet());
        currentDimensions.addAll(ctx.dep.moreDimensionedVariants);
View Full Code Here

    @Override
    public void follow(IndexUpdateBuilder indexUpdateBuilder, FollowCallback callback) throws RepositoryException, IOException, InterruptedException {
        if (!indexUpdateBuilder.getSystemFields().isSystemField(fieldType.getName())) {
            indexUpdateBuilder.addDependency(fieldType.getId());
        }
        IdGenerator idGenerator = indexUpdateBuilder.getRepository().getIdGenerator();

        RecordContext ctx = indexUpdateBuilder.getRecordContext();
        LRepository repository = indexUpdateBuilder.getRepository();

        // FIXME: it's more efficient to read all records at once
View Full Code Here

        //
        // Create some records
        //
        Repository repository = client.getRepository();
        TypeManager typeManager = repository.getTypeManager();
        IdGenerator idGenerator = repository.getIdGenerator();

        FieldType ft1 = typeManager.createFieldType("STRING", new QName("test", "field1"), Scope.NON_VERSIONED);
        FieldType ft2 = typeManager.createFieldType("LINK", new QName("test", "field2"), Scope.NON_VERSIONED);

        RecordType rt1 = typeManager.recordTypeBuilder()
                .defaultNamespace("test")
                .name("rt1")
                .fieldEntry().use(ft1).add()
                .fieldEntry().use(ft2).add()
                .create();

        for (int i = 0; i < 300; i++) {
            repository.recordBuilder()
                    .recordType(rt1.getName())
                    .field(ft1.getName(), "foo bar bar")
                    .field(ft2.getName(), new Link(idGenerator.newRecordId()))
                    .create();
        }

        Assert.assertTrue("Processing messages took too long", lilyProxy.waitSepEventsProcessed(60000L));
View Full Code Here

    public static final IdRecord readIdRecord(DataInput input, LRepository repository)
            throws RepositoryException, InterruptedException {
        Record record = read(input, repository);

        IdGenerator idGenerator = repository.getIdGenerator();

        int size = input.readVInt();
        Map<SchemaId, QName> idToQNameMapping = new HashMap<SchemaId, QName>();
        for (int i = 0; i < size; i++) {
            byte[] schemaIdBytes = readBytes(input);
            QName name = readQName(input);

            SchemaId schemaId = idGenerator.getSchemaId(schemaIdBytes);
            idToQNameMapping.put(schemaId, name);
        }

        Map<Scope, SchemaId> recordTypeIds = new EnumMap(Scope.class);
        for (Scope scope : Scope.values()) {
            byte[] schemaIdBytes = readNullOrBytes(input);
            if (schemaIdBytes != null) {
                SchemaId schemaId = idGenerator.getSchemaId(schemaIdBytes);
                recordTypeIds.put(scope, schemaId);
            }
        }

        return new IdRecordImpl(record, idToQNameMapping, recordTypeIds);
View Full Code Here

                    .create();
        }

        for (String repoName : repositories) {
            LRepository repo = repositoryManager.getRepository(repoName);
            IdGenerator idGenerator = repo.getIdGenerator();
            LTable table = repo.getTable("mytable");
            assertEquals(repoName + "-value1", table.read(idGenerator.newRecordId("id1")).getField(fieldType1.getName()));
        }
    }
View Full Code Here

    public void testScanners() throws Exception {
        LilyClient client = lilyProxy.getLilyServerProxy().getClient();

        // Obtain a repository
        Repository repository = client.getRepository();
        IdGenerator idGenerator = repository.getIdGenerator();

        String NS = "org.lilyproject.client.test";

        // Create a field type and record type
        TypeManager typeManager = repository.getTypeManager();
        FieldType fieldType = typeManager.newFieldType("STRING", new QName(NS, "scanfield"), Scope.VERSIONED);
        fieldType = typeManager.createFieldType(fieldType);

        RecordType recordType = typeManager.newRecordType(new QName(NS, "scanrt"));
        recordType.addFieldTypeEntry(fieldType.getId(), true);
        recordType = typeManager.createRecordType(recordType);

        // Create some records
        for (int i = 0; i < 10; i++) {
            Record record = repository.newRecord();
            record.setId(repository.getIdGenerator().newRecordId("A" + i));
            record.setRecordType(new QName(NS, "scanrt"));
            record.setField(new QName(NS, "scanfield"), "value " + i);
            repository.create(record);
        }

        // Do a scan
        RecordScan scan = new RecordScan();
        scan.setStartRecordId(idGenerator.newRecordId("A"));
        scan.setStopRecordId(idGenerator.newRecordId("B"));

        RecordScanner scanner = repository.getScanner(scan);
        int i = 0;
        while (scanner.next() != null) {
            i++;
View Full Code Here

TOP

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

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.