io.debezium.config.Field类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(550)

本文整理了Java中io.debezium.config.Field类的一些代码示例,展示了Field类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Field类的具体详情如下:
包路径:io.debezium.config.Field
类名称:Field

Field介绍

[英]An immutable definition of a field that make appear within a Configuration instance.
[中]字段的不可变定义,使其显示在配置实例中。

代码示例

代码示例来源:origin: debezium/debezium

/**
 * Create and return a new Field instance that is a copy of this field but with the given default value.
 * 
 * @param defaultValueGenerator the supplier for the new default value for the new field, called whenever a default value
 *            is needed
 * @return the new field; never null
 */
public Field withDefault(BooleanSupplier defaultValueGenerator) {
  return new Field(name(), displayName(), type(), width, description(), importance(), dependents,
      defaultValueGenerator::getAsBoolean, validator, recommender);
}

代码示例来源:origin: debezium/debezium

protected static ConfigDef configDef() {
  ConfigDef config = new ConfigDef();
  Field.group(config, "MongoDB", HOSTS, USER, PASSWORD, LOGICAL_NAME, CONNECT_BACKOFF_INITIAL_DELAY_MS,
        CONNECT_BACKOFF_MAX_DELAY_MS, MAX_FAILED_CONNECTIONS, AUTO_DISCOVER_MEMBERS,
        SSL_ENABLED, SSL_ALLOW_INVALID_HOSTNAMES);
  Field.group(config, "Events", DATABASE_WHITELIST, DATABASE_BLACKLIST, COLLECTION_WHITELIST, COLLECTION_BLACKLIST, FIELD_BLACKLIST, FIELD_RENAMES, CommonConnectorConfig.TOMBSTONES_ON_DELETE);
  Field.group(config, "Connector", MAX_COPY_THREADS, CommonConnectorConfig.MAX_QUEUE_SIZE,
      CommonConnectorConfig.MAX_BATCH_SIZE, CommonConnectorConfig.POLL_INTERVAL_MS,
      CommonConnectorConfig.SNAPSHOT_DELAY_MS);
  return config;
}

代码示例来源:origin: debezium/debezium

/**
 * Add this field to the given configuration definition.
 * 
 * @param configDef the definition of the configuration; may be null if none of the fields are to be added
 * @param groupName the name of the group; may be null
 * @param fields the fields to be added as a group to the definition of the configuration
 * @return the updated configuration; never null
 */
public static ConfigDef group(ConfigDef configDef, String groupName, Field... fields) {
  if (configDef != null) {
    if (groupName != null) {
      for (int i = 0; i != fields.length; ++i) {
        Field f = fields[i];
        configDef.define(f.name(), f.type(), f.defaultValue(), null, f.importance(), f.description(),
                 groupName, i + 1, f.width(), f.displayName(), f.dependents(), null);
      }
    } else {
      for (int i = 0; i != fields.length; ++i) {
        Field f = fields[i];
        configDef.define(f.name(), f.type(), f.defaultValue(), null, f.importance(), f.description(),
                 null, 1, f.width(), f.displayName(), f.dependents(), null);
      }
    }
  }
  return configDef;
}

代码示例来源:origin: debezium/debezium

/**
 * Get the string value associated with the given field, returning the field's default value if there is no such key-value
 * pair in this configuration.
 *
 * @param field the field; may not be null
 * @return the configuration's value for the field, or the field's {@link Field#defaultValue() default value} if there is no
 *         such key-value pair in the configuration
 */
default String getString(Field field) {
  return getString(field.name(), field.defaultValueAsString());
}

代码示例来源:origin: debezium/debezium

private Set(Collection<Field> fields) {
  Map<String, Field> all = new LinkedHashMap<>();
  fields.forEach(field -> {
    if (field != null) {
      all.put(field.name(), field);
    }
  });
  this.fieldsByName = Collections.unmodifiableMap(all);
}

代码示例来源:origin: debezium/debezium

private <T> void validateField(Config config, Field field, T expectedValue) {
  assertNoConfigurationErrors(config, field);
  Object actualValue = configValue(config, field.name()).value();
  if (actualValue == null) {
    actualValue = field.defaultValue();
  }
  if (expectedValue == null) {
    assertThat(actualValue).isNull();
  } else {
    if (expectedValue instanceof EnumeratedValue) {
      assertThat(((EnumeratedValue) expectedValue).getValue()).isEqualTo(actualValue.toString());
    }
    else {
      assertThat(expectedValue).isEqualTo(actualValue);
    }
  }
}

