Spring for Apache Hadoop

org.springframework.yarn.test.support
Class ContainerLogUtils

java.lang.Object
  extended by org.springframework.yarn.test.support.ContainerLogUtils

public abstract class ContainerLogUtils
extends java.lang.Object

Utilities for checking container logs.

Author:
Janne Valkealahti

Constructor Summary
ContainerLogUtils()
           
 
Method Summary
static java.lang.String getFileContent(java.io.File file)
          Reads a file content and return it as String.
static java.util.List<org.springframework.core.io.Resource> queryContainerLogs(YarnCluster yarnCluster, org.apache.hadoop.yarn.api.records.ApplicationId applicationId)
          Find container logs for running cluster and application.
static java.util.List<org.springframework.core.io.Resource> queryContainerLogs(YarnCluster yarnCluster, org.apache.hadoop.yarn.api.records.ApplicationId applicationId, java.lang.String fileName)
          Find container logs for running cluster and application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContainerLogUtils

public ContainerLogUtils()
Method Detail

queryContainerLogs

public static java.util.List<org.springframework.core.io.Resource> queryContainerLogs(YarnCluster yarnCluster,
                                                                                      org.apache.hadoop.yarn.api.records.ApplicationId applicationId,
                                                                                      java.lang.String fileName)
                                                                               throws java.io.IOException
Find container logs for running cluster and application.

Created pattern which is used with PathMatchingResourcePatternResolver is resolved from YarnCluster, ApplicationId and fileName. For example if fileName is given as *.std*, pattern will look like file:/path/to/project/target/yarn--1502101888/*logDir*/application_1382082435804_0001/**/*.std*

Parameters:
yarnCluster - the yarn cluster
applicationId - the application id
fileName - the part of a file name
Returns:
the list of log file Resources
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

queryContainerLogs

public static java.util.List<org.springframework.core.io.Resource> queryContainerLogs(YarnCluster yarnCluster,
                                                                                      org.apache.hadoop.yarn.api.records.ApplicationId applicationId)
                                                                               throws java.io.IOException
Find container logs for running cluster and application. fileName will be *.

Parameters:
yarnCluster - the yarn cluster
applicationId - the application id
Returns:
the list of log file Resources
Throws:
java.io.IOException - Signals that an I/O exception has occurred.
See Also:
queryContainerLogs(YarnCluster, ApplicationId, String)

getFileContent

public static java.lang.String getFileContent(java.io.File file)
                                       throws java.lang.Exception
Reads a file content and return it as String. Returns NULL if file doesn't exist and empty String if file exists but is empty.

Parameters:
file - the file
Returns:
the file content
Throws:
java.lang.Exception - the exception if error occurred

Spring for Apache Hadoop