Hi there:
I have a small app like below:
import org.apache.hadoop.fs._
import org.apache.hadoop.fs.FileSystem._
import org.apache.hadoop.conf._
object App {
def main(args: Array[String]) {
val path = "/user/root"
val hdfspath = new Path(path)
val recursive = true
val uri = new java.net.URI("hdfs://dserver1:8020")
val conf = new Configuration
val fs = FileSystem.get(uri, conf)
while (true) {
val files = fs.listFiles(hdfspath, recursive)
while (files.hasNext()) {
println(files.next().getPath)
}
Thread.sleep(5000)
}
}
}
And my question is : I’ve got a concern about while looping long enough, will
my app lose the connection to hdfs? If yes, how to reconnect to HDFS in a try
catch code block?
Thank you guys
San.Luo