代码示例来源:origin: debezium/debezium

/**
 * Get the string representation of the default value of the field.
 * 
 * @return the default value, or {@code null} if there is no default value
 */
public String defaultValueAsString() {
  Object defaultValue = defaultValue();
  return defaultValue != null ? defaultValue.toString() : null;
}

代码示例来源:origin: debezium/debezium

protected SnapshotMode snapshotMode() {
  String value = config.getString(MySqlConnectorConfig.SNAPSHOT_MODE);
  return SnapshotMode.parse(value, MySqlConnectorConfig.SNAPSHOT_MODE.defaultValueAsString());
}

代码示例来源:origin: debezium/debezium

@Override
public Builder changeString(Field field, Function<String, String> function) {
  return changeString(field.name(), field.defaultValueAsString(), function);
}

代码示例来源:origin: debezium/debezium

/**
 * Associate the given value with the key of the specified field.
 *
 * @param field the predefined field for the key
 * @param value the value
 * @return this builder object so methods can be chained together; never null
 */
default B with(Field field, Object value) {
  return with(field.name(), value);
}

代码示例来源:origin: io.debezium/debezium-connector-postgres

private <T> void validateField(Config config, Field field, T expectedValue) {
  assertNoConfigurationErrors(config, field);
  Object actualValue = configValue(config, field.name()).value();
  if (actualValue == null) {
    actualValue = field.defaultValue();
  }
  if (expectedValue == null) {
    assertThat(actualValue).isNull();
  } else {
    if (expectedValue instanceof EnumeratedValue) {
      assertThat(((EnumeratedValue) expectedValue).getValue()).isEqualTo(actualValue.toString());
    }
    else {
      assertThat(expectedValue).isEqualTo(actualValue);
    }
  }
}

代码示例来源:origin: debezium/debezium

@Before
public void beforeEach() {
  hostname = System.getProperty("database.hostname");
  if (hostname == null) hostname = "localhost";
  String portStr = System.getProperty("database.port");
  if (portStr != null) {
    port = Integer.parseInt(portStr);
  } else {
    port = (Integer) MySqlConnectorConfig.PORT.defaultValue();
  }
  username = "snapper";
  password = "snapperpass";
  serverId = 18965;
  serverName = "logical_server_name";
  databaseName = "connector_test_ro";
  Testing.Files.delete(DB_HISTORY_PATH);
}

代码示例来源:origin: debezium/debezium

public SqlServerConnectorConfig(Configuration config) {
  super(config, config.getString(LOGICAL_NAME), new SystemTablesPredicate(), x -> x.schema() + "." + x.table());
  this.databaseName = config.getString(DATABASE_NAME);
  this.snapshotMode = SnapshotMode.parse(config.getString(SNAPSHOT_MODE), SNAPSHOT_MODE.defaultValueAsString());
  this.snapshotIsolationMode = SnapshotIsolationMode.parse(config.getString(SNAPSHOT_ISOLATION_MODE), SNAPSHOT_ISOLATION_MODE.defaultValueAsString());
  this.columnFilter = Predicates.excludes(config.getString(RelationalDatabaseConnectorConfig.COLUMN_BLACKLIST),
      columnId -> String.format("%s.%s.%s", columnId.schema(), columnId.table(), columnId.columnName()));
}

代码示例来源:origin: debezium/debezium

/**
 * Create and return a new Field instance that is a copy of this field but with the given default value.
 * 
 * @param defaultValueGenerator the supplier for the new default value for the new field, called whenever a default value
 *            is needed
 * @return the new field; never null
 */
public Field withDefault(IntSupplier defaultValueGenerator) {
  return new Field(name(), displayName(), type(), width, description(), importance(), dependents,
      defaultValueGenerator::getAsInt, validator, recommender);
}

代码示例来源:origin: debezium/debezium

protected static void assertConfigDefIsValid(Connector connector, io.debezium.config.Field.Set fields) {
    ConfigDef configDef = connector.config();
    assertThat(configDef).isNotNull();
    fields.forEach(expected -> {
      assertThat(configDef.names()).contains(expected.name());
      ConfigKey key = configDef.configKeys().get(expected.name());
      assertThat(key).isNotNull();
      assertThat(key.name).isEqualTo(expected.name());
      assertThat(key.displayName).isEqualTo(expected.displayName());
      assertThat(key.importance).isEqualTo(expected.importance());
      assertThat(key.documentation).isEqualTo(expected.description());
      assertThat(key.type).isEqualTo(expected.type());
      if (expected.equals(MySqlConnectorConfig.DATABASE_HISTORY) || expected.equals(MySqlConnectorConfig.JDBC_DRIVER)) {
        assertThat(((Class<?>) key.defaultValue).getName()).isEqualTo((String) expected.defaultValue());
      } else if (!expected.equals(MySqlConnectorConfig.SERVER_ID)) {
        assertThat(key.defaultValue).isEqualTo(expected.defaultValue());
      }
      assertThat(key.dependents).isEqualTo(expected.dependents());
      assertThat(key.width).isNotNull();
      assertThat(key.group).isNotNull();
      assertThat(key.orderInGroup).isGreaterThan(0);
      assertThat(key.validator).isNull();
      assertThat(key.recommender).isNull();
    });
  }
}

