### Question:
EtcdMetaStore implements MetaStore { @Override public List<Metapb.CatalogInfo> getCatalogs() { List<Metapb.CatalogInfo> catalogs = new ArrayList<>(); Map<String, ByteSequence> kvs = etcdClient.listValues(DB_LIST, false); if (kvs != null) { kvs.forEach((k, v) -> { try { catalogs.add(Metapb.CatalogInfo.parseFrom(v.getBytes())); } catch (Throwable e) { throw DBException.get(ErrorModule.META, ErrorCode.ER_META_STORE_ERROR, e, "Get Catalogs"); } }); } Collections.sort(catalogs, (c1, c2) -> { if (c1.getId() == c2.getId()) { return 0; } return c1.getId() > c2.getId() ? 1 : -1; }); return catalogs; }  @Override void init(JimConfig c); @Override int allocMetaID(); @Override long allocTaskID(TaskType type); @Override long addAndGetVersion(long incr); @Override long addAndGetPrivVersion(long incr); @Override void register(long version); @Override void unRegister(); @Override Map<String, Long> getRegisters(); @Override boolean storeCatalog(Metapb.CatalogInfo expect, Metapb.CatalogInfo catalogInfo); @Override boolean removeCatalog(int id); @Override Metapb.CatalogInfo getCatalog(int id); @Override List<Metapb.CatalogInfo> getCatalogs(); @Override boolean storeTable(Metapb.TableInfo expect, Metapb.TableInfo tableInfo); @Override boolean removeTable(int dbID, int tableID); @Override Metapb.TableInfo getTable(int catalogID, int tableID); @Override List<Metapb.TableInfo> getTables(int catalogID); @Override Map<Metapb.CatalogInfo, List<Metapb.TableInfo>> getCatalogAndTables(); @Override Metapb.AutoIdInfo getAutoIdInfo(int catalogID, int tableID); @Override Metapb.AutoIdInfo storeAutoIdInfo(int catalogID, int tableID, Metapb.AutoIdInfo autoIdInfo, Metapb.AutoIdInfo expect); @Override boolean storeTask(TaskType type, Task expect, Task... tasks); @Override Task getTask(TaskType type, Task task); @Override List<Task> getTasks(TaskType type, Task task); @Override void removeTask(TaskType type, long taskId); @Override boolean tryLock(TaskType type, Task task); @Override void unLock(TaskType type, Task task); @Override void watch(WatchType type, LongConsumer consumer); @Override void close();  }### Answer:
@Test public void testGetCatalogs() throws Exception { int parallel = 16; CountDownLatch latch = new CountDownLatch(parallel); List<Integer> ids = new ArrayList<>(); for (int i = 0; i < parallel; i++) { Thread t = new Thread() { @Override public void run() { CatalogInfo.Builder builder = CatalogInfo.newBuilder(); int id = metaStore.allocMetaID(); ids.add(id); builder.setId(id) .setName("test_" + id); metaStore.storeCatalog(null, builder.build()); for (int j = 0; j < 5; j++) { TableInfo.Builder builder1 = TableInfo.newBuilder(); int id1 = metaStore.allocMetaID(); builder1.setDbId(builder.getId()) .setId(id1) .setName("test_table_" + id1); metaStore.storeTable(null, builder1.build()); } latch.countDown(); } }; t.start(); } latch.await(); List<CatalogInfo> catalogs = metaStore.getCatalogs(); Assert.assertEquals(parallel, catalogs.size()); Collections.sort(ids, (c1, c2) -> { if (c1.intValue() == c2.intValue()) { return 0; } return c1.intValue() > c2.intValue() ? 1 : -1; }); for (int i = 0; i < catalogs.size(); i++) { CatalogInfo catalogInfo = catalogs.get(i); int id = ids.get(i).intValue(); Assert.assertEquals(id, catalogInfo.getId()); Assert.assertEquals("test_" + id, catalogInfo.getName()); } }