本文整理汇总了Java中org.apache.kafka.common.config.ConfigDef.Width类的典型用法代码示例。如果您正苦于以下问题:Java Width类的具体用法?Java Width怎么用?Java Width使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Width类属于org.apache.kafka.common.config.ConfigDef包,在下文中一共展示了Width类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: configDef
import org.apache.kafka.common.config.ConfigDef.Width; //导入依赖的package包/类
public static ConfigDef configDef() {
return new ConfigDef()
.define(NAME_CONFIG, Type.STRING, Importance.HIGH, NAME_DOC, COMMON_GROUP, 1, Width.MEDIUM, NAME_DISPLAY)
.define(CONNECTOR_CLASS_CONFIG, Type.STRING, Importance.HIGH, CONNECTOR_CLASS_DOC, COMMON_GROUP, 2, Width.LONG, CONNECTOR_CLASS_DISPLAY)
.define(TASKS_MAX_CONFIG, Type.INT, TASKS_MAX_DEFAULT, atLeast(TASKS_MIN_CONFIG), Importance.HIGH, TASKS_MAX_DOC, COMMON_GROUP, 3, Width.SHORT, TASK_MAX_DISPLAY)
.define(KEY_CONVERTER_CLASS_CONFIG, Type.CLASS, null, Importance.LOW, KEY_CONVERTER_CLASS_DOC, COMMON_GROUP, 4, Width.SHORT, KEY_CONVERTER_CLASS_DISPLAY)
.define(VALUE_CONVERTER_CLASS_CONFIG, Type.CLASS, null, Importance.LOW, VALUE_CONVERTER_CLASS_DOC, COMMON_GROUP, 5, Width.SHORT, VALUE_CONVERTER_CLASS_DISPLAY)
.define(TRANSFORMS_CONFIG, Type.LIST, null, new ConfigDef.Validator() {
@Override
public void ensureValid(String name, Object value) {
if (value == null) return;
final List<String> transformAliases = (List<String>) value;
if (transformAliases.size() > new HashSet<>(transformAliases).size()) {
throw new ConfigException(name, value, "Duplicate alias provided.");
}
}
}, Importance.LOW, TRANSFORMS_DOC, TRANSFORMS_GROUP, 6, Width.LONG, TRANSFORMS_DISPLAY);
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:19,代码来源:ConnectorConfig.java
示例2: testGroupInference
import org.apache.kafka.common.config.ConfigDef.Width; //导入依赖的package包/类
@Test
public void testGroupInference() {
List<String> expected1 = Arrays.asList("group1", "group2");
ConfigDef def1 = new ConfigDef()
.define("a", Type.INT, Importance.HIGH, "docs", "group1", 1, Width.SHORT, "a")
.define("b", Type.INT, Importance.HIGH, "docs", "group2", 1, Width.SHORT, "b")
.define("c", Type.INT, Importance.HIGH, "docs", "group1", 2, Width.SHORT, "c");
assertEquals(expected1, def1.groups());
List<String> expected2 = Arrays.asList("group2", "group1");
ConfigDef def2 = new ConfigDef()
.define("a", Type.INT, Importance.HIGH, "docs", "group2", 1, Width.SHORT, "a")
.define("b", Type.INT, Importance.HIGH, "docs", "group2", 2, Width.SHORT, "b")
.define("c", Type.INT, Importance.HIGH, "docs", "group1", 2, Width.SHORT, "c");
assertEquals(expected2, def2.groups());
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:19,代码来源:ConfigDefTest.java
示例3: testValidate
import org.apache.kafka.common.config.ConfigDef.Width; //导入依赖的package包/类
@Test
public void testValidate() {
Map<String, ConfigValue> expected = new HashMap<>();
String errorMessageB = "Missing required configuration \"b\" which has no default value.";
String errorMessageC = "Missing required configuration \"c\" which has no default value.";
ConfigValue configA = new ConfigValue("a", 1, Arrays.<Object>asList(1, 2, 3), Collections.<String>emptyList());
ConfigValue configB = new ConfigValue("b", null, Arrays.<Object>asList(4, 5), Arrays.asList(errorMessageB, errorMessageB));
ConfigValue configC = new ConfigValue("c", null, Arrays.<Object>asList(4, 5), Arrays.asList(errorMessageC));
ConfigValue configD = new ConfigValue("d", 10, Arrays.<Object>asList(1, 2, 3), Collections.<String>emptyList());
expected.put("a", configA);
expected.put("b", configB);
expected.put("c", configC);
expected.put("d", configD);
ConfigDef def = new ConfigDef()
.define("a", Type.INT, Importance.HIGH, "docs", "group", 1, Width.SHORT, "a", Arrays.asList("b", "c"), new IntegerRecommender(false))
.define("b", Type.INT, Importance.HIGH, "docs", "group", 2, Width.SHORT, "b", new IntegerRecommender(true))
.define("c", Type.INT, Importance.HIGH, "docs", "group", 3, Width.SHORT, "c", new IntegerRecommender(true))
.define("d", Type.INT, Importance.HIGH, "docs", "group", 4, Width.SHORT, "d", Arrays.asList("b"), new IntegerRecommender(false));
Map<String, String> props = new HashMap<>();
props.put("a", "1");
props.put("d", "10");
List<ConfigValue> configs = def.validate(props);
for (ConfigValue config : configs) {
String name = config.name();
ConfigValue expectedConfig = expected.get(name);
assertEquals(expectedConfig, config);
}
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:34,代码来源:ConfigDefTest.java
示例4: testValidateMissingConfigKey
import org.apache.kafka.common.config.ConfigDef.Width; //导入依赖的package包/类
@Test
public void testValidateMissingConfigKey() {
Map<String, ConfigValue> expected = new HashMap<>();
String errorMessageB = "Missing required configuration \"b\" which has no default value.";
String errorMessageC = "Missing required configuration \"c\" which has no default value.";
String errorMessageD = "d is referred in the dependents, but not defined.";
ConfigValue configA = new ConfigValue("a", 1, Arrays.<Object>asList(1, 2, 3), Collections.<String>emptyList());
ConfigValue configB = new ConfigValue("b", null, Arrays.<Object>asList(4, 5), Arrays.asList(errorMessageB));
ConfigValue configC = new ConfigValue("c", null, Arrays.<Object>asList(4, 5), Arrays.asList(errorMessageC));
ConfigValue configD = new ConfigValue("d", null, Collections.emptyList(), Arrays.asList(errorMessageD));
configD.visible(false);
expected.put("a", configA);
expected.put("b", configB);
expected.put("c", configC);
expected.put("d", configD);
ConfigDef def = new ConfigDef()
.define("a", Type.INT, Importance.HIGH, "docs", "group", 1, Width.SHORT, "a", Arrays.asList("b", "c", "d"), new IntegerRecommender(false))
.define("b", Type.INT, Importance.HIGH, "docs", "group", 2, Width.SHORT, "b", new IntegerRecommender(true))
.define("c", Type.INT, Importance.HIGH, "docs", "group", 3, Width.SHORT, "c", new IntegerRecommender(true));
Map<String, String> props = new HashMap<>();
props.put("a", "1");
List<ConfigValue> configs = def.validate(props);
for (ConfigValue config: configs) {
String name = config.name();
ConfigValue expectedConfig = expected.get(name);
assertEquals(expectedConfig, config);
}
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:34,代码来源:ConfigDefTest.java
示例5: testMissingDependentConfigs
import org.apache.kafka.common.config.ConfigDef.Width; //导入依赖的package包/类
@Test(expected = ConfigException.class)
public void testMissingDependentConfigs() {
// Should not be possible to parse a config if a dependent config has not been defined
final ConfigDef configDef = new ConfigDef()
.define("parent", Type.STRING, Importance.HIGH, "parent docs", "group", 1, Width.LONG, "Parent", Collections.singletonList("child"));
configDef.parse(Collections.emptyMap());
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:8,代码来源:ConfigDefTest.java
示例6: testBaseConfigDefDependents
import org.apache.kafka.common.config.ConfigDef.Width; //导入依赖的package包/类
@Test
public void testBaseConfigDefDependents() {
// Creating a ConfigDef based on another should compute the correct number of configs with no parent, even
// if the base ConfigDef has already computed its parentless configs
final ConfigDef baseConfigDef = new ConfigDef().define("a", Type.STRING, Importance.LOW, "docs");
assertEquals(new HashSet<>(Arrays.asList("a")), baseConfigDef.getConfigsWithNoParent());
final ConfigDef configDef = new ConfigDef(baseConfigDef)
.define("parent", Type.STRING, Importance.HIGH, "parent docs", "group", 1, Width.LONG, "Parent", Collections.singletonList("child"))
.define("child", Type.STRING, Importance.HIGH, "docs");
assertEquals(new HashSet<>(Arrays.asList("a", "parent")), configDef.getConfigsWithNoParent());
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:14,代码来源:ConfigDefTest.java
示例7: newConfigDef
import org.apache.kafka.common.config.ConfigDef.Width; //导入依赖的package包/类
public static ConfigDef newConfigDef() {
ConfigDef configDef = S3SinkConnectorConfig.getConfig();
final String group = "S3 Tests";
int orderInGroup = 0;
configDef.define(TEST_PART_SIZE_CONFIG,
Type.INT,
1024,
Importance.HIGH,
"Tests - The Part Size in S3 Multi-part Uploads for tests.",
group,
++orderInGroup,
Width.MEDIUM,
"Tests - S3 Part Size for tests");
return configDef;
}
开发者ID:confluentinc,项目名称:kafka-connect-storage-cloud,代码行数:16,代码来源:MockS3SinkConnectorConfig.java
示例8: enrich
import org.apache.kafka.common.config.ConfigDef.Width; //导入依赖的package包/类
/**
* Returns an enriched {@link ConfigDef} building upon the {@code ConfigDef}, using the current configuration specified in {@code props} as an input.
* <p>
* {@code requireFullConfig} specifies whether required config values that are missing should cause an exception to be thrown.
*/
public static ConfigDef enrich(Plugins plugins, ConfigDef baseConfigDef, Map<String, String> props, boolean requireFullConfig) {
Object transformAliases = ConfigDef.parseType(TRANSFORMS_CONFIG, props.get(TRANSFORMS_CONFIG), Type.LIST);
if (!(transformAliases instanceof List)) {
return baseConfigDef;
}
ConfigDef newDef = new ConfigDef(baseConfigDef);
LinkedHashSet<?> uniqueTransformAliases = new LinkedHashSet<>((List<?>) transformAliases);
for (Object o : uniqueTransformAliases) {
if (!(o instanceof String)) {
throw new ConfigException("Item in " + TRANSFORMS_CONFIG + " property is not of "
+ "type String");
}
String alias = (String) o;
final String prefix = TRANSFORMS_CONFIG + "." + alias + ".";
final String group = TRANSFORMS_GROUP + ": " + alias;
int orderInGroup = 0;
final String transformationTypeConfig = prefix + "type";
final ConfigDef.Validator typeValidator = new ConfigDef.Validator() {
@Override
public void ensureValid(String name, Object value) {
getConfigDefFromTransformation(transformationTypeConfig, (Class) value);
}
};
newDef.define(transformationTypeConfig, Type.CLASS, ConfigDef.NO_DEFAULT_VALUE, typeValidator, Importance.HIGH,
"Class for the '" + alias + "' transformation.", group, orderInGroup++, Width.LONG, "Transformation type for " + alias,
Collections.<String>emptyList(), new TransformationClassRecommender(plugins));
final ConfigDef transformationConfigDef;
try {
final String className = props.get(transformationTypeConfig);
final Class<?> cls = (Class<?>) ConfigDef.parseType(transformationTypeConfig, className, Type.CLASS);
transformationConfigDef = getConfigDefFromTransformation(transformationTypeConfig, cls);
} catch (ConfigException e) {
if (requireFullConfig) {
throw e;
} else {
continue;
}
}
newDef.embed(prefix, group, orderInGroup, transformationConfigDef);
}
return newDef;
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:53,代码来源:ConnectorConfig.java
示例9: testParseForValidate
import org.apache.kafka.common.config.ConfigDef.Width; //导入依赖的package包/类
@Test
public void testParseForValidate() {
Map<String, Object> expectedParsed = new HashMap<>();
expectedParsed.put("a", 1);
expectedParsed.put("b", null);
expectedParsed.put("c", null);
expectedParsed.put("d", 10);
Map<String, ConfigValue> expected = new HashMap<>();
String errorMessageB = "Missing required configuration \"b\" which has no default value.";
String errorMessageC = "Missing required configuration \"c\" which has no default value.";
ConfigValue configA = new ConfigValue("a", 1, Collections.<Object>emptyList(), Collections.<String>emptyList());
ConfigValue configB = new ConfigValue("b", null, Collections.<Object>emptyList(), Arrays.asList(errorMessageB, errorMessageB));
ConfigValue configC = new ConfigValue("c", null, Collections.<Object>emptyList(), Arrays.asList(errorMessageC));
ConfigValue configD = new ConfigValue("d", 10, Collections.<Object>emptyList(), Collections.<String>emptyList());
expected.put("a", configA);
expected.put("b", configB);
expected.put("c", configC);
expected.put("d", configD);
ConfigDef def = new ConfigDef()
.define("a", Type.INT, Importance.HIGH, "docs", "group", 1, Width.SHORT, "a", Arrays.asList("b", "c"), new IntegerRecommender(false))
.define("b", Type.INT, Importance.HIGH, "docs", "group", 2, Width.SHORT, "b", new IntegerRecommender(true))
.define("c", Type.INT, Importance.HIGH, "docs", "group", 3, Width.SHORT, "c", new IntegerRecommender(true))
.define("d", Type.INT, Importance.HIGH, "docs", "group", 4, Width.SHORT, "d", Arrays.asList("b"), new IntegerRecommender(false));
Map<String, String> props = new HashMap<>();
props.put("a", "1");
props.put("d", "10");
Map<String, ConfigValue> configValues = new HashMap<>();
for (String name : def.configKeys().keySet()) {
configValues.put(name, new ConfigValue(name));
}
Map<String, Object> parsed = def.parseForValidate(props, configValues);
assertEquals(expectedParsed, parsed);
assertEquals(expected, configValues);
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:42,代码来源:ConfigDefTest.java
示例10: toEnrichedRst
import org.apache.kafka.common.config.ConfigDef.Width; //导入依赖的package包/类
@Test
public void toEnrichedRst() {
final ConfigDef def = new ConfigDef()
.define("opt1.of.group1", Type.STRING, "a", ValidString.in("a", "b", "c"), Importance.HIGH, "Doc doc.",
"Group One", 0, Width.NONE, "..", Collections.<String>emptyList())
.define("opt2.of.group1", Type.INT, ConfigDef.NO_DEFAULT_VALUE, Importance.MEDIUM, "Doc doc doc.",
"Group One", 1, Width.NONE, "..", Arrays.asList("some.option1", "some.option2"))
.define("opt2.of.group2", Type.BOOLEAN, false, Importance.HIGH, "Doc doc doc doc.",
"Group Two", 1, Width.NONE, "..", Collections.<String>emptyList())
.define("opt1.of.group2", Type.BOOLEAN, false, Importance.HIGH, "Doc doc doc doc doc.",
"Group Two", 0, Width.NONE, "..", Collections.singletonList("some.option"))
.define("poor.opt", Type.STRING, "foo", Importance.HIGH, "Doc doc doc doc.");
final String expectedRst = "" +
"``poor.opt``\n" +
" Doc doc doc doc.\n" +
"\n" +
" * Type: string\n" +
" * Default: foo\n" +
" * Importance: high\n" +
"\n" +
"Group One\n" +
"^^^^^^^^^\n" +
"\n" +
"``opt1.of.group1``\n" +
" Doc doc.\n" +
"\n" +
" * Type: string\n" +
" * Default: a\n" +
" * Valid Values: [a, b, c]\n" +
" * Importance: high\n" +
"\n" +
"``opt2.of.group1``\n" +
" Doc doc doc.\n" +
"\n" +
" * Type: int\n" +
" * Importance: medium\n" +
" * Dependents: ``some.option1``, ``some.option2``\n" +
"\n" +
"Group Two\n" +
"^^^^^^^^^\n" +
"\n" +
"``opt1.of.group2``\n" +
" Doc doc doc doc doc.\n" +
"\n" +
" * Type: boolean\n" +
" * Default: false\n" +
" * Importance: high\n" +
" * Dependents: ``some.option``\n" +
"\n" +
"``opt2.of.group2``\n" +
" Doc doc doc doc.\n" +
"\n" +
" * Type: boolean\n" +
" * Default: false\n" +
" * Importance: high\n" +
"\n";
assertEquals(expectedRst, def.toEnrichedRst());
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:61,代码来源:ConfigDefTest.java
示例11: testParseForValidate
import org.apache.kafka.common.config.ConfigDef.Width; //导入依赖的package包/类
@Test
public void testParseForValidate() {
Map<String, Object> expectedParsed = new HashMap<>();
expectedParsed.put("a", 1);
expectedParsed.put("b", null);
expectedParsed.put("c", null);
expectedParsed.put("d", 10);
Map<String, ConfigValue> expected = new HashMap<>();
String errorMessageB = "Missing required configuration \"b\" which has no default value.";
String errorMessageC = "Missing required configuration \"c\" which has no default value.";
ConfigValue configA = new ConfigValue("a", 1, Collections.<Object>emptyList(), Collections.<String>emptyList());
ConfigValue configB = new ConfigValue("b", null, Collections.<Object>emptyList(), Arrays.asList(errorMessageB, errorMessageB));
ConfigValue configC = new ConfigValue("c", null, Collections.<Object>emptyList(), Arrays.asList(errorMessageC));
ConfigValue configD = new ConfigValue("d", 10, Collections.<Object>emptyList(), Collections.<String>emptyList());
expected.put("a", configA);
expected.put("b", configB);
expected.put("c", configC);
expected.put("d", configD);
ConfigDef def = new ConfigDef()
.define("a", Type.INT, Importance.HIGH, "docs", "group", 1, Width.SHORT, "a", Arrays.asList("b", "c"), new IntegerRecommender(false))
.define("b", Type.INT, Importance.HIGH, "docs", "group", 2, Width.SHORT, "b", new IntegerRecommender(true))
.define("c", Type.INT, Importance.HIGH, "docs", "group", 3, Width.SHORT, "c", new IntegerRecommender(true))
.define("d", Type.INT, Importance.HIGH, "docs", "group", 4, Width.SHORT, "d", Arrays.asList("b"), new IntegerRecommender(false));
Map<String, String> props = new HashMap<>();
props.put("a", "1");
props.put("d", "10");
Map<String, ConfigValue> configValues = new HashMap<>();
for (String name: def.configKeys().keySet()) {
configValues.put(name, new ConfigValue(name));
}
Map<String, Object> parsed = def.parseForValidate(props, configValues);
assertEquals(expectedParsed, parsed);
assertEquals(expected, configValues);
}
开发者ID:txazo,项目名称:kafka,代码行数:42,代码来源:ConfigDefTest.java
示例12: newConfigDef
import org.apache.kafka.common.config.ConfigDef.Width; //导入依赖的package包/类
/**
* Create a new configuration definition.
*
* @param storageClassRecommender A recommender for storage classes shipping out-of-the-box
* with a connector. The recommender should not prevent additional custom classes from being
* added during runtime.
* @return the newly created configuration definition.
*/
public static ConfigDef newConfigDef(ConfigDef.Recommender storageClassRecommender) {
ConfigDef configDef = new ConfigDef();
{
// Define Store's basic configuration group
final String group = "Storage";
int orderInGroup = 0;
configDef.define(
STORAGE_CLASS_CONFIG,
Type.CLASS,
Importance.HIGH,
STORAGE_CLASS_DOC,
group,
++orderInGroup,
Width.NONE,
STORAGE_CLASS_DISPLAY,
storageClassRecommender
);
configDef.define(
TOPICS_DIR_CONFIG,
Type.STRING,
TOPICS_DIR_DEFAULT,
Importance.HIGH,
TOPICS_DIR_DOC,
group,
++orderInGroup,
Width.NONE,
TOPICS_DIR_DISPLAY
);
configDef.define(
STORE_URL_CONFIG,
Type.STRING,
STORE_URL_DEFAULT,
Importance.HIGH,
STORE_URL_DOC,
group,
++orderInGroup,
Width.NONE,
STORE_URL_DISPLAY
);
configDef.define(
DIRECTORY_DELIM_CONFIG,
Type.STRING,
DIRECTORY_DELIM_DEFAULT,
Importance.MEDIUM,
DIRECTORY_DELIM_DOC,
group,
++orderInGroup,
Width.LONG,
DIRECTORY_DELIM_DISPLAY
);
configDef.define(
FILE_DELIM_CONFIG,
Type.STRING,
FILE_DELIM_DEFAULT,
Importance.MEDIUM,
FILE_DELIM_DOC,
group,
++orderInGroup,
Width.LONG,
FILE_DELIM_DISPLAY
);
}
return configDef;
}
开发者ID:confluentinc,项目名称:kafka-connect-storage-common,代码行数:78,代码来源:StorageCommonConfig.java
注:本文中的org.apache.kafka.common.config.ConfigDef.Width类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论