public TableImpl(TableDescriptor tableDescriptor) { this.tableId = tableDescriptor.getTableId(); }
void addTable(TableDescriptor tableDescriptor) { tables.put(tableDescriptor.getTableId(), tableDescriptor); }
private TableSpecJson buildTableJson(TableDescriptor tableDescriptor, Map<String, TableSpecJson> tableSpecs) { String tableId = tableDescriptor.getTableId(); return tableSpecs.computeIfAbsent(tableId, k -> buildTableJson(tableDescriptor)); }
final void addTableDescriptor(TableDescriptor tableDescriptor) { String tableId = tableDescriptor.getTableId(); Preconditions.checkState(StringUtils.isNotBlank(tableId) && ID_PATTERN.matcher(tableId).matches(), String.format("tableId: %s must confirm to pattern: %s", tableId, ID_PATTERN.toString())); Preconditions.checkState(!tableDescriptors.containsKey(tableId) || tableDescriptors.get(tableId) == tableDescriptor, String.format("Cannot add multiple table descriptors with the same tableId: %s", tableId)); if (tableDescriptor instanceof HybridTableDescriptor) { List<? extends TableDescriptor> tableDescs = ((HybridTableDescriptor) tableDescriptor).getTableDescriptors(); tableDescs.forEach(td -> addTableDescriptor(td)); } tableDescriptors.put(tableId, tableDescriptor); }
final void addTableDescriptor(TableDescriptor tableDescriptor) { String tableId = tableDescriptor.getTableId(); Preconditions.checkState(StringUtils.isNotBlank(tableId) && ID_PATTERN.matcher(tableId).matches(), String.format("tableId: %s must confirm to pattern: %s", tableId, ID_PATTERN.toString())); Preconditions.checkState(!tableDescriptors.containsKey(tableId) || tableDescriptors.get(tableId) == tableDescriptor, String.format("Cannot add multiple table descriptors with the same tableId: %s", tableId)); if (tableDescriptor instanceof BaseHybridTableDescriptor) { List<? extends TableDescriptor> tableDescs = ((BaseHybridTableDescriptor) tableDescriptor).getTableDescriptors(); tableDescs.forEach(td -> addTableDescriptor(td)); } tableDescriptors.put(tableId, tableDescriptor); }
final void addTableDescriptor(TableDescriptor tableDescriptor) { String tableId = tableDescriptor.getTableId(); Preconditions.checkState(StringUtils.isNotBlank(tableId) && ID_PATTERN.matcher(tableId).matches(), String.format("tableId: %s must confirm to pattern: %s", tableId, ID_PATTERN.toString())); Preconditions.checkState(!tableDescriptors.containsKey(tableId) || tableDescriptors.get(tableId) == tableDescriptor, String.format("Cannot add multiple table descriptors with the same tableId: %s", tableId)); if (tableDescriptor instanceof BaseHybridTableDescriptor) { List<? extends TableDescriptor> tableDescs = ((BaseHybridTableDescriptor) tableDescriptor).getTableDescriptors(); tableDescs.forEach(td -> addTableDescriptor(td)); } tableDescriptors.put(tableId, tableDescriptor); }
final void addTableDescriptor(TableDescriptor tableDescriptor) { String tableId = tableDescriptor.getTableId(); Preconditions.checkState(StringUtils.isNotBlank(tableId) && ID_PATTERN.matcher(tableId).matches(), String.format("tableId: %s must confirm to pattern: %s", tableId, ID_PATTERN.toString())); Preconditions.checkState(!tableDescriptors.containsKey(tableId) || tableDescriptors.get(tableId) == tableDescriptor, String.format("Cannot add multiple table descriptors with the same tableId: %s", tableId)); if (tableDescriptor instanceof BaseHybridTableDescriptor) { List<? extends TableDescriptor> tableDescs = ((BaseHybridTableDescriptor) tableDescriptor).getTableDescriptors(); tableDescs.forEach(td -> addTableDescriptor(td)); } tableDescriptors.put(tableId, tableDescriptor); }
final void addTableDescriptor(TableDescriptor tableDescriptor) { String tableId = tableDescriptor.getTableId(); Preconditions.checkState(StringUtils.isNotBlank(tableId) && ID_PATTERN.matcher(tableId).matches(), String.format("tableId: %s must confirm to pattern: %s", tableId, ID_PATTERN.toString())); Preconditions.checkState(!tableDescriptors.containsKey(tableId) || tableDescriptors.get(tableId) == tableDescriptor, String.format("Cannot add multiple table descriptors with the same tableId: %s", tableId)); if (tableDescriptor instanceof BaseHybridTableDescriptor) { List<? extends TableDescriptor> tableDescs = ((BaseHybridTableDescriptor) tableDescriptor).getTableDescriptors(); tableDescs.forEach(td -> addTableDescriptor(td)); } tableDescriptors.put(tableId, tableDescriptor); }
/** * Get list of table specs given a list of table descriptors. * @param tableDescs the list of tableDescriptors * @return list of tableSpecs */ static public List<TableSpec> getTableSpecs(List<TableDescriptor> tableDescs) { Map<TableSpec, TableImpl> tableSpecs = new LinkedHashMap<>(); tableDescs.forEach(tableDesc -> { TableSpec tableSpec = ((BaseTableDescriptor) tableDesc).getTableSpec(); if (tableSpecs.containsKey(tableSpec)) { throw new IllegalStateException( String.format("getTable() invoked multiple times with the same tableId: %s", tableDesc.getTableId())); } tableSpecs.put(tableSpec, new TableImpl(tableSpec)); }); return new ArrayList<>(tableSpecs.keySet()); } }
/** * Get list of table specs given a list of table descriptors. * @param tableDescs the list of tableDescriptors * @return list of tableSpecs */ static public List<TableSpec> getTableSpecs(List<TableDescriptor> tableDescs) { Map<TableSpec, TableImpl> tableSpecs = new LinkedHashMap<>(); tableDescs.forEach(tableDesc -> { TableSpec tableSpec = ((BaseTableDescriptor) tableDesc).getTableSpec(); if (tableSpecs.containsKey(tableSpec)) { throw new IllegalStateException( String.format("getTable() invoked multiple times with the same tableId: %s", tableDesc.getTableId())); } tableSpecs.put(tableSpec, new TableImpl(tableSpec)); }); return new ArrayList<>(tableSpecs.keySet()); } }
/** * Get list of table specs given a list of table descriptors. * @param tableDescs the list of tableDescriptors * @return list of tableSpecs */ static public List<TableSpec> getTableSpecs(List<TableDescriptor> tableDescs) { Map<TableSpec, TableImpl> tableSpecs = new LinkedHashMap<>(); tableDescs.forEach(tableDesc -> { TableSpec tableSpec = ((BaseTableDescriptor) tableDesc).getTableSpec(); if (tableSpecs.containsKey(tableSpec)) { throw new IllegalStateException( String.format("getTable() invoked multiple times with the same tableId: %s", tableDesc.getTableId())); } tableSpecs.put(tableSpec, new TableImpl(tableSpec)); }); return new ArrayList<>(tableSpecs.keySet()); } }
/** * Get list of table specs given a list of table descriptors. * @param tableDescs the list of tableDescriptors * @return list of tableSpecs */ static public List<TableSpec> getTableSpecs(List<TableDescriptor> tableDescs) { Map<TableSpec, TableImpl> tableSpecs = new LinkedHashMap<>(); tableDescs.forEach(tableDesc -> { TableSpec tableSpec = ((BaseTableDescriptor) tableDesc).getTableSpec(); if (tableSpecs.containsKey(tableSpec)) { throw new IllegalStateException( String.format("getTable() invoked multiple times with the same tableId: %s", tableDesc.getTableId())); } tableSpecs.put(tableSpec, new TableImpl(tableSpec)); }); return new ArrayList<>(tableSpecs.keySet()); } }
private TableSpecJson buildTableJson(TableDescriptor tableDescriptor) { TableSpecJson tableSpecJson = new TableSpecJson(); tableSpecJson.id = tableDescriptor.getTableId(); tableSpecJson.providerFactory = ((BaseTableDescriptor) tableDescriptor).getProviderFactoryClassName(); return tableSpecJson; } }
@Override public Map<String, String> toConfig(Config jobConfig) { Map<String, String> tableConfig = new HashMap<>(super.toConfig(jobConfig)); if (cache != null) { addTableConfig(CACHE_TABLE_ID, cache.getTableId(), tableConfig); } else { if (readTtl != null) { addTableConfig(READ_TTL_MS, String.valueOf(readTtl.toMillis()), tableConfig); } if (writeTtl != null) { addTableConfig(WRITE_TTL_MS, String.valueOf(writeTtl.toMillis()), tableConfig); } if (cacheSize > 0) { addTableConfig(CACHE_SIZE, String.valueOf(cacheSize), tableConfig); } } addTableConfig(REAL_TABLE_ID, table.getTableId(), tableConfig); addTableConfig(WRITE_AROUND, String.valueOf(isWriteAround), tableConfig); return Collections.unmodifiableMap(tableConfig); }
Answer getRegisteredTableAnswer() { return (InvocationOnMock x) -> { TableDescriptor descriptor = x.getArgumentAt(0, TableDescriptor.class); String tableId = "t1"; TableImpl mockTable = mock(TableImpl.class); when(mockTable.getTableId()).thenReturn(tableId); this.registeredTables.putIfAbsent(descriptor.getTableId(), mockTable); return this.registeredTables.get(descriptor.getTableId()); }; }
private void validateTableConfigure(JobConfig jobConfig, Map<String, Serde> deserializedSerdes, TableDescriptor tableDescriptor) { Config tableConfig = jobConfig.subset(String.format("tables.%s.", tableDescriptor.getTableId())); assertEquals(MockTableProviderFactory.class.getName(), tableConfig.get("provider.factory")); assertEquals("mock.config.value", jobConfig.get("mock.table.provider.config")); validateTableSerdeConfigure(tableDescriptor.getTableId(), jobConfig, deserializedSerdes); }
Set<String> intStreamIds = intermediateEdges.stream().map(stream -> stream.getStreamSpec().getId()).collect(Collectors.toSet()); assertThat(jsonObject.intermediateStreams.keySet(), Matchers.containsInAnyOrder(intStreamIds.toArray())); Set<String> tableIds = tables.stream().map(t -> t.getTableId()).collect(Collectors.toSet()); assertThat(jsonObject.tables.keySet(), Matchers.containsInAnyOrder(tableIds.toArray())); JobGraphJsonGenerator.JobNodeJson expectedNodeJson = new JobGraphJsonGenerator.JobNodeJson();
tables.put(table1Descriptor.getTableId(), table1Descriptor); tables.put(table2Descriptor.getTableId(), table2Descriptor); when(mockJobNode.getTables()).thenReturn(tables);
private void doTestSerialize(TableDescriptor cache) { CachingTableDescriptor desc; TableDescriptor table = createDummyTableDescriptor("2"); if (cache == null) { desc = new CachingTableDescriptor("1", table) .withReadTtl(Duration.ofMinutes(3)) .withWriteTtl(Duration.ofMinutes(4)) .withCacheSize(1000); } else { desc = new CachingTableDescriptor("1", table, cache); } desc.withWriteAround(); Map<String, String> tableConfig = desc.toConfig(new MapConfig()); assertEquals("2", CachingTableDescriptor.REAL_TABLE_ID, "1", tableConfig); if (cache == null) { assertEquals("180000", CachingTableDescriptor.READ_TTL_MS, "1", tableConfig); assertEquals("240000", CachingTableDescriptor.WRITE_TTL_MS, "1", tableConfig); } else { assertEquals(cache.getTableId(), CachingTableDescriptor.CACHE_TABLE_ID, "1", tableConfig); } assertEquals("true", CachingTableDescriptor.WRITE_AROUND, "1", tableConfig); }