本文整理汇总了Java中jetbrains.exodus.env.Transaction.flush方法的典型用法代码示例。如果您正苦于以下问题:Java Transaction.flush方法的具体用法?Java Transaction.flush怎么用?Java Transaction.flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jetbrains.exodus.env.Transaction
的用法示例。
在下文中一共展示了Transaction.flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRenameFile
import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void testRenameFile() throws InterruptedException {
testFileCreation();
final Transaction txn = env.beginTransaction();
File file0 = vfs.openFile(txn, "file0", false);
txn.revert();
Assert.assertNotNull(file0);
final long fd = file0.getDescriptor();
final long created = file0.getCreated();
final long lastModified = file0.getLastModified();
Thread.sleep(50);
vfs.renameFile(txn, file0, "file1");
txn.flush();
file0 = vfs.openFile(txn, "file0", false);
File file1 = vfs.openFile(txn, "file1", false);
txn.abort();
Assert.assertNull(file0);
Assert.assertNotNull(file1);
Assert.assertEquals(fd, file1.getDescriptor());
Assert.assertEquals(created, file1.getCreated());
Assert.assertTrue(file1.getLastModified() > lastModified);
}
示例2: testDeleteFile4
import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void testDeleteFile4() throws IOException {
final Transaction txn = env.beginTransaction();
for (int i = 0; i < 50; ++i) {
final File file0 = vfs.createFile(txn, "file0");
final OutputStream outputStream = vfs.writeFile(txn, file0);
for (int j = 0; j < i; ++j) {
outputStream.write(new byte[vfs.getConfig().getClusteringStrategy().getFirstClusterSize()]);
}
outputStream.write("vain bytes to be deleted".getBytes());
for (int j = 0; j < i + 1; ++j) {
outputStream.write(new byte[vfs.getConfig().getClusteringStrategy().getFirstClusterSize()]);
}
outputStream.close();
txn.flush();
Assert.assertNotNull(vfs.deleteFile(txn, "file0"));
txn.flush();
}
Assert.assertEquals(0L, vfs.getContents().count(txn));
txn.commit();
}
示例3: testTouchFile
import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void testTouchFile() throws InterruptedException {
final Transaction txn = env.beginTransaction();
vfs.createFile(txn, "file0");
txn.flush();
File file0 = vfs.openFile(txn, "file0", false);
Assert.assertNotNull(file0);
Assert.assertEquals(file0.getCreated(), file0.getLastModified());
Thread.sleep(100);
vfs.touchFile(txn, file0);
txn.flush();
file0 = vfs.openFile(txn, "file0", false);
Assert.assertNotNull(file0);
Assert.assertTrue(file0.getCreated() + 50 < file0.getLastModified());
txn.commit();
}
示例4: writeRandomAccessRead
import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void writeRandomAccessRead() throws IOException {
final Transaction txn = env.beginTransaction();
final File file0 = vfs.createFile(txn, "file0");
final OutputStream outputStream = vfs.appendFile(txn, file0);
outputStream.write((HOEGAARDEN + HOEGAARDEN + HOEGAARDEN + HOEGAARDEN).getBytes(UTF_8));
outputStream.close();
txn.flush();
InputStream inputStream = vfs.readFile(txn, file0, 0);
Assert.assertEquals(HOEGAARDEN + HOEGAARDEN + HOEGAARDEN + HOEGAARDEN, streamAsString(inputStream));
inputStream.close();
inputStream = vfs.readFile(txn, file0, 10);
Assert.assertEquals(HOEGAARDEN + HOEGAARDEN + HOEGAARDEN, streamAsString(inputStream));
inputStream.close();
inputStream = vfs.readFile(txn, file0, 20);
Assert.assertEquals(HOEGAARDEN + HOEGAARDEN, streamAsString(inputStream));
inputStream.close();
inputStream = vfs.readFile(txn, file0, 30);
Assert.assertEquals(HOEGAARDEN, streamAsString(inputStream));
inputStream.close();
txn.abort();
}
示例5: writeOverwriteRead
import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void writeOverwriteRead() throws IOException {
final Transaction txn = env.beginTransaction();
final File file0 = vfs.createFile(txn, "file0");
OutputStream outputStream = vfs.appendFile(txn, file0);
outputStream.write(HOEGAARDEN.getBytes(UTF_8));
outputStream.close();
txn.flush();
outputStream = vfs.writeFile(txn, file0);
outputStream.write("x".getBytes(UTF_8));
outputStream.close();
txn.flush();
final InputStream inputStream = vfs.readFile(txn, file0);
Assert.assertEquals('x' + HOEGAARDEN.substring(1), streamAsString(inputStream));
inputStream.close();
txn.abort();
}
示例6: writeOverwriteRead2
import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void writeOverwriteRead2() throws IOException {
final Transaction txn = env.beginTransaction();
final File file0 = vfs.createFile(txn, "file0");
OutputStream outputStream = vfs.appendFile(txn, file0);
outputStream.write((HOEGAARDEN + HOEGAARDEN + HOEGAARDEN + HOEGAARDEN).getBytes(UTF_8));
outputStream.close();
txn.flush();
outputStream = vfs.writeFile(txn, file0);
outputStream.write("x".getBytes(UTF_8));
outputStream.write(HOEGAARDEN.substring(1).getBytes(UTF_8));
outputStream.write("x".getBytes(UTF_8));
outputStream.write(HOEGAARDEN.substring(1).getBytes(UTF_8));
outputStream.write("x".getBytes(UTF_8));
outputStream.write(HOEGAARDEN.substring(1).getBytes(UTF_8));
outputStream.write("x".getBytes(UTF_8));
outputStream.write(HOEGAARDEN.substring(1).getBytes(UTF_8));
outputStream.close();
txn.flush();
final InputStream inputStream = vfs.readFile(txn, file0);
Assert.assertEquals('x' + HOEGAARDEN.substring(1) +
'x' + HOEGAARDEN.substring(1) + 'x' + HOEGAARDEN.substring(1) +
'x' + HOEGAARDEN.substring(1), streamAsString(inputStream));
inputStream.close();
txn.abort();
}
示例7: writeRandomAccessOverwriteRead2
import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void writeRandomAccessOverwriteRead2() throws IOException {
final Transaction txn = env.beginTransaction();
final File file0 = vfs.createFile(txn, "file0");
OutputStream outputStream = vfs.appendFile(txn, file0);
outputStream.write((HOEGAARDEN + HOEGAARDEN + HOEGAARDEN + HOEGAARDEN).getBytes(UTF_8));
outputStream.close();
txn.flush();
outputStream = vfs.writeFile(txn, file0, 1000000);
outputStream.write("x".getBytes(UTF_8));
outputStream.close();
txn.flush();
final InputStream inputStream = vfs.readFile(txn, file0);
Assert.assertEquals(HOEGAARDEN + HOEGAARDEN + HOEGAARDEN + HOEGAARDEN + 'x', streamAsString(inputStream));
inputStream.close();
txn.abort();
}
示例8: testTimeFieldsOfFiles
import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void testTimeFieldsOfFiles() throws IOException, InterruptedException {
final long start = System.currentTimeMillis();
Thread.sleep(20);
final Transaction txn = env.beginTransaction();
File file0 = vfs.createFile(txn, "file0");
txn.flush();
Thread.sleep(20);
final OutputStream outputStream = vfs.appendFile(txn, file0);
outputStream.write(RENAT_GILFANOV.getBytes(UTF_8));
outputStream.close();
txn.flush();
file0 = vfs.openFile(txn, "file0", false);
Assert.assertNotNull(file0);
Assert.assertTrue(file0.getCreated() > start);
Assert.assertTrue(file0.getCreated() < file0.getLastModified());
txn.abort();
}
示例9: testFileLength
import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void testFileLength() throws IOException {
final Transaction txn = env.beginTransaction();
vfs.createFile(txn, "file0");
txn.flush();
for (int i = 0; i < 300; ++i) {
final File file0 = vfs.openFile(txn, "file0", false);
Assert.assertNotNull(file0);
Assert.assertEquals((long) i, vfs.getFileLength(txn, file0));
final OutputStream outputStream = vfs.appendFile(txn, file0);
outputStream.write(i);
outputStream.close();
txn.flush();
}
txn.abort();
}
示例10: testWriteAndSeek2
import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
@TestFor(issues = "XD-624")
public void testWriteAndSeek2() throws IOException {
Transaction txn = env.beginTransaction();
vfs.getConfig().setClusteringStrategy(new ClusteringStrategy.LinearClusteringStrategy(8));
final File file = vfs.createFile(txn, "file0");
OutputStream outputStream = vfs.writeFile(txn, file);
final byte[] bytes = HOEGAARDEN.getBytes(UTF_8);
outputStream.write(bytes);
outputStream.close();
outputStream = vfs.writeFile(txn, file, bytes.length);
outputStream.write(bytes);
outputStream.close();
txn.flush();
final InputStream inputStream = vfs.readFile(txn, file);
Assert.assertEquals(HOEGAARDEN + HOEGAARDEN, streamAsString(inputStream));
txn.abort();
}
示例11: testWriteAndSeek3
import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
@TestFor(issues = "XD-624")
public void testWriteAndSeek3() throws IOException {
Transaction txn = env.beginTransaction();
vfs.getConfig().setClusteringStrategy(new ClusteringStrategy.LinearClusteringStrategy(8));
final File file = vfs.createFile(txn, "file0");
OutputStream outputStream = vfs.writeFile(txn, file);
final byte[] bytes = HOEGAARDEN.getBytes(UTF_8);
outputStream.write(bytes);
outputStream.close();
outputStream = vfs.appendFile(txn, file);
outputStream.write(bytes);
outputStream.close();
txn.flush();
final InputStream inputStream = vfs.readFile(txn, file);
Assert.assertEquals(HOEGAARDEN + HOEGAARDEN, streamAsString(inputStream));
txn.abort();
}
示例12: testDeleteFile2
import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void testDeleteFile2() {
Transaction txn = env.beginTransaction();
vfs.createFile(txn, "file0");
txn.flush();
vfs.deleteFile(txn, "file0");
txn.flush();
Assert.assertNull(vfs.openFile(txn, "file0", false));
final File file0 = vfs.openFile(txn, "file0", true);
txn.commit();
Assert.assertNotNull(file0);
Assert.assertEquals("file0", file0.getPath());
}
示例13: testDeleteFile3
import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void testDeleteFile3() throws IOException {
final Transaction txn = env.beginTransaction();
for (int i = 0; i < 10; ++i) {
final File file0 = vfs.createFile(txn, "file0");
final OutputStream outputStream = vfs.writeFile(txn, file0);
outputStream.write("vain bytes to be deleted".getBytes());
outputStream.close();
txn.flush();
Assert.assertNotNull(vfs.deleteFile(txn, "file0"));
txn.flush();
}
Assert.assertEquals(0L, vfs.getContents().count(txn));
txn.commit();
}
示例14: writeRead
import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void writeRead() throws IOException {
final Transaction txn = env.beginTransaction();
final File file0 = vfs.createFile(txn, "file0");
final OutputStream outputStream = vfs.appendFile(txn, file0);
outputStream.write(HOEGAARDEN.getBytes(UTF_8));
outputStream.close();
txn.flush();
final InputStream inputStream = vfs.readFile(txn, file0);
Assert.assertEquals(HOEGAARDEN, streamAsString(inputStream));
inputStream.close();
txn.abort();
}
示例15: writeOverwriteAppendRead
import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void writeOverwriteAppendRead() throws IOException {
final Transaction txn = env.beginTransaction();
final File file0 = vfs.createFile(txn, "file0");
OutputStream outputStream = vfs.appendFile(txn, file0);
outputStream.write((HOEGAARDEN + HOEGAARDEN + HOEGAARDEN + HOEGAARDEN).getBytes(UTF_8));
outputStream.close();
txn.flush();
outputStream = vfs.writeFile(txn, file0);
outputStream.write("x".getBytes(UTF_8));
outputStream.write(HOEGAARDEN.substring(1).getBytes(UTF_8));
outputStream.write("x".getBytes(UTF_8));
outputStream.write(HOEGAARDEN.substring(1).getBytes(UTF_8));
outputStream.write("x".getBytes(UTF_8));
outputStream.write(HOEGAARDEN.substring(1).getBytes(UTF_8));
outputStream.write("x".getBytes(UTF_8));
outputStream.write(HOEGAARDEN.substring(1).getBytes(UTF_8));
outputStream.close();
txn.flush();
outputStream = vfs.appendFile(txn, file0);
outputStream.write(HOEGAARDEN.getBytes(UTF_8));
outputStream.close();
txn.flush();
final InputStream inputStream = vfs.readFile(txn, file0);
Assert.assertEquals('x' + HOEGAARDEN.substring(1) +
'x' + HOEGAARDEN.substring(1) + 'x' + HOEGAARDEN.substring(1) +
'x' + HOEGAARDEN.substring(1) + HOEGAARDEN, streamAsString(inputStream));
inputStream.close();
txn.abort();
}