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

Persistence redesign #4589

Merged
merged 89 commits into from
Oct 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
8aff1f8
Refactor: Move FileUtil
chimp1984 Oct 1, 2020
2350710
Refactor: Move CorruptedDatabaseFilesHandler
chimp1984 Oct 1, 2020
cda9d9e
Refactor: Move other 2 classes to file package
chimp1984 Oct 1, 2020
802dcad
Refactor: Rename CorruptedDatabaseFilesHandler
chimp1984 Oct 1, 2020
d27e4dc
Refactor: Rename fields and methods, return early
chimp1984 Oct 1, 2020
6f6836f
Refactor: Add removeAndBackupFile method
chimp1984 Oct 1, 2020
85b33bc
Remove awaitTermination
chimp1984 Oct 1, 2020
92c9c3c
Add getDefaultStorageFileName method
chimp1984 Oct 1, 2020
937c006
Add PersistenceManager class
chimp1984 Oct 1, 2020
fd0cc63
Refactor: use FileUtil.removeAndBackupFile instead of FileManager.rem…
chimp1984 Oct 1, 2020
c245026
Remove Storage and FileManager from logback
chimp1984 Oct 1, 2020
93f1108
Add PersistenceManager.flushAllDataToDisk to shutdown to write all pe…
chimp1984 Oct 1, 2020
4f3ded6
Use PersistenceManager instead of Storage for import/export
chimp1984 Oct 1, 2020
35d9338
Remove UserThreadMappedPersistableList and use PersistableList instead
chimp1984 Oct 1, 2020
d3be8dd
Remove UserThreadMappedPersistableEnvelope and use PersistableEnvelop…
chimp1984 Oct 1, 2020
3a348d5
Remove ThreadedPersistableEnvelope and use PersistableEnvelope instead
chimp1984 Oct 1, 2020
2e55251
Use PersistenceManager for StoreService (not yet supported for subcla…
chimp1984 Oct 1, 2020
92b0ea9
Use PersistenceManager for MapStoreService (not yet supported for sub…
chimp1984 Oct 1, 2020
5a1cd0e
Use PersistableNetworkPayloadStore for AppendOnlyDataStoreService
chimp1984 Oct 1, 2020
e2f0f61
Update PersistableNetworkPayloadStore
chimp1984 Oct 1, 2020
0682b99
Update ProtectedDataStoreService
chimp1984 Oct 1, 2020
9494439
Use PersistenceManager in HistoricalDataStoreService
chimp1984 Oct 1, 2020
827775c
Add missing import
chimp1984 Oct 1, 2020
34d8909
Add final at ResourceDataStoreService
chimp1984 Oct 1, 2020
a4acdda
Apply generics and super class methods
chimp1984 Oct 1, 2020
dc77b5c
Use PersistenceManager
chimp1984 Oct 1, 2020
d9a7aac
Update SignedWitness classes
chimp1984 Oct 1, 2020
8781c80
Update AccountAgeWitnessStorage classes
chimp1984 Oct 1, 2020
e6211ef
Update TempProposalStore and ProposalStore classes
chimp1984 Oct 1, 2020
9190f17
Update TradeStatistics2Storage classes
chimp1984 Oct 1, 2020
074ed67
Remove lombok Delegate from PersistableList
chimp1984 Oct 1, 2020
80e16a0
Use PersistenceManager
chimp1984 Oct 1, 2020
308c970
Use PersistenceManager
chimp1984 Oct 1, 2020
878f645
Use PersistenceManager
chimp1984 Oct 1, 2020
5d6cbf5
Refactor: Move classes to new package
chimp1984 Oct 1, 2020
0eb99f7
Use PersistenceManager
chimp1984 Oct 1, 2020
8f38de3
Use PersistableList as base class
chimp1984 Oct 1, 2020
158b7a9
Remove storage from dispute. We do persistence from outside now.
chimp1984 Oct 1, 2020
8a6b2a7
Use PersistenceManager. Make disputeList final
chimp1984 Oct 1, 2020
2d91c26
Remove storage and persist calls. Remove unused methods
chimp1984 Oct 1, 2020
1e91b09
Remove persist method
chimp1984 Oct 1, 2020
63fe1c9
Remove storage
chimp1984 Oct 1, 2020
4f18577
Extend PersistableList, remvoe storage
chimp1984 Oct 1, 2020
f6be9b0
Use PersistenceManager
chimp1984 Oct 2, 2020
2582f58
Use PersistenceManager
chimp1984 Oct 2, 2020
f4165dc
Use PersistenceManager
chimp1984 Oct 2, 2020
c3c869b
Use PersistenceManager
chimp1984 Oct 2, 2020
d4f460b
Use PersistenceManager
chimp1984 Oct 2, 2020
406afa9
Use PersistenceManager. Add setAll method
chimp1984 Oct 2, 2020
fae1cda
Use PersistenceManager
chimp1984 Oct 2, 2020
986f1bf
Use PersistenceManager. We do not persist inside openOffer anymore bu…
chimp1984 Oct 2, 2020
27c2cb8
Use PersistenceManager
chimp1984 Oct 2, 2020
e0ea742
Use PersistenceManager
chimp1984 Oct 2, 2020
e825613
Use PersistenceManager
chimp1984 Oct 2, 2020
fac4200
Remove unused fields, apply new params
chimp1984 Oct 2, 2020
486e6f4
Use PersistenceManager
chimp1984 Oct 2, 2020
9da13c3
Refactor: Rename persist to requestPersistence
chimp1984 Oct 2, 2020
482bc56
Use PersistenceManager
chimp1984 Oct 2, 2020
fe4c21b
Use PersistenceManager
chimp1984 Oct 2, 2020
197e871
Remove FileManager ans Storage. All is replaces not by PersistenceMan…
chimp1984 Oct 2, 2020
42e10f2
Apply generics
chimp1984 Oct 2, 2020
a797413
Remove persist method
chimp1984 Oct 2, 2020
7b4611e
Add requestPersistence call
chimp1984 Oct 2, 2020
b901f35
Add missing persist calls. Add generics. Remove persist method. Add f…
chimp1984 Oct 2, 2020
253c6c3
Remove unneeded param. Add requestPersistence calls. Cleanup removeTr…
chimp1984 Oct 2, 2020
fa0d261
Fix remaining issues, cleanups, add persit calls, remove unused code,...
chimp1984 Oct 2, 2020
270e89a
Fix wrong params
chimp1984 Oct 2, 2020
ccfda5b
Cleanups, add generics, add final, remove unused code/comments/todos,
chimp1984 Oct 2, 2020
5f47ed2
Use decrementAndGet instead of getAndDecrement
chimp1984 Oct 2, 2020
e242c54
Refactor: Rename getTradesAsObservableList to getObservableList
chimp1984 Oct 2, 2020
e88a810
Revert exit code to 1 as it was before. Not sure if there have been s…
chimp1984 Oct 2, 2020
c789650
Move methods to base class
chimp1984 Oct 2, 2020
32238f2
Rename getClosedTradables and getFailedTrades to getObservableList
chimp1984 Oct 2, 2020
b712445
Remove duplicate startApplication call. Remove checkCryptoSetup call …
chimp1984 Oct 2, 2020
232fa8d
Execute result handler on userThread
chimp1984 Oct 2, 2020
10e9b05
Rename writeCompleted to onWriteCompleted
chimp1984 Oct 2, 2020
18f64d5
Persist all Priority.HIGH stores at shutdown to be more safe that we …
chimp1984 Oct 2, 2020
137b5e8
Enforce that clients set the priority. Remove the initialize methods …
chimp1984 Oct 2, 2020
e9db7c6
Rename Priority to Source. This should make it more clear what is the…
chimp1984 Oct 2, 2020
c9cd58a
Fix rename mistakes
chimp1984 Oct 2, 2020
6693a03
Fix test class
chimp1984 Oct 2, 2020
a612405
Update common/src/main/java/bisq/common/persistence/PersistenceManage…
chimp1984 Oct 4, 2020
3b31dc9
Fix typo
chimp1984 Oct 4, 2020
0cc0cfc
Use runAfter instead of runPeriodically
chimp1984 Oct 4, 2020
f7c2464
Fix typo
chimp1984 Oct 4, 2020
f9f33aa
Add PersistableListAsObservable
chimp1984 Oct 4, 2020
d18b243
Do not use persistNow for snapshots but requestPersistence
chimp1984 Oct 4, 2020
c797317
Fix typo
chimp1984 Oct 4, 2020
e179ee4
Use Collection for constructor which is called from the fromProto met…
chimp1984 Oct 4, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,14 @@

package bisq.common.proto.persistable;

import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Stream;

import lombok.EqualsAndHashCode;
import lombok.Getter;

@EqualsAndHashCode
public abstract class PersistableList<T extends PersistablePayload> implements PersistableEnvelope {

@Getter
Expand All @@ -46,18 +41,6 @@ public PersistableList(List<T> list) {
setAll(list);
}

public void addListener(ListChangeListener<T> listener) {
((ObservableList<T>) getList()).addListener(listener);
}

public void removeListener(ListChangeListener<T> listener) {
((ObservableList<T>) getList()).removeListener(listener);
}

public ObservableList<T> getObservableList() {
return (ObservableList<T>) getList();
}

public void setAll(Collection<T> collection) {
this.list.clear();
this.list.addAll(collection);
Expand All @@ -71,8 +54,8 @@ public boolean add(T item) {
return false;
}

public boolean remove(T tradable) {
return list.remove(tradable);
public boolean remove(T item) {
return list.remove(item);
}

public Stream<T> stream() {
Expand All @@ -83,8 +66,8 @@ public int size() {
return list.size();
}

public boolean contains(T thing) {
return list.contains(thing);
public boolean contains(T item) {
return list.contains(item);
}

public boolean isEmpty() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.common.proto.persistable;

import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;

import java.util.List;

public abstract class PersistableListAsObservable<T extends PersistablePayload> extends PersistableList<T> {

public PersistableListAsObservable() {
}

protected PersistableListAsObservable(List<T> list) {
chimp1984 marked this conversation as resolved.
Show resolved Hide resolved
super(list);
}

protected List<T> createList() {
return FXCollections.observableArrayList();
}

public ObservableList<T> getObservableList() {
return (ObservableList<T>) getList();
}

public void addListener(ListChangeListener<T> listener) {
((ObservableList<T>) getList()).addListener(listener);
}

public void removeListener(ListChangeListener<T> listener) {
((ObservableList<T>) getList()).removeListener(listener);
}
}
9 changes: 2 additions & 7 deletions core/src/main/java/bisq/core/support/dispute/DisputeList.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

package bisq.core.support.dispute;

import bisq.common.proto.persistable.PersistableList;
import bisq.common.proto.persistable.PersistableListAsObservable;
import bisq.common.proto.persistable.PersistablePayload;

import javafx.collections.FXCollections;

import java.util.List;

import lombok.ToString;
Expand All @@ -35,10 +33,7 @@
* Calls to the List are delegated because this class intercepts the add/remove calls so changes
* can be saved to disc.
*/
public abstract class DisputeList<T extends PersistablePayload> extends PersistableList<T> {
protected List<T> createList() {
return FXCollections.observableArrayList();
}
public abstract class DisputeList<T extends PersistablePayload> extends PersistableListAsObservable<T> {

public DisputeList() {
}
Expand Down
10 changes: 2 additions & 8 deletions core/src/main/java/bisq/core/trade/TradableList.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@

import bisq.common.proto.ProtoUtil;
import bisq.common.proto.ProtobufferRuntimeException;
import bisq.common.proto.persistable.PersistableList;
import bisq.common.proto.persistable.PersistableListAsObservable;

import com.google.protobuf.Message;

import javafx.collections.FXCollections;

import java.util.List;
import java.util.stream.Collectors;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public final class TradableList<T extends Tradable> extends PersistableList<T> {
public final class TradableList<T extends Tradable> extends PersistableListAsObservable<T> {

///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
Expand All @@ -44,10 +42,6 @@ public final class TradableList<T extends Tradable> extends PersistableList<T> {
public TradableList() {
}

protected List<T> createList() {
return FXCollections.observableArrayList();
}


///////////////////////////////////////////////////////////////////////////////////////////
// PROTO BUFFER
Expand Down