@Test public void insertTableEvent() throws Exception { List<String> expectedFiles = ImmutableList.of("file:/a/b.txt", "file:/a/c.txt"); List<String> expectedFileChecksums = ImmutableList.of("123", "456"); Map<String, String> PARTITION_KEY_VALUE_MAP = ImmutableMap.of("col_1", "val_1", "col_2", "val_2", "col_3", "val_3"); ListenerEvent processedEvent = metaStoreEventDeserializer.unmarshal(insertEvent); InsertTableEvent insertTableEvent = (InsertTableEvent) processedEvent; assertThat(insertTableEvent.getDbName()).isEqualTo(TEST_DB); assertThat(insertTableEvent.getTableName()).isEqualTo(TEST_TABLE); assertThat(insertTableEvent.getProtocolVersion()).isEqualTo("1.0"); assertThat(insertTableEvent.getEventType()).isEqualTo(EventType.INSERT); assertThat(insertTableEvent.getPartitionKeyValues()).isEqualTo(PARTITION_KEY_VALUE_MAP); assertThat(insertTableEvent.getFiles()).isEqualTo(expectedFiles); assertThat(insertTableEvent.getFileChecksums()).isEqualTo(expectedFileChecksums); }
@Override public <T extends ListenerEvent> T unmarshal(String payload) throws SerDeException { try { log.debug("Marshalled event is: {}", payload); T genericEvent = mapper.readerFor(HelperSerializableListenerEvent.class).readValue(payload); log.debug("Unmarshal event of type: {}", genericEvent.getEventType()); T event = mapper.readerFor(genericEvent.getEventType().eventClass()).readValue(payload); log.debug("Unmarshalled event is: {}", event); return event; } catch (Exception e) { throw new SerDeException("Unable to unmarshal event from payload", e); } }
JsonMetaStoreEventDeserializer implements MetaStoreEventDeserializer { @Override public <T extends ListenerEvent> T unmarshal(String payload) throws SerDeException { try { log.debug("Marshalled event is: {}", payload); T genericEvent = mapper.readerFor(HelperSerializableListenerEvent.class).readValue(payload); log.debug("Unmarshal event of type: {}", genericEvent.getEventType()); T event = mapper.readerFor(genericEvent.getEventType().eventClass()).readValue(payload); log.debug("Unmarshalled event is: {}", event); return event; } catch (Exception e) { throw new SerDeException("Unable to unmarshal event from payload", e); } } }
JsonMetaStoreEventDeserializer implements MetaStoreEventDeserializer { @Override public <T extends ListenerEvent> T unmarshal(String payload) throws SerDeException { try { log.debug("Marshalled event is: {}", payload); T genericEvent = mapper.readerFor(HelperSerializableListenerEvent.class).readValue(payload); log.debug("Unmarshal event of type: {}", genericEvent.getEventType()); T event = mapper.readerFor(genericEvent.getEventType().eventClass()).readValue(payload); log.debug("Unmarshalled event is: {}", event); return event; } catch (Exception e) { throw new SerDeException("Unable to unmarshal event from payload", e); } } JsonMetaStoreEventDeserializer(ObjectMapper mapper); }
JsonMetaStoreEventDeserializer implements MetaStoreEventDeserializer { @Override public <T extends ListenerEvent> T unmarshal(String payload) throws SerDeException { try { log.debug("Marshalled event is: {}", payload); T genericEvent = mapper.readerFor(HelperSerializableListenerEvent.class).readValue(payload); log.debug("Unmarshal event of type: {}", genericEvent.getEventType()); T event = mapper.readerFor(genericEvent.getEventType().eventClass()).readValue(payload); log.debug("Unmarshalled event is: {}", event); return event; } catch (Exception e) { throw new SerDeException("Unable to unmarshal event from payload", e); } } JsonMetaStoreEventDeserializer(ObjectMapper mapper); @Override T unmarshal(String payload); }
JsonMetaStoreEventDeserializer implements MetaStoreEventDeserializer { @Override public <T extends ListenerEvent> T unmarshal(String payload) throws SerDeException { try { log.debug("Marshalled event is: {}", payload); T genericEvent = mapper.readerFor(HelperSerializableListenerEvent.class).readValue(payload); log.debug("Unmarshal event of type: {}", genericEvent.getEventType()); T event = mapper.readerFor(genericEvent.getEventType().eventClass()).readValue(payload); log.debug("Unmarshalled event is: {}", event); return event; } catch (Exception e) { throw new SerDeException("Unable to unmarshal event from payload", e); } } JsonMetaStoreEventDeserializer(ObjectMapper mapper); @Override T unmarshal(String payload);  }