### Question:
EtcdMetaStore implements MetaStore { @Override public long addAndGetVersion(long incr) { if (incr == 0) { ByteSequence value = etcdClient.get(SCHEMA_VERSION_PATH); return value == null ? 0 : Long.parseLong(value.toString(StandardCharsets.UTF_8)); } return etcdClient.incrAndGet(SCHEMA_VERSION_PATH, incr); }  @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 testAddAndGetVersion() throws Exception { int parallel = 16; ConcurrentHashMap<Long, Boolean> ids = new ConcurrentHashMap<>(); CountDownLatch latch = new CountDownLatch(parallel); for (int i = 0; i < parallel; i++) { Thread t = new Thread() { @Override public void run() { for (int j = 0; j < 100; j++) { Long id = metaStore.addAndGetVersion(1); if (ids.putIfAbsent(id, Boolean.TRUE) != null) { Assert.fail("AllocVersion Duplicate"); } } latch.countDown(); } }; t.start(); } latch.await(); long id = metaStore.addAndGetVersion(0); Assert.assertEquals(1600, id); }