Package org.apache.hadoop.raid.protocol

Examples of org.apache.hadoop.raid.protocol.PolicyList$CompareByPath


      Element element = (Element)node;
      String elementTagName = element.getTagName();
      if ("srcPath".equalsIgnoreCase(elementTagName)) {
        String srcPathPrefix = element.getAttribute("prefix");

        PolicyList policyList = null;
        if (srcPathPrefix != null && srcPathPrefix.length() != 0) {
          // Empty srcPath will have no effect but policies will be processed
          // This allow us to define some "abstract" policies
          policyList = new PolicyList();
          all.add(policyList);
          policyList.setSrcPath(conf, srcPathPrefix);
        }

        // loop through all the policies for this source path
        NodeList policies = element.getChildNodes();
        for (int j = 0; j < policies.getLength(); j++) {
          Node node1 = policies.item(j);
          if (!(node1 instanceof Element)) {
            continue;
          }
          Element policy = (Element)node1;
          if (!"policy".equalsIgnoreCase(policy.getTagName())) {
            throw new RaidConfigurationException("Bad configuration file: " +
              "Expecting <policy> for srcPath " + srcPathPrefix);
          }
          String policyName = policy.getAttribute("name");
          PolicyInfo curr = new PolicyInfo(policyName, conf);
          if (srcPathPrefix != null && srcPathPrefix.length() > 0) {
            curr.setSrcPath(srcPathPrefix);
          }
          // loop through all the properties of this policy
          NodeList properties = policy.getChildNodes();
          PolicyInfo parent = null;
          for (int k = 0; k < properties.getLength(); k++) {
            Node node2 = properties.item(k);
            if (!(node2 instanceof Element)) {
              continue;
            }
            Element property = (Element)node2;
            String propertyName = property.getTagName();
            if ("erasureCode".equalsIgnoreCase(propertyName)) {
              String text = ((Text)property.getFirstChild()).getData().trim();
              LOG.info(policyName + ".erasureCode = " + text);
              curr.setErasureCode(text);
            } else if ("description".equalsIgnoreCase(propertyName)) {
              String text = ((Text)property.getFirstChild()).getData().trim();
              curr.setDescription(text);
            } else if ("parentPolicy".equalsIgnoreCase(propertyName)) {
              String text = ((Text)property.getFirstChild()).getData().trim();
              parent = existingPolicies.get(text);
            } else if ("property".equalsIgnoreCase(propertyName)) {
              NodeList nl = property.getChildNodes();
              String pname=null,pvalue=null;
              for (int l = 0; l < nl.getLength(); l++){
                Node node3 = nl.item(l);
                if (!(node3 instanceof Element)) {
                  continue;
                }
                Element item = (Element) node3;
                String itemName = item.getTagName();
                if ("name".equalsIgnoreCase(itemName)){
                  pname = ((Text)item.getFirstChild()).getData().trim();
                } else if ("value".equalsIgnoreCase(itemName)){
                  pvalue = ((Text)item.getFirstChild()).getData().trim();
                }
              }
              if (pname != null && pvalue != null) {
                LOG.info(policyName + "." + pname + " = " + pvalue);
                curr.setProperty(pname,pvalue);
              }
            } else {
              LOG.info("Found bad property " + propertyName +
                       " for srcPath" + srcPathPrefix +
                       " policy name " + policyName +
                       ". Ignoring.");
            }
          }  // done with all properties of this policy

          PolicyInfo pinfo;
          if (parent != null) {
            pinfo = new PolicyInfo(policyName, conf);
            pinfo.copyFrom(parent);
            pinfo.copyFrom(curr);
          } else {
            pinfo = curr;
          }
          if (policyList != null) {
            policyList.add(pinfo);
          }
          existingPolicies.put(policyName, pinfo);

        }    // done with all policies for this srcpath
      }
