Search in sources :

Example 1 with SQLiteEventStore

use of com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore in project GreenHouse by utsanjan.

the class DaggerTransportRuntimeComponent method initialize.

private void initialize(Context setApplicationContextParam) {
    this.executorProvider = DoubleCheck.provider(ExecutionModule_ExecutorFactory.create());
    Factory create = InstanceFactory.create(setApplicationContextParam);
    this.setApplicationContextProvider = create;
    CreationContextFactory_Factory create2 = CreationContextFactory_Factory.create(create, TimeModule_EventClockFactory.create(), TimeModule_UptimeClockFactory.create());
    this.creationContextFactoryProvider = create2;
    this.metadataBackendRegistryProvider = DoubleCheck.provider(MetadataBackendRegistry_Factory.create(this.setApplicationContextProvider, create2));
    this.schemaManagerProvider = SchemaManager_Factory.create(this.setApplicationContextProvider, EventStoreModule_DbNameFactory.create(), EventStoreModule_SchemaVersionFactory.create());
    this.sQLiteEventStoreProvider = DoubleCheck.provider(SQLiteEventStore_Factory.create(TimeModule_EventClockFactory.create(), TimeModule_UptimeClockFactory.create(), EventStoreModule_StoreConfigFactory.create(), this.schemaManagerProvider));
    SchedulingConfigModule_ConfigFactory create3 = SchedulingConfigModule_ConfigFactory.create(TimeModule_EventClockFactory.create());
    this.configProvider = create3;
    SchedulingModule_WorkSchedulerFactory create4 = SchedulingModule_WorkSchedulerFactory.create(this.setApplicationContextProvider, this.sQLiteEventStoreProvider, create3, TimeModule_UptimeClockFactory.create());
    this.workSchedulerProvider = create4;
    Provider<Executor> provider = this.executorProvider;
    Provider provider2 = this.metadataBackendRegistryProvider;
    Provider<SQLiteEventStore> provider3 = this.sQLiteEventStoreProvider;
    this.defaultSchedulerProvider = DefaultScheduler_Factory.create(provider, provider2, create4, provider3, provider3);
    Provider<Context> provider4 = this.setApplicationContextProvider;
    Provider provider5 = this.metadataBackendRegistryProvider;
    Provider<SQLiteEventStore> provider6 = this.sQLiteEventStoreProvider;
    this.uploaderProvider = Uploader_Factory.create(provider4, provider5, provider6, this.workSchedulerProvider, this.executorProvider, provider6, TimeModule_EventClockFactory.create());
    Provider<Executor> provider7 = this.executorProvider;
    Provider<SQLiteEventStore> provider8 = this.sQLiteEventStoreProvider;
    this.workInitializerProvider = WorkInitializer_Factory.create(provider7, provider8, this.workSchedulerProvider, provider8);
    this.transportRuntimeProvider = DoubleCheck.provider(TransportRuntime_Factory.create(TimeModule_EventClockFactory.create(), TimeModule_UptimeClockFactory.create(), this.defaultSchedulerProvider, this.uploaderProvider, this.workInitializerProvider));
}
Also used : Context(android.content.Context) Executor(java.util.concurrent.Executor) SQLiteEventStore(com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore) WorkInitializer_Factory(com.google.android.datatransport.runtime.scheduling.jobscheduling.WorkInitializer_Factory) SchemaManager_Factory(com.google.android.datatransport.runtime.scheduling.persistence.SchemaManager_Factory) CreationContextFactory_Factory(com.google.android.datatransport.runtime.backends.CreationContextFactory_Factory) TimeModule_UptimeClockFactory(com.google.android.datatransport.runtime.time.TimeModule_UptimeClockFactory) EventStoreModule_DbNameFactory(com.google.android.datatransport.runtime.scheduling.persistence.EventStoreModule_DbNameFactory) DefaultScheduler_Factory(com.google.android.datatransport.runtime.scheduling.DefaultScheduler_Factory) SchedulingModule_WorkSchedulerFactory(com.google.android.datatransport.runtime.scheduling.SchedulingModule_WorkSchedulerFactory) EventStoreModule_SchemaVersionFactory(com.google.android.datatransport.runtime.scheduling.persistence.EventStoreModule_SchemaVersionFactory) EventStoreModule_StoreConfigFactory(com.google.android.datatransport.runtime.scheduling.persistence.EventStoreModule_StoreConfigFactory) InstanceFactory(dagger.internal.InstanceFactory) SchedulingConfigModule_ConfigFactory(com.google.android.datatransport.runtime.scheduling.SchedulingConfigModule_ConfigFactory) Uploader_Factory(com.google.android.datatransport.runtime.scheduling.jobscheduling.Uploader_Factory) SQLiteEventStore_Factory(com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore_Factory) TimeModule_EventClockFactory(com.google.android.datatransport.runtime.time.TimeModule_EventClockFactory) MetadataBackendRegistry_Factory(com.google.android.datatransport.runtime.backends.MetadataBackendRegistry_Factory) Factory(dagger.internal.Factory) CreationContextFactory_Factory(com.google.android.datatransport.runtime.backends.CreationContextFactory_Factory) SchedulingConfigModule_ConfigFactory(com.google.android.datatransport.runtime.scheduling.SchedulingConfigModule_ConfigFactory) SchedulingModule_WorkSchedulerFactory(com.google.android.datatransport.runtime.scheduling.SchedulingModule_WorkSchedulerFactory) Provider(javax.inject.Provider)

