|
@@ -31,6 +31,7 @@ import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
+import java.util.HashSet;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.LinkedList;
|
|
import java.util.LinkedList;
|
|
@@ -183,6 +184,10 @@ public class RBFMetrics implements RouterMBean, FederationMBean {
|
|
@Override
|
|
@Override
|
|
public String getNamenodes() {
|
|
public String getNamenodes() {
|
|
final Map<String, Map<String, Object>> info = new LinkedHashMap<>();
|
|
final Map<String, Map<String, Object>> info = new LinkedHashMap<>();
|
|
|
|
+ if (membershipStore == null) {
|
|
|
|
+ return "{}";
|
|
|
|
+ }
|
|
|
|
+
|
|
try {
|
|
try {
|
|
// Get the values from the store
|
|
// Get the values from the store
|
|
GetNamenodeRegistrationsRequest request =
|
|
GetNamenodeRegistrationsRequest request =
|
|
@@ -252,6 +257,9 @@ public class RBFMetrics implements RouterMBean, FederationMBean {
|
|
@Override
|
|
@Override
|
|
public String getMountTable() {
|
|
public String getMountTable() {
|
|
final List<Map<String, Object>> info = new LinkedList<>();
|
|
final List<Map<String, Object>> info = new LinkedList<>();
|
|
|
|
+ if (mountTableStore == null) {
|
|
|
|
+ return "[]";
|
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
try {
|
|
// Get all the mount points in order
|
|
// Get all the mount points in order
|
|
@@ -302,6 +310,9 @@ public class RBFMetrics implements RouterMBean, FederationMBean {
|
|
@Override
|
|
@Override
|
|
public String getRouters() {
|
|
public String getRouters() {
|
|
final Map<String, Map<String, Object>> info = new LinkedHashMap<>();
|
|
final Map<String, Map<String, Object>> info = new LinkedHashMap<>();
|
|
|
|
+ if (routerStore == null) {
|
|
|
|
+ return "{}";
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
// Get all the routers in order
|
|
// Get all the routers in order
|
|
GetRouterRegistrationsRequest request =
|
|
GetRouterRegistrationsRequest request =
|
|
@@ -391,6 +402,9 @@ public class RBFMetrics implements RouterMBean, FederationMBean {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public int getNumNamenodes() {
|
|
public int getNumNamenodes() {
|
|
|
|
+ if (membershipStore == null) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
GetNamenodeRegistrationsRequest request =
|
|
GetNamenodeRegistrationsRequest request =
|
|
GetNamenodeRegistrationsRequest.newInstance();
|
|
GetNamenodeRegistrationsRequest.newInstance();
|
|
@@ -406,6 +420,9 @@ public class RBFMetrics implements RouterMBean, FederationMBean {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public int getNumExpiredNamenodes() {
|
|
public int getNumExpiredNamenodes() {
|
|
|
|
+ if (membershipStore == null) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
GetNamenodeRegistrationsRequest request =
|
|
GetNamenodeRegistrationsRequest request =
|
|
GetNamenodeRegistrationsRequest.newInstance();
|
|
GetNamenodeRegistrationsRequest.newInstance();
|
|
@@ -670,6 +687,9 @@ public class RBFMetrics implements RouterMBean, FederationMBean {
|
|
*/
|
|
*/
|
|
private Collection<String> getNamespaceInfo(
|
|
private Collection<String> getNamespaceInfo(
|
|
Function<FederationNamespaceInfo, String> f) throws IOException {
|
|
Function<FederationNamespaceInfo, String> f) throws IOException {
|
|
|
|
+ if (membershipStore == null) {
|
|
|
|
+ return new HashSet<>();
|
|
|
|
+ }
|
|
GetNamespaceInfoRequest request = GetNamespaceInfoRequest.newInstance();
|
|
GetNamespaceInfoRequest request = GetNamespaceInfoRequest.newInstance();
|
|
GetNamespaceInfoResponse response =
|
|
GetNamespaceInfoResponse response =
|
|
membershipStore.getNamespaceInfo(request);
|
|
membershipStore.getNamespaceInfo(request);
|
|
@@ -719,8 +739,11 @@ public class RBFMetrics implements RouterMBean, FederationMBean {
|
|
*/
|
|
*/
|
|
private List<MembershipState> getActiveNamenodeRegistrations()
|
|
private List<MembershipState> getActiveNamenodeRegistrations()
|
|
throws IOException {
|
|
throws IOException {
|
|
-
|
|
|
|
List<MembershipState> resultList = new ArrayList<>();
|
|
List<MembershipState> resultList = new ArrayList<>();
|
|
|
|
+ if (membershipStore == null) {
|
|
|
|
+ return resultList;
|
|
|
|
+ }
|
|
|
|
+
|
|
GetNamespaceInfoRequest request = GetNamespaceInfoRequest.newInstance();
|
|
GetNamespaceInfoRequest request = GetNamespaceInfoRequest.newInstance();
|
|
GetNamespaceInfoResponse response =
|
|
GetNamespaceInfoResponse response =
|
|
membershipStore.getNamespaceInfo(request);
|
|
membershipStore.getNamespaceInfo(request);
|