3838import com .alibaba .fluss .row .encode .KeyEncoder ;
3939import com .alibaba .fluss .rpc .gateway .CoordinatorGateway ;
4040import com .alibaba .fluss .server .testutils .FlussClusterExtension ;
41- import com .alibaba .fluss .server .zk .ZooKeeperClient ;
4241import com .alibaba .fluss .types .DataTypes ;
4342import com .alibaba .fluss .types .RowType ;
4443
4544import org .apache .flink .test .util .AbstractTestBase ;
46- import org .apache .paimon .catalog .Catalog ;
47- import org .apache .paimon .catalog .CatalogContext ;
48- import org .apache .paimon .catalog .CatalogFactory ;
49- import org .apache .paimon .options .Options ;
5045import org .junit .jupiter .api .AfterAll ;
5146import org .junit .jupiter .api .BeforeAll ;
5247import org .junit .jupiter .api .BeforeEach ;
5853import java .time .Duration ;
5954import java .util .HashMap ;
6055import java .util .Map ;
61- import java .util .Optional ;
6256
63- import static com .alibaba .fluss .server .utils .LakeStorageUtils .extractLakeProperties ;
6457import static com .alibaba .fluss .testutils .DataTestUtils .row ;
65- import static com .alibaba .fluss .testutils .common .CommonTestUtils .waitValue ;
6658
6759/** A base class for testing {@link TieringSource} with Fluss cluster prepared. */
6860public class TieringTestBase extends AbstractTestBase {
@@ -153,7 +145,6 @@ public class TieringTestBase extends AbstractTestBase {
153145 protected static Connection conn ;
154146 protected static Admin admin ;
155147 protected static CoordinatorGateway coordinatorGateway ;
156- protected static Catalog paimonCatalog ;
157148
158149 protected static Configuration clientConf ;
159150 protected static String bootstrapServers ;
@@ -206,10 +197,6 @@ private static Configuration flussClusterConfig() {
206197 }
207198 conf .setString ("datalake.paimon.warehouse" , warehousePath );
208199
209- paimonCatalog =
210- CatalogFactory .createCatalog (
211- CatalogContext .create (Options .fromMap (extractLakeProperties (conf ))));
212-
213200 return conf ;
214201 }
215202
@@ -236,10 +223,10 @@ protected void waitUntilSnapshot(long tableId, long snapshotId) {
236223 }
237224
238225 protected void waitUntilPartitionTableSnapshot (
239- long tableId , Map <Long , String > partitionNameByIds , long snapshotId ) {
240- for (Map .Entry <Long , String > entry : partitionNameByIds .entrySet ()) {
226+ long tableId , Map <String , Long > partitionNameByIds , long snapshotId ) {
227+ for (Map .Entry <String , Long > entry : partitionNameByIds .entrySet ()) {
241228 for (int i = 0 ; i < DEFAULT_BUCKET_NUM ; i ++) {
242- TableBucket tableBucket = new TableBucket (tableId , entry .getKey (), i );
229+ TableBucket tableBucket = new TableBucket (tableId , entry .getValue (), i );
243230 FLUSS_CLUSTER_EXTENSION .waitUtilSnapshotFinished (tableBucket , snapshotId );
244231 }
245232 }
@@ -252,53 +239,19 @@ protected void waitUntilSnapshot(long tableId, @Nullable Long partitionId, long
252239 }
253240 }
254241
255- /**
256- * Wait until the default number of partitions is created. Return the map from partition id to
257- * partition name. .
258- */
259- public static Map <Long , String > waitUntilPartitions (
260- ZooKeeperClient zooKeeperClient , TablePath tablePath ) {
261- return waitUntilPartitions (
262- zooKeeperClient ,
263- tablePath ,
264- ConfigOptions .TABLE_AUTO_PARTITION_NUM_PRECREATE .defaultValue ());
265- }
266-
267- /**
268- * Wait until the given number of partitions is created. Return the map from partition id to
269- * partition name.
270- */
271- public static Map <Long , String > waitUntilPartitions (
272- ZooKeeperClient zooKeeperClient , TablePath tablePath , int expectPartitions ) {
273- return waitValue (
274- () -> {
275- Map <Long , String > gotPartitions =
276- zooKeeperClient .getPartitionIdAndNames (tablePath );
277- return expectPartitions == gotPartitions .size ()
278- ? Optional .of (gotPartitions )
279- : Optional .empty ();
280- },
281- Duration .ofMinutes (1 ),
282- String .format ("expect %d table partition has not been created" , expectPartitions ));
283- }
284-
285242 protected static Map <Long , Map <Integer , Long >> upsertRowForPartitionedTable (
286243 TablePath tablePath ,
287244 TableDescriptor tableDescriptor ,
288- Map <Long , String > partitionNameByIds ,
245+ Map <String , Long > partitionNameByIds ,
289246 int pkStart ,
290247 int rowsNum )
291248 throws Exception {
292249 Map <Long , Map <Integer , Long >> bucketRows = new HashMap <>();
293- for (Map .Entry <Long , String > partitionEntry : partitionNameByIds .entrySet ()) {
250+ for (Map .Entry <String , Long > partitionEntry : partitionNameByIds .entrySet ()) {
294251 Map <Integer , Long > bucketRowsForPartition =
295252 upsertRow (
296- tablePath ,
297- tableDescriptor ,
298- pkStart ,
299- rowsNum ,
300- partitionEntry .getValue ());
301- bucketRows .put (partitionEntry .getKey (), bucketRowsForPartition );
253+ tablePath , tableDescriptor , pkStart , rowsNum , partitionEntry .getKey ());
254+ bucketRows .put (partitionEntry .getValue (), bucketRowsForPartition );
302255 }
303256 return bucketRows ;
304257 }
@@ -343,20 +296,16 @@ protected static Map<Integer, Long> upsertRow(
343296 protected static Map <Long , Map <Integer , Long >> appendRowForPartitionedTable (
344297 TablePath tablePath ,
345298 TableDescriptor tableDescriptor ,
346- Map <Long , String > partitionNameByIds ,
299+ Map <String , Long > partitionNameByIds ,
347300 int pkStart ,
348301 int rowsNum )
349302 throws Exception {
350303 Map <Long , Map <Integer , Long >> bucketRows = new HashMap <>();
351- for (Map .Entry <Long , String > partitionEntry : partitionNameByIds .entrySet ()) {
304+ for (Map .Entry <String , Long > partitionEntry : partitionNameByIds .entrySet ()) {
352305 Map <Integer , Long > bucketRowsForPartition =
353306 appendRow (
354- tablePath ,
355- tableDescriptor ,
356- pkStart ,
357- rowsNum ,
358- partitionEntry .getValue ());
359- bucketRows .put (partitionEntry .getKey (), bucketRowsForPartition );
307+ tablePath , tableDescriptor , pkStart , rowsNum , partitionEntry .getKey ());
308+ bucketRows .put (partitionEntry .getValue (), bucketRowsForPartition );
360309 }
361310 return bucketRows ;
362311 }
0 commit comments