View Full Code Here


      Element element = (Element)node;
      String elementTagName = element.getTagName();
      if ("srcPath".equalsIgnoreCase(elementTagName)) {
        String srcPathPrefix = element.getAttribute("prefix");

        PolicyList policyList = null;
        if (srcPathPrefix != null && srcPathPrefix.length() != 0) {
          // Empty srcPath will have no effect but policies will be processed
          // This allow us to define some "abstract" policies
          policyList = new PolicyList();
          all.add(policyList);
          policyList.setSrcPath(conf, srcPathPrefix);
        }

        // loop through all the policies for this source path
        NodeList policies = element.getChildNodes();
        for (int j = 0; j < policies.getLength(); j++) {
          Node node1 = policies.item(j);
          if (!(node1 instanceof Element)) {
            continue;
          }
          Element policy = (Element)node1;
          if (!"policy".equalsIgnoreCase(policy.getTagName())) {
            throw new RaidConfigurationException("Bad configuration file: " +
              "Expecting <policy> for srcPath " + srcPathPrefix);
          }
          String policyName = policy.getAttribute("name");
          PolicyInfo curr = new PolicyInfo(policyName, conf);
          if (srcPathPrefix != null && srcPathPrefix.length() > 0) {
            curr.setSrcPath(srcPathPrefix);
          }
          // loop through all the properties of this policy
          NodeList properties = policy.getChildNodes();
          PolicyInfo parent = null;
          for (int k = 0; k < properties.getLength(); k++) {
            Node node2 = properties.item(k);
            if (!(node2 instanceof Element)) {
              continue;
            }
            Element property = (Element)node2;
            String propertyName = property.getTagName();
            if ("erasureCode".equalsIgnoreCase(propertyName)) {
              String text = ((Text)property.getFirstChild()).getData().trim();
              LOG.info(policyName + ".erasureCode = " + text);
              curr.setErasureCode(text);
            } else if ("description".equalsIgnoreCase(propertyName)) {
              String text = ((Text)property.getFirstChild()).getData().trim();
              curr.setDescription(text);
            } else if ("parentPolicy".equalsIgnoreCase(propertyName)) {
              String text = ((Text)property.getFirstChild()).getData().trim();
              parent = existingPolicies.get(text);
            } else if ("property".equalsIgnoreCase(propertyName)) {
              NodeList nl = property.getChildNodes();
              String pname=null,pvalue=null;
              for (int l = 0; l < nl.getLength(); l++){
                Node node3 = nl.item(l);
                if (!(node3 instanceof Element)) {
                  continue;
                }
                Element item = (Element) node3;
                String itemName = item.getTagName();
                if ("name".equalsIgnoreCase(itemName)){
                  pname = ((Text)item.getFirstChild()).getData().trim();
                } else if ("value".equalsIgnoreCase(itemName)){
                  pvalue = ((Text)item.getFirstChild()).getData().trim();
                }
              }
              if (pname != null && pvalue != null) {
                LOG.info(policyName + "." + pname + " = " + pvalue);
                curr.setProperty(pname,pvalue);
              }
            } else {
              LOG.warn("Found bad property " + propertyName +
                       " for srcPath" + srcPathPrefix +
                       " policy name " + policyName +
                       ". Ignoring.");
            }
          }  // done with all properties of this policy

          PolicyInfo pinfo;
          if (parent != null) {
            pinfo = new PolicyInfo(policyName, conf);
            pinfo.copyFrom(parent);
            pinfo.copyFrom(curr);
          } else {
            pinfo = curr;
          }
          if (policyList != null) {
            policyList.add(pinfo);
          }
          existingPolicies.put(policyName, pinfo);

        }    // done with all policies for this srcpath
      }
View Full Code Here

        if (srcPathPrefix == null || srcPathPrefix.length() == 0) {
          throw new RaidConfigurationException("Bad configuration file: " +
             "srcPathPrefix not set.");
        }
        PolicyList policyList = new PolicyList();
        all.add(policyList);

        policyList.setSrcPath(conf, srcPathPrefix);
       
        // loop through all the policies for this source path
        NodeList policies = element.getChildNodes();
        for (int j = 0; j < policies.getLength(); j++) {
          Node node1 = policies.item(j);
          if (!(node1 instanceof Element)) {
            continue;
          }
          Element policy = (Element)node1;
          if (!"policy".equalsIgnoreCase(policy.getTagName())) {
            throw new RaidConfigurationException("Bad configuration file: " +
              "Expecting <policy> for srcPath " + srcPathPrefix);
          }
          String policyName = policy.getAttribute("name");
          PolicyInfo pinfo = new PolicyInfo(policyName, conf);
          pinfo.setSrcPath(srcPathPrefix);
          policyList.add(pinfo);

          // loop through all the properties of this policy
          NodeList properties = policy.getChildNodes();
          for (int k = 0; k < properties.getLength(); k++) {
            Node node2 = properties.item(k);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.raid.protocol.PolicyList$CompareByPath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.