代码示例来源:origin: debezium/debezium

/**
 * Get the string value associated with the given field, returning the field's default value if there is no such key-value
 * pair in this configuration.
 *
 * @param field the field; may not be null
 * @param defaultValue the default value
 * @return the configuration's value for the field, or the field's {@link Field#defaultValue() default value} if there is no
 *         such key-value pair in the configuration
 */
default String getString(Field field, String defaultValue) {
  return getString(field.name(), () -> {
    String value = field.defaultValueAsString();
    return value != null ? value : defaultValue;
  });
}

代码示例来源:origin: debezium/debezium

/**
 * Associate the given value with the key of the specified field.
 *
 * @param field the predefined field for the key
 * @param value the value
 * @return this builder object so methods can be chained together; never null
 */
default B with(Field field, long value) {
  return with(field.name(), value);
}

代码示例来源:origin: debezium/debezium

public static ConfigDef configDef() {
  ConfigDef config = new ConfigDef();
  Field.group(config, "SQL Server", LOGICAL_NAME, DATABASE_NAME, SNAPSHOT_MODE);
  Field.group(config, "History Storage", KafkaDatabaseHistory.BOOTSTRAP_SERVERS,
      KafkaDatabaseHistory.TOPIC, KafkaDatabaseHistory.RECOVERY_POLL_ATTEMPTS,
      KafkaDatabaseHistory.RECOVERY_POLL_INTERVAL_MS, HistorizedRelationalDatabaseConnectorConfig.DATABASE_HISTORY);
  Field.group(config, "Events", RelationalDatabaseConnectorConfig.TABLE_WHITELIST,
      RelationalDatabaseConnectorConfig.TABLE_BLACKLIST,
      RelationalDatabaseConnectorConfig.COLUMN_BLACKLIST,
      RelationalDatabaseConnectorConfig.TABLE_IGNORE_BUILTIN,
      Heartbeat.HEARTBEAT_INTERVAL, Heartbeat.HEARTBEAT_TOPICS_PREFIX
  );
  Field.group(config, "Connector", CommonConnectorConfig.POLL_INTERVAL_MS, CommonConnectorConfig.MAX_BATCH_SIZE,
      CommonConnectorConfig.MAX_QUEUE_SIZE, CommonConnectorConfig.SNAPSHOT_DELAY_MS);
  return config;
}

代码示例来源:origin: io.debezium/debezium-core

/**
 * Get the string representation of the default value of the field.
 * 
 * @return the default value, or {@code null} if there is no default value
 */
public String defaultValueAsString() {
  Object defaultValue = defaultValue();
  return defaultValue != null ? defaultValue.toString() : null;
}

代码示例来源:origin: debezium/debezium

assertThat(context.getConnectorConfig().getLogicalName()).isEqualTo(serverName);
assertThat("" + context.includeSchemaChangeRecords()).isEqualTo(MySqlConnectorConfig.INCLUDE_SCHEMA_CHANGES.defaultValueAsString());
assertThat("" + context.includeSqlQuery()).isEqualTo(MySqlConnectorConfig.INCLUDE_SQL_QUERY.defaultValueAsString());
assertThat("" + context.getConnectorConfig().getMaxBatchSize()).isEqualTo(MySqlConnectorConfig.MAX_BATCH_SIZE.defaultValueAsString());
assertThat("" + context.getConnectorConfig().getMaxQueueSize()).isEqualTo(MySqlConnectorConfig.MAX_QUEUE_SIZE.defaultValueAsString());
assertThat("" + context.getConnectorConfig().getPollInterval().toMillis()).isEqualTo(MySqlConnectorConfig.POLL_INTERVAL_MS.defaultValueAsString());
assertThat("" + context.snapshotMode().getValue()).isEqualTo(MySqlConnectorConfig.SNAPSHOT_MODE.defaultValueAsString());

相关文章