-
Notifications
You must be signed in to change notification settings - Fork 626
add uploader #327
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
add uploader #327
Conversation
...t-runtime/src/main/java/com/google/android/datatransport/runtime/TransportRuntimeModule.java
Outdated
Show resolved
Hide resolved
...rc/main/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/Uploader.java
Show resolved
Hide resolved
void logAndUpdateState(String backendName, int attemptNumber) { | ||
TransportBackend backend = backendRegistry.get(backendName); | ||
List<EventInternal> eventInternals = new ArrayList<>(); | ||
Iterable<PersistedEvent> persistedEvents = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, the explicit synchronization is only required because we want to support multi process thread safety ?
Questions
- The API for the datastore seems to require that call sites responsibly call eventStore methods in critical sections. I see that this cannot be done within the implementations of the eventStore since we invoke others apis from within critical sections, that are outside of the store. Would a single operation on datastore have to be run in a critical section too?
- If the critical sections are scattered across the project, I would vote to bring them all into a single file and encapsulate them as higher level functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require that call sites responsibly call eventStore methods in critical sections
It's not the case, you can call them by themselves they will just be part of their own isolated transaction, the reason you'd want to call them within a critical section is to guarantee atomicity.
- iiu your comment correctly
runCriticalSection
is exactly the higher-level function you're describing, so I am not sure what the suggestion is here, can you be more specific, e.g. provide an example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. So it seems like each operation on datastore itself need not be in a critical section. THis is requires only when multiple operations are to be atomic.
- What I mean is -> All invocations of
runCriticalSection
could be centralized. We will have a single place to reason about all higher level operations that we need to be atomic. Is this file that place or are there other files that invokerunCtiticalSection
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we have to places that need to synchronize:
- Event producing "side", namely
transport.send(event)
- Event uploading "side"
I would prefer not to place everything "synchronization related" to a single file/class. The reason is: synchronization is a cross-cutting concern, namely not related to business logic but rather an implementation detail that crosses the boundaries of different domains(storage, scheduling, uploading). For this reason there is no good central place to put synchronization and doing so would result in a "god-object" that does everything. I don't think it is justified in general and in our case in particular, as we have just 2 places that need synchronization. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are other files which invoke runCriticalSection as well. Like the DefaultScheduler.java does the schedule and the decorate in one critical section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VinayGuthal this is what I was referring to in 1. Namely, this is what's called as a result of transport.send(event)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Defer to your judgement
...rc/main/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/Uploader.java
Outdated
Show resolved
Hide resolved
void logAndUpdateState(String backendName, int attemptNumber) { | ||
TransportBackend backend = backendRegistry.get(backendName); | ||
List<EventInternal> eventInternals = new ArrayList<>(); | ||
Iterable<PersistedEvent> persistedEvents = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Defer to your judgement
/test connected-check-changed |
@@ -67,6 +68,17 @@ static WorkScheduler workScheduler( | |||
} | |||
} | |||
|
|||
@Provides | |||
static Uploader uploader( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this as the uploader is annotated with @Inject
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please mark the executor above as @Singleton
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this as the uploader is annotated with
@Inject
Also please mark the executor above as@Singleton
These 2 are still not done, please change
...rc/main/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/Uploader.java
Outdated
Show resolved
Hide resolved
...java/com/google/android/datatransport/runtime/scheduling/jobscheduling/JobInfoScheduler.java
Show resolved
Hide resolved
368de01
to
d41f320
Compare
<service | ||
android:name=".scheduling.jobscheduling.JobInfoSchedulerService" | ||
android:label="JobScheduler Service" | ||
android:permission="android.permission.BIND_JOB_SERVICE" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add android:exported="false"
, also it seems we don't need the label(none of our services/content-providers are labeled)
@@ -67,6 +68,17 @@ static WorkScheduler workScheduler( | |||
} | |||
} | |||
|
|||
@Provides | |||
static Uploader uploader( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this as the uploader is annotated with
@Inject
Also please mark the executor above as@Singleton
These 2 are still not done, please change
Add uploader which the scheduler will use to upload to our sqlite database.