0

I need to copy the files which are generated within Grails to Hadoop dynamically. How will I write code for this in Grails? Whenever a file is generated it should be copied into Hadoop. If the incoming file already exists, it should get updated in Hadoop.

4

1 回答 1

0

I used shell script to connect grails and hadoop.

I had all the commands to run hadoop jobs in myjob.sh (Workflow Script)

And i added the code to execute shell script in my controller

def scriptCom="/folderlocation/shellscript.sh"

println "[[Running $scriptCom]]"
def proc = scriptCom.execute()

def oneMinute = 60000
proc.waitForOrKill(oneMinute)

if(proc.exitValue()!=0){
    println "[[return code: ${proc.exitValue()}]]"
    println "[[stderr: ${proc.err.text}]]"
    return null
}else{
    println "[[stdout:$revisionid]]"
    return proc.in.text.readLines()
}
于 2013-05-10T06:36:37.863 回答