コード例 #1
0
  @Override
  public void prepareAMAndConfigForLaunch(
      SliderFileSystem fileSystem,
      Configuration serviceConf,
      AbstractLauncher launcher,
      AggregateConf instanceDescription,
      Path snapshotConfDirPath,
      Path generatedConfDirPath,
      Configuration clientConfExtras,
      String libdir,
      Path tempPath,
      boolean miniClusterTestRun)
      throws IOException, SliderException {
    // load in the template site config
    log.debug("Loading template configuration from {}", snapshotConfDirPath);
    Configuration siteConf =
        ConfigHelper.loadTemplateConfiguration(
            serviceConf,
            snapshotConfDirPath,
            AccumuloKeys.SITE_XML,
            AccumuloKeys.SITE_XML_RESOURCE);

    Map<String, LocalResource> providerResources;
    providerResources =
        fileSystem.submitDirectory(generatedConfDirPath, SliderKeys.PROPAGATED_CONF_DIR_NAME);

    ProviderUtils.addProviderJar(
        providerResources,
        this,
        "slider-accumulo-provider.jar",
        fileSystem,
        tempPath,
        libdir,
        miniClusterTestRun);

    addAccumuloDependencyJars(providerResources, fileSystem, libdir, tempPath);
    launcher.addLocalResources(providerResources);

    // construct the cluster configuration values

    ConfTreeOperations appconf = instanceDescription.getAppConfOperations();

    Map<String, String> clusterConfMap = buildSiteConfFromInstance(instanceDescription);

    // merge them
    ConfigHelper.addConfigMap(siteConf, clusterConfMap.entrySet(), "Accumulo Provider");

    // now, if there is an extra client conf, merge it in too
    if (clientConfExtras != null) {
      ConfigHelper.mergeConfigurations(siteConf, clientConfExtras, "Slider Client");
    }

    if (log.isDebugEnabled()) {
      log.debug("Merged Configuration");
      ConfigHelper.dumpConf(siteConf);
    }

    Path sitePath =
        ConfigHelper.saveConfig(serviceConf, siteConf, generatedConfDirPath, AccumuloKeys.SITE_XML);

    log.debug("Saving the config to {}", sitePath);
    launcher.submitDirectory(generatedConfDirPath, SliderKeys.PROPAGATED_CONF_DIR_NAME);
  }
コード例 #2
0
  @Override
  public void buildContainerLaunchContext(
      ContainerLauncher launcher,
      AggregateConf instanceDefinition,
      Container container,
      String role,
      SliderFileSystem coreFS,
      Path generatedConfPath,
      MapOperations resourceComponent,
      MapOperations appComponent,
      Path containerTmpDirPath)
      throws IOException, SliderException {

    // Set the environment
    launcher.putEnv(SliderUtils.buildEnvMap(appComponent));

    String logDirs = providerUtils.getLogdir();
    String logDir;
    int idx = logDirs.indexOf(",");
    if (idx > 0) {
      // randomly choose a log dir candidate
      String[] segments = logDirs.split(",");
      Random rand = new Random();
      logDir = segments[rand.nextInt(segments.length)];
    } else logDir = logDirs;
    launcher.setEnv(HBASE_LOG_DIR, logDir);

    launcher.setEnv(
        PROPAGATED_CONFDIR,
        ProviderUtils.convertToAppRelativePath(SliderKeys.PROPAGATED_CONF_DIR_NAME));

    // local resources

    // add the configuration resources
    launcher.addLocalResources(
        coreFS.submitDirectory(generatedConfPath, SliderKeys.PROPAGATED_CONF_DIR_NAME));
    // Add binaries
    // now add the image if it was set
    String imageURI =
        instanceDefinition
            .getInternalOperations()
            .get(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH);
    coreFS.maybeAddImagePath(launcher.getLocalResources(), imageURI);

    CommandLineBuilder cli = new CommandLineBuilder();

    String heap = appComponent.getOption(RoleKeys.JVM_HEAP, DEFAULT_JVM_HEAP);
    if (SliderUtils.isSet(heap)) {
      String adjustedHeap = SliderUtils.translateTrailingHeapUnit(heap);
      launcher.setEnv(HBASE_HEAPSIZE, adjustedHeap);
    }

    String gcOpts = appComponent.getOption(RoleKeys.GC_OPTS, DEFAULT_GC_OPTS);
    if (SliderUtils.isSet(gcOpts)) {
      launcher.setEnv(HBASE_GC_OPTS, gcOpts);
    }

    // this must stay relative if it is an image
    cli.add(providerUtils.buildPathToScript(instanceDefinition, "bin", HBASE_SCRIPT));
    // config dir is relative to the generated file
    cli.add(ARG_CONFIG);
    cli.add("$PROPAGATED_CONFDIR");

    String roleCommand;
    String logfile;
    // now look at the role

    /* JDK7
        switch (role) {
          case ROLE_WORKER:
            //role is region server
            roleCommand = REGION_SERVER;
            logfile = "/region-server.txt";
            break;
          case ROLE_MASTER:
            roleCommand = MASTER;

            logfile = "/master.txt";
            break;
          case ROLE_REST_GATEWAY:
            roleCommand = REST_GATEWAY;

            logfile = "/rest-gateway.txt";
            break;
          case ROLE_THRIFT_GATEWAY:
            roleCommand = THRIFT_GATEWAY;

            logfile = "/thrift-gateway.txt";
            break;
          case ROLE_THRIFT2_GATEWAY:
            roleCommand = THRIFT2_GATEWAY;

            logfile = "/thrift2-gateway.txt";
            break;
          default:
            throw new SliderInternalStateException("Cannot start role %s", role);
        }

    */
    if (ROLE_WORKER.equals(role)) {
      // role is region server
      roleCommand = REGION_SERVER;
      logfile = "/region-server.txt";

    } else if (ROLE_MASTER.equals(role)) {
      roleCommand = MASTER;
      logfile = "/master.txt";

    } else if (ROLE_REST_GATEWAY.equals(role)) {
      roleCommand = REST_GATEWAY;
      logfile = "/rest-gateway.txt";

    } else if (ROLE_THRIFT_GATEWAY.equals(role)) {
      roleCommand = THRIFT_GATEWAY;
      logfile = "/thrift-gateway.txt";

    } else if (ROLE_THRIFT2_GATEWAY.equals(role)) {
      roleCommand = THRIFT2_GATEWAY;
      logfile = "/thrift2-gateway.txt";
    } else {
      throw new SliderInternalStateException("Cannot start role %s", role);
    }

    cli.add(roleCommand);
    cli.add(ACTION_START);
    // log details
    cli.addOutAndErrFiles(logfile, null);
    launcher.addCommand(cli.build());
  }