Java Code Examples for io.debezium.config.Configuration#from()

The following examples show how to use io.debezium.config.Configuration#from() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueueProcessorTest.java    From debezium-incubator with Apache License 2.0 6 votes vote down vote up
@Test
public void testProcessChangeRecords() throws Exception {
    doNothing().when(emitter).emit(any());

    int recordSize = 5;
    ChangeEventQueue<Event> queue = context.getQueue();
    for (int i = 0; i < recordSize; i++) {
        CassandraConnectorConfig config = new CassandraConnectorConfig(Configuration.from(new Properties()));
        SourceInfo sourceInfo = new SourceInfo(config, DatabaseDescriptor.getClusterName(),
                new OffsetPosition("CommitLog-6-123.log", i),
                new KeyspaceTable(TEST_KEYSPACE, "cdc_table"), false,
                Conversions.toInstantFromMicros(System.currentTimeMillis() * 1000));
        Record record = new ChangeRecord(sourceInfo, new RowData(), Schema.INT32_SCHEMA, Schema.INT32_SCHEMA, Record.Operation.INSERT, false);
        queue.enqueue(record);
    }

    assertEquals(recordSize, queue.totalCapacity() - queue.remainingCapacity());
    queueProcessor.process();
    verify(emitter, times(recordSize)).emit(any());
    assertEquals(queue.totalCapacity(), queue.remainingCapacity());
}
 
Example 2
Source File: QueueProcessorTest.java    From debezium-incubator with Apache License 2.0 6 votes vote down vote up
@Test
public void testProcessTombstoneRecords() throws Exception {
    doNothing().when(emitter).emit(any());

    int recordSize = 5;
    ChangeEventQueue<Event> queue = context.getQueue();
    for (int i = 0; i < recordSize; i++) {
        CassandraConnectorConfig config = new CassandraConnectorConfig(Configuration.from(new Properties()));
        SourceInfo sourceInfo = new SourceInfo(config, DatabaseDescriptor.getClusterName(),
                new OffsetPosition("CommitLog-6-123.log", i),
                new KeyspaceTable(TEST_KEYSPACE, "cdc_table"), false,
                Conversions.toInstantFromMicros(System.currentTimeMillis() * 1000));
        Record record = new TombstoneRecord(sourceInfo, new RowData(), Schema.INT32_SCHEMA);
        queue.enqueue(record);
    }

    assertEquals(recordSize, queue.totalCapacity() - queue.remainingCapacity());
    queueProcessor.process();
    verify(emitter, times(recordSize)).emit(any());
    assertEquals(queue.totalCapacity(), queue.remainingCapacity());
}
 
