[ https://issues.apache.org/jira/browse/HDDS-976?focusedWorklogId=222786&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-222786 ]
ASF GitHub Bot logged work on HDDS-976: --------------------------------------- Author: ASF GitHub Bot Created on: 04/Apr/19 03:46 Start Date: 04/Apr/19 03:46 Worklog Time Spent: 10m Work Description: xiaoyuyao commented on pull request #661: HDDS-976: Parse network topology from yaml file URL: https://github.com/apache/hadoop/pull/661#discussion_r272008319 ########## File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/net/NodeSchemaLoader.java ########## @@ -165,6 +169,81 @@ private NodeSchemaLoadResult loadSchema(File schemaFile) throws return schemaList; } + /** + * Load user defined network layer schemas from a YAML configuration file. + * @param schemaFilePath path of schema file + * @return all valid node schemas defined in schema file + */ + public NodeSchemaLoadResult loadSchemaFromYaml(String schemaFilePath) + throws IllegalArgumentException { + try { + File schemaFile = new File(schemaFilePath); + if (!schemaFile.exists()) { + String msg = "Network topology layer schema file " + schemaFilePath + + " is not found."; + LOG.warn(msg); + throw new IllegalArgumentException(msg); + } + return loadSchemaFromYaml(schemaFile); + } catch (Exception e) { + throw new IllegalArgumentException("Fail to load network topology node" + + " schema file: " + schemaFilePath + " , error:" + e.getMessage()); + } + } + + /** + * Load network topology layer schemas from a YAML configuration file. + * @param schemaFile schema file + * @return all valid node schemas defined in schema file + * @throws ParserConfigurationException ParserConfigurationException happen + * @throws IOException no such schema file + * @throws SAXException xml file has some invalid elements + * @throws IllegalArgumentException xml file content is logically invalid + */ + private NodeSchemaLoadResult loadSchemaFromYaml(File schemaFile) { + LOG.info("Loading network topology layer schema file " + schemaFile); + NodeSchemaLoadResult finalSchema; + + try { + FileInputStream fileInputStream = new FileInputStream(schemaFile); Review comment: Can we use try-with-resource to ensure the FileInputStream is closed properly? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 222786) Time Spent: 50m (was: 40m) > Support YAML format network topology cluster definition > ------------------------------------------------------- > > Key: HDDS-976 > URL: https://issues.apache.org/jira/browse/HDDS-976 > Project: Hadoop Distributed Data Store > Issue Type: Sub-task > Reporter: Sammi Chen > Assignee: Junjie Chen > Priority: Major > Labels: pull-request-available > Attachments: NetworkTopologyDefault.yaml > > Time Spent: 50m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org