Skip to content

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

Merged
merged 17 commits into from
Apr 8, 2019
Merged

add uploader #327

merged 17 commits into from
Apr 8, 2019

Conversation

VinayGuthal
Copy link
Contributor

@VinayGuthal VinayGuthal commented Mar 29, 2019

Add uploader which the scheduler will use to upload to our sqlite database.

@googlebot googlebot added the cla: yes Override cla label Mar 29, 2019
void logAndUpdateState(String backendName, int attemptNumber) {
TransportBackend backend = backendRegistry.get(backendName);
List<EventInternal> eventInternals = new ArrayList<>();
Iterable<PersistedEvent> persistedEvents =
Copy link
Contributor

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

  1. 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?
  2. 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

Copy link
Member

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.

  1. 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?

Copy link
Contributor

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.

  1. 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 invoke runCtiticalSection ?

Copy link
Member

@vkryachko vkryachko Apr 1, 2019

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:

  1. Event producing "side", namely transport.send(event)
  2. 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?

Copy link
Contributor Author

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

Copy link
Member

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).

Copy link
Contributor

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

void logAndUpdateState(String backendName, int attemptNumber) {
TransportBackend backend = backendRegistry.get(backendName);
List<EventInternal> eventInternals = new ArrayList<>();
Iterable<PersistedEvent> persistedEvents =
Copy link
Contributor

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

@VinayGuthal
Copy link
Contributor Author

/test connected-check-changed

@@ -67,6 +68,17 @@ static WorkScheduler workScheduler(
}
}

@Provides
static Uploader uploader(
Copy link
Member

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

Copy link
Member

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

Copy link
Member

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

<service
android:name=".scheduling.jobscheduling.JobInfoSchedulerService"
android:label="JobScheduler Service"
android:permission="android.permission.BIND_JOB_SERVICE" >
Copy link
Member

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(
Copy link
Member

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

@VinayGuthal VinayGuthal merged commit 410feec into master Apr 8, 2019
@VinayGuthal VinayGuthal deleted the add_uploader branch April 8, 2019 14:29
@firebase firebase locked and limited conversation to collaborators Oct 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Override cla size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants