This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Generating .dmp file thro' Java Process Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Generating .dmp file thro Watch "Generating .dmp file thro New topic
Author

Generating .dmp file thro' Java Process

Sreedevi Jagadisha
Greenhorn

Joined: Feb 03, 2010
Posts: 7
I am generating .dmp file of Oracle database using java ProcessBuilder. I pass expdp copmmand and supporting arguments to ProcessBuilder and start the process.
Since database has too many tables, it takes quite a long time to complete file generation.
File gets generated, no problem with that.

Another job I have to do is, I have to keep watching when the file would get complete and later upload it to ftp.
I tried using thread which keeps making note of file size, but the time taken for the file size to change depends upon machine performance, number of tables in database and other factors. I cannot say the tread to sleep for a particular milliseconds of time, because it varies with different conditions.
how would I do this?
Guys please help me with this.
Sreedevi Jagadisha
Greenhorn

Joined: Feb 03, 2010
Posts: 7
Hi Joe, Thanks for the reply.

I have tried the first option suggested by you, but it takes more than a minute to change the file size and time required to change file size is not consistent, as it depends on number of tables in database. The application would get deployed in different client places where few clients could have huge data and few others won't.
In this case I need to design this in such a manner that it works fine in all cases.
But I failed in all attempts I did.

Sreedevi Jagadisha
Greenhorn

Joined: Feb 03, 2010
Posts: 7
Hi Joe,

The second option what you have suggested is implicitly happening. I mean to say that the dump process creates a log file mentioning which all tables it exported and how many rows of each table it has exported. But its file size keep changing and this file size changing is as inconsistent as the file size change of .dmp file. Finally after export completes the log file says tables exported successfully.
I could check for that particular string in that file, but I don't think this would be the right way.
Friends please get me out of this challenge.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8713
    
    6

Sreedevi Jagadisha wrote:it takes more than a minute to change the file size

So take 20 minutes. Take an hour. This isn't an interactive process, right? Nobody is sitting there waiting for the data.

Sreedevi Jagadisha wrote:The second option what you have suggested is implicitly happening.


I don't think so. I suggested having the dump process create a second file specifically to signal the end of the dump, and that the transfer process watch for that file. The file would not have any content. It would only function as a signal (hence my reference to semaphore).


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Sreedevi Jagadisha
Greenhorn

Joined: Feb 03, 2010
Posts: 7
Hi Joe,

I found out a solution. Once process which creates .dmp file starts we would wait untill it creates .dmp file, using process.WaitFor() method.
Later do file upload. The process would be started in one thread so that it becomes asynchronous. But again there is problem. Once the process creates .dmp file completely it has return control to its parent thread which is not happening, because the process creates a subprocess 'expdp.exe' which would be running in the jvm even after its job is complete, I just killed expdp.exe process manually in Task manager and the control returned to parent and file upload was done successfully.
This has held me back from doing other work... I am lagging in my schedule.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8713
    
    6

Sreedevi Jagadisha wrote:
But again there is problem. Once the process creates .dmp file completely it has return control to its parent thread which is not happening, because the process creates a subprocess 'expdp.exe' which would be running in the jvm even after its job is complete,


Are you reading the standard output and standard error streams of the new process? If you don't, the spawned process can lock up because their buffers are full.
Sreedevi Jagadisha
Greenhorn

Joined: Feb 03, 2010
Posts: 7
Hi Joe,

Thank you for your suggestions....
I had done the mistake what you had predicted....
I was not reading standard output and standard error streams of the new process.
But eventually the examples posted in the link,

http://mindprod.com/jgloss/exec.html

helped me to over come my mistake.

Now my problem is completely solved.

Thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generating .dmp file thro' Java Process
 
Similar Threads
restoring databse using jdbc
Dumping MySql database
Oracle imp commands
help using runtime.exec
problem with process builder