Example 2 with SQLiteEventStore

use of com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore in project firebase-android-sdk by firebase.

the class UploaderIntegrationTest method uploader_withPendingClientMetricsAndSuccessfulUpload_shouldResetCounters.

@Test
public void uploader_withPendingClientMetricsAndSuccessfulUpload_shouldResetCounters() {
    TransportRuntime runtime = TransportRuntime.getInstance();
    SQLiteEventStore store = component.getEventStore();
    String anotherTransport = "anotherTransport";
    store.recordLogEventDropped(20, LogEventDropped.Reason.CACHE_FULL, testTransport);
    store.recordLogEventDropped(1, LogEventDropped.Reason.MAX_RETRIES_REACHED, testTransport);
    store.recordLogEventDropped(1, LogEventDropped.Reason.INVALID_PAYLOD, anotherTransport);
    assertThat(store.loadClientMetrics().getLogSourceMetricsList()).hasSize(2);
    String mockBackendName = generateBackendName();
    byte[] mockExtras = "extras".getBytes(Charset.defaultCharset());
    when(mockRegistry.get(mockBackendName)).thenReturn(mockBackend);
    when(mockBackend.send(any())).thenReturn(BackendResponse.ok(1));
    Transport<String> transport = runtime.newFactory(new TestDestination(mockBackendName, mockExtras)).getTransport(testTransport, String.class, String::getBytes);
    EventInternal expectedEvent = EventInternal.builder().setEventMillis(3).setUptimeMillis(1).setTransportName(testTransport).setEncodedPayload(new EncodedPayload(PROTOBUF_ENCODING, "TelemetryData".getBytes(Charset.defaultCharset()))).build();
    EventInternal metricsEvent = component.getUploader().createMetricsEvent(mockBackend);
    transport.send(Event.ofTelemetry("TelemetryData"));
    verify(mockBackend, times(1)).send(eq(BackendRequest.builder().setEvents(Arrays.asList(expectedEvent, metricsEvent)).setExtras(mockExtras).build()));
    verify(spyScheduler, times(0)).schedule(any(), eq(2));
    assertThat(store.loadClientMetrics().getLogSourceMetricsList()).isEmpty();
}
Also used : SQLiteEventStore(com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore) Test(org.junit.Test)

Example 3 with SQLiteEventStore

use of com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore in project firebase-android-sdk by firebase.

