Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

improvement: add detailed information when operation has exception #106

Merged
merged 12 commits into from
May 19, 2020
8 changes: 5 additions & 3 deletions src/main/java/com/xiaomi/infra/pegasus/client/PException.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.xiaomi.infra.pegasus.client;

import com.xiaomi.infra.pegasus.base.error_code;
import com.xiaomi.infra.pegasus.client.PegasusTable.Request;
import com.xiaomi.infra.pegasus.rpc.ReplicationException;
import java.util.concurrent.TimeoutException;

Expand Down Expand Up @@ -40,13 +41,14 @@ static PException threadInterrupted(String tableName, InterruptedException e) {
String.format("[table=%s] Thread was interrupted: %s", tableName, e.getMessage())));
}

static PException timeout(String tableName, int timeout, TimeoutException e) {
static PException timeout(
String metaList, String tableName, Request request, int timeout, TimeoutException e) {
return new PException(
new ReplicationException(
error_code.error_types.ERR_TIMEOUT,
String.format(
"[table=%s, timeout=%dms] Timeout on Future await: %s",
tableName, timeout, e.getMessage())));
"[metaServer=%s, table=%s, request=%s, timeout=%dms] Timeout on Future await: %s",
metaList, tableName, request.toString(), timeout, e.getMessage())));
}

private static String loadVersion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class PegasusClient implements PegasusClientInterface {
private final Properties config;
private final ConcurrentHashMap<String, PegasusTable> tableMap;
private final Object tableMapLock;
private final String[] metaList;
private Cluster cluster;

private static class PegasusHasher implements KeyHasher {
Expand Down Expand Up @@ -88,6 +89,7 @@ public PegasusClient(Properties config) throws PException {
this.cluster = Cluster.createCluster(config);
this.tableMap = new ConcurrentHashMap<String, PegasusTable>();
this.tableMapLock = new Object();
this.metaList = cluster.getMetaList();
foreverneverer marked this conversation as resolved.
Show resolved Hide resolved
this.enableWriteLimit =
Boolean.parseBoolean(
config.getProperty(PEGASUS_ENABLE_WRITE_LIMIT, PEGASUS_ENABLE_WRITE_LIMIT_DEF));
Expand All @@ -98,6 +100,10 @@ public boolean isWriteLimitEnabled() {
return enableWriteLimit;
}

String getMetaList() {
return Arrays.toString(metaList);
}

@Override
public void finalize() {
close();
Expand Down
Loading