public static void doMetaCheck(AdminClient adminClient, List<String> metaKeys) {
            Map<String, Integer> roStoreToReplicationFactorMap = new HashMap<String, Integer>();
            Collection<Node> allNodes = adminClient.getAdminClientCluster().getNodes();

            for(String key: metaKeys) {
                Map<String, Map<Object, List<String>>> storeDefToNodeMap = new HashMap<String, Map<Object, List<String>>>(); 
                Map<Object, List<String>> metadataNodeValueMap = new HashMap<Object, List<String>>();
                
                Collection<String> allNodeNames = new ArrayList<String>();

                Boolean checkResult = true;
                for(Node node: allNodes) {
                    String nodeName = "Host '" + node.getHost() + "' : ID " + node.getId();
                    allNodeNames.add(nodeName);

                    Versioned<String> versioned = adminClient.metadataMgmtOps.getRemoteMetadata(node.getId(),
                                                                                                key);
                    if(versioned == null || versioned.getValue() == null) {
                        throw new VoldemortException("Value returned from node " + node.getId()
                                                     + " was null");
                    } else if(key.compareTo(MetadataStore.STORES_KEY) == 0) {
                        List<StoreDefinition> storeDefinitions = new StoreDefinitionsMapper().readStoreList(new StringReader(versioned.getValue()));
                        for(StoreDefinition storeDef: storeDefinitions) {
                            String storeName = storeDef.getName();

                            if(storeDef.getType().compareTo(ReadOnlyStorageConfiguration.TYPE_NAME) == 0) {
                                roStoreToReplicationFactorMap.put(storeName, storeDef.getReplicationFactor());
                            }

                            if(storeDefToNodeMap.containsKey(storeName) == false) {
                                storeDefToNodeMap.put(storeName,
                                                      new HashMap<Object, List<String>>());
                            }
                            Map<Object, List<String>> storeDefMap = storeDefToNodeMap.get(storeName);
                            addMetadataValue(storeDefMap, storeDef, nodeName);
                            
                            // Try a random Get against one key for store/Node
                            checkGetStore(adminClient, storeDef, node);
                        }
                    } else {
                        if(key.compareTo(MetadataStore.CLUSTER_KEY) == 0
                           || key.compareTo(MetadataStore.REBALANCING_SOURCE_CLUSTER_XML) == 0) {
                            Cluster cluster = new ClusterMapper().readCluster(new StringReader(versioned.getValue()));
                            addMetadataValue(metadataNodeValueMap, cluster, nodeName);
                        } else if(key.compareTo(MetadataStore.SERVER_STATE_KEY) == 0) {
                            VoldemortState voldemortStateValue = VoldemortState.valueOf(versioned.getValue());
                            addMetadataValue(metadataNodeValueMap, voldemortStateValue, nodeName);
                        } else {
                            throw new VoldemortException("Incorrect metadata key");
                        }

                    }
                }

                if(metadataNodeValueMap.size() > 0) {
                    checkResult &= checkDiagnostics("Key " + key,
                                                    metadataNodeValueMap,
                                                    allNodeNames);
                }

                if(storeDefToNodeMap.size() > 0) {
                    for(Map.Entry<String, Map<Object, List<String>>> storeNodeValueEntry: storeDefToNodeMap.entrySet()) {
                        String storeName = storeNodeValueEntry.getKey();
                        Map<Object, List<String>> storeDefMap = storeNodeValueEntry.getValue();
                        checkResult &= checkDiagnostics("Store " + storeName,
                                                        storeDefMap,
                                                        allNodeNames);
                        for(QuotaType type : QuotaType.values()) {
                          Map<Object, List<String>> quotaNodeValues = new HashMap<Object, List<String>>();
                          String keyName = "Store:" + storeName + "_QuotaType_"+ type;
                          for(Node node: allNodes) {                          
                            String nodeName = "Host '" + node.getHost() + "' : ID " + node.getId();
                            Versioned<String> quotaValue = adminClient.quotaMgmtOps.getQuotaForNode(storeName, type, node.getId());
                            if(quotaValue == null || quotaValue.getValue() == null) {
                              continue;
                            }
                            addMetadataValue( quotaNodeValues , quotaValue.getValue() , nodeName);
                          }

                          if(quotaNodeValues.size() > 0) {
                            boolean result = checkDiagnostics(keyName,
                                quotaNodeValues,
                                allNodeNames);
                            checkResult &= result;
                          }
                        }
                    }
                }

                System.out.println(key + " metadata check : " + (checkResult ? "PASSED" : "FAILED"));
            }

            validateROFiles(adminClient, allNodes, roStoreToReplicationFactorMap);
        }
