use of io.mantisrx.runtime.parameter.Parameters in project mantis by Netflix.
the class MantisKafkaConsumerConfigTest method testDefaultConsumerConfig.
@Test
public void testDefaultConsumerConfig() {
Context context = mock(Context.class);
Parameters params = ParameterTestUtils.createParameters();
when(context.getParameters()).then((Answer<Parameters>) invocation -> params);
MantisKafkaConsumerConfig mantisKafkaConsumerConfig = new MantisKafkaConsumerConfig(context);
Map<String, Object> consumerProperties = mantisKafkaConsumerConfig.getConsumerProperties();
assertEquals(Boolean.valueOf(MantisKafkaConsumerConfig.DEFAULT_AUTO_COMMIT_ENABLED), consumerProperties.get(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG));
assertEquals(MantisKafkaConsumerConfig.DEFAULT_AUTO_COMMIT_INTERVAL_MS, consumerProperties.get(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG));
assertEquals(MantisKafkaConsumerConfig.DEFAULT_AUTO_OFFSET_RESET, consumerProperties.get(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG));
assertEquals(MantisKafkaConsumerConfig.DEFAULT_FETCH_MAX_WAIT_MS, consumerProperties.get(ConsumerConfig.FETCH_MAX_WAIT_MS_CONFIG));
assertEquals(MantisKafkaConsumerConfig.DEFAULT_FETCH_MIN_BYTES, consumerProperties.get(ConsumerConfig.FETCH_MIN_BYTES_CONFIG));
assertEquals(MantisKafkaConsumerConfig.DEFAULT_HEARTBEAT_INTERVAL_MS, consumerProperties.get(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG));
assertEquals(MantisKafkaConsumerConfig.DEFAULT_SESSION_TIMEOUT_MS, consumerProperties.get(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG));
assertEquals(MantisKafkaConsumerConfig.DEFAULT_KEY_DESERIALIZER, consumerProperties.get(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG));
assertEquals(MantisKafkaConsumerConfig.DEFAULT_VALUE_DESERIALIZER, consumerProperties.get(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG));
assertEquals(MantisKafkaConsumerConfig.DEFAULT_MAX_PARTITION_FETCH_BYTES, consumerProperties.get(ConsumerConfig.MAX_PARTITION_FETCH_BYTES_CONFIG));
assertEquals(MantisKafkaConsumerConfig.DEFAULT_RECEIVE_BUFFER_BYTES, consumerProperties.get(ConsumerConfig.RECEIVE_BUFFER_CONFIG));
assertEquals(MantisKafkaConsumerConfig.DEFAULT_SEND_BUFFER_BYTES, consumerProperties.get(ConsumerConfig.SEND_BUFFER_CONFIG));
assertEquals(Arrays.asList(MantisKafkaConsumerConfig.DEFAULT_BOOTSTRAP_SERVERS_CONFIG), consumerProperties.get(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG));
assertEquals(Arrays.asList(JmxReporter.class.getName()), consumerProperties.get(ConsumerConfig.METRIC_REPORTER_CLASSES_CONFIG));
assertEquals(Arrays.asList(RangeAssignor.class.getName()), consumerProperties.get(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG));
assertEquals(MantisKafkaConsumerConfig.getGroupId(), consumerProperties.get(ConsumerConfig.GROUP_ID_CONFIG));
assertEquals(MantisKafkaConsumerConfig.DEFAULT_MAX_POLL_INTERVAL_MS, consumerProperties.get(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG));
assertEquals(MantisKafkaConsumerConfig.DEFAULT_MAX_POLL_RECORDS, consumerProperties.get(ConsumerConfig.MAX_POLL_RECORDS_CONFIG));
assertEquals(MantisKafkaConsumerConfig.DEFAULT_REQUEST_TIMEOUT_MS, consumerProperties.get(ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG));
}
use of io.mantisrx.runtime.parameter.Parameters in project mantis by Netflix.
the class FixedIcebergWriterPoolTest method setUp.
@BeforeEach
void setUp() {
Parameters parameters = StageOverrideParameters.newParameters();
WriterConfig config = new WriterConfig(parameters, mock(Configuration.class));
IcebergWriterFactory factory = mock(IcebergWriterFactory.class);
this.writer = mock(IcebergWriter.class);
when(this.writer.length()).thenReturn(Long.MAX_VALUE);
when(factory.newIcebergWriter()).thenReturn(this.writer);
this.writerPool = spy(new FixedIcebergWriterPool(factory, config.getWriterFlushFrequencyBytes(), config.getWriterMaximumPoolSize()));
this.record = GenericRecord.create(SCHEMA);
this.record.setField("id", 1);
// Identity partitioning (without explicitly using a Partitioner).
this.partition = this.record.copy();
}
use of io.mantisrx.runtime.parameter.Parameters in project mantis by Netflix.
the class IcebergWriterStageTest method setUp.
@BeforeEach
void setUp() {
record = GenericRecord.create(SCHEMA);
record.setField("id", 1);
this.scheduler = new TestScheduler();
this.subscriber = new TestSubscriber<>();
// Writer
Parameters parameters = StageOverrideParameters.newParameters();
WriterConfig config = new WriterConfig(parameters, mock(Configuration.class));
WriterMetrics metrics = new WriterMetrics();
IcebergWriterFactory factory = FakeIcebergWriter::new;
this.writerPool = spy(new FixedIcebergWriterPool(factory, config.getWriterFlushFrequencyBytes(), config.getWriterMaximumPoolSize()));
doReturn(Collections.singleton(record)).when(writerPool).getFlushableWriters();
this.partitioner = mock(Partitioner.class);
when(partitioner.partition(record)).thenReturn(record);
this.transformer = new IcebergWriterStage.Transformer(config, metrics, this.writerPool, this.partitioner, this.scheduler, this.scheduler);
// Catalog
ServiceLocator serviceLocator = mock(ServiceLocator.class);
when(serviceLocator.service(Configuration.class)).thenReturn(mock(Configuration.class));
this.catalog = mock(Catalog.class);
Table table = mock(Table.class);
PartitionSpec spec = PartitionSpec.builderFor(SCHEMA).identity("id").build();
when(table.spec()).thenReturn(spec);
when(this.catalog.loadTable(any())).thenReturn(table);
when(serviceLocator.service(Catalog.class)).thenReturn(this.catalog);
when(serviceLocator.service(PartitionerFactory.class)).thenReturn(mock(PartitionerFactory.class));
// Mantis Context
this.context = mock(Context.class);
when(this.context.getParameters()).thenReturn(parameters);
when(this.context.getServiceLocator()).thenReturn(serviceLocator);
when(this.context.getWorkerInfo()).thenReturn(new WorkerInfo("testJobName", "jobId", 1, 1, 1, MantisJobDurationType.Perpetual, "host"));
// Flow
Observable<Record> source = Observable.interval(1, TimeUnit.MILLISECONDS, this.scheduler).map(i -> record);
this.flow = source.compose(this.transformer);
}
Aggregations