Package org.apache.ambari.server.api.util

Examples of org.apache.ambari.server.api.util.StackExtensionHelper


    if (!stackRoot.isDirectory() && !stackRoot.exists())
      throw new IOException("" + Configuration.METADETA_DIR_PATH
        + " should be a directory with stack"
        + ", stackRoot = " + stackRootAbsPath);

    StackExtensionHelper stackExtensionHelper = new StackExtensionHelper
      (stackRoot);
    stackExtensionHelper.fillInfo();

    List<StackInfo> stacks = stackExtensionHelper.getAllAvailableStacks();
    if (stacks.isEmpty()) {
      throw new AmbariException("Unable to find stack definitions under " +
        "stackRoot = " + stackRootAbsPath);
    }

    ExecutorService es = Executors.newSingleThreadExecutor(new ThreadFactory() {
      @Override
      public Thread newThread(Runnable r) {
        return new Thread(r, "Stack Version Loading Thread");
      }
    });
   
    List<LatestRepoCallable> lookupList = new ArrayList<LatestRepoCallable>();
   
    for (StackInfo stack : stacks) {
      LOG.debug("Adding new stack to known stacks"
        + ", stackName = " + stack.getName()
        + ", stackVersion = " + stack.getVersion());

      stacksResult.add(stack);

      String stackPath = stackRootAbsPath + File.separator +
              stack.getName() + File.separator + stack.getVersion();

      // get repository data for current stack of techs
      File repositoryFolder = new File(stackPath
        + File.separator + REPOSITORY_FOLDER_NAME + File.separator
        + REPOSITORY_FILE_NAME);

      if (repositoryFolder.exists()) {
        LOG.debug("Adding repositories to stack"
          + ", stackName=" + stack.getName()
          + ", stackVersion=" + stack.getVersion()
          + ", repoFolder=" + repositoryFolder.getPath());

        List<RepositoryInfo> repositoryInfoList = getRepository(repositoryFolder,
            stack, lookupList);

        stack.getRepositories().addAll(repositoryInfoList);
      } else {
        LOG.warn("No repository information defined for "
          + ", stackName=" + stack.getName()
          + ", stackVersion=" + stack.getVersion()
          + ", repoFolder=" + repositoryFolder.getPath());
      }

      // Populate services
      List<ServiceInfo> services = stackExtensionHelper
        .getAllApplicableServices(stack);
      stack.setServices(services);

      // Resolve hooks folder
      String stackHooksToUse = stackExtensionHelper.
              resolveHooksFolder(stack);
      stack.setStackHooksFolder(stackHooksToUse);
    }
   
    es.invokeAll(lookupList);
View Full Code Here


    allStacks.add(newStack);

    Method method = StackExtensionHelper.class.getDeclaredMethod
      ("getParentStacksInOrder", Collection.class);
    method.setAccessible(true);
    StackExtensionHelper helper = new StackExtensionHelper(metaInfo.getStackRoot());
    helper.fillInfo();
    Map<String, List<StackInfo>> stacks = (Map<String, List<StackInfo>>)
      method.invoke(helper, allStacks);

    Assert.assertNotNull(stacks.get("2.0.99"));
    // Verify order
