Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修正快照的接口问题 #8

Merged
merged 68 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
06f9219
增加错误基类、简单的记录接口
kaaass Jan 1, 2021
e9fd13f
增加.gitignore
kaaass Jan 1, 2021
7e3e2b4
完成记录的mock
kaaass Jan 1, 2021
f6edd17
增加记录接口的简易单元测试
kaaass Jan 1, 2021
910fc57
Merge branch 'dev' into feature-mock
kaaass Jan 1, 2021
481bea3
引入Slf4j、log4j、jbbp外部库
kaaass Jan 1, 2021
eb3d19c
[+]add table mock and unit test
KveinAxel Jan 1, 2021
50a8ad6
Merge branch 'feature-mock' into feature-table
KveinAxel Jan 2, 2021
1776095
Merge pull request #2 from kaaass/feature-table
KveinAxel Jan 2, 2021
d8aa315
增加Travis配置
kaaass Jan 2, 2021
c89d9c0
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
kaaass Jan 2, 2021
a2d5fa2
fix: transform java14 to java11
KveinAxel Jan 2, 2021
2491186
更新Gradle配置以允许Scan ToS
kaaass Jan 2, 2021
b1b8e33
删除冗余Travis配置
kaaass Jan 2, 2021
f843d2f
README增加Travis Badge
kaaass Jan 2, 2021
8211faf
增加UTF-8 gradle配置
kaaass Jan 8, 2021
2e50aba
对于数据项管理的mock和测试部分
xwinks Jan 8, 2021
0e6bddf
修改测试用例的文件名
KveinAxel Jan 8, 2021
9240fe7
index mock
DctorWei1314 Jan 8, 2021
845c7f9
增加事务的Mock
Criterionist Jan 8, 2021
37a86d8
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
Criterionist Jan 8, 2021
642c52e
testPage
xiaoxuanNLP Jan 9, 2021
96fc8dd
Merge branch 'feature-mock' of https://github.com/kaaass/rumbase_java…
xiaoxuanNLP Jan 9, 2021
2797554
index mock plus test
DctorWei1314 Jan 9, 2021
3079b1f
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
DctorWei1314 Jan 9, 2021
be73a7d
对于数据项管理的mock和测试部分的修改
xwinks Jan 9, 2021
aa6faa7
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
xwinks Jan 9, 2021
35f6267
testPage1.01
xiaoxuanNLP Jan 9, 2021
015b1d1
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
xiaoxuanNLP Jan 9, 2021
4d046cc
dataitem模块修改建议
kaaass Jan 9, 2021
934e336
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
kaaass Jan 9, 2021
4f79206
dataitem模块修改建议
kaaass Jan 9, 2021
dd92f0e
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
Criterionist Jan 9, 2021
2f0874e
修正编码风格
Criterionist Jan 9, 2021
2c4cbbb
对于数据项管理的mock和测试部分
xwinks Jan 9, 2021
0242ee6
对于数据项管理的mock和测试部分
xwinks Jan 9, 2021
fd25691
对于数据项管理的mock和测试部分
xwinks Jan 9, 2021
6029610
Index审计、修改建议
kaaass Jan 9, 2021
03f8b09
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
kaaass Jan 9, 2021
019036d
增加JBBP的使用示例
kaaass Jan 9, 2021
5656c6f
page模块审计、修改建议
kaaass Jan 9, 2021
4c3e3c2
删除table模块,更改record模块
kaaass Jan 9, 2021
c381c2e
recovery模块审计
kaaass Jan 9, 2021
1fc4b5c
transaction模块审计
kaaass Jan 9, 2021
c2b5606
对于日志恢复的接口和测试
xwinks Jan 9, 2021
69845d0
完善事务模块接口
Criterionist Jan 9, 2021
4974a28
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
Criterionist Jan 9, 2021
6511024
testPage1.02
xiaoxuanNLP Jan 9, 2021
e590bf2
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
xiaoxuanNLP Jan 9, 2021
7e6ccd9
testPage1.03
xiaoxuanNLP Jan 10, 2021
e50c917
复审recovery,tx
kaaass Jan 10, 2021
795ecef
格式化代码
kaaass Jan 10, 2021
26f1626
更新README
kaaass Jan 10, 2021
8fefaa0
Merge branch 'dev' into feature-mock
kaaass Jan 10, 2021
ecbe27f
修改异常名称
xwinks Jan 11, 2021
7fe37c4
修正编译失败
kaaass Jan 11, 2021
f8c5bff
Merge branch 'dev' into feature-mock
kaaass Jan 12, 2021
3aa86e3
表创建、表头解析以及页头解析
xwinks Jan 13, 2021
1cebb4a
Merge branch 'feature-dataitem' into feature-mock
xwinks Jan 13, 2021
476e115
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
xwinks Jan 13, 2021
78f7433
索引审计修改
DctorWei1314 Jan 13, 2021
39870f8
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
DctorWei1314 Jan 13, 2021
5a84ca0
RumbaseException增加错误原因
kaaass Jan 13, 2021
f6a5fe0
Merge to dev
kaaass Jan 13, 2021
98da699
完善事务模块接口,增加事务模块测试用例
Criterionist Jan 13, 2021
668121e
修正事务接口
Criterionist Jan 13, 2021
a46b8c0
Merge remote-tracking branch 'origin/dev' into feature-mock
kaaass Jan 13, 2021
25930c7
修正事务接口
Criterionist Jan 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
增加事务的Mock
  • Loading branch information
