Search in sources :

Example 6 with TableRateLimiter

use of org.apache.samza.table.remote.TableRateLimiter in project samza by apache.

the class TestRemoteTableEndToEnd method testCatchWriterException.

@Test(expected = SamzaException.class)
public void testCatchWriterException() {
    TableReadFunction<String, String> reader = mock(TableReadFunction.class);
    TableWriteFunction<String, String, Void> writer = mock(TableWriteFunction.class);
    CompletableFuture<String> future = new CompletableFuture<>();
    future.completeExceptionally(new RuntimeException("Expected test exception"));
    doReturn(future).when(writer).putAsync(anyString(), any());
    TableRateLimiter rateLimitHelper = mock(TableRateLimiter.class);
    RemoteTable<String, String, Void> table = new RemoteTable<>("table1", reader, writer, rateLimitHelper, rateLimitHelper, rateLimitHelper, Executors.newSingleThreadExecutor(), null, null, null, null, null, null);
    table.init(createMockContext());
    table.put("abc", "efg");
}
Also used : TableRateLimiter(org.apache.samza.table.remote.TableRateLimiter) CompletableFuture(java.util.concurrent.CompletableFuture) RemoteTable(org.apache.samza.table.remote.RemoteTable) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

TableRateLimiter (org.apache.samza.table.remote.TableRateLimiter)6 Test (org.junit.Test)6 RemoteTable (org.apache.samza.table.remote.RemoteTable)5 Matchers.anyString (org.mockito.Matchers.anyString)4 CompletableFuture (java.util.concurrent.CompletableFuture)3 AsyncReadWriteUpdateTable (org.apache.samza.table.AsyncReadWriteUpdateTable)2 AsyncRemoteTable (org.apache.samza.table.remote.AsyncRemoteTable)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 SamzaException (org.apache.samza.SamzaException)1 Config (org.apache.samza.config.Config)1 JavaTableConfig (org.apache.samza.config.JavaTableConfig)1 MapConfig (org.apache.samza.config.MapConfig)1 TaskName (org.apache.samza.container.TaskName)1 ContainerContext (org.apache.samza.context.ContainerContext)1 Context (org.apache.samza.context.Context)1 JobContext (org.apache.samza.context.JobContext)1 TaskContextImpl (org.apache.samza.context.TaskContextImpl)1