Logo Search packages:      
Sourcecode: henplus version File versions  Download package

int henplus::commands::DumpCommand::retryReadDump ( String  fileName,
SQLSession  session,
int  commitPoint 
) [inline, private]

reads a dump and does a retry if the file encoding does not match.

Definition at line 275 of file DumpCommand.java.

References henplus::Command::EXEC_FAILED, skipWhite(), and henplus::Command::SUCCESS.

Referenced by execute().

                                                                                    {
        LineNumberReader in = null;
        boolean hot = (session != null);
        try {
            SigIntHandler.getInstance().pushInterruptable(this);
            String fileEncoding = FILE_ENCODING;
            boolean retryPossible = true;
            do {
                try {
                    in = openInputReader(fileName, fileEncoding);
                    while (skipWhite(in)) {
                        int result = readTableDump(in, fileEncoding,
                                                   session, hot, commitPoint);
                        retryPossible = false;
                        if (!_running) {
                            HenPlus.msg().print("interrupted.");
                            return result;
                        }
                        if (result != SUCCESS) {
                            return result;
                        }
                    }
                }
                catch (EncodingMismatchException e) {
                    // did we already retry with another encoding?
                    if (!fileEncoding.equals(FILE_ENCODING)) {
                        throw new Exception("got file encoding problem twice");
                    }
                    fileEncoding = e.getEncoding();
                    HenPlus.msg().println("got a different encoding; retry with " + fileEncoding);
                }
            }
            while (retryPossible);
            return SUCCESS;
        }
        catch (Exception e) {
            HenPlus.msg().println("failed: " + e.getMessage());
            return EXEC_FAILED;
        }
        finally {
            try { 
                if (in != null) in.close(); 
            } 
            catch (IOException e) {
                HenPlus.msg().println("closing file failed.");
            }
        }
    }


Generated by  Doxygen 1.6.0   Back to index