the class UploaderIntegrationTest method uploader_withPendingClientMetricsAndInvalidPayload_shouldNotResetCounters.

@Test
public void uploader_withPendingClientMetricsAndInvalidPayload_shouldNotResetCounters() {
    TransportRuntime runtime = TransportRuntime.getInstance();
    SQLiteEventStore store = component.getEventStore();
    String anotherTransport = "anotherTransport";
    store.recordLogEventDropped(1, LogEventDropped.Reason.INVALID_PAYLOD, anotherTransport);
    assertThat(store.loadClientMetrics().getLogSourceMetricsList()).hasSize(1);
    String mockBackendName = generateBackendName();
    byte[] mockExtras = "extras".getBytes(Charset.defaultCharset());
    when(mockRegistry.get(mockBackendName)).thenReturn(mockBackend);
    when(mockBackend.send(any())).thenReturn(BackendResponse.invalidPayload());
    Transport<String> transport = runtime.newFactory(new TestDestination(mockBackendName, mockExtras)).getTransport(testTransport, String.class, String::getBytes);
    EventInternal expectedEvent = EventInternal.builder().setEventMillis(3).setUptimeMillis(1).setTransportName(testTransport).setEncodedPayload(new EncodedPayload(PROTOBUF_ENCODING, "TelemetryData".getBytes(Charset.defaultCharset()))).build();
    EventInternal metricsEvent = component.getUploader().createMetricsEvent(mockBackend);
    transport.send(Event.ofTelemetry("TelemetryData"));
    verify(mockBackend, times(1)).send(eq(BackendRequest.builder().setEvents(Arrays.asList(expectedEvent, metricsEvent)).setExtras(mockExtras).build()));
    verify(spyScheduler, times(0)).schedule(any(), eq(2));
    assertThat(store.loadClientMetrics().getLogSourceMetricsList()).hasSize(2);
}
Also used : SQLiteEventStore(com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore) Test(org.junit.Test)

Example 4 with SQLiteEventStore

use of com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore in project firebase-android-sdk by firebase.

the class UploaderIntegrationTest method uploader_withPendingClientMetricsAndSuccessfulUploadButNotLegacyTarget_shouldNotResetCounters.

@Test
public void uploader_withPendingClientMetricsAndSuccessfulUploadButNotLegacyTarget_shouldNotResetCounters() {
    TransportRuntime runtime = TransportRuntime.getInstance();
    SQLiteEventStore store = component.getEventStore();
    String anotherTransport = "anotherTransport";
    store.recordLogEventDropped(1, LogEventDropped.Reason.INVALID_PAYLOD, anotherTransport);
    assertThat(store.loadClientMetrics().getLogSourceMetricsList()).hasSize(1);
    String mockBackendName = generateBackendName();
    when(mockRegistry.get(mockBackendName)).thenReturn(mockBackend);
    when(mockBackend.send(any())).thenReturn(BackendResponse.ok(1));
    Transport<String> transport = runtime.newFactory(new TestDestination(mockBackendName, null)).getTransport(testTransport, String.class, String::getBytes);
    EventInternal expectedEvent = EventInternal.builder().setEventMillis(3).setUptimeMillis(1).setTransportName(testTransport).setEncodedPayload(new EncodedPayload(PROTOBUF_ENCODING, "TelemetryData".getBytes(Charset.defaultCharset()))).build();
    transport.send(Event.ofTelemetry("TelemetryData"));
    verify(mockBackend, times(1)).send(eq(BackendRequest.create(Collections.singletonList(expectedEvent))));
    verify(spyScheduler, times(0)).schedule(any(), eq(2));
    assertThat(store.loadClientMetrics().getLogSourceMetricsList()).hasSize(1);
}
Also used : SQLiteEventStore(com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore) Test(org.junit.Test)

Example 5 with SQLiteEventStore

use of com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore in project firebase-android-sdk by firebase.

the class UploaderIntegrationTest method uploader_invalidPayload_shouldNotReschedule.

