Package com.cloudera.lib.util

Examples of com.cloudera.lib.util.XConfiguration


   */
  @Override
  public final void init(Server server) throws ServiceException {
    this.server = server;
    String servicePrefix = getPrefixedName("");
    serviceConfig = new XConfiguration();
    for (Map.Entry<String, String> entry : server.getConfig().resolve()) {
      String key = entry.getKey();
      if (key.startsWith(servicePrefix)) {
        serviceConfig.set(key.substring(servicePrefix.length()), entry.getValue());
      }
View Full Code Here


    checkAbsolutePath(homeDir, "homeDir");
    checkAbsolutePath(configDir, "configDir");
    checkAbsolutePath(logDir, "logDir");
    checkAbsolutePath(tempDir, "tempDir");
    if (config != null) {
      this.config = new XConfiguration();
      XConfiguration.copy(config, this.config);
    }
    status = Status.UNDEF;
  }
View Full Code Here

    String defaultConfig = name + "-default.xml";
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    InputStream inputStream = classLoader.getResourceAsStream(defaultConfig);
    if (inputStream == null) {
      log.warn("Default configuration file not available in classpath [{}]", defaultConfig);
      defaultConf = new XConfiguration();
    }
    else {
      try {
        defaultConf = new XConfiguration(inputStream);
      }
      catch (IOException ex) {
        throw new ServerException(ServerException.ERROR.S03, defaultConfig, ex.getMessage(), ex);
      }
    }

    if (config == null) {
      XConfiguration siteConf;
      File siteFile = new File(file, name + "-site.xml");
      if (!siteFile.exists()) {
        log.warn("Site configuration file [{}] not found in config directory", siteFile);
        siteConf = new XConfiguration();
      }
      else {
        if (!siteFile.isFile()) {
          throw new ServerException(ServerException.ERROR.S05, siteFile.getAbsolutePath());
        }
        try {
          log.debug("Loading site configuration from [{}]", siteFile);
          inputStream = new FileInputStream(siteFile);
          siteConf = new XConfiguration(inputStream);
        }
        catch (IOException ex) {
          throw new ServerException(ServerException.ERROR.S06, siteFile, ex.getMessage(), ex);
        }
      }

      config = new XConfiguration();
      XConfiguration.copy(siteConf, config);
    }

    XConfiguration.injectDefaults(defaultConf, config);
View Full Code Here

    super(PREFIX);
  }

  @Override
  protected void init() throws ServiceException {
    Configuration hConf = new XConfiguration();
    XConfiguration.copy(getServiceConfig(), hConf);
    hGroups = new org.apache.hadoop.security.Groups(hConf);
  }
View Full Code Here

    }
    else {
      throw new ServiceException(HadoopException.ERROR.H09, security);
    }

    serviceHadoopConf = new XConfiguration();
    for (Map.Entry entry : getServiceConfig()) {
      String name = (String) entry.getKey();
      if (name.startsWith(HADOOP_CONF_PREFIX)) {
        name = name.substring(HADOOP_CONF_PREFIX.length());
        String value = (String) entry.getValue();
View Full Code Here

  }


  @Override
  public Configuration getDefaultConfiguration() {
    Configuration conf = new XConfiguration();
    XConfiguration.copy(serviceHadoopConf, conf);
    return conf;
  }
View Full Code Here

  @Test(expectedExceptions = AccessControlException.class)
  @TestDir
  public void validateUserNotACL() throws Exception {
    String dir = getTestDir().getAbsolutePath();
    XConfiguration conf = new XConfiguration();
    conf.set("server.services", StringUtils.toString(Arrays.asList(GroupsService.class.getName(),
                                                                   ACLService.class.getName()), ","));
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
    ACL acl = server.get(ACL.class);
    String user = System.getProperty("user.name");
View Full Code Here

  @Test
  @TestDir
  public void service() throws Exception {
    String dir = getTestDir().getAbsolutePath();
    XConfiguration conf = new XConfiguration();
    conf.set("server.services", StringUtils.toString(Arrays.asList(InstrumentationService.class.getName(),
                                                                   SchedulerService.class.getName()), ","));
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
    Assert.assertNotNull(server.get(Scheduler.class));
    server.destroy();
View Full Code Here

  @Test
  @TestDir
  public void service() throws Exception {
    String dir = getTestDir().getAbsolutePath();
    XConfiguration conf = new XConfiguration();
    conf.set("server.services", StringUtils.toString(Arrays.asList(GroupsService.class.getName(),
                                                                   ProxyUserService.class.getName()), ","));
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
    ProxyUser proxyUser = server.get(ProxyUser.class);
    Assert.assertNotNull(proxyUser);
View Full Code Here

  @Test(expectedExceptions = ServiceException.class, expectedExceptionsMessageRegExp = "PRXU02.*")
  @TestDir
  public void wrongConfigGroups() throws Exception {
    String dir = getTestDir().getAbsolutePath();
    XConfiguration conf = new XConfiguration();
    conf.set("server.services", StringUtils.toString(Arrays.asList(GroupsService.class.getName(),
                                                                   ProxyUserService.class.getName()), ","));
    conf.set("server.proxyuser.foo.hosts", "*");
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
  }
View Full Code Here

TOP

Related Classes of com.cloudera.lib.util.XConfiguration

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.