You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by si...@apache.org on 2019/07/29 11:52:25 UTC
[bookkeeper] branch master updated: Remove redundant array creation
This is an automated email from the ASF dual-hosted git repository.
sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 1df8ae9 Remove redundant array creation
1df8ae9 is described below
commit 1df8ae9abd2069d7db7f5551ec7cb1de1b9e3bae
Author: vzhikserg <vz...@users.noreply.github.com>
AuthorDate: Mon Jul 29 13:52:20 2019 +0200
Remove redundant array creation
### Changes
Remove redundant array creation in log statements to simplify the code.
Reviewers: Enrico Olivelli <eo...@gmail.com>, Sijie Guo <None>
This closes #2129 from vzhikserg/remove-redundant-array-creation
---
.../apache/bookkeeper/client/UpdateLedgerOp.java | 3 +-
.../server/http/service/ListDiskFilesService.java | 12 ++---
.../TestRackawareEnsemblePlacementPolicy.java | 11 ++---
.../distributedlog/AppendOnlyStreamReader.java | 2 +-
.../distributedlog/BKDistributedLogManager.java | 2 +-
.../org/apache/distributedlog/BKLogHandler.java | 4 +-
.../apache/distributedlog/BKLogReadHandler.java | 3 +-
.../apache/distributedlog/BKLogSegmentWriter.java | 17 ++++---
.../apache/distributedlog/BKLogWriteHandler.java | 19 ++++----
.../apache/distributedlog/BookKeeperClient.java | 16 +++----
.../distributedlog/ReadAheadEntryReader.java | 10 ++--
.../java/org/apache/distributedlog/ReadUtils.java | 17 +++----
.../distributedlog/admin/DistributedLogAdmin.java | 3 +-
.../apache/distributedlog/auditor/DLAuditor.java | 7 ++-
.../distributedlog/bk/SimpleLedgerAllocator.java | 4 +-
.../distributedlog/impl/BKNamespaceDriver.java | 11 +++--
.../distributedlog/impl/ZKNamespaceWatcher.java | 2 +-
.../impl/acl/ZKAccessControlManager.java | 2 +-
.../federated/FederatedZKLogMetadataStore.java | 6 +--
.../impl/logsegment/BKLogSegmentEntryStore.java | 3 +-
.../impl/metadata/ZKLogStreamMetadataStore.java | 2 +-
.../apache/distributedlog/lock/ZKSessionLock.java | 55 ++++++++++------------
.../logsegment/PerStreamLogSegmentCache.java | 6 +--
.../org/apache/distributedlog/DLMTestUtil.java | 6 +--
.../distributedlog/TestAsyncReaderWriter.java | 2 +-
.../distributedlog/TestDistributedLogBase.java | 2 +-
.../java/org/apache/distributedlog/TestReader.java | 6 +--
27 files changed, 109 insertions(+), 124 deletions(-)
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/UpdateLedgerOp.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/UpdateLedgerOp.java
index 268eff6..83143fb 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/UpdateLedgerOp.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/UpdateLedgerOp.java
@@ -104,8 +104,7 @@ public class UpdateLedgerOp {
(metadata) -> {
return metadata.getAllEnsembles().values().stream()
.flatMap(Collection::stream)
- .filter(b -> b.equals(oldBookieId))
- .count() > 0;
+ .anyMatch(b -> b.equals(oldBookieId));
},
(metadata) -> {
return replaceBookieInEnsembles(metadata, oldBookieId, newBookieId);
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListDiskFilesService.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListDiskFilesService.java
index 330ea7f..4e12bf8 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListDiskFilesService.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListDiskFilesService.java
@@ -92,9 +92,9 @@ public class ListDiskFilesService implements HttpEndpointService {
if (all || journal) {
File[] journalDirs = conf.getJournalDirs();
List<File> journalFiles = listFilesAndSort(journalDirs, "txn");
- StringBuffer files = new StringBuffer();
+ StringBuilder files = new StringBuilder();
for (File journalFile : journalFiles) {
- files.append(journalFile.getName() + "\t");
+ files.append(journalFile.getName()).append("\t");
}
output.put("journal files", files.toString());
}
@@ -102,9 +102,9 @@ public class ListDiskFilesService implements HttpEndpointService {
if (all || entrylog) {
File[] ledgerDirs = conf.getLedgerDirs();
List<File> ledgerFiles = listFilesAndSort(ledgerDirs, "log");
- StringBuffer files = new StringBuffer();
+ StringBuilder files = new StringBuilder();
for (File ledgerFile : ledgerFiles) {
- files.append(ledgerFile.getName() + "\t");
+ files.append(ledgerFile.getName()).append("\t");
}
output.put("entrylog files", files.toString());
}
@@ -112,9 +112,9 @@ public class ListDiskFilesService implements HttpEndpointService {
if (all || index) {
File[] indexDirs = (conf.getIndexDirs() == null) ? conf.getLedgerDirs() : conf.getIndexDirs();
List<File> indexFiles = listFilesAndSort(indexDirs, "idx");
- StringBuffer files = new StringBuffer();
+ StringBuilder files = new StringBuilder();
for (File indexFile : indexFiles) {
- files.append(indexFile.getName() + "\t");
+ files.append(indexFile.getName()).append("\t");
}
output.put("index files", files.toString());
}
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRackawareEnsemblePlacementPolicy.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRackawareEnsemblePlacementPolicy.java
index 6017ad9..51e7ea6 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRackawareEnsemblePlacementPolicy.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRackawareEnsemblePlacementPolicy.java
@@ -23,13 +23,12 @@ import static org.apache.bookkeeper.client.RoundRobinDistributionSchedule.writeS
import static org.apache.bookkeeper.feature.SettableFeatureProvider.DISABLE_ALL;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
import io.netty.util.HashedWheelTimer;
-
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -37,9 +36,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
-
import junit.framework.TestCase;
-
import org.apache.bookkeeper.client.BKException.BKNotEnoughBookiesException;
import org.apache.bookkeeper.client.BookieInfoReader.BookieInfo;
import org.apache.bookkeeper.client.EnsemblePlacementPolicy.PlacementPolicyAdherence;
@@ -2130,7 +2127,8 @@ public class TestRackawareEnsemblePlacementPolicy extends TestCase {
assertEquals("NUM_WRITABLE_BOOKIES_IN_DEFAULT_RACK guage value", 2, numBookiesInDefaultRackGauge.getSample());
// newAddr4 rack is changed and it is not in default anymore
- StaticDNSResolver.changeRack(Arrays.asList(newAddr4), Arrays.asList("/default-region/r4"));
+ StaticDNSResolver
+ .changeRack(Collections.singletonList(newAddr4), Collections.singletonList("/default-region/r4"));
assertEquals("NUM_WRITABLE_BOOKIES_IN_DEFAULT_RACK guage value", 1, numBookiesInDefaultRackGauge.getSample());
writeableBookies.clear();
@@ -2138,7 +2136,8 @@ public class TestRackawareEnsemblePlacementPolicy extends TestCase {
repp.onClusterChanged(writeableBookies, readOnlyBookies);
assertEquals("NUM_WRITABLE_BOOKIES_IN_DEFAULT_RACK guage value", 0, numBookiesInDefaultRackGauge.getSample());
- StaticDNSResolver.changeRack(Arrays.asList(newAddr1), Arrays.asList("/default-region/r2"));
+ StaticDNSResolver
+ .changeRack(Collections.singletonList(newAddr1), Collections.singletonList("/default-region/r2"));
readOnlyBookies.clear();
writeableBookies.add(newAddr1);
writeableBookies.add(newAddr2);
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/AppendOnlyStreamReader.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/AppendOnlyStreamReader.java
index 357fc6c..47f1ed6 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/AppendOnlyStreamReader.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/AppendOnlyStreamReader.java
@@ -47,7 +47,7 @@ public class AppendOnlyStreamReader extends InputStream {
checkNotNull(logRecord);
LOG.debug("Got record dlsn = {}, txid = {}, len = {}",
- new Object[] {logRecord.getDlsn(), logRecord.getTransactionId(), logRecord.getPayload().length});
+ logRecord.getDlsn(), logRecord.getTransactionId(), logRecord.getPayload().length);
this.logRecord = logRecord;
this.payloadStream = logRecord.getPayLoadInputStream();
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKDistributedLogManager.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKDistributedLogManager.java
index 43c0973..8a79d8b 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKDistributedLogManager.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKDistributedLogManager.java
@@ -755,7 +755,7 @@ class BKDistributedLogManager implements DistributedLogManager {
return subscriptionsStore.getLastCommitPosition(subscriberId.get())
.thenCompose(lastCommitPosition -> {
LOG.info("Reader {} @ {} positioned to last commit position {}.",
- new Object[] { subscriberId.get(), name, lastCommitPosition });
+ subscriberId.get(), name, lastCommitPosition);
try {
reader.setStartDLSN(lastCommitPosition);
} catch (UnexpectedException e) {
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogHandler.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogHandler.java
index a319d44..75203cc 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogHandler.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogHandler.java
@@ -515,7 +515,7 @@ abstract class BKLogHandler implements AsyncCloseable, AsyncAbortable {
if (elapsedMicroSec > 0) {
if (elapsedMillis > metadataLatencyWarnThresholdMillis) {
LOG.warn("{} received inprogress log segment in {} millis: {}",
- new Object[] { getFullyQualifiedName(), elapsedMillis, metadata });
+ getFullyQualifiedName(), elapsedMillis, metadata);
}
getInprogressSegmentStat.registerSuccessfulEvent(elapsedMicroSec, TimeUnit.MICROSECONDS);
} else {
@@ -527,7 +527,7 @@ abstract class BKLogHandler implements AsyncCloseable, AsyncAbortable {
if (elapsedMicroSec > 0) {
if (elapsedMillis > metadataLatencyWarnThresholdMillis) {
LOG.warn("{} received completed log segment in {} millis : {}",
- new Object[] { getFullyQualifiedName(), elapsedMillis, metadata });
+ getFullyQualifiedName(), elapsedMillis, metadata);
}
getCompletedSegmentStat.registerSuccessfulEvent(elapsedMicroSec, TimeUnit.MICROSECONDS);
} else {
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogReadHandler.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogReadHandler.java
index 1175f39..c865c28 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogReadHandler.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogReadHandler.java
@@ -205,8 +205,7 @@ class BKLogReadHandler extends BKLogHandler implements LogSegmentNamesListener {
@Override
public void onFailure(Throwable cause) {
- LOG.info("failed to acquire readlock {} at {}",
- new Object[]{ getLockClientId(), getReadLockPath(), cause });
+ LOG.info("failed to acquire readlock {} at {}", getLockClientId(), getReadLockPath(), cause);
threadAcquirePromise.completeExceptionally(cause);
}
});
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogSegmentWriter.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogSegmentWriter.java
index 4ad977b..880393c 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogSegmentWriter.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogSegmentWriter.java
@@ -332,7 +332,7 @@ class BKLogSegmentWriter implements LogSegmentWriter, AddCallback, Runnable, Siz
final int configuredTransmissionThreshold = dynConf.getOutputBufferSize();
if (configuredTransmissionThreshold > MAX_LOGRECORDSET_SIZE) {
LOG.warn("Setting output buffer size {} greater than max transmission size {} for log segment {}",
- new Object[] {configuredTransmissionThreshold, MAX_LOGRECORDSET_SIZE, fullyQualifiedLogSegment});
+ configuredTransmissionThreshold, MAX_LOGRECORDSET_SIZE, fullyQualifiedLogSegment);
this.transmissionThreshold = MAX_LOGRECORDSET_SIZE;
} else {
this.transmissionThreshold = configuredTransmissionThreshold;
@@ -610,8 +610,8 @@ class BKLogSegmentWriter implements LogSegmentWriter, AddCallback, Runnable, Siz
final CompletableFuture<Void> closePromise) {
LOG.info("Closing BKPerStreamLogWriter (abort={}) for {} :"
+ " lastDLSN = {} outstandingTransmits = {} writesPendingTransmit = {}",
- new Object[]{abort, fullyQualifiedLogSegment, getLastDLSN(),
- outstandingTransmitsUpdater.get(this), getWritesPendingTransmit()});
+ abort, fullyQualifiedLogSegment, getLastDLSN(),
+ outstandingTransmitsUpdater.get(this), getWritesPendingTransmit());
// Save the current packet to reset, leave a new empty packet to avoid a race with
// addCompleteDeferredProcessing.
@@ -832,7 +832,7 @@ class BKLogSegmentWriter implements LogSegmentWriter, AddCallback, Runnable, Siz
if (record.getTransactionId() < lastTxId) {
LOG.info("Log Segment {} TxId decreased Last: {} Record: {}",
- new Object[] {fullyQualifiedLogSegment, lastTxId, record.getTransactionId()});
+ fullyQualifiedLogSegment, lastTxId, record.getTransactionId());
}
if (!record.isControl()) {
// only update last tx id for user records
@@ -1187,7 +1187,7 @@ class BKLogSegmentWriter implements LogSegmentWriter, AddCallback, Runnable, Siz
// Sanity check to make sure we're receiving these callbacks in order.
if (entryId > -1 && lastEntryId >= entryId) {
LOG.error("Log segment {} saw out of order entry {} lastEntryId {}",
- new Object[] {fullyQualifiedLogSegment, entryId, lastEntryId});
+ fullyQualifiedLogSegment, entryId, lastEntryId);
}
lastEntryId = entryId;
@@ -1236,9 +1236,8 @@ class BKLogSegmentWriter implements LogSegmentWriter, AddCallback, Runnable, Siz
@Override
public void onFailure(Throwable cause) {
LOG.error("addComplete processing failed for {} entry {} lastTxId {} rc {} with error",
- new Object[] {
- fullyQualifiedLogSegment, entryId,
- transmitPacket.getRecordSet().getMaxTxId(), rc, cause});
+ fullyQualifiedLogSegment, entryId,
+ transmitPacket.getRecordSet().getMaxTxId(), rc, cause);
}
});
// Race condition if we notify before the addComplete is enqueued.
@@ -1266,7 +1265,7 @@ class BKLogSegmentWriter implements LogSegmentWriter, AddCallback, Runnable, Siz
cancelPendingPromises = (BKException.Code.OK != rc);
} else {
LOG.warn("Log segment {} entryId {}: Tried to set transmit result to ({}) but is already ({})",
- new Object[] {fullyQualifiedLogSegment, entryId, rc, transmitResultUpdater.get(this)});
+ fullyQualifiedLogSegment, entryId, rc, transmitResultUpdater.get(this));
}
if (transmitResultUpdater.get(this) != BKException.Code.OK) {
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogWriteHandler.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogWriteHandler.java
index 3095ec7..df830cb 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogWriteHandler.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BKLogWriteHandler.java
@@ -501,8 +501,8 @@ class BKLogWriteHandler extends BKLogHandler {
// case 2 can occur when the writer crashes with an empty in progress ledger. This is then deleted
// on recovery, so the next new segment will have a matching sequence number
LOG.warn("Unexpected max log segment sequence number {} for {} : list of cached segments = {}",
- new Object[]{maxLogSegmentSequenceNo.getSequenceNumber(), getFullyQualifiedName(),
- getCachedLogSegments(LogSegmentMetadata.DESC_COMPARATOR)});
+ maxLogSegmentSequenceNo.getSequenceNumber(), getFullyQualifiedName(),
+ getCachedLogSegments(LogSegmentMetadata.DESC_COMPARATOR));
// there is max log segment number recorded there and it isn't match. throw exception.
throw new DLIllegalStateException("Unexpected max log segment sequence number "
+ maxLogSegmentSequenceNo.getSequenceNumber() + " for " + getFullyQualifiedName()
@@ -942,8 +942,7 @@ class BKLogWriteHandler extends BKLogHandler {
new Object[] { logSegmentSeqNo, inprogressLogSegment.getZkPath() });
} else {
LOG.warn("Unexpected max ledger sequence number {} found while completing log segment {} for {}",
- new Object[] {
- maxLogSegmentSequenceNo.getSequenceNumber(), logSegmentSeqNo, getFullyQualifiedName() });
+ maxLogSegmentSequenceNo.getSequenceNumber(), logSegmentSeqNo, getFullyQualifiedName());
if (validateLogSegmentSequenceNumber) {
FutureUtils.completeExceptionally(promise,
new DLIllegalStateException("Unexpected max log segment sequence number "
@@ -990,8 +989,8 @@ class BKLogWriteHandler extends BKLogHandler {
@Override
public void onSuccess(Void value) {
LOG.info("Completed {} to {} for {} : {}",
- new Object[] { inprogressZnodeName, completedLogSegment.getSegmentName(),
- getFullyQualifiedName(), completedLogSegment });
+ inprogressZnodeName, completedLogSegment.getSegmentName(),
+ getFullyQualifiedName(), completedLogSegment);
FutureUtils.complete(promise, completedLogSegment);
}
@@ -1087,7 +1086,7 @@ class BKLogWriteHandler extends BKLogHandler {
private CompletableFuture<List<LogSegmentMetadata>> setLogSegmentsOlderThanDLSNTruncated(
List<LogSegmentMetadata> logSegments, final DLSN dlsn) {
LOG.debug("Setting truncation status on logs older than {} from {} for {}",
- new Object[]{dlsn, logSegments, getFullyQualifiedName()});
+ dlsn, logSegments, getFullyQualifiedName());
List<LogSegmentMetadata> truncateList = new ArrayList<LogSegmentMetadata>(logSegments.size());
LogSegmentMetadata partialTruncate = null;
LOG.info("{}: Truncating log segments older than {}", getFullyQualifiedName(), dlsn);
@@ -1106,7 +1105,7 @@ class BKLogWriteHandler extends BKLogHandler {
return FutureUtils.exception(new DLIllegalStateException(logMsg));
}
LOG.info("{}: Partially truncating log segment {} older than {}.",
- new Object[] {getFullyQualifiedName(), l, dlsn});
+ getFullyQualifiedName(), l, dlsn);
partialTruncate = l;
} else {
break;
@@ -1163,7 +1162,7 @@ class BKLogWriteHandler extends BKLogHandler {
}
}
LOG.info("Deleting log segments older than {} for {} : {}",
- new Object[] { minTimestampToKeep, getFullyQualifiedName(), purgeList });
+ minTimestampToKeep, getFullyQualifiedName(), purgeList);
return deleteLogSegments(purgeList);
}
});
@@ -1295,7 +1294,7 @@ class BKLogWriteHandler extends BKLogHandler {
return;
} else {
LOG.error("Couldn't purge {} for {}: with error {}",
- new Object[]{ segmentMetadata, getFullyQualifiedName(), t });
+ segmentMetadata, getFullyQualifiedName(), t);
promise.completeExceptionally(t);
}
}
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BookKeeperClient.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BookKeeperClient.java
index 8878135..1f69633 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BookKeeperClient.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BookKeeperClient.java
@@ -177,17 +177,17 @@ public class BookKeeperClient {
if (ownZK) {
LOG.info("BookKeeper Client created {} with its own ZK Client : ledgersPath = {}, numRetries = {}, "
+ "sessionTimeout = {}, backoff = {}, maxBackoff = {}, dnsResolver = {}",
- new Object[] { name, ledgersPath,
- conf.getBKClientZKNumRetries(), conf.getBKClientZKSessionTimeoutMilliSeconds(),
- conf.getBKClientZKRetryBackoffStartMillis(), conf.getBKClientZKRetryBackoffMaxMillis(),
- conf.getBkDNSResolverOverrides() });
+ name, ledgersPath,
+ conf.getBKClientZKNumRetries(), conf.getBKClientZKSessionTimeoutMilliSeconds(),
+ conf.getBKClientZKRetryBackoffStartMillis(), conf.getBKClientZKRetryBackoffMaxMillis(),
+ conf.getBkDNSResolverOverrides());
} else {
LOG.info("BookKeeper Client created {} with shared zookeeper client : ledgersPath = {}, numRetries = {}, "
+ "sessionTimeout = {}, backoff = {}, maxBackoff = {}, dnsResolver = {}",
- new Object[] { name, ledgersPath,
- conf.getZKNumRetries(), conf.getZKSessionTimeoutMilliseconds(),
- conf.getZKRetryBackoffStartMillis(), conf.getZKRetryBackoffMaxMillis(),
- conf.getBkDNSResolverOverrides() });
+ name, ledgersPath,
+ conf.getZKNumRetries(), conf.getZKSessionTimeoutMilliseconds(),
+ conf.getZKRetryBackoffStartMillis(), conf.getZKRetryBackoffMaxMillis(),
+ conf.getBkDNSResolverOverrides());
}
}
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/ReadAheadEntryReader.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/ReadAheadEntryReader.java
index 424615a..11a7e7e 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/ReadAheadEntryReader.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/ReadAheadEntryReader.java
@@ -547,8 +547,8 @@ class ReadAheadEntryReader implements
&& isCatchingUp
&& reader.hasCaughtUpOnInprogress()) {
logger.info("ReadAhead for {} is caught up at entry {} @ log segment {}.",
- new Object[] { readHandler.getFullyQualifiedName(),
- reader.getLastAddConfirmed(), reader.getSegment() });
+ readHandler.getFullyQualifiedName(),
+ reader.getLastAddConfirmed(), reader.getSegment());
isCatchingUp = false;
}
}
@@ -704,7 +704,7 @@ class ReadAheadEntryReader implements
if (reader.getSegment().getLogSegmentSequenceNumber() != newMetadata.getLogSegmentSequenceNumber()) {
logger.error("Inconsistent state found in entry reader for {} : "
+ "current segment = {}, new segment = {}",
- new Object[] { streamName, reader.getSegment(), newMetadata });
+ streamName, reader.getSegment(), newMetadata);
setLastException(new DLIllegalStateException("Inconsistent state found in entry reader for "
+ streamName + " : current segment = " + reader.getSegment() + ", new segment = " + newMetadata));
return false;
@@ -746,7 +746,7 @@ class ReadAheadEntryReader implements
if (currentSegmentSequenceNumber != segment.getLogSegmentSequenceNumber()) {
logger.error("Inconsistent state found in entry reader for {} : "
+ "current segment sn = {}, new segment sn = {}",
- new Object[] { streamName, currentSegmentSequenceNumber, segment.getLogSegmentSequenceNumber() });
+ streamName, currentSegmentSequenceNumber, segment.getLogSegmentSequenceNumber());
setLastException(new DLIllegalStateException("Inconsistent state found in entry reader for "
+ streamName + " : current segment sn = " + currentSegmentSequenceNumber
+ ", new segment sn = " + segment.getLogSegmentSequenceNumber()));
@@ -889,7 +889,7 @@ class ReadAheadEntryReader implements
}
if (!conf.getIgnoreTruncationStatus()) {
logger.error("{}: Trying to position reader on {} when {} is marked partially truncated",
- new Object[]{ streamName, fromDLSN, segment });
+ streamName, fromDLSN, segment);
setLastException(new AlreadyTruncatedTransactionException(streamName
+ " : trying to position read ahead at " + fromDLSN
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/ReadUtils.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/ReadUtils.java
index 4b1991a..3233473 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/ReadUtils.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/ReadUtils.java
@@ -251,7 +251,7 @@ public class ReadUtils {
final long endEntryId = context.curEndEntryId.get();
if (LOG.isDebugEnabled()) {
LOG.debug("{} reading entries [{} - {}] from {}.",
- new Object[] { streamName, startEntryId, endEntryId, metadata});
+ streamName, startEntryId, endEntryId, metadata);
}
FutureEventListener<List<Entry.Reader>> readEntriesListener =
new FutureEventListener<List<Entry.Reader>>() {
@@ -259,7 +259,7 @@ public class ReadUtils {
public void onSuccess(final List<Entry.Reader> entries) {
if (LOG.isDebugEnabled()) {
LOG.debug("{} finished reading entries [{} - {}] from {}",
- new Object[]{ streamName, startEntryId, endEntryId, metadata});
+ streamName, startEntryId, endEntryId, metadata);
}
for (Entry.Reader entry : entries) {
try {
@@ -275,8 +275,7 @@ public class ReadUtils {
LogRecordWithDLSN record = selector.result();
if (LOG.isDebugEnabled()) {
LOG.debug("{} got record from entries [{} - {}] of {} : {}",
- new Object[]{streamName, startEntryId, endEntryId,
- metadata, record});
+ streamName, startEntryId, endEntryId, metadata, record);
}
promise.complete(record);
}
@@ -348,8 +347,8 @@ public class ReadUtils {
public void onSuccess(LogRecordWithDLSN value) {
if (LOG.isDebugEnabled()) {
LOG.debug("{} read record from [{} - {}] of {} : {}",
- new Object[]{streamName, context.curStartEntryId.get(), context.curEndEntryId.get(),
- metadata, value});
+ streamName, context.curStartEntryId.get(), context.curEndEntryId.get(),
+ metadata, value);
}
if (null != value) {
promise.complete(value);
@@ -431,13 +430,11 @@ public class ReadUtils {
@Override
public void onSuccess(final LogSegmentRandomAccessEntryReader reader) {
if (LOG.isDebugEnabled()) {
- LOG.debug("{} Opened log segment {} for reading record",
- streamName, l);
+ LOG.debug("{} Opened log segment {} for reading record", streamName, l);
}
promise.whenComplete((value, cause) -> reader.asyncClose());
if (LOG.isDebugEnabled()) {
- LOG.debug("{} {} scanning {}.", new Object[]{
- (backward ? "backward" : "forward"), streamName, l});
+ LOG.debug("{} {} scanning {}.", (backward ? "backward" : "forward"), streamName, l);
}
asyncReadRecordFromLogSegment(
streamName, reader, l, executorService,
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/admin/DistributedLogAdmin.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/admin/DistributedLogAdmin.java
index 1776c3e..02bd41a 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/admin/DistributedLogAdmin.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/admin/DistributedLogAdmin.java
@@ -138,8 +138,7 @@ public class DistributedLogAdmin extends DistributedLogTool {
final LogSegmentMetadata newSegment =
FutureUtils.result(metadataUpdater.changeSequenceNumber(inprogressSegment,
newLogSegmentSequenceNumber));
- LOG.info("Fixed {} : {} -> {} ",
- new Object[] { streamName, inprogressSegment, newSegment });
+ LOG.info("Fixed {} : {} -> {} ", streamName, inprogressSegment, newSegment);
if (verbose) {
System.out.println("Fixed " + streamName + " : " + inprogressSegment.getZNodeName()
+ " -> " + newSegment.getZNodeName());
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/auditor/DLAuditor.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/auditor/DLAuditor.java
index 655762c..d97909a 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/auditor/DLAuditor.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/auditor/DLAuditor.java
@@ -256,7 +256,7 @@ public class DLAuditor {
collectLedgersFromAllocator(uri, namespace, aps, ledgers);
synchronized (ledgers) {
logger.info("Collected {} ledgers from allocators for {} : {} ",
- new Object[]{ledgers.size(), uri, ledgers});
+ ledgers.size(), uri, ledgers);
}
collectLedgersFromDL(uri, namespace, ledgers);
} catch (IOException e) {
@@ -360,8 +360,7 @@ public class DLAuditor {
streamQueue.add(streams.next());
}
- logger.info("Collected {} streams from uri {} : {}",
- new Object[] { streamQueue.size(), uri, streams });
+ logger.info("Collected {} streams from uri {} : {}", streamQueue.size(), uri, streams);
executeAction(streamQueue, 10, new Action<String>() {
@Override
@@ -561,7 +560,7 @@ public class DLAuditor {
try {
doneFuture.get();
logger.info("calculated {} ledgers\n\ttotal bytes = {}\n\ttotal entries = {}",
- new Object[] { numLedgers.get(), totalBytes.get(), totalEntries.get() });
+ numLedgers.get(), totalBytes.get(), totalEntries.get());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new DLInterruptedException("Interrupted on calculating ledger space : ", e);
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/SimpleLedgerAllocator.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/SimpleLedgerAllocator.java
index 015a961..0115a6e 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/SimpleLedgerAllocator.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/SimpleLedgerAllocator.java
@@ -399,7 +399,7 @@ public class SimpleLedgerAllocator implements LedgerAllocator, FutureEventListen
setPhase(Phase.ERROR);
deleteLedger(lh.getId());
LOG.error("Fail mark ledger {} as allocated under {} : ",
- new Object[] { lh.getId(), allocatePath, cause });
+ lh.getId(), allocatePath, cause);
// fail the allocation since failed to mark it as allocated
failAllocation(cause);
}
@@ -414,7 +414,7 @@ public class SimpleLedgerAllocator implements LedgerAllocator, FutureEventListen
deleteFuture.whenComplete((value, cause) -> {
if (null != cause) {
LOG.error("Error deleting ledger {} for ledger allocator {}, retrying : ",
- new Object[] { ledgerId, allocatePath, cause });
+ ledgerId, allocatePath, cause);
if (!isClosing()) {
deleteLedger(ledgerId);
}
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/BKNamespaceDriver.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/BKNamespaceDriver.java
index f64bae1..f316986 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/BKNamespaceDriver.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/BKNamespaceDriver.java
@@ -217,7 +217,7 @@ public class BKNamespaceDriver implements NamespaceDriver {
initialized = true;
LOG.info("Initialized BK namespace driver: clientId = {}, regionId = {}, federated = {}.",
- new Object[]{clientId, regionId, bkdlConfig.isFederatedNamespace()});
+ clientId, regionId, bkdlConfig.isFederatedNamespace());
return this;
}
@@ -587,9 +587,10 @@ public class BKNamespaceDriver implements NamespaceDriver {
.statsLogger(statsLogger)
.zkAclId(conf.getZkAclId());
LOG.info("Created shared zooKeeper client builder {}: zkServers = {}, numRetries = {}, sessionTimeout = {},"
- + " retryBackoff = {}, maxRetryBackoff = {}, zkAclId = {}.", new Object[] {
- zkcName, zkServers, conf.getZKNumRetries(), conf.getZKSessionTimeoutMilliseconds(),
- conf.getZKRetryBackoffStartMillis(), conf.getZKRetryBackoffMaxMillis(), conf.getZkAclId() });
+ + " retryBackoff = {}, maxRetryBackoff = {}, zkAclId = {}.", zkcName, zkServers,
+ conf.getZKNumRetries(), conf.getZKSessionTimeoutMilliseconds(),
+ conf.getZKRetryBackoffStartMillis(), conf.getZKRetryBackoffMaxMillis(),
+ conf.getZkAclId());
return builder;
}
@@ -611,7 +612,7 @@ public class BKNamespaceDriver implements NamespaceDriver {
.featureProvider(featureProviderOptional)
.statsLogger(statsLogger);
LOG.info("Created shared client builder {} : zkServers = {}, ledgersPath = {}, numIOThreads = {}",
- new Object[] { bkcName, zkServers, ledgersPath, conf.getBKClientNumberIOThreads() });
+ bkcName, zkServers, ledgersPath, conf.getBKClientNumberIOThreads());
return builder;
}
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKNamespaceWatcher.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKNamespaceWatcher.java
index 9d9783f..952f1b3 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKNamespaceWatcher.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKNamespaceWatcher.java
@@ -68,7 +68,7 @@ public class ZKNamespaceWatcher extends NamespaceWatcher
try {
scheduler.schedule(r, ms, TimeUnit.MILLISECONDS);
} catch (RejectedExecutionException ree) {
- logger.error("Task {} scheduled in {} ms is rejected : ", new Object[]{r, ms, ree});
+ logger.error("Task {} scheduled in {} ms is rejected : ", r, ms, ree);
}
}
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/acl/ZKAccessControlManager.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/acl/ZKAccessControlManager.java
index 7b775c4..bf11137 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/acl/ZKAccessControlManager.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/acl/ZKAccessControlManager.java
@@ -196,7 +196,7 @@ public class ZKAccessControlManager implements AccessControlManager, Watcher {
streamEntries.remove(streamName);
} else if (cause instanceof ZKAccessControl.CorruptedAccessControlException) {
logger.warn("Access control is corrupted for stream {} @ {},skipped it ...",
- new Object[] { streamName, zkRootPath, cause });
+ streamName, zkRootPath, cause);
streamEntries.remove(streamName);
} else {
if (1 == numFailures.incrementAndGet()) {
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/federated/FederatedZKLogMetadataStore.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/federated/FederatedZKLogMetadataStore.java
index d208aab..8d45866 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/federated/FederatedZKLogMetadataStore.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/federated/FederatedZKLogMetadataStore.java
@@ -150,7 +150,7 @@ public class FederatedZKLogMetadataStore
URI oldURI = log2Locations.putIfAbsent(logName, uri);
if (null != oldURI && !Objects.equal(uri, oldURI)) {
logger.error("Log {} is found duplicated in multiple locations : old location = {},"
- + " new location = {}", new Object[] { logName, oldURI, uri });
+ + " new location = {}", logName, oldURI, uri);
duplicatedLogFound.set(true);
}
}
@@ -232,7 +232,7 @@ public class FederatedZKLogMetadataStore
try {
scheduler.schedule(r, ms, TimeUnit.MILLISECONDS);
} catch (RejectedExecutionException ree) {
- logger.error("Task {} scheduled in {} ms is rejected : ", new Object[]{r, ms, ree});
+ logger.error("Task {} scheduled in {} ms is rejected : ", r, ms, ree);
}
}
@@ -668,7 +668,7 @@ public class FederatedZKLogMetadataStore
if (result.isPresent()) {
if (fetchResult.isPresent()) {
logger.error("Log {} is found in multiple sub namespaces : {} & {}.",
- new Object[] { logName, result.get(), fetchResult.get() });
+ logName, result.get(), fetchResult.get());
duplicatedLogName.compareAndSet(null, logName);
duplicatedLogFound.set(true);
fetchPromise.completeExceptionally(new UnexpectedException("Log " + logName
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/logsegment/BKLogSegmentEntryStore.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/logsegment/BKLogSegmentEntryStore.java
index b164a39..66e9940 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/logsegment/BKLogSegmentEntryStore.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/logsegment/BKLogSegmentEntryStore.java
@@ -140,8 +140,7 @@ public class BKLogSegmentEntryStore implements
deleteRequest.segment.getLogSegmentId(), deleteRequest.segment);
} else if (BKException.Code.OK != rc) {
logger.error("Couldn't delete ledger {} from bookkeeper for {} : {}",
- new Object[]{ deleteRequest.segment.getLogSegmentId(), deleteRequest.segment,
- BKException.getMessage(rc) });
+ deleteRequest.segment.getLogSegmentId(), deleteRequest.segment, BKException.getMessage(rc));
FutureUtils.completeExceptionally(deleteRequest.deletePromise,
new BKTransmitException("Couldn't delete log segment " + deleteRequest.segment, rc));
return;
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/metadata/ZKLogStreamMetadataStore.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/metadata/ZKLogStreamMetadataStore.java
index 0e923c6..869a968 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/metadata/ZKLogStreamMetadataStore.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/metadata/ZKLogStreamMetadataStore.java
@@ -585,7 +585,7 @@ public class ZKLogStreamMetadataStore implements LogStreamMetadataStore {
try {
PathUtils.validatePath(logRootPath);
} catch (IllegalArgumentException e) {
- LOG.error("Illegal path value {} for stream {}", new Object[]{logRootPath, logName, e});
+ LOG.error("Illegal path value {} for stream {}", logRootPath, logName, e);
return FutureUtils.exception(new InvalidStreamNameException(logName, "Log name is invalid"));
}
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/lock/ZKSessionLock.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/lock/ZKSessionLock.java
index 84c516c..80e24d0 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/lock/ZKSessionLock.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/lock/ZKSessionLock.java
@@ -203,8 +203,7 @@ class ZKSessionLock implements SessionLock {
public void transition(State toState) {
if (!validTransition(toState)) {
- LOG.error("Invalid state transition from {} to {} ",
- new Object[] { this.state, toState, getStack() });
+ LOG.error("Invalid state transition from {} to {} ", this.state, toState, getStack());
}
this.state = toState;
}
@@ -400,19 +399,18 @@ class ZKSessionLock implements SessionLock {
if (getEpoch() == lockEpoch) {
if (LOG.isTraceEnabled()) {
LOG.trace("{} executing lock action '{}' under epoch {} for lock {}",
- new Object[]{lockId, func.getActionName(), lockEpoch, lockPath});
+ lockId, func.getActionName(), lockEpoch, lockPath);
}
func.execute();
if (LOG.isTraceEnabled()) {
LOG.trace("{} executed lock action '{}' under epoch {} for lock {}",
- new Object[]{lockId, func.getActionName(), lockEpoch, lockPath});
+ lockId, func.getActionName(), lockEpoch, lockPath);
}
} else {
if (LOG.isTraceEnabled()) {
LOG.trace("{} skipped executing lock action '{}' for lock {},"
+ " since epoch is changed from {} to {}.",
- new Object[]{lockId, func.getActionName(),
- lockPath, lockEpoch, getEpoch()});
+ lockId, func.getActionName(), lockPath, lockEpoch, getEpoch());
}
}
}
@@ -440,18 +438,18 @@ class ZKSessionLock implements SessionLock {
if (currentEpoch == lockEpoch) {
if (LOG.isTraceEnabled()) {
LOG.trace("{} executed lock action '{}' under epoch {} for lock {}",
- new Object[]{lockId, func.getActionName(), lockEpoch, lockPath});
+ lockId, func.getActionName(), lockEpoch, lockPath);
}
func.execute();
if (LOG.isTraceEnabled()) {
LOG.trace("{} executed lock action '{}' under epoch {} for lock {}",
- new Object[]{lockId, func.getActionName(), lockEpoch, lockPath});
+ lockId, func.getActionName(), lockEpoch, lockPath);
}
} else {
if (LOG.isTraceEnabled()) {
LOG.trace("{} skipped executing lock action '{}' for lock {},"
+ " since epoch is changed from {} to {}.",
- new Object[]{lockId, func.getActionName(), lockPath, lockEpoch, currentEpoch});
+ lockId, func.getActionName(), lockPath, lockEpoch, currentEpoch);
}
promise.completeExceptionally(new EpochChangedException(lockPath, lockEpoch, currentEpoch));
}
@@ -699,13 +697,13 @@ class ZKSessionLock implements SessionLock {
// If tryLock failed due to state changed, we don't need to cleanup
if (lockCause instanceof LockStateChangedException) {
LOG.info("skipping cleanup for {} at {} after encountering lock "
- + "state change exception : ", new Object[] { lockId, lockPath, lockCause });
+ + "state change exception : ", lockId, lockPath, lockCause);
result.completeExceptionally(lockCause);
return;
}
if (LOG.isDebugEnabled()) {
LOG.debug("{} is cleaning up its lock state for {} due to : ",
- new Object[] { lockId, lockPath, lockCause });
+ lockId, lockPath, lockCause);
}
// If we encountered any exception we should cleanup
@@ -782,7 +780,7 @@ class ZKSessionLock implements SessionLock {
if (null != currentNode) {
LOG.error("Current node for {} overwritten current = {} new = {}",
- new Object[] { lockPath, lockId, getLockIdFromPath(currentNode) });
+ lockPath, lockId, getLockIdFromPath(currentNode));
}
currentNode = name;
@@ -899,9 +897,9 @@ class ZKSessionLock implements SessionLock {
FutureUtils.result(unlockResult, lockOpTimeout, TimeUnit.MILLISECONDS);
} catch (TimeoutException toe) {
// This shouldn't happen unless we lose a watch, and may result in a leaked lock.
- LOG.error("Timeout unlocking {} owned by {} : ", new Object[] { lockPath, lockId, toe });
+ LOG.error("Timeout unlocking {} owned by {} : ", lockPath, lockId, toe);
} catch (Exception e) {
- LOG.warn("{} failed to unlock {} : ", new Object[] { lockId, lockPath, e });
+ LOG.warn("{} failed to unlock {} : ", lockId, lockPath, e);
}
}
@@ -915,8 +913,7 @@ class ZKSessionLock implements SessionLock {
lockContext.addLockId(lockId);
if (LOG.isDebugEnabled()) {
LOG.debug("Notify lock waiters on {} at {} : watcher epoch {}, lock epoch {}",
- new Object[] { lockPath, System.currentTimeMillis(),
- lockEpoch, getEpoch() });
+ lockPath, System.currentTimeMillis(), lockEpoch, getEpoch());
}
acquireFuture.complete(true);
}
@@ -937,8 +934,7 @@ class ZKSessionLock implements SessionLock {
return;
}
- LOG.info("Lock {} for {} is closed from state {}.",
- new Object[] { lockId, lockPath, lockState.getState() });
+ LOG.info("Lock {} for {} is closed from state {}.", lockId, lockPath, lockState.getState());
final boolean skipCleanup = lockState.inState(State.INIT) || lockState.inState(State.EXPIRED);
@@ -990,10 +986,10 @@ class ZKSessionLock implements SessionLock {
} else if (KeeperException.Code.NONODE.intValue() == rc
|| KeeperException.Code.SESSIONEXPIRED.intValue() == rc) {
LOG.info("Delete node failed. Node already gone for node {} id {}, rc = {}",
- new Object[] { path, lockId, KeeperException.Code.get(rc) });
+ path, lockId, KeeperException.Code.get(rc));
} else {
LOG.error("Failed on deleting lock node {} for {} : {}",
- new Object[] { path, lockId, KeeperException.Code.get(rc) });
+ path, lockId, KeeperException.Code.get(rc));
}
FailpointUtils.checkFailPointNoThrow(FailpointUtils.FailPointName.FP_LockUnlockCleanup);
@@ -1062,7 +1058,7 @@ class ZKSessionLock implements SessionLock {
// The lock is either expired or closed
if (!lockState.inState(State.WAITING)) {
LOG.info("{} ignore watched node {} deleted event, since lock state has moved to {}.",
- new Object[] { lockId, event.getPath(), lockState.getState() });
+ lockId, event.getPath(), lockState.getState());
return;
}
lockState.transition(State.PREPARED);
@@ -1185,7 +1181,7 @@ class ZKSessionLock implements SessionLock {
});
} else {
LOG.error("Member {} doesn't exist in the members list {} for lock {}.",
- new Object[]{ cid, children, lockPath});
+ cid, children, lockPath);
promise.completeExceptionally(
new UnexpectedException("Member " + cid + " doesn't exist in member list "
+ children + " for lock " + lockPath));
@@ -1235,7 +1231,7 @@ class ZKSessionLock implements SessionLock {
shouldWatch = true;
shouldClaimOwnership = true;
LOG.info("LockWatcher {} for {} found its previous session {} held lock,"
- + " watch it to claim ownership.", new Object[] { myNode, lockPath, currentOwner });
+ + " watch it to claim ownership.", myNode, lockPath, currentOwner);
} else if (lockId.compareTo(currentOwner) == 0 && areLockWaitersInSameSession(siblingNode, ownerNode)) {
// I found that my sibling is the current owner with same lock id (client id & session id)
// It must be left by any race condition from same zookeeper client
@@ -1243,14 +1239,14 @@ class ZKSessionLock implements SessionLock {
shouldClaimOwnership = true;
LOG.info("LockWatcher {} for {} found itself {} already held lock at sibling node {},"
+ " watch it to claim ownership.",
- new Object[]{myNode, lockPath, lockId, siblingNode});
+ myNode, lockPath, lockId, siblingNode);
} else {
shouldWatch = wait;
if (wait) {
if (LOG.isDebugEnabled()) {
LOG.debug("Current LockWatcher for {} with ephemeral node {}, "
+ "is waiting for {} to release lock at {}.",
- new Object[]{lockPath, myNode, siblingNode, System.currentTimeMillis()});
+ lockPath, myNode, siblingNode, System.currentTimeMillis());
}
}
shouldClaimOwnership = false;
@@ -1275,7 +1271,7 @@ class ZKSessionLock implements SessionLock {
if (shouldClaimOwnership) {
// watch owner successfully
LOG.info("LockWatcher {} claimed ownership for {} after set watcher on {}.",
- new Object[]{ myNode, lockPath, ownerNode });
+ myNode, lockPath, ownerNode);
claimOwnership(lockWatcher.epoch);
promise.complete(currentOwner.getLeft());
} else {
@@ -1329,15 +1325,14 @@ class ZKSessionLock implements SessionLock {
@Override
public void process(WatchedEvent event) {
LOG.debug("Received event {} from lock {} at {} : watcher epoch {}, lock epoch {}.",
- new Object[] {event, lockPath, System.currentTimeMillis(), epoch, getEpoch() });
+ event, lockPath, System.currentTimeMillis(), epoch, getEpoch());
if (event.getType() == Watcher.Event.EventType.None) {
switch (event.getState()) {
case SyncConnected:
break;
case Expired:
LOG.info("Session {} is expired for lock {} at {} : watcher epoch {}, lock epoch {}.",
- new Object[] { lockId.getRight(), lockPath, System.currentTimeMillis(),
- epoch, getEpoch() });
+ lockId.getRight(), lockPath, System.currentTimeMillis(), epoch, getEpoch());
handleSessionExpired(epoch);
break;
default:
@@ -1348,7 +1343,7 @@ class ZKSessionLock implements SessionLock {
// watch on the nextLowestNode. This is a workaround since ZK doesn't support unsub.
if (!event.getPath().equals(watchedNode)) {
LOG.warn("{} (watching {}) ignored watched event from {} ",
- new Object[] { lockId, watchedNode, event.getPath() });
+ lockId, watchedNode, event.getPath());
return;
}
handleNodeDelete(epoch, event);
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/logsegment/PerStreamLogSegmentCache.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/logsegment/PerStreamLogSegmentCache.java
index a2796c2..c640b10 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/logsegment/PerStreamLogSegmentCache.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/logsegment/PerStreamLogSegmentCache.java
@@ -102,7 +102,7 @@ public class PerStreamLogSegmentCache {
>= LogSegmentMetadata.LogSegmentMetadataVersion.VERSION_V2_LEDGER_SEQNO.value
&& prevSegment.getLogSegmentSequenceNumber() + 1 != segment.getLogSegmentSequenceNumber()) {
LOG.error("{} found ledger sequence number gap between log segment {} and {}",
- new Object[] { streamName, prevSegment, segment });
+ streamName, prevSegment, segment);
throw new UnexpectedException(streamName + " found ledger sequence number gap between log segment "
+ prevSegment.getLogSegmentSequenceNumber()
+ " and " + segment.getLogSegmentSequenceNumber());
@@ -122,7 +122,7 @@ public class PerStreamLogSegmentCache {
if (null != prevSegment && prevSegment.supportsSequenceId()
&& prevSegment.getStartSequenceId() > segment.getStartSequenceId()) {
LOG.warn("{} found decreasing start sequence id in log segment {}, previous is {}",
- new Object[] { streamName, segment, prevSegment });
+ streamName, segment, prevSegment);
}
} else {
startSequenceId = DistributedLogConstants.UNASSIGNED_SEQUENCE_ID;
@@ -159,7 +159,7 @@ public class PerStreamLogSegmentCache {
if (!logSegments.containsKey(name)) {
logSegments.put(name, metadata);
LOG.info("{} added log segment ({} : {}) to cache.",
- new Object[]{ streamName, name, metadata });
+ streamName, name, metadata);
}
LogSegmentMetadata oldMetadata = lid2LogSegments.remove(metadata.getLogSegmentId());
if (null == oldMetadata) {
diff --git a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/DLMTestUtil.java b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/DLMTestUtil.java
index fa3b743..36b1f38 100644
--- a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/DLMTestUtil.java
+++ b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/DLMTestUtil.java
@@ -63,11 +63,11 @@ public class DLMTestUtil {
private static final byte[] payloadStatic = repeatString("abc", 512).getBytes();
static String repeatString(String s, int n) {
- String ret = s;
+ StringBuilder ret = new StringBuilder(s);
for (int i = 1; i < n; i++) {
- ret += s;
+ ret.append(s);
}
- return ret;
+ return ret.toString();
}
public static Map<Long, LogSegmentMetadata> readLogSegments(ZooKeeperClient zkc, String ledgerPath)
diff --git a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestAsyncReaderWriter.java b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestAsyncReaderWriter.java
index b04c27b..c683346 100644
--- a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestAsyncReaderWriter.java
+++ b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestAsyncReaderWriter.java
@@ -681,7 +681,7 @@ public class TestAsyncReaderWriter extends TestDistributedLogBase {
@Override
public void onFailure(Throwable cause) {
LOG.error("Encountered failures on writing record as (lid = {}, eid = {}) :",
- new Object[]{currentLogSegmentSeqNo, currentEntryId, cause});
+ currentLogSegmentSeqNo, currentEntryId, cause);
errorsFound.set(true);
syncLatch.countDown();
}
diff --git a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestDistributedLogBase.java b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestDistributedLogBase.java
index 16565a8..d069e72 100644
--- a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestDistributedLogBase.java
+++ b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestDistributedLogBase.java
@@ -135,7 +135,7 @@ public class TestDistributedLogBase {
try {
zkc = LocalDLMEmulator.connectZooKeeper("127.0.0.1", zkPort);
} catch (Exception ex) {
- LOG.error("hit exception connecting to zookeeper at {}:{}", new Object[] { "127.0.0.1", zkPort, ex });
+ LOG.error("hit exception connecting to zookeeper at {}:{}", "127.0.0.1", zkPort, ex);
throw ex;
}
}
diff --git a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestReader.java b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestReader.java
index d349dda..3219691 100644
--- a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestReader.java
+++ b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestReader.java
@@ -134,7 +134,7 @@ public class TestReader implements FutureEventListener<LogRecordWithDLSN> {
} catch (IOException exc) {
int nextMs = nextDelayMs();
LOG.info("Encountered exception {} on opening reader {} at {}, retrying in {} ms",
- new Object[] { exc, readerName, dlsn, nextMs });
+ exc, readerName, dlsn, nextMs);
positionReader(dlsn);
}
}
@@ -158,7 +158,7 @@ public class TestReader implements FutureEventListener<LogRecordWithDLSN> {
DLMTestUtil.verifyLargeLogRecord(value);
} catch (Exception exc) {
LOG.error("Exception encountered when verifying received log record {} for reader {} :",
- new Object[] { value.getDlsn(), exc, readerName });
+ value.getDlsn(), exc, readerName);
errorsFound.set(true);
completionLatch.countDown();
return;
@@ -171,7 +171,7 @@ public class TestReader implements FutureEventListener<LogRecordWithDLSN> {
completionLatch.countDown();
} else {
LOG.info("Reader {} : read count becomes {}, latch = {}",
- new Object[] { readerName, readCount.get(), countLatch.getCount() });
+ readerName, readCount.get(), countLatch.getCount());
nextDLSN = value.getDlsn().getNextDLSN();
readNext();
}