### Question:
ZKLogSegmentMetadataStore implements LogSegmentMetadataStore, Watcher, Children2Callback { @Override public void deleteLogSegment(Transaction<Object> txn, final LogSegmentMetadata segment, final OpListener<Void> listener) { Op deleteOp = Op.delete( segment.getZkPath(), -1); logger.info("Delete segment : {}", segment); txn.addOp(DefaultZKOp.of(deleteOp, new OpListener<Void>() { @Override public void onCommit(Void r) { if (null != listener) { listener.onCommit(r); } } @Override public void onAbort(Throwable t) { logger.info("Aborted transaction on deleting segment {}", segment); KeeperException.Code kc; if (t instanceof KeeperException) { kc = ((KeeperException) t).code(); } else if (t instanceof ZKException) { kc = ((ZKException) t).getKeeperExceptionCode(); } else { abortListener(t); return; } if (KeeperException.Code.NONODE == kc) { abortListener(new LogSegmentNotFoundException(segment.getZkPath())); return; } abortListener(t); } private void abortListener(Throwable t) { if (null != listener) { listener.onAbort(t); } } })); } ZKLogSegmentMetadataStore(DistributedLogConfiguration conf,
                                     ZooKeeperClient zkc,
                                     OrderedScheduler scheduler); @Override void storeMaxLogSegmentSequenceNumber(Transaction<Object> txn,
                                                 LogMetadata logMetadata,
                                                 Versioned<Long> lssn,
                                                 Transaction.OpListener<Version> listener); @Override void storeMaxTxnId(Transaction<Object> txn,
                              LogMetadataForWriter logMetadata,
                              Versioned<Long> transactionId,
                              Transaction.OpListener<Version> listener); @Override Transaction<Object> transaction(); @Override void createLogSegment(Transaction<Object> txn,
                                 LogSegmentMetadata segment,
                                 OpListener<Void> listener); @Override void deleteLogSegment(Transaction<Object> txn,
                                 final LogSegmentMetadata segment,
                                 final OpListener<Void> listener); @Override void updateLogSegment(Transaction<Object> txn, LogSegmentMetadata segment); @Override void process(WatchedEvent event); @Override CompletableFuture<LogSegmentMetadata> getLogSegment(String logSegmentPath); @Override @SuppressWarnings("unchecked") void processResult(int rc, String path, Object ctx, List<String> children, Stat stat); @Override CompletableFuture<Versioned<List<String>>> getLogSegmentNames(String logSegmentsPath,
                                                              LogSegmentNamesListener listener); @Override void unregisterLogSegmentListener(String logSegmentsPath,
                                             LogSegmentNamesListener listener); @Override void close();  }### Answer:
@Test(timeout = 60000) public void testDeleteLogSegment() throws Exception { LogSegmentMetadata segment = createLogSegment(1L); Transaction<Object> createTxn = lsmStore.transaction(); lsmStore.createLogSegment(createTxn, segment, null); Utils.ioResult(createTxn.execute()); assertNotNull("LogSegment " + segment + " should be created", zkc.get().exists(segment.getZkPath(), false)); Transaction<Object> deleteTxn = lsmStore.transaction(); lsmStore.deleteLogSegment(deleteTxn, segment, null); Utils.ioResult(deleteTxn.execute()); assertNull("LogSegment " + segment + " should be deleted", zkc.get().exists(segment.getZkPath(), false)); }