@Test
public void uploader_invalidPayload_shouldNotReschedule() {
    TransportRuntime runtime = TransportRuntime.getInstance();
    SQLiteEventStore store = component.getEventStore();
    String mockBackendName = generateBackendName();
    byte[] mockExtras = "extras".getBytes(Charset.defaultCharset());
    when(mockRegistry.get(mockBackendName)).thenReturn(mockBackend);
    when(mockBackend.send(any())).thenReturn(BackendResponse.invalidPayload());
    Transport<String> transport = runtime.newFactory(new TestDestination(mockBackendName, mockExtras)).getTransport(testTransport, String.class, String::getBytes);
    transport.send(Event.ofTelemetry("TelemetryData"));
    verify(spyScheduler, times(0)).schedule(any(), eq(2));
    List<LogSourceMetrics> logSourceMetrics = store.loadClientMetrics().getLogSourceMetricsList();
    assertThat(logSourceMetrics).hasSize(1);
    LogSourceMetrics metrics = logSourceMetrics.get(0);
    List<LogEventDropped> logEventDroppedList = metrics.getLogEventDroppedList();
    assertThat(logEventDroppedList).hasSize(1);
    LogEventDropped logEventDropped = logEventDroppedList.get(0);
    assertThat(logEventDropped.getEventsDroppedCount()).isEqualTo(1);
    assertThat(logEventDropped.getReason()).isEqualTo(LogEventDropped.Reason.INVALID_PAYLOD);
}
Also used : LogSourceMetrics(com.google.android.datatransport.runtime.firebase.transport.LogSourceMetrics) LogEventDropped(com.google.android.datatransport.runtime.firebase.transport.LogEventDropped) SQLiteEventStore(com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore) Test(org.junit.Test)

Aggregations

SQLiteEventStore (com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore)6 Test (org.junit.Test)5 Context (android.content.Context)1 CreationContextFactory_Factory (com.google.android.datatransport.runtime.backends.CreationContextFactory_Factory)1 MetadataBackendRegistry_Factory (com.google.android.datatransport.runtime.backends.MetadataBackendRegistry_Factory)1 LogEventDropped (com.google.android.datatransport.runtime.firebase.transport.LogEventDropped)1 LogSourceMetrics (com.google.android.datatransport.runtime.firebase.transport.LogSourceMetrics)1 DefaultScheduler_Factory (com.google.android.datatransport.runtime.scheduling.DefaultScheduler_Factory)1 SchedulingConfigModule_ConfigFactory (com.google.android.datatransport.runtime.scheduling.SchedulingConfigModule_ConfigFactory)1 SchedulingModule_WorkSchedulerFactory (com.google.android.datatransport.runtime.scheduling.SchedulingModule_WorkSchedulerFactory)1 Uploader_Factory (com.google.android.datatransport.runtime.scheduling.jobscheduling.Uploader_Factory)1 WorkInitializer_Factory (com.google.android.datatransport.runtime.scheduling.jobscheduling.WorkInitializer_Factory)1 EventStoreModule_DbNameFactory (com.google.android.datatransport.runtime.scheduling.persistence.EventStoreModule_DbNameFactory)1 EventStoreModule_SchemaVersionFactory (com.google.android.datatransport.runtime.scheduling.persistence.EventStoreModule_SchemaVersionFactory)1 EventStoreModule_StoreConfigFactory (com.google.android.datatransport.runtime.scheduling.persistence.EventStoreModule_StoreConfigFactory)1 SQLiteEventStore_Factory (com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore_Factory)1 SchemaManager_Factory (com.google.android.datatransport.runtime.scheduling.persistence.SchemaManager_Factory)1 TimeModule_EventClockFactory (com.google.android.datatransport.runtime.time.TimeModule_EventClockFactory)1 TimeModule_UptimeClockFactory (com.google.android.datatransport.runtime.time.TimeModule_UptimeClockFactory)1 Factory (dagger.internal.Factory)1