Example 3
Source File: CassandraConnectorConfigTest.java    From debezium-incubator with Apache License 2.0 6 votes vote down vote up
@Test
public void testDefaultConfigs() {
    Properties props = new Properties();
    CassandraConnectorConfig config = new CassandraConnectorConfig(Configuration.from(props));
    assertEquals(CassandraConnectorConfig.DEFAULT_SNAPSHOT_CONSISTENCY, config.snapshotConsistencyLevel().name().toUpperCase());
    assertEquals(CassandraConnectorConfig.DEFAULT_HTTP_PORT, config.httpPort());
    assertArrayEquals(CassandraConnectorConfig.DEFAULT_CASSANDRA_HOST.split(","), config.cassandraHosts());
    assertEquals(CassandraConnectorConfig.DEFAULT_CASSANDRA_PORT, config.cassandraPort());
    assertEquals(CassandraConnectorConfig.DEFAULT_MAX_QUEUE_SIZE, config.maxQueueSize());
    assertEquals(CassandraConnectorConfig.DEFAULT_MAX_BATCH_SIZE, config.maxBatchSize());
    assertEquals(CassandraConnectorConfig.DEFAULT_POLL_INTERVAL_MS, config.pollIntervalMs().toMillis());
    assertEquals(CassandraConnectorConfig.DEFAULT_MAX_OFFSET_FLUSH_SIZE, config.maxOffsetFlushSize());
    assertEquals(CassandraConnectorConfig.DEFAULT_OFFSET_FLUSH_INTERVAL_MS, config.offsetFlushIntervalMs().toMillis());
    assertEquals(CassandraConnectorConfig.DEFAULT_SCHEMA_POLL_INTERVAL_MS, config.schemaPollIntervalMs().toMillis());
    assertEquals(CassandraConnectorConfig.DEFAULT_CDC_DIR_POLL_INTERVAL_MS, config.cdcDirPollIntervalMs().toMillis());
    assertEquals(CassandraConnectorConfig.DEFAULT_SNAPSHOT_POLL_INTERVAL_MS, config.snapshotPollIntervalMs().toMillis());
    assertEquals(CassandraConnectorConfig.DEFAULT_COMMIT_LOG_POST_PROCESSING_ENABLED, config.postProcessEnabled());
    assertEquals(CassandraConnectorConfig.DEFAULT_COMMIT_LOG_TRANSFER_CLASS, config.getCommitLogTransfer().getClass().getName());
    assertFalse(config.cassandraSslEnabled());
    assertFalse(config.tombstonesOnDelete());
    assertEquals(CassandraConnectorConfig.SnapshotMode.INITIAL, config.snapshotMode());
    assertEquals(CassandraConnectorConfig.DEFAULT_LATEST_COMMIT_LOG_ONLY, config.latestCommitLogOnly());
}
 
Example 4
Source File: CassandraConnectorConfigTest.java    From debezium-incubator with Apache License 2.0 4 votes vote down vote up
private CassandraConnectorConfig buildTaskConfigs(HashMap<String, Object> map) {
    return new CassandraConnectorConfig(Configuration.from(map));
}
 
Example 5
Source File: CassandraConnectorConfigTest.java    From debezium-incubator with Apache License 2.0 4 votes vote down vote up
private CassandraConnectorConfig buildTaskConfig(String key, Object value) {
    Properties props = new Properties();
    props.put(key, value);
    return new CassandraConnectorConfig(Configuration.from(props));
}
 
Example 6
Source File: FileOffsetWriterTest.java    From debezium-incubator with Apache License 2.0 4 votes vote down vote up
private ChangeRecord generateRecord(boolean markOffset, boolean isSnapshot, OffsetPosition offsetPosition, KeyspaceTable keyspaceTable) {
    CassandraConnectorConfig config = new CassandraConnectorConfig(Configuration.from(new Properties()));
    SourceInfo sourceInfo = new SourceInfo(config, "test-cluster", offsetPosition, keyspaceTable,
            isSnapshot, Conversions.toInstantFromMicros(System.currentTimeMillis() * 1000));
    return new ChangeRecord(sourceInfo, new RowData(), Schema.INT32_SCHEMA, Schema.INT32_SCHEMA, Record.Operation.INSERT, markOffset);
}
 
Example 7
Source File: EmbeddedCassandraConnectorTestBase.java    From debezium-incubator with Apache License 2.0 4 votes vote down vote up
/**
 * Generate a task context with default test configs
 */
protected static CassandraConnectorContext generateTaskContext() throws Exception {
    Properties defaults = generateDefaultConfigMap();
    return new CassandraConnectorContext(new CassandraConnectorConfig(Configuration.from(defaults)));
}
 
Example 8
Source File: EmbeddedCassandraConnectorTestBase.java    From debezium-incubator with Apache License 2.0 4 votes vote down vote up
/**
 * General a task context with default and custom test configs
 */
protected static CassandraConnectorContext generateTaskContext(Map<String, Object> configs) throws Exception {
    Properties defaults = generateDefaultConfigMap();
    defaults.putAll(configs);
    return new CassandraConnectorContext(new CassandraConnectorConfig(Configuration.from(defaults)));
}