tkalkirill commented on code in PR #1556:
URL: https://github.com/apache/ignite-3/pull/1556#discussion_r1083926252
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/raft/snapshot/PartitionAccessImpl.java:
##########
@@ -57,48 +70,147 @@ public PartitionKey partitionKey() {
}
@Override
- public MvPartitionStorage mvPartitionStorage() {
- MvPartitionStorage mvPartition =
mvTableStorage.getMvPartition(partId());
+ public CompletableFuture<Void> reCreateMvPartitionStorage() throws
StorageException {
+ assert mvTableStorage.getMvPartition(partitionId()) != null : "table="
+ tableName() + ", part=" + partitionId();
+
+ // TODO: IGNITE-18030 - actually recreate or do in a different way
+ //return mvTableStorage.destroyPartition(partId())
+ return CompletableFuture.completedFuture(null)
+ .thenApply(unused -> {
+ MvPartitionStorage mvPartitionStorage =
mvTableStorage.getOrCreateMvPartition(partitionId());
+
+ mvPartitionStorage.runConsistently(() -> {
+
mvPartitionStorage.lastApplied(FULL_RABALANCING_STARTED, 0);
- assert mvPartition != null : "table=" + tableName() + ", part=" +
partId();
+ return null;
+ });
- return mvPartition;
+ return null;
+ });
}
@Override
- public TxStateStorage txStatePartitionStorage() {
- TxStateStorage txStatePartitionStorage =
txStateTableStorage.getTxStateStorage(partId());
+ public void reCreateTxStatePartitionStorage() throws StorageException {
+ assert txStateTableStorage.getTxStateStorage(partitionId()) != null :
"table=" + tableName() + ", part=" + partitionId();
+
+ // TODO: IGNITE-18030 - actually recreate or do in a different way
+ //txStateTableStorage.destroyTxStateStorage(partId());
+
+
txStateTableStorage.getOrCreateTxStateStorage(partitionId()).lastApplied(FULL_RABALANCING_STARTED,
0);
+ }
- assert txStatePartitionStorage != null : "table=" + tableName() + ",
part=" + partId();
+ private int partitionId() {
+ return partitionKey.partitionId();
+ }
- return txStatePartitionStorage;
+ private String tableName() {
+ return mvTableStorage.configuration().name().value();
}
@Override
- public CompletableFuture<MvPartitionStorage> reCreateMvPartitionStorage()
throws StorageException {
- assert mvTableStorage.getMvPartition(partId()) != null : "table=" +
tableName() + ", part=" + partId();
+ public Cursor<IgniteBiTuple<UUID, TxMeta>> getAllTxMeta() {
+ return getTxStateStorage(partitionId()).scan();
+ }
- // TODO: IGNITE-18030 - actually recreate or do in a different way
- //return mvTableStorage.destroyPartition(partId())
- return CompletableFuture.completedFuture(null)
- .thenApply(unused ->
mvTableStorage.getOrCreateMvPartition(partId()));
+ @Override
+ public void addTxMeta(UUID txId, TxMeta txMeta) {
+ getTxStateStorage(partitionId()).put(txId, txMeta);
}
@Override
- public TxStateStorage reCreateTxStatePartitionStorage() throws
StorageException {
- assert txStateTableStorage.getTxStateStorage(partId()) != null :
"table=" + tableName() + ", part=" + partId();
+ public @Nullable RowId closestRowId(RowId lowerBound) {
+ return getMvPartitionStorage(partitionId()).closestRowId(lowerBound);
+ }
- // TODO: IGNITE-18030 - actually recreate or do in a different way
- //txStateTableStorage.destroyTxStateStorage(partId());
+ @Override
+ public Cursor<ReadResult> getAllRowVersions(RowId rowId) {
+ return getMvPartitionStorage(partitionId()).scanVersions(rowId);
+ }
- return txStateTableStorage.getOrCreateTxStateStorage(partId());
+ @Override
+ public @Nullable RaftGroupConfiguration committedGroupConfiguration() {
+ return
getMvPartitionStorage(partitionId()).committedGroupConfiguration();
}
- private int partId() {
- return partitionKey.partitionId();
+ @Override
+ public void addWrite(RowId rowId, TableRow row, UUID txId, UUID
commitTableId, int commitPartitionId) {
+ MvPartitionStorage mvPartitionStorage =
getMvPartitionStorage(partitionId());
+
+ mvPartitionStorage.runConsistently(() ->
mvPartitionStorage.addWrite(rowId, row, txId, commitTableId,
commitPartitionId));
}
- private String tableName() {
- return mvTableStorage.configuration().name().value();
+ @Override
+ public void addWriteCommitted(RowId rowId, TableRow row, HybridTimestamp
commitTimestamp) {
+ MvPartitionStorage mvPartitionStorage =
getMvPartitionStorage(partitionId());
+
+ mvPartitionStorage.runConsistently(() -> {
+ mvPartitionStorage.addWriteCommitted(rowId, row, commitTimestamp);
+
+ return null;
+ });
+ }
+
+ @Override
+ public void updateLastApplied(long lastAppliedIndex, long lastAppliedTerm,
RaftGroupConfiguration raftGroupConfig) {
+ MvPartitionStorage mvPartitionStorage =
getMvPartitionStorage(partitionId());
+ TxStateStorage txStateStorage = getTxStateStorage(partitionId());
+
+ mvPartitionStorage.runConsistently(() -> {
+ mvPartitionStorage.lastApplied(lastAppliedIndex, lastAppliedTerm);
+
+ txStateStorage.lastApplied(lastAppliedIndex, lastAppliedTerm);
+
+ mvPartitionStorage.committedGroupConfiguration(raftGroupConfig);
+
+ return null;
+ });
+ }
+
+ @Override
+ public long minLastAppliedIndex() {
Review Comment:
I think there are already tests:
-
`org.apache.ignite.internal.table.distributed.raft.snapshot.PartitionSnapshotStorageFactoryTest#testForChoosingMinimumAppliedIndexForMeta`
-
`org.apache.ignite.internal.table.distributed.raft.snapshot.outgoing.OutgoingSnapshotReaderTest#testForChoosingMaximumAppliedIndexForMeta`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]