Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -184,6 +184,25 @@ public void proxyOpFailureCommunicate(String nsId) {
}
}

@Override
public void proxyOpPermitRejected(String nsId) {
if (metrics != null) {
metrics.incrProxyOpPermitRejected();
}
if (nameserviceRPCMetricsMap != null &&
nameserviceRPCMetricsMap.containsKey(nsId)) {
nameserviceRPCMetricsMap.get(nsId).incrProxyOpPermitRejected();
}
}

@Override
public void proxyOpPermitAccepted(String nsId) {
if (nameserviceRPCMetricsMap != null &&
nameserviceRPCMetricsMap.containsKey(nsId)) {
nameserviceRPCMetricsMap.get(nsId).incrProxyOpPermitAccepted();
}
}

@Override
public void proxyOpFailureClientOverloaded() {
if (metrics != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ public interface NameserviceRPCMBean {

long getProxyOpNoNamenodes();

long getProxyOpPermitRejected();

long getProxyOpPermitAccepted();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.hadoop.metrics2.annotation.Metric;
import org.apache.hadoop.metrics2.annotation.Metrics;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.apache.hadoop.metrics2.lib.MetricsRegistry;
import org.apache.hadoop.metrics2.lib.MutableCounterLong;
import org.apache.hadoop.metrics2.lib.MutableRate;

Expand All @@ -37,6 +38,7 @@ public class NameserviceRPCMetrics implements NameserviceRPCMBean {
public final static String NAMESERVICE_RPC_METRICS_PREFIX = "NameserviceActivity-";

private final String nsId;
private final MetricsRegistry registry = new MetricsRegistry("NameserviceRPCActivity");

@Metric("Time for the Router to proxy an operation to the Nameservice")
private MutableRate proxy;
Expand All @@ -49,19 +51,24 @@ public class NameserviceRPCMetrics implements NameserviceRPCMBean {
private MutableCounterLong proxyOpFailureCommunicate;
@Metric("Number of operations to hit no namenodes available")
private MutableCounterLong proxyOpNoNamenodes;
@Metric("Number of operations to hit permit limits")
private MutableCounterLong proxyOpPermitRejected;
@Metric("Number of operations accepted to hit a namenode")
private MutableCounterLong proxyOpPermitAccepted;

public NameserviceRPCMetrics(Configuration conf, String nsId) {
this.nsId = nsId;
this.nsId = NAMESERVICE_RPC_METRICS_PREFIX + nsId;
registry.tag("ns", "Nameservice", nsId);
}

public static NameserviceRPCMetrics create(Configuration conf,
String nameService) {
MetricsSystem ms = DefaultMetricsSystem.instance();
String name = NAMESERVICE_RPC_METRICS_PREFIX + (nameService.isEmpty()
? "UndefinedNameService"+ ThreadLocalRandom.current().nextInt()
: nameService);
return ms.register(name, "HDFS Federation NameService RPC Metrics",
new NameserviceRPCMetrics(conf, name));
String nsId = (nameService.isEmpty() ?
"UndefinedNameService" + ThreadLocalRandom.current().nextInt() :
nameService);
return ms.register(NAMESERVICE_RPC_METRICS_PREFIX + nsId,
"HDFS Federation NameService RPC Metrics", new NameserviceRPCMetrics(conf, nsId));
}

public void incrProxyOpFailureStandby() {
Expand Down Expand Up @@ -91,6 +98,23 @@ public long getProxyOpNoNamenodes() {
return proxyOpNoNamenodes.value();
}

public void incrProxyOpPermitRejected() {
proxyOpPermitRejected.incr();
}

@Override
public long getProxyOpPermitRejected() {
return proxyOpPermitRejected.value();
}

public void incrProxyOpPermitAccepted() {
proxyOpPermitAccepted.incr();
}

@Override
public long getProxyOpPermitAccepted() {
return proxyOpPermitAccepted.value();
}

/**
* Add the time to proxy an operation from the moment the Router sends it to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@ private void acquirePermit(final String nsId, final UserGroupInformation ugi,
// Throw StandByException,
// Clients could fail over and try another router.
if (rpcMonitor != null) {
rpcMonitor.getRPCMetrics().incrProxyOpPermitRejected();
rpcMonitor.proxyOpPermitRejected(nsId);
}
incrRejectedPermitForNs(nsId);
LOG.debug("Permit denied for ugi: {} for method: {}",
Expand All @@ -1590,6 +1590,9 @@ private void acquirePermit(final String nsId, final UserGroupInformation ugi,
" is overloaded for NS: " + nsId;
throw new StandbyException(msg);
}
if (rpcMonitor != null) {
rpcMonitor.proxyOpPermitAccepted(nsId);
}
incrAcceptedPermitForNs(nsId);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ void init(
*/
void proxyOpFailureCommunicate(String nsId);

/**
* Rejected to proxy an operation to a Namenode.
*/
void proxyOpPermitRejected(String nsId);

/**
* Accepted to proxy an operation to a Namenode.
*/
void proxyOpPermitAccepted(String nsId);

/**
* Failed to proxy an operation to a Namenode because the client was
* overloaded.
Expand Down