コード例 #1
0
ファイル: SVMconfig.java プロジェクト: ptribble/solview
 /*
  * Parsing metastat output: we take two passes. In the first, we enumerate
  * the list of devices. In the second, we assign properties to build up
  * relationships.
  */
 private void parse_metastat() {
   InfoCommand ic = new InfoCommand("MD", "/usr/sbin/metastat", "-p");
   if (ic.exists()) {
     String[] lines = ic.getOutput().split("\n");
     for (String line : lines) {
       String[] ds = line.split("\\s+");
       /*
        * Conventionally, metadevices start with d; the only other
        * possible entries are hot spares starting with hsp.
        */
       if (ds[0].startsWith("d")) {
         // metadevice
         MetaDevice md = parse_metadevice(ds);
         metadevices.add(md);
         metamap.put(ds[0], md);
       } else if (ds[0].startsWith("hsp")) {
         // Hot spare pool
         metahotspares.add(parse_hotspare(ds));
       } else {
         System.err.println("Unhandled metastat output\n" + line);
       }
     }
     for (String line : lines) {
       if (line.startsWith("d")) {
         relate_metadevices(line.split("\\s+"));
       }
     }
   }
 }
コード例 #2
0
ファイル: SVMconfig.java プロジェクト: ptribble/solview
 private void parse_metadb() {
   InfoCommand ic = new InfoCommand("MD", "/usr/sbin/metadb");
   if (ic.exists()) {
     for (String line : ic.getOutput().split("\n")) {
       String[] ts = line.split("\\s+");
       String ms = ts[ts.length - 1];
       if (ms.startsWith("/")) {
         boolean gotit = false;
         for (MetaDB mdb : metadbs) {
           if (ms.equals(mdb.getDevice())) {
             mdb.addReplica();
             gotit = true;
           }
         }
         if (!gotit) {
           metadbs.add(new MetaDB(ms));
         }
       }
     }
   }
 }