Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ public class ConnectionImplementation implements ClusterConnection, Closeable {

private ChoreService choreService;

private long userRegionLockHeldStartTime;

/**
* constructor
* @param conf Configuration object
Expand Down Expand Up @@ -1112,6 +1114,11 @@ rpcControllerFactory, getMetaLookupPool(), connectionConfig.getMetaReadRpcTimeou
ConnectionUtils.getPauseTime(pauseBase, tries), TimeUnit.MILLISECONDS);
}
} finally {
// update duration of the lock being held
Comment thread
vli02 marked this conversation as resolved.
if (metrics != null) {
metrics.updateUserRegionLockHeld(
EnvironmentEdgeManager.currentTime() - userRegionLockHeldStartTime);
}
userRegionLock.unlock();
}
try {
Expand All @@ -1126,9 +1133,21 @@ rpcControllerFactory, getMetaLookupPool(), connectionConfig.getMetaReadRpcTimeou
void takeUserRegionLock() throws IOException {
try {
long waitTime = connectionConfig.getMetaOperationTimeout();
long waitStartTime = 0;
if (metrics != null) {
Comment thread
shahrs87 marked this conversation as resolved.
metrics.updateUserRegionLockQueue(userRegionLock.getQueueLength());
waitStartTime = EnvironmentEdgeManager.currentTime();
}
if (!userRegionLock.tryLock(waitTime, TimeUnit.MILLISECONDS)) {
if (metrics != null) {
metrics.incrUserRegionLockTimeout();
}
throw new LockTimeoutException("Failed to get user region lock in" + waitTime + " ms. "
+ " for accessing meta region server.");
} else if (metrics != null) {
Comment thread
vli02 marked this conversation as resolved.
// successfully grabbed the lock, start timer of holding the lock
userRegionLockHeldStartTime = EnvironmentEdgeManager.currentTime();
metrics.updateUserRegionLockWaiting(userRegionLockHeldStartTime - waitStartTime);
}
} catch (InterruptedException ie) {
LOG.error("Interrupted while waiting for a lock", ie);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ public Counter newMetric(Class<?> clazz, String name, String scope) {
private final Counter nsLookups;
private final Counter nsLookupsFailed;
private final Timer overloadedBackoffTimer;
private final Counter userRegionLockTimeoutCount;
private final Timer userRegionLockWaitingTimer;
private final Timer userRegionLockHeldTimer;
private final Histogram userRegionLockQueueHist;

// dynamic metrics

Expand Down Expand Up @@ -443,6 +447,15 @@ protected Ratio getRatio() {
this.nsLookups = registry.counter(name(this.getClass(), NS_LOOKUPS, scope));
this.nsLookupsFailed = registry.counter(name(this.getClass(), NS_LOOKUPS_FAILED, scope));

this.userRegionLockTimeoutCount =
registry.counter(name(this.getClass(), "userRegionLockTimeoutCount", scope));
this.userRegionLockWaitingTimer =
registry.timer(name(this.getClass(), "userRegionLockWaitingDurationMs", scope));
Comment thread
vli02 marked this conversation as resolved.
Outdated
this.userRegionLockHeldTimer =
registry.timer(name(this.getClass(), "userRegionLockHeldDurationMs", scope));
this.userRegionLockQueueHist =
registry.histogram(name(MetricsConnection.class, "userRegionLockQueueLength", scope));

this.overloadedBackoffTimer =
registry.timer(name(this.getClass(), "overloadedBackoffDurationMs", scope));

Expand Down Expand Up @@ -598,6 +611,24 @@ public void incrementServerOverloadedBackoffTime(long time, TimeUnit timeUnit) {
overloadedBackoffTimer.update(time, timeUnit);
}

/** incr */
Comment thread
vli02 marked this conversation as resolved.
public void incrUserRegionLockTimeout() {
userRegionLockTimeoutCount.inc();
}

/** update */
public void updateUserRegionLockWaiting(long duration) {
userRegionLockWaitingTimer.update(duration, TimeUnit.MILLISECONDS);
}

public void updateUserRegionLockHeld(long duration) {
userRegionLockHeldTimer.update(duration, TimeUnit.MILLISECONDS);
}

public void updateUserRegionLockQueue(int count) {
userRegionLockQueueHist.update(count);
}

/** Return the connection count of the metrics within a scope */
public long getConnectionCount() {
return connectionCount.getCount();
Expand Down