public TableImpl(TableDescriptor tableDescriptor) { this.tableId = tableDescriptor.getTableId(); }
private TableSpecJson buildTableJson(TableDescriptor tableDescriptor) { TableSpecJson tableSpecJson = new TableSpecJson(); tableSpecJson.id = tableDescriptor.getTableId(); tableSpecJson.providerFactory = ((BaseTableDescriptor) tableDescriptor).getProviderFactoryClassName(); return tableSpecJson; } }
@Override protected void validate() { super.validate(); Preconditions.checkArgument(cache != null, "Must provide a Guava cache instance."); } }
@Override public TaskApplicationDescriptor withTable(TableDescriptor tableDescriptor) { addTableDescriptor(tableDescriptor); BaseTableDescriptor baseTableDescriptor = (BaseTableDescriptor) tableDescriptor; getOrCreateTableSerdes(baseTableDescriptor.getTableId(), baseTableDescriptor.getSerde()); return this; }
@Override public <K, V> Table<KV<K, V>> getTable(TableDescriptor<K, V, ?> tableDescriptor) { addTableDescriptor(tableDescriptor); BaseTableDescriptor baseTableDescriptor = (BaseTableDescriptor) tableDescriptor; getOrCreateTableSerdes(baseTableDescriptor.getTableId(), baseTableDescriptor.getSerde()); return new TableImpl(baseTableDescriptor.getTableSpec()); }
@Test public void testChangelogEnabledWithCustomParameters() { Map<String, String> tableConfig = createTableDescriptor() .withChangelogStream("my-stream") .withChangelogReplicationFactor(100) .toConfig(createJobConfig()); Assert.assertEquals(3, tableConfig.size()); Assert.assertEquals("my-stream", String.format( tableConfig.get(String.format(StorageConfig.CHANGELOG_STREAM(), TABLE_ID)))); Assert.assertEquals("100", String.format( tableConfig.get(String.format(StorageConfig.CHANGELOG_REPLICATION_FACTOR(), TABLE_ID)))); }
@Test public void testStoreConfig() { Map<String, String> tableConfig = createTableDescriptor() .toConfig(createJobConfig()); Assert.assertEquals(1, tableConfig.size()); }
@Test(expected = NullPointerException.class) public void testChangelogWithoutJobId() { Map<String, String> jobConfig = new HashMap<>(); jobConfig.put("job.name", JOB_NAME); createTableDescriptor() .withChangelogEnabled() .toConfig(new MapConfig(jobConfig)); }
@Override public Map<String, String> toConfig(Config jobConfig) { Map<String, String> tableConfig = new HashMap<>(super.toConfig(jobConfig)); addTableConfig(GUAVA_CACHE, SerdeUtils.serialize("Guava cache", cache), tableConfig); return Collections.unmodifiableMap(tableConfig); }
@Override public TaskApplicationDescriptor withTable(TableDescriptor tableDescriptor) { addTableDescriptor(tableDescriptor); if (tableDescriptor instanceof LocalTableDescriptor) { LocalTableDescriptor localTableDescriptor = (LocalTableDescriptor) tableDescriptor; getOrCreateTableSerdes(localTableDescriptor.getTableId(), localTableDescriptor.getSerde()); } return this; }
@Override public TableProvider getTableProvider(String tableId) { return new MockTableProvider(); } }
@Override public TaskApplicationDescriptor withTable(TableDescriptor tableDescriptor) { addTableDescriptor(tableDescriptor); BaseTableDescriptor baseTableDescriptor = (BaseTableDescriptor) tableDescriptor; getOrCreateTableSerdes(baseTableDescriptor.getTableId(), baseTableDescriptor.getSerde()); return this; }
@Override protected void validate() { super.validate(); Preconditions.checkArgument(cache != null, "Must provide a Guava cache instance."); } }
void addTable(TableDescriptor tableDescriptor) { tables.put(tableDescriptor.getTableId(), tableDescriptor); }
@Test public void testMinimal() { Config jobConfig = createJobConfig(); Assert.assertEquals(2, jobConfig.size()); Map<String, String> tableConfig = createTableDescriptor().toConfig(jobConfig); Assert.assertNotNull(tableConfig); Assert.assertEquals(1, tableConfig.size()); }
@Test(expected = NullPointerException.class) public void testChangelogWithoutJobName() { Map<String, String> jobConfig = new HashMap<>(); jobConfig.put("job.id", JOB_ID); createTableDescriptor() .withChangelogEnabled() .toConfig(new MapConfig(jobConfig)); }
@Override public TaskApplicationDescriptor withTable(TableDescriptor tableDescriptor) { addTableDescriptor(tableDescriptor); BaseTableDescriptor baseTableDescriptor = (BaseTableDescriptor) tableDescriptor; getOrCreateTableSerdes(baseTableDescriptor.getTableId(), baseTableDescriptor.getSerde()); return this; }
@Override protected void validate() { super.validate(); Preconditions.checkArgument(cache != null, "Must provide a Guava cache instance."); } }
@Override public TaskApplicationDescriptor withTable(TableDescriptor tableDescriptor) { addTableDescriptor(tableDescriptor); BaseTableDescriptor baseTableDescriptor = (BaseTableDescriptor) tableDescriptor; getOrCreateTableSerdes(baseTableDescriptor.getTableId(), baseTableDescriptor.getSerde()); return this; }
@Override protected void validate() { super.validate(); Preconditions.checkArgument(cache != null, "Must provide a Guava cache instance."); } }