@SuppressWarnings({ "unchecked", "cast", "rawtypes" })
        public static void doMetaGet(AdminClient adminClient,
                                     Collection<Integer> nodeIds,
                                     List<String> metaKeys,
                                     File directory,
                                     Boolean verbose) throws IOException {
            Map<String, List<Node>> nodeMap = new HashMap<String, List<Node>>();
            Map<Node, Version> versionMap = new HashMap<Node, Version>();
            for(String key: metaKeys) {
                nodeMap.clear();
                versionMap.clear();
                System.out.println("Metadata: " + key);
                for(Integer nodeId: nodeIds) {
                    Versioned<String> versioned = null;
                    try {
                        versioned = adminClient.metadataMgmtOps.getRemoteMetadata(nodeId, key);
                    } catch(Exception e) {
                        System.out.println("Error in retrieving " + e.getMessage());
                        System.out.println();
                        continue;
                    }
                    if(directory != null) {
                        FileUtils.writeStringToFile(new File(directory, key + "_" + nodeId),
                                                    ((versioned == null) ? ""
                                                                        : versioned.getValue()));
                    } else {
                        Node node = adminClient.getAdminClientCluster().getNodeById(nodeId);
                        if(verbose) {
                            System.out.println(node.getHost() + ":" + nodeId);
                            if(versioned == null) {
                                System.out.println("null");
                            } else {
                                System.out.println(versioned.getVersion());
                                System.out.print(": ");
                                System.out.println(versioned.getValue());
                                System.out.println();
                            }
                        } else {
                            if(!nodeMap.containsKey(versioned.getValue())) {
                                nodeMap.put(versioned.getValue(), new ArrayList<Node>());
                            }
                            nodeMap.get(versioned.getValue()).add(node);
                            if(!versionMap.containsKey(node)) {
                                versionMap.put(node, versioned.getVersion());
                            }
                        }
                    }
                }
                if(!verbose && !nodeMap.isEmpty()) {
                    Iterator<Entry<String, List<Node>>> iter = nodeMap.entrySet().iterator();
                    while(iter.hasNext()) {
                        Map.Entry entry = (Map.Entry) iter.next();
                        String metaValue = (String) entry.getKey();
                        List<Node> nodeList = (List<Node>) entry.getValue();
                        for(Node node: nodeList) {
                            System.out.println(node.getHost() + ":" + node.getId() + "   "
                                               + versionMap.get(node));
                        }
                        System.out.println(metaValue);
                        System.out.println();
                    }
                }
            }
        }
@ SuppressWarnings ( { "unchecked" , "cast" , "rawtypes" } ) public static void doMetaGet ( AdminClient adminClient , Collection < Integer > nodeIds , List < String > metaKeys , File directory , Boolean verbose ) throws IOException { Map < String , List < Node > > nodeMap = new HashMap < String , List < Node > > ( ) ; Map < Node , Version > versionMap = new HashMap < Node , Version > ( ) ; for ( String key : metaKeys ) { nodeMap . clear ( ) ; versionMap . clear ( ) ; System . out . println ( "Metadata: " + key ) ; for ( Integer nodeId : nodeIds ) { Versioned < String > versioned = null ; try { versioned = adminClient . metadataMgmtOps . getRemoteMetadata ( nodeId , key ) ; } catch ( Exception e ) { System . out . println ( "Error in retrieving " + e . getMessage ( ) ) ; System . out . println ( ) ; continue ; } if ( directory != null ) { FileUtils . writeStringToFile ( new File ( directory , key + "_" + nodeId ) , ( ( versioned == null ) ? "" : versioned . getValue ( ) ) ) ; } else { Node node = adminClient . getAdminClientCluster ( ) . getNodeById ( nodeId ) ; if ( verbose ) { System . out . println ( node . getHost ( ) + ":" + nodeId ) ; if ( versioned == null ) { System . out . println ( "null" ) ; } else { System . out . println ( versioned . getVersion ( ) ) ; System . out . print ( ": " ) ; System . out . println ( versioned . getValue ( ) ) ; System . out . println ( ) ; } } else { if ( ! nodeMap . containsKey ( versioned . getValue ( ) ) ) { nodeMap . put ( versioned . getValue ( ) , new ArrayList < Node > ( ) ) ; } nodeMap . get ( versioned . getValue ( ) ) . add ( node ) ; if ( ! versionMap . containsKey ( node ) ) { versionMap . put ( node , versioned . getVersion ( ) ) ; } } } } if ( ! verbose && ! nodeMap . isEmpty ( ) ) { Iterator < Entry < String , List < Node > > > iter = nodeMap . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) iter . next ( ) ; String metaValue = ( String ) entry . getKey ( ) ; List < Node > nodeList = ( List < Node > ) entry . getValue ( ) ; for ( Node node : nodeList ) { System . out . println ( node . getHost ( ) + ":" + node . getId ( ) + "   " + versionMap . get ( node ) ) ; } System . out . println ( metaValue ) ; System . out . println ( ) ; } } } }
Gets metadata.

@param adminClient An instance of AdminClient points to given cluster
@param nodeIds Node ids to fetch metadata from
@param metaKeys List of metadata to fetch
@param directory Directory to output to
@param verbose Tells whether to print metadata verbosely
@throws IOException