Criterionist committed Jan 8, 2021
commit 845c7f9e4e0cbfed8d9fa8c928b2bc3d76c0edff
37 changes: 37 additions & 0 deletions src/main/java/net/kaaass/rumbase/transaction/LockTable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package net.kaaass.rumbase.transaction;

/**
* 锁表
*
* <p>
* 记录锁的信息
* </p>
*
* @author criki
*/
public interface LockTable {
/**
* 添加共享锁
*
* @param xid 事务id
* @param uuid 记录id
*/
void addSharedLock(int xid, long uuid);

/**
* 添加排他锁
*
* @param xid 事务id
* @param uuid 记录id
*/
void addExclusiveLock(int xid, long uuid);

/**
* 释放事务的锁
*
* @param xid 事务id
*/
void release(int xid);


}
38 changes: 38 additions & 0 deletions src/main/java/net/kaaass/rumbase/transaction/LockTableManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package net.kaaass.rumbase.transaction;

import net.kaaass.rumbase.transaction.mock.MockLockTable;

import java.util.HashMap;
import java.util.Map;

/**
* 锁表管理器
* <p>
* 管理锁表
* </p>
*
* @author criki
*/
public class LockTableManager {
/**
* 表名与锁表的映射
*/
private final Map<String, LockTable> lockTables;

/**
* 锁表管理器
*/
public LockTableManager() {
this.lockTables = new HashMap<>();
}

public LockTable getTable(String tableName) {
if (lockTables.containsKey(tableName)) {
return lockTables.get(tableName);
} else {
LockTable table = new MockLockTable();
lockTables.put(tableName, table);
return table;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,75 @@
package net.kaaass.rumbase.transaction;

import net.kaaass.rumbase.transaction.mock.MockTransactionContext;

/**
* 事务上下文
*
* @author
* <p>
* 存储事务状态,对事务进行操作
* </p>
*
* @author criki
*/
public class TransactionContext {
public interface TransactionContext {

private TransactionContext() {
}

/**
* 返回空事务上下文。空事务或超级事务XID为0,不受事务限制,也不具备ACID性质。
*
* @return 空事务上下文
*/
public static TransactionContext empty() {
return new TransactionContext();
static TransactionContext empty() {
return new MockTransactionContext();
}

/**
* 获取事务隔离度
*
* @return 事务隔离度
*/
TransactionIsolation getIsolation();

/**
* 获取事务状态
*
* @return 事务状态
*/
TransactionStatus getStatus();

/**
* 获取事务id
*
* @return 事务id
*/
int getXid();

/**
* 事务开始
*/
void start();

/**
* 事务提交
*/
void commit();

/**
* 事务撤销
*/
void rollback();

/**
* 对记录加共享锁
*
* @param uuid 记录id
*/
void sharedLock(long uuid);

/**
* 对记录加排他锁
*
* @param uuid 记录id
*/
void exclusiveLock(long uuid);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.kaaass.rumbase.transaction;

import lombok.Getter;

/**
* 事务隔离度
*
* @author criki
*/
public enum TransactionIsolation {
READ_UNCOMMITTED(0), //读未提交
READ_COMMITTED(1), //读已提交
REPEATABLE_READ(2), //重复读
SERIALIZABLE(3); //串行化

/**
* 事务隔离度Id
*/
@Getter
private final int isolationId;

/**
* 事务隔离度
*
* @param isolationId 事务隔离度Id
*/
TransactionIsolation(int isolationId) {
this.isolationId = isolationId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.kaaass.rumbase.transaction;

/**
* 事务管理器
*
* <p>
* 管理事务的状态
* </p>
*
* @author criki
*/
public interface TransactionManager {

/**
* 创建新事务
*
* @param isolation 事务隔离度
* @return 创建的事物对象
*/
TransactionContext createTransactionContext(TransactionIsolation isolation);

/**
* 改变事务日志中的事务状态
*
* @param xid 事务id
* @param status 新事务状态
*/
void changeTransactionStatus(int xid, TransactionStatus status);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.kaaass.rumbase.transaction;

import lombok.Getter;

/**
* 事务状态
*
* @author criki
*/
public enum TransactionStatus {
PREPARING(0), //未开始
ACTIVE(1), //正在进行
COMMITTED(2), //已提交
ABORTED(3); //被撤销

/**
* 事务状态Id
*/
@Getter
private final byte statusId;

/**
* 事务状态
*
* @param statusId 事务状态Id
*/
TransactionStatus(int statusId) {
this.statusId = (byte) statusId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.kaaass.rumbase.transaction.exception;


import net.kaaass.rumbase.exception.RumbaseException;

import java.util.HashMap;
import java.util.Map;

/**
* E6001 死锁异常
* <p>
* E6001-1 发生死锁
* </p>
*/
public class DeadlockException extends RumbaseException {

public static final Map<Integer, String> REASONS = new HashMap<>() {{
put(1, "发生死锁");
}};

/**
* 死锁异常
*
* @param subId 子错误号
*/
public DeadlockException(int subId) {
super(6001, subId, REASONS.get(subId));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.kaaass.rumbase.transaction.mock;

import net.kaaass.rumbase.transaction.LockTable;

/**
* Mock锁表
*
* @author criki
*/

@Deprecated
public class MockLockTable implements LockTable {



@Override
public void addSharedLock(int xid, long uuid) {

}

@Override
public void addExclusiveLock(int xid, long uuid) {

}

@Override
public void release(int xid) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package net.kaaass.rumbase.transaction.mock;

import lombok.Getter;
import net.kaaass.rumbase.transaction.*;

import java.util.ArrayList;
import java.util.List;

/**
* Mock事务上下文
*
* @author criki
*/
@Deprecated
public class MockTransactionContext implements TransactionContext {

@Getter
private static final List<Integer> snapshot;

static {
snapshot = new ArrayList<>();
}

@Getter
private final int xid; //事务Id
@Getter
private final TransactionIsolation isolation; //事务隔离度
private final TransactionManager manager; //存储创建它的管理器
@Getter
private TransactionStatus status; //事务状态

public MockTransactionContext() {
this.xid = 0;
this.status = TransactionStatus.COMMITTED;
this.isolation = TransactionIsolation.READ_UNCOMMITTED;
this.manager = null;
}

/**
* 事务上下文
*
* @param isolation 事务隔离度
* @param manager 创建事务的管理器
*/
public MockTransactionContext(int xid, TransactionIsolation isolation, TransactionManager manager) {
this.xid = xid;
this.status = TransactionStatus.PREPARING;
this.isolation = isolation;
this.manager = manager;
}

@Override
public void start() {
this.status = TransactionStatus.ACTIVE;
if (manager != null) {
manager.changeTransactionStatus(xid, TransactionStatus.ACTIVE);
}
}

@Override
public void commit() {
this.status = TransactionStatus.COMMITTED;
if (manager != null) {
manager.changeTransactionStatus(xid, TransactionStatus.COMMITTED);
}
}

@Override
public void rollback() {
this.status = TransactionStatus.ABORTED;
if (manager != null) {
manager.changeTransactionStatus(xid, TransactionStatus.ABORTED);
}
}

@Override
public void sharedLock(long uuid) {

}

@Override
public void exclusiveLock(long uuid) {

}
}
Loading