Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b59f296
commit 3093ecb
Showing
14 changed files
with
1,210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0"?> | ||
|
||
<project | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.permazen</groupId> | ||
<artifactId>permazen</artifactId> | ||
<version>4.1.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>permazen-kv-xodus</artifactId> | ||
<name>Permazen Xodus Key/Value Store</name> | ||
<description>Permazen key/value store implementation based on Xodus.</description> | ||
<distributionManagement> | ||
<site> | ||
<id>${project.artifactId}-site</id> | ||
<url>file://${project.basedir}/../site/${project.artifactId}/</url> | ||
</site> | ||
</distributionManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-kv</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-kv-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-util</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains.xodus</groupId> | ||
<artifactId>xodus-environment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains.xodus</groupId> | ||
<artifactId>xodus-openAPI</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
64 changes: 64 additions & 0 deletions
64
permazen-kv-xodus/src/main/java/io/permazen/kv/xodus/TransactionType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
/* | ||
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved. | ||
*/ | ||
|
||
package io.permazen.kv.xodus; | ||
|
||
import com.google.common.base.Preconditions; | ||
|
||
import java.util.function.Function; | ||
|
||
import jetbrains.exodus.env.Environment; | ||
import jetbrains.exodus.env.Transaction; | ||
|
||
/** | ||
* Xodus transaction types. | ||
*/ | ||
public enum TransactionType implements Function<Environment, Transaction> { | ||
|
||
/** | ||
* Read-only transaction. | ||
* | ||
* @see Environment#beginReadonlyTransaction | ||
*/ | ||
READ_ONLY(true, false, Environment::beginReadonlyTransaction), | ||
|
||
/** | ||
* Normal read-write transaction. | ||
* | ||
* @see Environment#beginTransaction | ||
*/ | ||
READ_WRITE(false, false, Environment::beginTransaction), | ||
|
||
/** | ||
* Exclusive read-write transaction. | ||
* | ||
* @see Environment#beginExclusiveTransaction | ||
*/ | ||
READ_WRITE_EXCLUSIVE(false, true, Environment::beginExclusiveTransaction); | ||
|
||
private final boolean readOnly; | ||
private final boolean exclusive; | ||
private final Function<Environment, Transaction> creator; | ||
|
||
TransactionType(boolean readOnly, boolean exclusive, Function<Environment, Transaction> creator) { | ||
this.readOnly = readOnly; | ||
this.exclusive = exclusive; | ||
this.creator = creator; | ||
} | ||
|
||
public boolean isReadOnly() { | ||
return this.readOnly; | ||
} | ||
|
||
public boolean isExclusive() { | ||
return this.exclusive; | ||
} | ||
|
||
@Override | ||
public Transaction apply(Environment env) { | ||
Preconditions.checkArgument(env != null, "null env"); | ||
return this.creator.apply(env); | ||
} | ||
} |
Oops, something went wrong.