Skip to content

Conversation

jsflax
Copy link
Contributor

@jsflax jsflax commented Mar 13, 2019

No description provided.

@jsflax jsflax requested a review from dkaminsky March 13, 2019 20:54
@coveralls
Copy link

coveralls commented Mar 14, 2019

Coverage Status

Coverage remained the same at 21.436% when pulling 2a3dd51 on jsflax:STITCH-2584 into c28f9d5 on mongodb:master.

Copy link
Contributor

@edaniels edaniels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mostly questions before I give final approval. I didn't look at tests. Really nice changes and great stress test app improvements though!

}
testInstrumentationRunnerArgument "test.stitch.baseURL", properties.getProperty("test.stitch.baseURL", "http://10.0.2.2:9090")
testInstrumentationRunnerArgument "test.stitch.baseURL",
properties.getProperty("test.stitch.baseURL", "http://10.1.14.181:9090")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo

implementation "com.android.support:appcompat-v7:${support_library_version}"
implementation "com.android.support:recyclerview-v7:${support_library_version}"
implementation "com.android.support.constraint:constraint-layout:1.1.0"
// implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uncomment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can just delete, we don't need core.

<manifest package="com.mongodb.stitch.android.services.mongodb.remote">
<manifest package="com.mongodb.stitch.android.services.mongodb.remote"
xmlns:android="http://schemas.android.com/apk/res/android">
<application android:usesCleartextTraffic="true" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can undo these changes


override fun getStitchBaseURL(): String {
return InstrumentationRegistry.getArguments().getString("test.stitch.baseURL", "http://10.0.2.2:9090")
return "http://10.0.2.2:9090"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be reverted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

) {
Map<BsonValue, CoreDocumentSynchronizationConfig> configs = new HashMap<>();
for (final BsonValue documentId : documentIds) {
if (getSynchronizedDocument(documentId) == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] Should we add a getSynchronizedDocuments to speed this up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to, it's just reading from a hashmap.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

* documents.
*/
public class DataSynchronizer implements NetworkMonitor.StateListener {
class BatchOps {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] May be better to move this into its own class in a different file instead of this being an inner non-static class. Would just need to provide more args for its methods though to compensate not having direct access. Might be cleaner though.

}

void merge(@Nullable final BatchOps batchOps) {
if (batchOps != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Can make this if null early return to reduce indentation

undoCollection.deleteOne(getDocumentIdFilter(documentId));
eventsToEmit.add(event);
}
triggerListeningToNamespace(namespace);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] Do we need to trigger here as a part of this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, desync used to trigger every time it was called. It no longer does that, so we need to do it manually after desyncing has been done. There is a cleaner way to do this by tracking what operations have been done and if the streams need to be restarted.

}
}

void setPendingWritesCompleteNoDB(final BsonDocument atVersion) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] Is the point of this to make sync not skip over these during batch processing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point of this is to not replace the doc config everytime we set pending writes– that's very slow. So we change it in memory here and do a bulk write after the pass on the namespace is done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

new BsonDocument(
CoreDocumentSynchronizationConfig.ConfigCodec.Fields.IS_STALE,
new BsonBoolean(stale))));
// docsColl.updateOne(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be uncommented or method removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Copy link
Contributor

@edaniels edaniels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@dkaminsky dkaminsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address questions.

new BsonDocument(
CoreDocumentSynchronizationConfig.ConfigCodec.Fields.IS_STALE,
new BsonBoolean(stale))));
isStale = stale;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] approve of caching locally but looks like this never gets written to the docConfig as a result - are we ok with this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does get written when we do the bulk writes.

In the event that the app crashes before it can be written, the document is marked stale anyway on app restart.

* @param atVersion the version for which the write occurred.
* @param changeEvent the description of the write/change.
*/
void setSomePendingWrites(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] why add this? does not appear this is called anywhere? did I miss it?

@jsflax jsflax merged commit 1923649 into mongodb:master Mar 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants