/** * Initialize the recover test. * * @param recoverTest the value of the recover test parameter */ public static synchronized void init(String recoverTest) { RecoverTester tester = RecoverTester.getInstance(); if (StringUtils.isNumber(recoverTest)) { tester.setTestEvery(Integer.parseInt(recoverTest)); } FilePathRec.setRecorder(tester); }
/** * Log the operation. * * @param op the operation * @param fileName the file name(s) */ void log(int op, String fileName) { log(op, fileName, null, 0); }
/** * Create a connection info object. * * @param u the database URL (must start with jdbc:h2:) * @param info the connection properties */ public ConnectionInfo(String u, Properties info) { u = remapURL(u); this.originalURL = u; if (!u.startsWith(Constants.START_URL)) { throw DbException.getInvalidValueException("url", u); } this.url = u; readProperties(info); readSettingsFromURL(); setUserName(removeProperty("USER", "")); convertPasswords(); name = url.substring(Constants.START_URL.length()); parseName(); String recoverTest = removeProperty("RECOVER_TEST", null); if (recoverTest != null) { FilePathRec.register(); try { Utils.callStaticMethod("org.h2.store.RecoverTester.init", recoverTest); } catch (Exception e) { throw DbException.convert(e); } name = "rec:" + name; } }
@Override public FileChannel truncate(long newLength) throws IOException { rec.log(Recorder.TRUNCATE, name, null, newLength); channel.truncate(newLength); return this; }
/** * Create a connection info object. * * @param u the database URL (must start with jdbc:h2:) * @param info the connection properties */ public ConnectionInfo(String u, Properties info) { u = remapURL(u); this.originalURL = u; if (!u.startsWith(Constants.START_URL)) { throw DbException.getInvalidValueException("url", u); } this.url = u; readProperties(info); readSettingsFromURL(); setUserName(removeProperty("USER", "")); convertPasswords(); name = url.substring(Constants.START_URL.length()); parseName(); String recoverTest = removeProperty("RECOVER_TEST", null); if (recoverTest != null) { FilePathRec.register(); try { Utils.callStaticMethod("org.h2.store.RecoverTester.init", recoverTest); } catch (Exception e) { throw DbException.convert(e); } name = "rec:" + name; } }
@Override public int write(ByteBuffer src, long position) throws IOException { byte[] buff = src.array(); int len = src.remaining(); if (src.position() != 0 || len != buff.length) { int offset = src.arrayOffset() + src.position(); buff = Arrays.copyOfRange(buff, offset, offset + len); } int result = channel.write(src, position); rec.log(Recorder.WRITE, name, buff, position); return result; }
/** * Initialize the recover test. * * @param recoverTest the value of the recover test parameter */ public static synchronized void init(String recoverTest) { RecoverTester tester = RecoverTester.getInstance(); if (StringUtils.isNumber(recoverTest)) { tester.setTestEvery(Integer.parseInt(recoverTest)); } FilePathRec.setRecorder(tester); }
/** * Create a connection info object. * * @param u the database URL (must start with jdbc:h2:) * @param info the connection properties */ public ConnectionInfo(String u, Properties info) { u = remapURL(u); this.originalURL = u; if (!u.startsWith(Constants.START_URL)) { throw DbException.getInvalidValueException("url", u); } this.url = u; readProperties(info); readSettingsFromURL(); setUserName(removeProperty("USER", "")); convertPasswords(); name = url.substring(Constants.START_URL.length()); parseName(); String recoverTest = removeProperty("RECOVER_TEST", null); if (recoverTest != null) { FilePathRec.register(); try { Utils.callStaticMethod("org.h2.store.RecoverTester.init", recoverTest); } catch (Exception e) { throw DbException.convert(e); } name = "rec:" + name; } }
@Override public int write(ByteBuffer src) throws IOException { byte[] buff = src.array(); int len = src.remaining(); if (src.position() != 0 || len != buff.length) { int offset = src.arrayOffset() + src.position(); buff = Arrays.copyOfRange(buff, offset, offset + len); } int result = channel.write(src); rec.log(Recorder.WRITE, name, buff, channel.position()); return result; }
/** * Initialize the recover test. * * @param recoverTest the value of the recover test parameter */ public static synchronized void init(String recoverTest) { RecoverTester tester = RecoverTester.getInstance(); if (StringUtils.isNumber(recoverTest)) { tester.setTestEvery(Integer.parseInt(recoverTest)); } FilePathRec.setRecorder(tester); }
@Override public OutputStream newOutputStream(boolean append) throws IOException { log(Recorder.OPEN_OUTPUT_STREAM, name); return super.newOutputStream(append); }
@Override public boolean createFile() { log(Recorder.CREATE_NEW_FILE, name); return super.createFile(); }
@Override public void delete() { log(Recorder.DELETE, name); super.delete(); }
/** * Log the operation. * * @param op the operation * @param fileName the file name(s) */ void log(int op, String fileName) { log(op, fileName, null, 0); }