diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/DaemonThreadFactory.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/DaemonThreadFactory.java deleted file mode 100644 index feddf2a6308..00000000000 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/DaemonThreadFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.bookkeeper.util; - -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; - -/** - * Daemon thread factory. - */ -public class DaemonThreadFactory implements ThreadFactory { - private ThreadFactory defaultThreadFactory = Executors.defaultThreadFactory(); - private int priority = Thread.NORM_PRIORITY; - public DaemonThreadFactory() { - } - public DaemonThreadFactory(int priority) { - assert priority >= Thread.MIN_PRIORITY && priority <= Thread.MAX_PRIORITY; - this.priority = priority; - } - @Override - public Thread newThread(Runnable r) { - Thread thread = defaultThreadFactory.newThread(r); - thread.setDaemon(true); - thread.setPriority(priority); - return thread; - } -} diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRegionAwareEnsemblePlacementPolicy.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRegionAwareEnsemblePlacementPolicy.java index 4f5bf086215..e6ee04501e2 100644 --- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRegionAwareEnsemblePlacementPolicy.java +++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRegionAwareEnsemblePlacementPolicy.java @@ -1179,7 +1179,7 @@ public void testEnsembleWithThreeRegionsReplaceInternal(int minDurability, boole try { BookieId replacedBookie = repp.replaceBookie(6, 6, ackQuorum, null, ensemble, bookieToReplace, excludedAddrs).getResult(); - assert (replacedBookie.equals(replacedBookieExpected)); + assertEquals(replacedBookieExpected, replacedBookie); assertEquals(3, getNumRegionsInEnsemble(ensemble)); } catch (BKNotEnoughBookiesException bnebe) { fail("Should not get not enough bookies exception even there is only one rack."); diff --git a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestBKDistributedLogManager.java b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestBKDistributedLogManager.java index e26667dd04f..9341dece0b6 100644 --- a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestBKDistributedLogManager.java +++ b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestBKDistributedLogManager.java @@ -187,7 +187,7 @@ private void testNonPartitionedWritesInternal(String name, DistributedLogConfigu long lastTxId = -1; while (null != record) { DLMTestUtil.verifyLogRecord(record); - assert (lastTxId < record.getTransactionId()); + assertTrue(lastTxId < record.getTransactionId()); lastTxId = record.getTransactionId(); numTrans++; record = reader.readNext(false); @@ -465,7 +465,7 @@ public void testContinuousReaderBulk() throws Exception { long lastTxId = -1; while (!recordList.isEmpty()) { for (LogRecord record : recordList) { - assert (lastTxId < record.getTransactionId()); + assertTrue(lastTxId < record.getTransactionId()); lastTxId = record.getTransactionId(); DLMTestUtil.verifyLogRecord(record); numTrans++; @@ -792,7 +792,7 @@ private void markEndOfStreamOnEmptyLogSegment(int numCompletedSegments) throws E long lastTxId = -1; while (null != record) { DLMTestUtil.verifyLogRecord(record); - assert (lastTxId < record.getTransactionId()); + assertTrue(lastTxId < record.getTransactionId()); lastTxId = record.getTransactionId(); numTrans++; record = reader.readNext(false); @@ -874,7 +874,7 @@ public void deleteDuringRead() throws Exception { LogReader reader = dlm.getInputStream(1); LogRecord record = reader.readNext(false); - assert (null != record); + assertNotNull(record); DLMTestUtil.verifyLogRecord(record); long lastTxId = record.getTransactionId(); @@ -885,7 +885,7 @@ public void deleteDuringRead() throws Exception { record = reader.readNext(false); while (null != record) { DLMTestUtil.verifyLogRecord(record); - assert (lastTxId < record.getTransactionId()); + assertTrue(lastTxId < record.getTransactionId()); lastTxId = record.getTransactionId(); record = reader.readNext(false); } @@ -1247,26 +1247,26 @@ public void testTruncationValidation() throws Exception { for (LogSegmentMetadata segment: cachedSegments) { if (segment.getLastDLSN().compareTo(truncDLSN) < 0) { assertTrue(segment.isTruncated()); - assertTrue(!segment.isPartiallyTruncated()); + assertFalse(segment.isPartiallyTruncated()); } else if (segment.getFirstDLSN().compareTo(truncDLSN) < 0) { - assertTrue(!segment.isTruncated()); + assertFalse(segment.isTruncated()); assertTrue(segment.isPartiallyTruncated()); } else { - assertTrue(!segment.isTruncated()); - assertTrue(!segment.isPartiallyTruncated()); + assertFalse(segment.isTruncated()); + assertFalse(segment.isPartiallyTruncated()); } } segmentList = DLMTestUtil.readLogSegments(zookeeperClient, LogMetadata.getLogSegmentsPath(uri, name, conf.getUnpartitionedStreamName())); - assertTrue(segmentList.get(truncDLSN.getLogSegmentSequenceNo()) - .getMinActiveDLSN().compareTo(truncDLSN) == 0); + assertEquals(0, segmentList.get(truncDLSN.getLogSegmentSequenceNo()) + .getMinActiveDLSN().compareTo(truncDLSN)); { LogReader reader = dlm.getInputStream(DLSN.InitialDLSN); LogRecordWithDLSN record = reader.readNext(false); - assertTrue(record != null); + assertNotNull(record); assertEquals(truncDLSN, record.getDlsn()); reader.close(); } @@ -1274,7 +1274,7 @@ public void testTruncationValidation() throws Exception { { LogReader reader = dlm.getInputStream(1); LogRecordWithDLSN record = reader.readNext(false); - assertTrue(record != null); + assertNotNull(record); assertEquals(truncDLSN, record.getDlsn()); reader.close(); } @@ -1282,7 +1282,7 @@ public void testTruncationValidation() throws Exception { { AsyncLogReader reader = dlm.getAsyncLogReader(DLSN.InitialDLSN); LogRecordWithDLSN record = Utils.ioResult(reader.readNext()); - assertTrue(record != null); + assertNotNull(record); assertEquals(truncDLSN, record.getDlsn()); Utils.close(reader); } @@ -1291,7 +1291,7 @@ public void testTruncationValidation() throws Exception { { LogReader reader = dlm.getInputStream(beyondTruncDLSN); LogRecordWithDLSN record = reader.readNext(false); - assertTrue(record != null); + assertNotNull(record); assertEquals(beyondTruncDLSN, record.getDlsn()); reader.close(); } @@ -1299,7 +1299,7 @@ public void testTruncationValidation() throws Exception { { LogReader reader = dlm.getInputStream(beyondTruncTxId); LogRecordWithDLSN record = reader.readNext(false); - assertTrue(record != null); + assertNotNull(record); assertEquals(beyondTruncDLSN, record.getDlsn()); assertEquals(beyondTruncTxId, record.getTransactionId()); reader.close(); @@ -1308,7 +1308,7 @@ public void testTruncationValidation() throws Exception { { AsyncLogReader reader = dlm.getAsyncLogReader(beyondTruncDLSN); LogRecordWithDLSN record = Utils.ioResult(reader.readNext()); - assertTrue(record != null); + assertNotNull(record); assertEquals(beyondTruncDLSN, record.getDlsn()); Utils.close(reader); }