public static void doMetaCheck ( AdminClient adminClient , List < String > metaKeys ) { Map < String , Integer > roStoreToReplicationFactorMap = new HashMap < String , Integer > ( ) ; Collection < Node > allNodes = adminClient . getAdminClientCluster ( ) . getNodes ( ) ; for ( String key : metaKeys ) { Map < String , Map < Object , List < String > > > storeDefToNodeMap = new HashMap < String , Map < Object , List < String > > > ( ) ; Map < Object , List < String > > metadataNodeValueMap = new HashMap < Object , List < String > > ( ) ; Collection < String > allNodeNames = new ArrayList < String > ( ) ; Boolean checkResult = true ; for ( Node node : allNodes ) { String nodeName = "Host '" + node . getHost ( ) + "' : ID " + node . getId ( ) ; allNodeNames . add ( nodeName ) ; Versioned < String > versioned = adminClient . metadataMgmtOps . getRemoteMetadata ( node . getId ( ) , key ) ; if ( versioned == null || versioned . getValue ( ) == null ) { throw new VoldemortException ( "Value returned from node " + node . getId ( ) + " was null" ) ; } else if ( key . compareTo ( MetadataStore . STORES_KEY ) == 0 ) { List < StoreDefinition > storeDefinitions = new StoreDefinitionsMapper ( ) . readStoreList ( new StringReader ( versioned . getValue ( ) ) ) ; for ( StoreDefinition storeDef : storeDefinitions ) { String storeName = storeDef . getName ( ) ; if ( storeDef . getType ( ) . compareTo ( ReadOnlyStorageConfiguration . TYPE_NAME ) == 0 ) { roStoreToReplicationFactorMap . put ( storeName , storeDef . getReplicationFactor ( ) ) ; } if ( storeDefToNodeMap . containsKey ( storeName ) == false ) { storeDefToNodeMap . put ( storeName , new HashMap < Object , List < String > > ( ) ) ; } Map < Object , List < String > > storeDefMap = storeDefToNodeMap . get ( storeName ) ; addMetadataValue ( storeDefMap , storeDef , nodeName ) ; checkGetStore ( adminClient , storeDef , node ) ; } } else { if ( key . compareTo ( MetadataStore . CLUSTER_KEY ) == 0 || key . compareTo ( MetadataStore . REBALANCING_SOURCE_CLUSTER_XML ) == 0 ) { Cluster cluster = new ClusterMapper ( ) . readCluster ( new StringReader ( versioned . getValue ( ) ) ) ; addMetadataValue ( metadataNodeValueMap , cluster , nodeName ) ; } else if ( key . compareTo ( MetadataStore . SERVER_STATE_KEY ) == 0 ) { VoldemortState voldemortStateValue = VoldemortState . valueOf ( versioned . getValue ( ) ) ; addMetadataValue ( metadataNodeValueMap , voldemortStateValue , nodeName ) ; } else { throw new VoldemortException ( "Incorrect metadata key" ) ; } } } if ( metadataNodeValueMap . size ( ) > 0 ) { checkResult &= checkDiagnostics ( "Key " + key , metadataNodeValueMap , allNodeNames ) ; } if ( storeDefToNodeMap . size ( ) > 0 ) { for ( Map . Entry < String , Map < Object , List < String > > > storeNodeValueEntry : storeDefToNodeMap . entrySet ( ) ) { String storeName = storeNodeValueEntry . getKey ( ) ; Map < Object , List < String > > storeDefMap = storeNodeValueEntry . getValue ( ) ; checkResult &= checkDiagnostics ( "Store " + storeName , storeDefMap , allNodeNames ) ; for ( QuotaType type : QuotaType . values ( ) ) { Map < Object , List < String > > quotaNodeValues = new HashMap < Object , List < String > > ( ) ; String keyName = "Store:" + storeName + "_QuotaType_" + type ; for ( Node node : allNodes ) { String nodeName = "Host '" + node . getHost ( ) + "' : ID " + node . getId ( ) ; Versioned < String > quotaValue = adminClient . quotaMgmtOps . getQuotaForNode ( storeName , type , node . getId ( ) ) ; if ( quotaValue == null || quotaValue . getValue ( ) == null ) { continue ; } addMetadataValue ( quotaNodeValues , quotaValue . getValue ( ) , nodeName ) ; } if ( quotaNodeValues . size ( ) > 0 ) { boolean result = checkDiagnostics ( keyName , quotaNodeValues , allNodeNames ) ; checkResult &= result ; } } } } System . out . println ( key + " metadata check : " + ( checkResult ? "PASSED" : "FAILED" ) ) ; } validateROFiles ( adminClient , allNodes , roStoreToReplicationFactorMap ) ; }
Checks if metadata is consistent across all nodes.

@param adminClient An instance of AdminClient points to given cluster
@param metaKeys List of metakeys to check