use of com.baidu.hugegraph.config.ConfigListOption in project hugegraph-computer by hugegraph.
the class KubernetesDriver method defaultSpec.
private Map<String, Object> defaultSpec() {
Map<String, Object> defaultSpec = new HashMap<>();
Collection<TypedOption<?, ?>> options = KubeSpecOptions.instance().options().values();
for (TypedOption<?, ?> typeOption : options) {
Object value = this.conf.get(typeOption);
if (value != null) {
String specKey = KubeUtil.covertSpecKey(typeOption.name());
if (KubeSpecOptions.MAP_TYPE_CONFIGS.contains(typeOption)) {
if (!Objects.equals(String.valueOf(value), "[]")) {
value = this.conf.getMap((ConfigListOption<String>) typeOption);
defaultSpec.put(specKey, value);
}
} else {
defaultSpec.put(specKey, value);
}
}
}
ComputerJobSpec spec = HugeGraphComputerJob.mapToSpec(defaultSpec);
// Add pullSecrets
List<String> secretNames = this.conf.get(KubeDriverOptions.PULL_SECRET_NAMES);
if (CollectionUtils.isNotEmpty(secretNames)) {
List<LocalObjectReference> secrets = new ArrayList<>();
for (String name : secretNames) {
if (StringUtils.isBlank(name)) {
continue;
}
secrets.add(new LocalObjectReference(name));
}
if (CollectionUtils.isNotEmpty(secrets)) {
spec.withPullSecrets(secrets);
}
}
// Add log4j.xml
String log4jXmlPath = this.conf.get(KubeDriverOptions.LOG4J_XML_PATH);
if (StringUtils.isNotBlank(log4jXmlPath)) {
try {
File file = new File(log4jXmlPath);
@SuppressWarnings("deprecation") String log4jXml = FileUtils.readFileToString(file);
spec.withLog4jXml(log4jXml);
} catch (IOException exception) {
throw new ComputerDriverException("Failed to read log4j file for computer job", exception);
}
}
Map<String, Object> specMap = HugeGraphComputerJob.specToMap(spec);
return Collections.unmodifiableMap(specMap);
}
Aggregations