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);
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);