ServiceApiUtil { public static void checkServiceDependencySatisified(Service service) { while (!serviceDependencySatisfied(service)) { try { LOG.info("Waiting for service dependencies."); Thread.sleep(15000L); } catch (InterruptedException e) { } } } static  String(String s); @VisibleForTesting static void setJsonSerDeser(JsonSerDeser jsd); @VisibleForTesting static void validateAndResolveService(Service service,
      SliderFileSystem fs, org.apache.hadoop.conf.Configuration conf); static void validateJvmOpts(String jvmOpts); static void validateKerberosPrincipal(
      KerberosPrincipal kerberosPrincipal); static void validateNameFormat(String name,
      org.apache.hadoop.conf.Configuration conf); @VisibleForTesting static List<Component> getComponents(SliderFileSystem
      fs, String serviceName); static Service loadService(SliderFileSystem fs, String
      serviceName); static Service loadServiceUpgrade(SliderFileSystem fs,
      String serviceName, String version); static Service loadServiceFrom(SliderFileSystem fs,
      Path appDefPath); static Path getServiceJsonPath(SliderFileSystem fs, String serviceName); static void validateCompResourceSize(
      org.apache.hadoop.yarn.api.records.Resource maxResource,
      Service service); static Collection<Component> sortByDependencies(List<Component>
      components); static void createDirAndPersistApp(SliderFileSystem fs, Path appDir,
      Service service); static Path writeAppDefinition(SliderFileSystem fs, Path appDir,
      Service service); static Path writeAppDefinition(SliderFileSystem fs, Service service); static List<Container> getLiveContainers(Service service,
      List<String> componentInstances); static void validateInstancesUpgrade(List<Container>
      liveContainers); static boolean isUpgradable(Container container); static List<Container> validateAndResolveCompsUpgrade(
      Service liveService, Collection<String> compNames); static List<Container> validateAndResolveCompsStable(
      Service liveService, Collection<String> compNames); static String getHostnameSuffix(String serviceName, org.apache
      .hadoop.conf.Configuration conf); static String parseAndValidateComponentInstanceName(String
      instanceOrHostname, String serviceName, org.apache.hadoop.conf
      .Configuration conf); static String parseComponentName(String componentInstanceName); static List<String> resolveCompsDependency(Service service); static void checkServiceDependencySatisified(Service service); static JsonSerDeser<Service> jsonSerDeser; static final JsonSerDeser<Container[]> CONTAINER_JSON_SERDE; static final JsonSerDeser<ComponentContainers[]> COMP_CONTAINERS_JSON_SERDE; static final JsonSerDeser<Component[]> COMP_JSON_SERDE; }
@Test(timeout = 1500) public void testNoServiceDependencies() { Service service = createExampleApplication(); Component compa = createComponent("compa"); Component compb = createComponent("compb"); service.addComponent(compa); service.addComponent(compb); List<String> dependencies = new ArrayList<String>(); service.setDependencies(dependencies); ServiceApiUtil.checkServiceDependencySatisified(service); }
@Test public void testServiceDependencies() { Thread thread = new Thread() { @Override public void run() { Service service = createExampleApplication(); Component compa = createComponent("compa"); Component compb = createComponent("compb"); service.addComponent(compa); service.addComponent(compb); List<String> dependencies = new ArrayList<String>(); dependencies.add("abc"); service.setDependencies(dependencies); Service dependent = createExampleApplication(); dependent.setState(ServiceState.STOPPED); ServiceApiUtil.checkServiceDependencySatisified(service); } }; thread.start(); try { Thread.sleep(1000); } catch (InterruptedException e) { } Assert.assertTrue(thread.isAlive()); }