Search in sources :

Example 1 with TableMutation

use of com.hortonworks.streamline.streams.notification.store.hbase.mappers.TableMutation in project streamline by hortonworks.

the class HBaseNotificationStoreIntegrationTest method testStoreNotification.

@Test
public void testStoreNotification() throws IOException {
    Notification notification = NotificationTestObjectFactory.getOne();
    sut.store(notification);
    // rely on result of tableMutations() to avoid checking manually
    // didn't check each cell's value but comparing will be covered by testGetNotification()
    List<TableMutation> expectedMutations = notificationMapper.tableMutations(notification);
    checkMutationsReflectToHBase(expectedMutations);
}
Also used : Notification(com.hortonworks.streamline.streams.notification.Notification) TableMutation(com.hortonworks.streamline.streams.notification.store.hbase.mappers.TableMutation) Test(org.junit.Test) HBaseIntegrationTest(com.hortonworks.streamline.common.test.HBaseIntegrationTest)

Example 2 with TableMutation

use of com.hortonworks.streamline.streams.notification.store.hbase.mappers.TableMutation in project streamline by hortonworks.

the class HBaseNotificationStoreIntegrationTest method testUpdateNotificationStatus.

@Test
public void testUpdateNotificationStatus() throws Exception {
    Notification notification = NotificationTestObjectFactory.getOne();
    sut.store(notification);
    Notification.Status newStatus = Notification.Status.FAILED;
    Notification fetchedNotification = sut.updateNotificationStatus(notification.getId(), newStatus);
    assertEquals(fetchedNotification.getId(), notification.getId());
    assertEquals(fetchedNotification.getStatus(), newStatus);
    // rely on result of status() to avoid checking manually
    List<TableMutation> expectedMutations = notificationMapper.status(notification, newStatus);
    checkMutationsReflectToHBase(expectedMutations);
}
Also used : Notification(com.hortonworks.streamline.streams.notification.Notification) TableMutation(com.hortonworks.streamline.streams.notification.store.hbase.mappers.TableMutation) Test(org.junit.Test) HBaseIntegrationTest(com.hortonworks.streamline.common.test.HBaseIntegrationTest)

Example 3 with TableMutation

use of com.hortonworks.streamline.streams.notification.store.hbase.mappers.TableMutation in project streamline by hortonworks.

the class HBaseNotificationStore method store.

private void store(List<TableMutation> tableMutations) throws IOException {
    for (TableMutation tm : tableMutations) {
        LOG.debug("Insert/Update {} row(s), Delete {} row(s) in table {}", tm.updates().size(), tm.deletes().size(), tm.tableName());
        Table table = tables.get(tm.tableName()).get();
        if (!tm.updates().isEmpty()) {
            table.put(tm.updates());
        }
        if (!tm.deletes().isEmpty()) {
            table.delete(tm.deletes());
        }
    }
}
Also used : Table(org.apache.hadoop.hbase.client.Table) TableMutation(com.hortonworks.streamline.streams.notification.store.hbase.mappers.TableMutation)

Aggregations

TableMutation (com.hortonworks.streamline.streams.notification.store.hbase.mappers.TableMutation)3 HBaseIntegrationTest (com.hortonworks.streamline.common.test.HBaseIntegrationTest)2 Notification (com.hortonworks.streamline.streams.notification.Notification)2 Test (org.junit.Test)2 Table (org.apache.hadoop.hbase.client.Table)1