Package org.lilyproject.util.repo

Examples of org.lilyproject.util.repo.RecordEvent


    /**
     * Configure the mocks so that the given Put will be returned for the given Record.
     */
    private void configurePutCreation(Record record, Put put) throws InterruptedException, RepositoryException {
        RecordEvent expectedRecordEvent = new RecordEvent();
        expectedRecordEvent.setType(Type.CREATE);
        when(hbaseRepository.buildPut(record, 1L, fieldTypes, expectedRecordEvent,
                Sets.<BlobReference>newHashSet(), Sets.<BlobReference>newHashSet(), 1L)).thenReturn(put);
    }
View Full Code Here


     *
     * @param record The record to be translated into an HBase {@code Put}
     * @return Put which can be directly written to HBase
     */
    public Put buildPut(Record record) throws InterruptedException, RepositoryException {
        RecordEvent recordEvent = new RecordEvent();
        recordEvent.setType(Type.CREATE);
        recordEvent.setTableName(hbaseRepo.getTableName());
        // set empty IndexRecordFilterData to omit the warnings in the IndexEditFilter
        recordEvent.setIndexRecordFilterData(new RecordEvent.IndexRecordFilterData());
        if (record.getId() == null) {
            record.setId(getIdGenerator().newRecordId());
        }
        Put put = hbaseRepo.buildPut(record, 1L, fieldTypes, recordEvent, Sets.<BlobReference>newHashSet(),
                Sets.<BlobReference>newHashSet(), 1L);
        put.add(LilyHBaseSchema.RecordCf.DATA.bytes, LilyHBaseSchema.RecordColumn.PAYLOAD.bytes, recordEvent.toJsonBytes());
        return put;
    }
View Full Code Here

    @Test
    public void testBeforeUpdate() throws RepositoryException, InterruptedException {
        IndexInfo inclusion = createMockIndexInfo("include", true);
        when(indexesInfo.getIndexInfos()).thenReturn(Lists.newArrayList(inclusion));

        RecordEvent recordEvent = new RecordEvent();
        recordEvent.setType(Type.UPDATE);
        recordEvent.setTableName(Table.RECORD.name);

        indexFilterHook.beforeUpdate(newRecord, oldRecord, repository, fieldTypes, recordEvent);

        IndexRecordFilterData idxFilterData = recordEvent.getIndexRecordFilterData();
        assertTrue(idxFilterData.getOldRecordExists());
        assertTrue(idxFilterData.getNewRecordExists());
        verify(indexFilterHook).calculateIndexInclusion(RepoAndTableUtil.DEFAULT_REPOSITORY,
                Table.RECORD.name, oldRecord, newRecord, idxFilterData);
    }
View Full Code Here

    @Test
    public void testBeforeCreate() throws RepositoryException, InterruptedException {
        IndexInfo inclusion = createMockIndexInfo("include", true);
        when(indexesInfo.getIndexInfos()).thenReturn(Lists.newArrayList(inclusion));

        RecordEvent recordEvent = new RecordEvent();
        recordEvent.setType(Type.CREATE);
        recordEvent.setTableName(Table.RECORD.name);

        indexFilterHook.beforeCreate(newRecord, repository, fieldTypes, recordEvent);

        IndexRecordFilterData idxFilterData = recordEvent.getIndexRecordFilterData();
        assertFalse(idxFilterData.getOldRecordExists());
        assertTrue(idxFilterData.getNewRecordExists());
        verify(indexFilterHook).calculateIndexInclusion(RepoAndTableUtil.DEFAULT_REPOSITORY,
                Table.RECORD.name, null, newRecord, idxFilterData);
    }
View Full Code Here

    @Test
    public void testBeforeDelete() throws RepositoryException, InterruptedException {
        IndexInfo inclusion = createMockIndexInfo("include", true);
        when(indexesInfo.getIndexInfos()).thenReturn(Lists.newArrayList(inclusion));

        RecordEvent recordEvent = new RecordEvent();
        recordEvent.setType(Type.DELETE);
        recordEvent.setTableName(Table.RECORD.name);

        indexFilterHook.beforeDelete(oldRecord, repository, fieldTypes, recordEvent);

        IndexRecordFilterData idxFilterData = recordEvent.getIndexRecordFilterData();
        assertTrue(idxFilterData.getOldRecordExists());
        assertFalse(idxFilterData.getNewRecordExists());
        verify(indexFilterHook).calculateIndexInclusion(RepoAndTableUtil.DEFAULT_REPOSITORY,
                Table.RECORD.name, oldRecord, null, idxFilterData);
    }
View Full Code Here

        public void processEvent(SepEvent event) {
            if (event.getPayload() == null) {
                return;
            }
            try {
                RecordEvent recordEvent = new RecordEvent(event.getPayload(), idGenerator);
                Assert.assertEquals(attr, recordEvent.getAttributes());
                messageCounter++;
            } catch (IOException e) {
                Assert.fail(e.getMessage());
            }
        }
View Full Code Here

        }
        return absRecordId;
    }

    public RecordEvent getRecordEvent() throws IOException {
        return new RecordEvent(getPayload(), idGenerator);
    }
View Full Code Here

        assertEquals(0, walEdit.size());
    }

    @Test
    public void testApply_Payload_NotApplicableIndex() {
        RecordEvent recordEvent = new RecordEvent();
        IndexRecordFilterData filterData = new IndexRecordFilterData();
        filterData.setSubscriptionInclusions(ImmutableSet.of("SomeOtherIndexName"));
        recordEvent.setIndexRecordFilterData(filterData);

        WALEdit walEdit = new WALEdit();
        walEdit.add(new KeyValue(Bytes.toBytes("row"), RecordCf.DATA.bytes, RecordColumn.PAYLOAD.bytes,
                recordEvent.toJsonBytes()));

        editFilter.apply(walEdit);

        assertEquals(0, walEdit.size());
    }
View Full Code Here

        assertEquals(0, walEdit.size());
    }

    @Test
    public void testApply_Payload_ApplicableIndex() {
        RecordEvent recordEvent = new RecordEvent();
        IndexRecordFilterData filterData = new IndexRecordFilterData();
        filterData.setSubscriptionInclusions(ImmutableSet.of(INDEX_NAME));
        recordEvent.setIndexRecordFilterData(filterData);

        WALEdit walEdit = new WALEdit();
        walEdit.add(new KeyValue(Bytes.toBytes("row"), RecordCf.DATA.bytes, RecordColumn.PAYLOAD.bytes,
                recordEvent.toJsonBytes()));

        editFilter.apply(walEdit);

        assertEquals(1, walEdit.size());
    }
View Full Code Here

        assertEquals(1, walEdit.size());
    }

    @Test
    public void testApply_Payload_ApplicableIndexButNoIndexFlagIsSet() {
        RecordEvent recordEvent = new RecordEvent();
        IndexRecordFilterData filterData = new IndexRecordFilterData();
        filterData.setSubscriptionInclusions(ImmutableSet.of(INDEX_NAME));
        recordEvent.setIndexRecordFilterData(filterData);
        recordEvent.getAttributes().put(IndexerEditFilter.NO_INDEX_FLAG, "false");

        WALEdit walEdit = new WALEdit();
        walEdit.add(new KeyValue(Bytes.toBytes("row"), RecordCf.DATA.bytes, RecordColumn.PAYLOAD.bytes,
                recordEvent.toJsonBytes()));

        editFilter.apply(walEdit);

        assertEquals(0, walEdit.size());
    }
View Full Code Here

TOP

Related Classes of org.lilyproject.util.repo.RecordEvent

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.