AbstractProviderService implements ProviderService,
    YarnServiceConstants { public void buildContainerLaunchCommand(AbstractLauncher launcher, Service service, ComponentInstance instance, SliderFileSystem fileSystem, Configuration yarnConf, Container container, ContainerLaunchService.ComponentLaunchContext compLaunchContext, Map<String, String> tokensForSubstitution) throws IOException, SliderException { String launchCommand = compLaunchContext.getLaunchCommand(); if (!StringUtils.isEmpty(launchCommand)) { launchCommand = ProviderUtils .substituteStrWithTokens(launchCommand, tokensForSubstitution); CommandLineBuilder operation = new CommandLineBuilder(); operation.add(launchCommand); operation.addOutAndErrFiles(OUT_FILE, ERR_FILE); launcher.addCommand(operation.build()); } }  abstract void processArtifact(AbstractLauncher launcher,
      ComponentInstance compInstance, SliderFileSystem fileSystem,
      Service service,
      ContainerLaunchService.ComponentLaunchContext compLaunchCtx); Map<String, String> buildContainerTokens(ComponentInstance instance,
      Container container,
      ContainerLaunchService.ComponentLaunchContext compLaunchContext); void buildContainerEnvironment(AbstractLauncher launcher,
      Service service, ComponentInstance instance,
      SliderFileSystem fileSystem, Configuration yarnConf, Container container,
      ContainerLaunchService.ComponentLaunchContext compLaunchContext,
      Map<String, String> tokensForSubstitution); void buildContainerLaunchCommand(AbstractLauncher launcher,
      Service service, ComponentInstance instance,
      SliderFileSystem fileSystem, Configuration yarnConf, Container container,
      ContainerLaunchService.ComponentLaunchContext compLaunchContext,
      Map<String, String> tokensForSubstitution); void buildContainerRetry(AbstractLauncher launcher,
      Configuration yarnConf,
      ContainerLaunchService.ComponentLaunchContext compLaunchContext,
      ComponentInstance instance); ResolvedLaunchParams buildContainerLaunchContext(
      AbstractLauncher launcher,
      Service service, ComponentInstance instance,
      SliderFileSystem fileSystem, Configuration yarnConf, Container container,
      ContainerLaunchService.ComponentLaunchContext compLaunchContext);  }
@Test public void testBuildContainerLaunchCommand() throws Exception { AbstractProviderService providerService = new DockerProviderService(); Component component = serviceContext.scheduler.getAllComponents().entrySet() .iterator().next().getValue(); ContainerLaunchService.ComponentLaunchContext clc = createEntryPointCLCFor(testService, component, "sleep,9000"); ComponentInstance instance = component.getAllComponentInstances().iterator() .next(); Container container = mock(Container.class); providerService.buildContainerLaunchCommand(launcher, testService, instance, rule.getFs(), serviceContext.scheduler.getConfig(), container, clc, null); Assert.assertEquals("commands", Lists.newArrayList(clc.getLaunchCommand()), launcher.getCommands()); }
@Test public void testBuildContainerLaunchCommandWithSpace() throws Exception { AbstractProviderService providerService = new DockerProviderService(); Component component = serviceContext.scheduler.getAllComponents().entrySet() .iterator().next().getValue(); ContainerLaunchService.ComponentLaunchContext clc = createEntryPointCLCFor(testService, component, "ls -l \" space\""); ComponentInstance instance = component.getAllComponentInstances().iterator() .next(); Container container = mock(Container.class); providerService.buildContainerLaunchCommand(launcher, testService, instance, rule.getFs(), serviceContext.scheduler.getConfig(), container, clc, null); Assert.assertEquals("commands don't match.", Lists.newArrayList("ls,-l, space"), launcher.getCommands()); }