SliderUtils { public static String extractFirstLine(String msg) { if (StringUtils.isNotBlank(msg)) { int newlineIndex = msg.indexOf(System.lineSeparator()); if (newlineIndex != -1) { msg = msg.substring(0, newlineIndex); } } return msg; } private  SliderUtils(); static boolean isUnset(String s); static boolean isSet(String s); static boolean isNotEmpty(List l); static boolean isNotEmpty(Map m); static String translateTrailingHeapUnit(String heapsize); static void deleteDirectoryTree(File dir); static File findContainingJarOrFail(Class clazz); static File findContainingJar(Class my_class); static void checkPort(String hostname, int port, int connectTimeout); @SuppressWarnings("SocketOpenedButNotSafelyClosed") static void checkPort(String name,
      InetSocketAddress address,
      int connectTimeout); static void checkURL(String name, String url, int timeout); static File requiredFile(String filename, String role); static boolean isClusternameValid(String name); static boolean oldIsClusternameValid(String name); static int copyDirectory(Configuration conf,
      Path srcDirPath,
      Path destDirPath,
      FsPermission permission); static void copy(Configuration conf,
      Path srcFile,
      Path destFile); static String stringify(Throwable t); static String extractFirstLine(String msg); static YarnConfiguration createConfiguration(); static Configuration patchConfiguration(Configuration conf); static List<String> collectionToStringList(Collection c); static String join(Collection collection, String separator); static String join(Collection collection,
      String separator,
      boolean trailing); static String join(String[] collection, String separator); static String join(String[] collection, String separator,
      boolean trailing); static String joinWithInnerSeparator(String separator,
      Object... collection); static String mandatoryEnvVariable(String key); static String appReportToString(ApplicationReport r,
      String separator); static String instanceDetailsToString(String name,
      ApplicationReport report,
      List<ContainerInformation> containers,
      String version,
      Set<String> components,
      boolean verbose); static String containersToString(
      List<ContainerInformation> containers, String version,
      Set<String> components); static boolean filter(String value, String filter); static boolean filter(String value, Set<String> filters); static void sortApplicationsByMostRecent(List<ApplicationReport> instances); static void sortApplicationReport(List<ApplicationReport> instances); static Map<String, ApplicationReport> buildApplicationReportMap(
      List<ApplicationReport> instances,
      YarnApplicationState minState, YarnApplicationState maxState); static Map<String, String> sortedMap(Map<String, String> source); static Map<String, String> toMap(Properties properties); static Map<String, String> mergeMap(Map<String, String> first,
      Map<String, String> second); static Map<String, String> mergeEntries(Map<String, String> dest,
      Iterable<Map.Entry<String, String>> entries); static Map<T1, T2> mergeMaps(Map<T1, T2> first,
      Map<T1, T2> second); static Map<T1, T2> mergeMapsIgnoreDuplicateKeys(Map<T1, T2> first,
      Map<T1, T2> second); static Map<String, String> mergeMapsIgnoreDuplicateKeysAndPrefixes(
      Map<String, String> first, Map<String, String> second,
      String... prefixes); static String stringifyMap(Map<String, String> map); static int getIntValue(Map<String, String> roleMap,
      String key,
      int defVal,
      int min,
      int max
  ); static int parseAndValidate(String errorKey,
      String valS,
      int defVal,
      int min, int max); static InetSocketAddress getRmAddress(Configuration conf); static InetSocketAddress getRmSchedulerAddress(Configuration conf); static boolean isRmSchedulerAddressDefined(Configuration conf); static boolean isAddressDefined(InetSocketAddress address); static void setRmAddress(Configuration conf, String rmAddr); static void setRmSchedulerAddress(Configuration conf, String rmAddr); static boolean hasAppFinished(ApplicationReport report); static String containerToString(Container container); static String reportToString(ApplicationReport report); static String stringify(org.apache.hadoop.yarn.api.records.URL url); static int findFreePort(int start, int limit); static int getOpenPort(); static boolean isPortAvailable(int port); static Map<String, String> buildEnvMap(Map<String, String> roleOpts); static Map<String, String> buildEnvMap(Map<String, String> roleOpts,
      Map<String,String> tokenMap); static void applyCommandLineRoleOptsToRoleMap(
      Map<String, Map<String, String>> clusterRoleMap,
      Map<String, Map<String, String>> commandOptions); static void validateClusterName(String clustername); static void verifyPrincipalSet(Configuration conf,
      String principal); static boolean isHadoopClusterSecure(Configuration conf); static boolean maybeInitSecurity(Configuration conf); static boolean initProcessSecurity(Configuration conf); static void forceLogin(); static LocalResource putJar(Map<String, LocalResource> providerResources,
      SliderFileSystem sliderFileSystem,
      Class clazz,
      Path tempPath,
      String libdir,
      String jarName
  ); static void putAllJars(Map<String, LocalResource> providerResources,
                                SliderFileSystem sliderFileSystem,
                                Path tempPath,
                                String libDir,
                                String srcPath); static FilenameFilter createJarFilter(); static void putAmTarGzipAndUpdate(
      Map<String, LocalResource> providerResources,
      SliderFileSystem sliderFileSystem
  ); static Map<String, Map<String, String>> deepClone(Map<String, Map<String, String>> src); static Map<String, String> stringMapClone(Map<String, String> src); static String listDir(File dir); static Path createLocalPath(File file); static UserGroupInformation getCurrentUser(); static String getKerberosRealm(); static URL registerClientResource(); static Configuration loadSliderClientXML(); static String sequenceToString(CharSequence charSequence); static ClasspathConstructor buildClasspath(String sliderConfDir,
      String libdir,
      Configuration config,
      SliderFileSystem sliderFileSystem,
      boolean usingMiniMRCluster); static final String JAVA_SECURITY_KRB5_REALM; static final String JAVA_SECURITY_KRB5_KDC; static final String WINUTILS; static final String OPENSSL; static final String PYTHON; static final String DOCKER; static final String DOCKER_YARN; static final int NODE_LIST_LIMIT; }
@Test public void testExtractFirstLine() { String firstLine = "hello"; String msg = firstLine + "\n2nd line\n3rd line"; Assert.assertEquals("Should be first line only", firstLine, SliderUtils.extractFirstLine(msg)); msg = ""; Assert.assertEquals("Should be empty", msg, SliderUtils.extractFirstLine(msg)); msg = " "; Assert.assertEquals("Should contain spaces only", msg, SliderUtils.extractFirstLine(msg)); msg = null; Assert.assertEquals("Should be null", msg, SliderUtils.extractFirstLine(msg)); }