View Full Code Here

      "preserved.", target.toArray(), actual.toArray());
  }

  @Test
  public void testGetApplicableServices() throws Exception {
    StackExtensionHelper helper = new StackExtensionHelper(
      metaInfo.getStackRoot());
    helper.fillInfo();
    List<ServiceInfo> allServices = helper.getAllApplicableServices(metaInfo
      .getStackInfo(STACK_NAME_HDP, EXT_STACK_NAME));

    ServiceInfo testService = null;
    ServiceInfo existingService = null;
    for (ServiceInfo serviceInfo : allServices) {
View Full Code Here

    if (!stackRoot.isDirectory() && !stackRoot.exists())
      throw new IOException("" + Configuration.METADETA_DIR_PATH
        + " should be a directory with stack"
        + ", stackRoot = " + stackRoot.getAbsolutePath());

    StackExtensionHelper stackExtensionHelper = new StackExtensionHelper
      (stackRoot);

    List<StackInfo> stacks = stackExtensionHelper.getAllAvailableStacks();
    if (stacks.isEmpty()) {
      throw new AmbariException("Unable to find stack definitions under " +
        "stackRoot = " + stackRoot.getAbsolutePath());
    }

    for (StackInfo stack : stacks) {
      LOG.debug("Adding new stack to known stacks"
        + ", stackName = " + stack.getName()
        + ", stackVersion = " + stack.getVersion());

      stacksResult.add(stack);

      // get repository data for current stack of techs
      File repositoryFolder = new File(stackRoot.getAbsolutePath()
        + File.separator + stack.getName() + File.separator + stack.getVersion()
        + File.separator + REPOSITORY_FOLDER_NAME + File.separator
        + REPOSITORY_FILE_NAME);

      if (repositoryFolder.exists()) {
        LOG.debug("Adding repositories to stack"
          + ", stackName=" + stack.getName()
          + ", stackVersion=" + stack.getVersion()
          + ", repoFolder=" + repositoryFolder.getPath());

        List<RepositoryInfo> repositoryInfoList = getRepository
          (repositoryFolder, stack.getVersion());

        stack.getRepositories().addAll(repositoryInfoList);
      } else {
        LOG.warn("No repository information defined for "
          + ", stackName=" + stack.getName()
          + ", stackVersion=" + stack.getVersion()
          + ", repoFolder=" + repositoryFolder.getPath());
      }

      List<ServiceInfo> services = stackExtensionHelper
        .getAllApplicableServices(stack);

      stack.setServices(services);
    }
  }
View Full Code Here

    allStacks.add(newStack);

    Method method = StackExtensionHelper.class.getDeclaredMethod
      ("getParentStacksInOrder", Collection.class);
    method.setAccessible(true);
    StackExtensionHelper helper = new StackExtensionHelper(metaInfo.getStackRoot());
    Map<String, List<StackInfo>> stacks = (Map<String, List<StackInfo>>)
      method.invoke(helper, allStacks);

    Assert.assertNotNull(stacks.get("2.0.99"));
    // Verify order
View Full Code Here

      "preserved.", target.toArray(), actual.toArray());
  }

  @Test
  public void testGetApplicableServices() throws Exception {
    StackExtensionHelper helper = new StackExtensionHelper(
      metaInfo.getStackRoot());
    List<ServiceInfo> allServices = helper.getAllApplicableServices(metaInfo
      .getStackInfo(STACK_NAME_HDP, EXT_STACK_NAME));

    ServiceInfo testService = null;
    ServiceInfo existingService = null;
    for (ServiceInfo serviceInfo : allServices) {
View Full Code Here

    if (!stackRoot.isDirectory() && !stackRoot.exists())
      throw new IOException("" + Configuration.METADETA_DIR_PATH
        + " should be a directory with stack"
        + ", stackRoot = " + stackRootAbsPath);

    StackExtensionHelper stackExtensionHelper = new StackExtensionHelper(injector, stackRoot);
    stackExtensionHelper.fillInfo();

    List<StackInfo> stacks = stackExtensionHelper.getAllAvailableStacks();
    if (stacks.isEmpty()) {
      throw new AmbariException("Unable to find stack definitions under " +
        "stackRoot = " + stackRootAbsPath);
    }

    ExecutorService es = Executors.newSingleThreadExecutor(new ThreadFactory() {
      @Override
      public Thread newThread(Runnable r) {
        return new Thread(r, "Stack Version Loading Thread");
      }
    });

    List<LatestRepoCallable> lookupList = new ArrayList<LatestRepoCallable>();

    for (StackInfo stack : stacks) {
      LOG.debug("Adding new stack to known stacks"
        + ", stackName = " + stack.getName()
        + ", stackVersion = " + stack.getVersion());

      stacksResult.add(stack);

      String stackPath = stackRootAbsPath + File.separator +
              stack.getName() + File.separator + stack.getVersion();

      // get repository data for current stack of techs
      File repositoryFolder = new File(stackPath
        + File.separator + REPOSITORY_FOLDER_NAME + File.separator
        + REPOSITORY_FILE_NAME);

      if (repositoryFolder.exists()) {
        LOG.debug("Adding repositories to stack"
          + ", stackName=" + stack.getName()
          + ", stackVersion=" + stack.getVersion()
          + ", repoFolder=" + repositoryFolder.getPath());

        List<RepositoryInfo> repositoryInfoList = getRepository(repositoryFolder,
            stack, lookupList);

        stack.getRepositories().addAll(repositoryInfoList);
      } else {
        LOG.warn("No repository information defined for "
          + ", stackName=" + stack.getName()
          + ", stackVersion=" + stack.getVersion()
          + ", repoFolder=" + repositoryFolder.getPath());
      }

      // Populate services
      List<ServiceInfo> services = stackExtensionHelper.getAllApplicableServices(stack);
      stack.setServices(services);

      Map<String, Map<String, PropertyInfo>> stackRequiredProps = new HashMap<String, Map<String, PropertyInfo>>();
      requiredProperties.put(new StackId(stack.getName(), stack.getVersion()), stackRequiredProps);
      for (ServiceInfo service : services) {
        // Set required config properties
        stackRequiredProps.put(service.getName(), getAllRequiredProperties(service));
      }

      // Resolve hooks folder
      String stackHooksToUse = stackExtensionHelper.resolveHooksFolder(stack);
      stack.setStackHooksFolder(stackHooksToUse);
    }

    es.invokeAll(lookupList);
View Full Code Here

    allStacks.add(newStack);

    Method method = StackExtensionHelper.class.getDeclaredMethod
      ("getParentStacksInOrder", Collection.class);
    method.setAccessible(true);
    StackExtensionHelper helper = new StackExtensionHelper(injector, metaInfo.getStackRoot());
    helper.fillInfo();
    Map<String, List<StackInfo>> stacks =
      (Map<String, List<StackInfo>>) method.invoke(helper, allStacks);

    Assert.assertNotNull(stacks.get("2.0.99"));
    // Verify order
View Full Code Here

      "preserved.", target.toArray(), actual.toArray());
  }

  @Test
  public void testGetApplicableServices() throws Exception {
    StackExtensionHelper helper = new StackExtensionHelper(injector,
      metaInfo.getStackRoot());
    helper.fillInfo();
    List<ServiceInfo> allServices = helper.getAllApplicableServices(metaInfo
      .getStackInfo(STACK_NAME_HDP, EXT_STACK_NAME));

    ServiceInfo testService = null;
    ServiceInfo existingService = null;
    for (ServiceInfo serviceInfo : allServices) {
View Full Code Here

    allStacks.add(newStack);

    Method method = StackExtensionHelper.class.getDeclaredMethod
      ("getParentStacksInOrder", Collection.class);
    method.setAccessible(true);
    StackExtensionHelper helper = new StackExtensionHelper(metaInfo.getStackRoot());
    helper.fillInfo();
    Map<String, List<StackInfo>> stacks =
      (Map<String, List<StackInfo>>) method.invoke(helper, allStacks);

    Assert.assertNotNull(stacks.get("2.0.99"));
    // Verify order
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.api.util.StackExtensionHelper

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.