Skip to content

Commit

Permalink
Revert "Concurrent case handling for Yorkie.tree (#131)"
Browse files Browse the repository at this point in the history
This reverts commit a15496b.
  • Loading branch information
7hong13 authored Aug 28, 2023
1 parent a15496b commit 3fa7502
Show file tree
Hide file tree
Showing 36 changed files with 941 additions and 2,760 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ jobs:
ram-size: 4096M
emulator-boot-timeout: 12000
disable-animations: true
script: |
./gradlew yorkie:connectedCheck -Pandroid.testInstrumentationRunnerArguments.notAnnotation=androidx.test.filters.LargeTest --no-build-cache --no-daemon --stacktrace
./gradlew yorkie:connectedCheck -Pandroid.testInstrumentationRunnerArguments.annotation=androidx.test.filters.LargeTest --no-build-cache --no-daemon --stacktrace
script: ./gradlew yorkie:connectedCheck --no-build-cache --no-daemon --stacktrace
- if: ${{ matrix.api-level == 30 }}
run: ./gradlew yorkie:jacocoDebugTestReport
- if: ${{ matrix.api-level == 30 }}
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
depends_on:
- yorkie
yorkie:
image: 'yorkieteam/yorkie:0.4.6'
image: 'yorkieteam/yorkie:0.4.5'
container_name: 'yorkie'
command: [
'server',
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
extra_hosts:
- "host.docker.internal:host-gateway"
yorkie:
image: 'yorkieteam/yorkie:0.4.6'
image: 'yorkieteam/yorkie:0.4.5'
container_name: 'yorkie'
command: [
'server',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ class EditorViewModel(private val client: Client) : ViewModel(), YorkieEditText.
private val _content = MutableSharedFlow<String>()
val content = _content.asSharedFlow()

private val _textOperationInfos =
MutableSharedFlow<Pair<ActorID, OperationInfo.TextOperationInfo>>()
val textOpInfos = _textOperationInfos.asSharedFlow()
private val _textOpInfos = MutableSharedFlow<Pair<ActorID, OperationInfo.TextOpInfo>>()
val textOpInfos = _textOpInfos.asSharedFlow()

val removedPeers = document.events.filterIsInstance<PresenceChange.Others.Unwatched>()
.map { it.unwatched.actorID }
Expand Down Expand Up @@ -74,7 +73,7 @@ class EditorViewModel(private val client: Client) : ViewModel(), YorkieEditText.
private suspend fun emitEditOpInfos(changeInfo: Document.Event.ChangeInfo) {
changeInfo.operations.filterIsInstance<OperationInfo.EditOpInfo>()
.forEach { opInfo ->
_textOperationInfos.emit(changeInfo.actorID to opInfo)
_textOpInfos.emit(changeInfo.actorID to opInfo)
}
}

Expand All @@ -86,7 +85,7 @@ class EditorViewModel(private val client: Client) : ViewModel(), YorkieEditText.
gson.fromJson(jsonArray.getString(1), TextPosStructure::class.java) ?: return
val (from, to) = document.getRoot().getAs<JsonText>(TEXT_KEY)
.posRangeToIndexRange(fromPos to toPos)
_textOperationInfos.emit(actorID to OperationInfo.SelectOpInfo(from, to))
_textOpInfos.emit(actorID to OperationInfo.SelectOpInfo(from, to))
}

fun syncText() {
Expand Down
33 changes: 11 additions & 22 deletions yorkie/proto/src/main/proto/yorkie/v1/resources.proto
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ message Operation {
TimeTicket executed_at = 6;
map<string, string> attributes = 7;
}
// NOTE(hackerwins): Select Operation is not used in the current version.
// In the previous version, it was used to represent selection of Text.
// However, it has been replaced by Presence now. It is retained for backward
// compatibility purposes.
message Select {
TimeTicket parent_created_at = 1;
TextNodePos from = 2;
Expand All @@ -121,9 +117,8 @@ message Operation {
TimeTicket parent_created_at = 1;
TreePos from = 2;
TreePos to = 3;
map<string, TimeTicket> created_at_map_by_actor = 4;
repeated TreeNodes contents = 5;
TimeTicket executed_at = 6;
repeated TreeNodes contents = 4;
TimeTicket executed_at = 5;
}
message TreeStyle {
TimeTicket parent_created_at = 1;
Expand Down Expand Up @@ -238,30 +233,24 @@ message TextNodeID {
}

message TreeNode {
TreeNodeID id = 1;
TreePos pos = 1;
string type = 2;
string value = 3;
TimeTicket removed_at = 4;
TreeNodeID ins_prev_id = 5;
TreeNodeID ins_next_id = 6;
int32 depth = 7;
map<string, NodeAttr> attributes = 8;
TreePos ins_prev_pos = 5;
int32 depth = 6;
map<string, NodeAttr> attributes = 7;
}

message TreeNodes {
repeated TreeNode content = 1;
}

message TreeNodeID {
message TreePos {
TimeTicket created_at = 1;
int32 offset = 2;
}

message TreePos {
TreeNodeID parent_id = 1;
TreeNodeID left_sibling_id = 2;
}

/////////////////////////////////////////
// Messages for Common //
/////////////////////////////////////////
Expand Down Expand Up @@ -354,12 +343,12 @@ enum ValueType {
}

enum DocEventType {
DOC_EVENT_TYPE_DOCUMENT_CHANGED = 0;
DOC_EVENT_TYPE_DOCUMENT_WATCHED = 1;
DOC_EVENT_TYPE_DOCUMENT_UNWATCHED = 2;
DOC_EVENT_TYPE_DOCUMENTS_CHANGED = 0;
DOC_EVENT_TYPE_DOCUMENTS_WATCHED = 1;
DOC_EVENT_TYPE_DOCUMENTS_UNWATCHED = 2;
}

message DocEvent {
DocEventType type = 1;
string publisher = 2;
bytes publisher = 2;
}
30 changes: 18 additions & 12 deletions yorkie/proto/src/main/proto/yorkie/v1/yorkie.proto
Original file line number Diff line number Diff line change
Expand Up @@ -42,45 +42,49 @@ message ActivateClientRequest {
}

message ActivateClientResponse {
string client_id = 1;
string client_key = 1;
bytes client_id = 2;
}

message DeactivateClientRequest {
string client_id = 1;
bytes client_id = 1;
}

message DeactivateClientResponse {
bytes client_id = 1;
}

message AttachDocumentRequest {
string client_id = 1;
bytes client_id = 1;
ChangePack change_pack = 2;
}

message AttachDocumentResponse {
string document_id = 1;
ChangePack change_pack = 2;
bytes client_id = 1;
string document_id = 2;
ChangePack change_pack = 3;
}

message DetachDocumentRequest {
string client_id = 1;
bytes client_id = 1;
string document_id = 2;
ChangePack change_pack = 3;
bool remove_if_not_attached = 4;
}

message DetachDocumentResponse {
string client_key = 1;
ChangePack change_pack = 2;
}

message WatchDocumentRequest {
string client_id = 1;
bytes client_id = 1;
string document_id = 2;
}

message WatchDocumentResponse {
message Initialization {
repeated string client_ids = 1;
repeated bytes client_ids = 1;
}

oneof body {
Expand All @@ -90,22 +94,24 @@ message WatchDocumentResponse {
}

message RemoveDocumentRequest {
string client_id = 1;
bytes client_id = 1;
string document_id = 2;
ChangePack change_pack = 3;
}

message RemoveDocumentResponse {
ChangePack change_pack = 1;
string client_key = 1;
ChangePack change_pack = 2;
}

message PushPullChangesRequest {
string client_id = 1;
bytes client_id = 1;
string document_id = 2;
ChangePack change_pack = 3;
bool push_only = 4;
}

message PushPullChangesResponse {
ChangePack change_pack = 1;
bytes client_id = 1;
ChangePack change_pack = 2;
}
20 changes: 8 additions & 12 deletions yorkie/src/androidTest/kotlin/dev/yorkie/core/ClientTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package dev.yorkie.core
import androidx.test.ext.junit.runners.AndroidJUnit4
import dev.yorkie.assertJsonContentEquals
import dev.yorkie.core.Client.DocumentSyncResult
import dev.yorkie.core.Client.Event.DocumentChanged
import dev.yorkie.core.Client.Event.DocumentSynced
import dev.yorkie.core.Client.Event.DocumentsChanged
import dev.yorkie.core.Client.StreamConnectionStatus
import dev.yorkie.document.Document
import dev.yorkie.document.Document.Event.LocalChange
Expand Down Expand Up @@ -89,8 +89,8 @@ class ClientTest {
delay(50)
}
}
val changeEvent = assertIs<DocumentChanged>(
client2Events.first { it is DocumentChanged },
val changeEvent = assertIs<DocumentsChanged>(
client2Events.first { it is DocumentsChanged },
)
assertContentEquals(listOf(documentKey), changeEvent.documentKeys)
var syncEvent = assertIs<DocumentSynced>(client2Events.first { it is DocumentSynced })
Expand Down Expand Up @@ -121,15 +121,11 @@ class ClientTest {
root.remove("k1")
}.await()

withTimeout(GENERAL_TIMEOUT) {
while (client1Events.none { it is DocumentSynced }) {
delay(50)
}
while (client1Events.none { it is DocumentSynced }) {
delay(50)
}
withTimeout(GENERAL_TIMEOUT) {
while (client2Events.isEmpty()) {
delay(50)
}
while (client2Events.isEmpty()) {
delay(50)
}
syncEvent = assertIs(client2Events.first { it is DocumentSynced })
assertIs<DocumentSyncResult.Synced>(syncEvent.result)
Expand Down Expand Up @@ -195,7 +191,7 @@ class ClientTest {
root["version"] = "v2"
}.await()
client1.syncAsync().await()
withTimeout(GENERAL_TIMEOUT) {
withTimeout(5_000) {
while (client2Events.size < 2) {
delay(50)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ class DocumentTest {
assertEquals(document1.toJson(), document2.toJson())

client1.removeAsync(document1).await()
if (document2.status != DocumentStatus.Removed) {
client2.detachAsync(document2).await()
}
client2.detachAsync(document2).await()
assertEquals(DocumentStatus.Removed, document1.status)
assertEquals(DocumentStatus.Removed, document2.status)
}
Expand Down
Loading

0 comments on commit 3fa7502

Please sign in to comment.