当前位置: 首页>>代码示例>>Java>>正文


Java Transaction.commit方法代码示例

本文整理汇总了Java中jetbrains.exodus.env.Transaction.commit方法的典型用法代码示例。如果您正苦于以下问题:Java Transaction.commit方法的具体用法?Java Transaction.commit怎么用?Java Transaction.commit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jetbrains.exodus.env.Transaction的用法示例。


在下文中一共展示了Transaction.commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:22,代码来源:VfsFileTests.java

示例2: 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();
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:17,代码来源:VfsFileTests.java

示例3: testWriteReadWithStrategy

import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
private void testWriteReadWithStrategy(@NotNull final ClusteringStrategy strategy) throws IOException {
    vfs.shutdown();
    final VfsConfig config = new VfsConfig();
    config.setClusteringStrategy(strategy);
    vfs = new VirtualFileSystem(getEnvironment(), config);
    final Transaction txn = env.beginTransaction();
    final byte[] bytes = RENAT_GILFANOV.getBytes(UTF_8);
    final File file0 = vfs.createFile(txn, "file0");
    final OutputStream outputStream0 = vfs.appendFile(txn, file0);
    outputStream0.write(bytes);
    outputStream0.close();
    final File file1 = vfs.createFile(txn, "file1");
    final OutputStream outputStream1 = vfs.appendFile(txn, file1);
    outputStream1.write(bytes);
    outputStream1.close();
    final InputStream inputStream0 = vfs.readFile(txn, file0);
    Assert.assertEquals(RENAT_GILFANOV, streamAsString(inputStream0));
    inputStream0.close();
    final InputStream inputStream1 = vfs.readFile(txn, file1);
    Assert.assertEquals(RENAT_GILFANOV, streamAsString(inputStream1));
    inputStream1.close();
    Assert.assertEquals((long) bytes.length, vfs.getFileLength(txn, file0));
    Assert.assertEquals((long) bytes.length, vfs.getFileLength(txn, file1));
    txn.commit();
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:26,代码来源:VfsStreamsTests.java

示例4: testWriteOverwriteReadWithStrategy

import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
private void testWriteOverwriteReadWithStrategy(@NotNull final ClusteringStrategy strategy) throws IOException {
    vfs.shutdown();
    final VfsConfig config = new VfsConfig();
    config.setClusteringStrategy(strategy);
    vfs = new VirtualFileSystem(getEnvironment(), config);
    Transaction txn = env.beginTransaction();
    final File file0 = vfs.createFile(txn, "file0");
    OutputStream outputStream = vfs.writeFile(txn, file0);
    outputStream.write(HOEGAARDEN.getBytes(UTF_8));
    outputStream.close();
    InputStream inputStream = vfs.readFile(txn, file0);
    String actualRead = streamAsString(inputStream);
    Assert.assertEquals(HOEGAARDEN, actualRead);
    inputStream.close();
    txn.commit();
    txn = env.beginTransaction();
    outputStream = vfs.writeFile(txn, file0);
    outputStream.write(RENAT_GILFANOV.getBytes(UTF_8));
    outputStream.close();
    inputStream = vfs.readFile(txn, file0);
    actualRead = streamAsString(inputStream);
    Assert.assertEquals(RENAT_GILFANOV, actualRead);
    inputStream.close();
    txn.commit();
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:26,代码来源:VfsStreamsTests.java

示例5: testFileCreation

import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void testFileCreation() {
    final Transaction txn = env.beginTransaction();
    final File file0 = vfs.createFile(txn, "file0");
    txn.commit();
    Assert.assertEquals(0L, file0.getDescriptor());
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:8,代码来源:VfsFileTests.java

示例6: testFileCreation1

import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void testFileCreation1() {
    final Transaction txn = env.beginTransaction();
    final File file0 = vfs.openFile(txn, "file0", true);
    txn.commit();
    Assert.assertNotNull(file0);
    Assert.assertEquals(0L, file0.getDescriptor());
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:9,代码来源:VfsFileTests.java

示例7: testCreateUniqueFile

import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void testCreateUniqueFile() {
    final Transaction txn = env.beginTransaction();
    final File file = vfs.createUniqueFile(txn, "file");
    txn.commit();
    Assert.assertEquals(0L, file.getDescriptor());
    Assert.assertTrue(file.getPath().startsWith("file"));
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:9,代码来源:VfsFileTests.java

示例8: testOpenFile

import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void testOpenFile() {
    testFileCreation();
    final Transaction txn = env.beginTransaction();
    final File file0 = vfs.openFile(txn, "file0", false);
    txn.commit();
    Assert.assertNotNull(file0);
    Assert.assertEquals(0L, file0.getDescriptor());
    Assert.assertTrue(file0.getCreated() > 0);
    Assert.assertTrue(file0.getLastModified() > 0);
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:12,代码来源:VfsFileTests.java

示例9: testDeleteFile

import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void testDeleteFile() {
    Transaction txn = env.beginTransaction();
    vfs.createFile(txn, "file0");
    txn.commit();
    txn = env.beginTransaction();
    final File file0 = vfs.deleteFile(txn, "file0");
    txn.commit();
    Assert.assertNotNull(file0);
    Assert.assertEquals("file0", file0.getPath());
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:12,代码来源:VfsFileTests.java

示例10: 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());
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:14,代码来源:VfsFileTests.java

示例11: 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();
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:16,代码来源:VfsFileTests.java

示例12: testNumberOfFiles

import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void testNumberOfFiles() {
    final Transaction txn = env.beginTransaction();
    final HashSet<String> files = new HashSet<>();
    final int numberOfFiles = (int) (Math.random() * 1000 + 5000);
    for (int i = 0; i < numberOfFiles; ++i) {
        final String file = "file" + Math.random();
        if (!files.contains(file)) {
            files.add(file);
            vfs.createFile(txn, file);
        }
    }
    Assert.assertEquals(files.size(), vfs.getNumberOfFiles(txn));
    txn.commit();
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:16,代码来源:VfsFileTests.java

示例13: writeRead2

import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void writeRead2() 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();
    final InputStream inputStream = vfs.readFile(txn, file0);
    Assert.assertEquals(HOEGAARDEN, streamAsString(inputStream));
    inputStream.close();
    txn.commit();
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:13,代码来源:VfsStreamsTests.java

示例14: writeRead3

import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void writeRead3() throws IOException {
    final Transaction txn = env.beginTransaction();
    final File file0 = vfs.createFile(txn, "file0");
    final OutputStream outputStream = vfs.writeFile(txn, file0);
    outputStream.write(0);
    outputStream.close();
    final InputStream inputStream = vfs.readFile(txn, file0);
    Assert.assertEquals(0, inputStream.read());
    inputStream.close();
    txn.commit();
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:13,代码来源:VfsStreamsTests.java

示例15: writeRead4

import jetbrains.exodus.env.Transaction; //导入方法依赖的package包/类
@Test
public void writeRead4() throws IOException {
    final Transaction txn = env.beginTransaction();
    final File file0 = vfs.createFile(txn, "file0");
    final OutputStream outputStream = vfs.writeFile(txn, file0);
    final int count = 0x10000;
    outputStream.write(new byte[count]);
    outputStream.close();
    final InputStream inputStream = vfs.readFile(txn, file0);
    for (int i = 0; i < count; ++i) {
        Assert.assertEquals(0, inputStream.read());
    }
    inputStream.close();
    txn.commit();
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:16,代码来源:VfsStreamsTests.java


注:本文中的jetbrains.exodus.env.Transaction.commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。