use of org.yaml.snakeyaml.Yaml in project spring-security by spring-projects.
the class GitHubMilestoneNextReleaseTask method calculateNextReleaseMilestone.
@TaskAction
public void calculateNextReleaseMilestone() throws IOException {
String currentVersion = getProject().getVersion().toString();
String nextPreRelease = this.milestones.getNextReleaseMilestone(this.repository, currentVersion);
System.out.println("The next release milestone is: " + nextPreRelease);
NextVersionYml nextVersionYml = new NextVersionYml();
nextVersionYml.setVersion(nextPreRelease);
File outputFile = getNextReleaseFile().get().getAsFile();
FileWriter outputWriter = new FileWriter(outputFile);
Yaml yaml = getYaml();
yaml.dump(nextVersionYml, outputWriter);
}
use of org.yaml.snakeyaml.Yaml in project storm by apache.
the class RuncLibContainerManager method saveRuncYaml.
// save runc.yaml in artifacts dir so we can track which image the worker was launched with
private void saveRuncYaml(String topologyId, int port, String containerId, String imageName, OciResource configResource) {
String fname = String.format("runc-%s.yaml", containerId);
File file = new File(ConfigUtils.workerArtifactsRoot(conf, topologyId, port), fname);
DumperOptions options = new DumperOptions();
options.setIndent(2);
options.setPrettyFlow(true);
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
Yaml yaml = new Yaml(options);
Map<String, Object> data = new HashMap<>();
data.put("imageName", imageName);
data.put("manifest", configResource.getFileName());
data.put("configPath", configResource.getPath());
try (Writer writer = new FileWriter(file)) {
yaml.dump(data, writer);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.yaml.snakeyaml.Yaml in project cassandra by apache.
the class StressProfile method load.
public static StressProfile load(URI file) throws IOError {
try {
Constructor constructor = new Constructor(StressYaml.class);
Yaml yaml = new Yaml(constructor);
InputStream yamlStream = file.toURL().openStream();
if (yamlStream.available() == 0)
throw new IOException("Unable to load yaml file from: " + file);
StressYaml profileYaml = yaml.loadAs(yamlStream, StressYaml.class);
StressProfile profile = new StressProfile();
profile.init(profileYaml);
return profile;
} catch (YAMLException | IOException | RequestValidationException e) {
throw new IOError(e);
}
}
use of org.yaml.snakeyaml.Yaml in project storm by apache.
the class Container method writeLogMetadata.
/**
* Write out the file used by the log viewer to allow/reject log access.
*
* @param user the user this is going to run as
* @throws IOException on any error
*/
protected void writeLogMetadata(String user) throws IOException {
type.assertFull();
Map<String, Object> data = new HashMap<>();
data.put(Config.TOPOLOGY_SUBMITTER_USER, user);
data.put("worker-id", workerId);
Set<String> logsGroups = new HashSet<>();
if (topoConf.get(DaemonConfig.LOGS_GROUPS) != null) {
List<String> groups = ObjectReader.getStrings(topoConf.get(DaemonConfig.LOGS_GROUPS));
logsGroups.addAll(groups);
}
if (topoConf.get(Config.TOPOLOGY_GROUPS) != null) {
List<String> topGroups = ObjectReader.getStrings(topoConf.get(Config.TOPOLOGY_GROUPS));
logsGroups.addAll(topGroups);
}
data.put(DaemonConfig.LOGS_GROUPS, logsGroups.toArray());
Set<String> logsUsers = new HashSet<>();
if (topoConf.get(DaemonConfig.LOGS_USERS) != null) {
List<String> logUsers = ObjectReader.getStrings(topoConf.get(DaemonConfig.LOGS_USERS));
logsUsers.addAll(logUsers);
}
if (topoConf.get(Config.TOPOLOGY_USERS) != null) {
List<String> topUsers = ObjectReader.getStrings(topoConf.get(Config.TOPOLOGY_USERS));
logsUsers.addAll(topUsers);
}
data.put(DaemonConfig.LOGS_USERS, logsUsers.toArray());
if (topoConf.get(Config.TOPOLOGY_WORKER_TIMEOUT_SECS) != null) {
int topoTimeout = ObjectReader.getInt(topoConf.get(Config.TOPOLOGY_WORKER_TIMEOUT_SECS));
int defaultWorkerTimeout = ObjectReader.getInt(conf.get(Config.SUPERVISOR_WORKER_TIMEOUT_SECS));
topoTimeout = Math.max(topoTimeout, defaultWorkerTimeout);
data.put(Config.TOPOLOGY_WORKER_TIMEOUT_SECS, topoTimeout);
}
File file = ServerConfigUtils.getLogMetaDataFile(conf, topologyId, port);
Yaml yaml = new Yaml();
try (Writer writer = ops.getWriter(file)) {
yaml.dump(data, writer);
}
}
use of org.yaml.snakeyaml.Yaml in project storm by apache.
the class FileConfigLoaderTest method testValidFile.
@Test
public void testValidFile() throws Exception {
File temp = File.createTempFile("FileLoader", ".yaml");
temp.deleteOnExit();
Map<String, Integer> testMap = new HashMap<>();
testMap.put("a", 1);
testMap.put("b", 2);
testMap.put("c", 3);
testMap.put("d", 4);
testMap.put("e", 5);
Map<String, Map<String, Integer>> confMap = new HashMap<>();
confMap.put(DaemonConfig.MULTITENANT_SCHEDULER_USER_POOLS, testMap);
Yaml yaml = new Yaml();
FileWriter fw = new FileWriter(temp);
yaml.dump(confMap, fw);
fw.flush();
fw.close();
Config conf = new Config();
conf.put(DaemonConfig.SCHEDULER_CONFIG_LOADER_URI, FILE_SCHEME_PREFIX + temp.getCanonicalPath());
FileConfigLoader loader = new FileConfigLoader(conf);
Map<String, Object> result = loader.load(DaemonConfig.MULTITENANT_SCHEDULER_USER_POOLS);
Assert.assertNotNull("Unexpectedly returned null", result);
Assert.assertEquals("Maps are a different size", testMap.keySet().size(), result.keySet().size());
for (String key : testMap.keySet()) {
Integer expectedValue = testMap.get(key);
Integer returnedValue = (Integer) result.get(key);
Assert.assertEquals("Bad value for key=" + key, expectedValue, returnedValue);
}
}
Aggregations