Skip to content

Commit

Permalink
supply-debug-log (apache#9239)
Browse files Browse the repository at this point in the history
### Motivation
When in debug log, this doesn't provide useful informations
![image](https://user-images.githubusercontent.com/12933197/105045964-74c26c80-5aa3-11eb-9fa5-dcef81213ea1.png)


### Modifications
- add the toString method of OpAddEntry
- fix some java doc problems
  • Loading branch information
hezhangjian authored Jan 21, 2021
1 parent 7c5d6b1 commit 06cd01c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public boolean insert(EntryImpl entry) {
entry.getLength());
}

ByteBuf cachedData = null;
ByteBuf cachedData;
if (copyEntries) {
cachedData = copyEntry(entry);
if (cachedData == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ public class EntryCacheManager {

private static final double evictionTriggerThresholdPercent = 0.98;

/**
*
*/

public EntryCacheManager(ManagedLedgerFactoryImpl factory) {
this.maxSize = factory.getConfig().getMaxCacheSize();
this.evictionTriggerThreshold = (long) (maxSize * evictionTriggerThresholdPercent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.bookkeeper.mledger.impl;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ComparisonChain;

import io.netty.buffer.ByteBuf;
Expand Down Expand Up @@ -56,7 +57,7 @@ public static EntryImpl create(LedgerEntry ledgerEntry) {
return entry;
}

// Used just for tests
@VisibleForTesting
public static EntryImpl create(long ledgerId, long entryId, byte[] data) {
EntryImpl entry = RECYCLER.get();
entry.timestamp = System.nanoTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ public void recordCacheEviction() {
cacheEvictions.recordEvent();
}

// //

@Override
public int getNumberOfManagedLedgers() {
return factory.ledgers.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public class ManagedLedgerImpl implements ManagedLedger, CreateCallback {
private long lastLedgerCreationInitiationTimestamp = 0;

private static final Random random = new Random(System.currentTimeMillis());
private long maximumRolloverTimeMs;
private final long maximumRolloverTimeMs;
protected final Supplier<Boolean> mlOwnershipChecker;

volatile PositionImpl lastConfirmedEntry;
Expand Down Expand Up @@ -265,8 +265,6 @@ public enum PositionBound {
@VisibleForTesting
Map<String, byte[]> createdLedgerCustomMetadata;

// //////////////////////////////////////////////////////////////////////

public ManagedLedgerImpl(ManagedLedgerFactoryImpl factory, BookKeeper bookKeeper, MetaStore store,
ManagedLedgerConfig config, OrderedScheduler scheduledExecutor, OrderedExecutor orderedExecutor,
final String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public class ManagedLedgerOfflineBacklog {
private final byte[] password;
private final BookKeeper.DigestType digestType;
private static final int META_READ_TIMEOUT_SECONDS = 60;
private boolean accurate = false;
private String brokerName;
private final boolean accurate;
private final String brokerName;

public ManagedLedgerOfflineBacklog(DigestType digestType, byte[] password, String brokerName,
boolean accurate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@
*/
package org.apache.bookkeeper.mledger.impl;

import static com.google.common.base.Preconditions.checkArgument;

import io.netty.buffer.ByteBuf;
import io.netty.util.Recycler;
import io.netty.util.Recycler.Handle;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

import io.netty.util.ReferenceCountUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.bookkeeper.client.AsyncCallback.AddCallback;
import org.apache.bookkeeper.client.AsyncCallback.CloseCallback;
import org.apache.bookkeeper.client.BKException;
Expand All @@ -37,13 +31,18 @@
import org.apache.bookkeeper.mledger.ManagedLedgerException;
import org.apache.bookkeeper.mledger.util.SafeRun;
import org.apache.bookkeeper.util.SafeRunnable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

import static com.google.common.base.Preconditions.checkArgument;

/**
* Handles the life-cycle of an addEntry() operation.
*
*/
@Slf4j
public class OpAddEntry extends SafeRunnable implements AddCallback, CloseCallback {
protected ManagedLedgerImpl ml;
LedgerHandle ledger;
Expand Down Expand Up @@ -220,7 +219,7 @@ public void closeComplete(int rc, LedgerHandle lh, Object ctx) {
lh.getId());

if (rc == BKException.Code.OK) {
log.debug("Successfuly closed ledger {}", lh.getId());
log.debug("Successfully closed ledger {}", lh.getId());
} else {
log.warn("Error when closing ledger {}. Status={}", lh.getId(), BKException.getMessage(rc));
}
Expand Down Expand Up @@ -333,5 +332,15 @@ public void recycle() {
recyclerHandle.recycle(this);
}

private static final Logger log = LoggerFactory.getLogger(OpAddEntry.class);
@Override
public String toString() {
return "OpAddEntry{" +
"mlName" + ml.getName() +
"ledgerId=" + ledger.getId() +
", entryId=" + entryId +
", startTime=" + startTime +
", dataLength=" + dataLength +
'}';
}

}

0 comments on commit 06cd01c

Please sign in to comment.