HDFS-15633. Avoid redundant RPC calls for getDiskStatus. (#2386). Contributed by Ayush Saxena.
This commit is contained in:
parent
162923e799
commit
8354ce680b
|
@ -1939,8 +1939,17 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory,
|
||||||
* @see ClientProtocol#getStats()
|
* @see ClientProtocol#getStats()
|
||||||
*/
|
*/
|
||||||
public FsStatus getDiskStatus() throws IOException {
|
public FsStatus getDiskStatus() throws IOException {
|
||||||
return new FsStatus(getStateByIndex(0),
|
try (TraceScope ignored = tracer.newScope("getStats")) {
|
||||||
getStateByIndex(1), getStateByIndex(2));
|
long[] states = namenode.getStats();
|
||||||
|
return new FsStatus(getStateAtIndex(states, 0),
|
||||||
|
getStateAtIndex(states, 1), getStateAtIndex(states, 2));
|
||||||
|
} catch (RemoteException re) {
|
||||||
|
throw re.unwrapRemoteException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private long getStateAtIndex(long[] states, int index) {
|
||||||
|
return states.length > index ? states[index] : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue