By the time run() gets executed, main() has already started shutdown. Can you perform some action in main() - now it's empty.
On Tue, Mar 9, 2010 at 9:39 PM, Silllllence <[email protected]> wrote: > > Hi fellows > Below code segment add a shutdown hook to JVM, but when I got a strange > exception, > java.lang.IllegalStateException: Shutdown in progress > at > java.lang.ApplicationShutdownHooks.add(ApplicationShutdownHooks.java:39) > at java.lang.Runtime.addShutdownHook(Runtime.java:192) > at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1387) > at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:191) > at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:95) > at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:180) > at org.apache.hadoop.fs.Path.getFileSystem(Path.java:175) > at young.Main$1.run(Main.java:21) > Java doc said this exception is threw when the virtual machine is already > in > the process of shutting down, (http://java.sun.com/j2se/1.5.0/docs/api/), > what does this mean? Why this happen? How to fix ? > I'm really appreciate if you can try this code, and help me to figure out > what's going on here, thank you ! > > --------------------------------------------------------------------------------------- > import org.apache.hadoop.conf.Configuration; > import org.apache.hadoop.fs.FileSystem; > import org.apache.hadoop.fs.Path; > import org.apache.hadoop.mapred.JobConf; > > @SuppressWarnings("deprecation") > public class Main { > > public static void main(String[] args) { > Runtime.getRuntime().addShutdownHook(new Thread() { > @Override > public void run() { > Path path = new Path("/temp/hadoop-young"); > System.out.println("Thread run : " + path); > Configuration conf = new JobConf(); > FileSystem fs; > try { > fs = path.getFileSystem(conf); > if(fs.exists(path)){ > fs.delete(path); > } > } catch (Exception e) { > System.err.println(e.getMessage()); > e.printStackTrace(); > } > }; > }); > } > } > -- > View this message in context: > http://old.nabble.com/%28Strange%21%29getFileSystem-in-JVM-shutdown-hook-throws-shutdown-in-progress-exception-tp27845803p27845803.html > Sent from the Hadoop core-user mailing list archive at Nabble.com. > >
