id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
138,100 | QSFT/Doradus | doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java | CSVLoader.getSchema | private String getSchema() {
if (Utils.isEmpty(m_config.schema)) {
m_config.schema = m_config.root + m_config.app + ".xml";
}
File schemaFile = new File(m_config.schema);
if (!schemaFile.exists()) {
logErrorThrow("Schema file not found: {}", m_config.schema);
}
StringBuilder schemaBuffer = new StringBuilder();
char[] charBuffer = new char[65536];
try (FileReader reader = new FileReader(schemaFile)) {
for (int bytesRead = reader.read(charBuffer); bytesRead > 0; bytesRead = reader.read(charBuffer)) {
schemaBuffer.append(charBuffer, 0, bytesRead);
}
} catch (Exception e) {
logErrorThrow("Cannot read schema file '{}': {}", m_config.schema, e);
}
return schemaBuffer.toString();
} | java | private String getSchema() {
if (Utils.isEmpty(m_config.schema)) {
m_config.schema = m_config.root + m_config.app + ".xml";
}
File schemaFile = new File(m_config.schema);
if (!schemaFile.exists()) {
logErrorThrow("Schema file not found: {}", m_config.schema);
}
StringBuilder schemaBuffer = new StringBuilder();
char[] charBuffer = new char[65536];
try (FileReader reader = new FileReader(schemaFile)) {
for (int bytesRead = reader.read(charBuffer); bytesRead > 0; bytesRead = reader.read(charBuffer)) {
schemaBuffer.append(charBuffer, 0, bytesRead);
}
} catch (Exception e) {
logErrorThrow("Cannot read schema file '{}': {}", m_config.schema, e);
}
return schemaBuffer.toString();
} | [
"private",
"String",
"getSchema",
"(",
")",
"{",
"if",
"(",
"Utils",
".",
"isEmpty",
"(",
"m_config",
".",
"schema",
")",
")",
"{",
"m_config",
".",
"schema",
"=",
"m_config",
".",
"root",
"+",
"m_config",
".",
"app",
"+",
"\".xml\"",
";",
"}",
"File",
"schemaFile",
"=",
"new",
"File",
"(",
"m_config",
".",
"schema",
")",
";",
"if",
"(",
"!",
"schemaFile",
".",
"exists",
"(",
")",
")",
"{",
"logErrorThrow",
"(",
"\"Schema file not found: {}\"",
",",
"m_config",
".",
"schema",
")",
";",
"}",
"StringBuilder",
"schemaBuffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"char",
"[",
"]",
"charBuffer",
"=",
"new",
"char",
"[",
"65536",
"]",
";",
"try",
"(",
"FileReader",
"reader",
"=",
"new",
"FileReader",
"(",
"schemaFile",
")",
")",
"{",
"for",
"(",
"int",
"bytesRead",
"=",
"reader",
".",
"read",
"(",
"charBuffer",
")",
";",
"bytesRead",
">",
"0",
";",
"bytesRead",
"=",
"reader",
".",
"read",
"(",
"charBuffer",
")",
")",
"{",
"schemaBuffer",
".",
"append",
"(",
"charBuffer",
",",
"0",
",",
"bytesRead",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logErrorThrow",
"(",
"\"Cannot read schema file '{}': {}\"",
",",
"m_config",
".",
"schema",
",",
"e",
")",
";",
"}",
"return",
"schemaBuffer",
".",
"toString",
"(",
")",
";",
"}"
] | Load schema contents from m_config.schema file. | [
"Load",
"schema",
"contents",
"from",
"m_config",
".",
"schema",
"file",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L332-L350 |
138,101 | QSFT/Doradus | doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java | CSVLoader.loadTables | private void loadTables() {
ApplicationDefinition appDef = m_session.getAppDef();
m_tableNameList = new ArrayList<String>(appDef.getTableDefinitions().keySet());
Collections.sort(m_tableNameList, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
// We want longer table names to be first. So, if s1 == "a" and s2 == "aa",
// "a".length() - "aa".length() == -1, which means "aa" appears first. We
// don't care about the order of same-length names.
return s2.length() - s1.length();
} // compare
});
} | java | private void loadTables() {
ApplicationDefinition appDef = m_session.getAppDef();
m_tableNameList = new ArrayList<String>(appDef.getTableDefinitions().keySet());
Collections.sort(m_tableNameList, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
// We want longer table names to be first. So, if s1 == "a" and s2 == "aa",
// "a".length() - "aa".length() == -1, which means "aa" appears first. We
// don't care about the order of same-length names.
return s2.length() - s1.length();
} // compare
});
} | [
"private",
"void",
"loadTables",
"(",
")",
"{",
"ApplicationDefinition",
"appDef",
"=",
"m_session",
".",
"getAppDef",
"(",
")",
";",
"m_tableNameList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"appDef",
".",
"getTableDefinitions",
"(",
")",
".",
"keySet",
"(",
")",
")",
";",
"Collections",
".",
"sort",
"(",
"m_tableNameList",
",",
"new",
"Comparator",
"<",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"compare",
"(",
"String",
"s1",
",",
"String",
"s2",
")",
"{",
"// We want longer table names to be first. So, if s1 == \"a\" and s2 == \"aa\",\r",
"// \"a\".length() - \"aa\".length() == -1, which means \"aa\" appears first. We\r",
"// don't care about the order of same-length names.\r",
"return",
"s2",
".",
"length",
"(",
")",
"-",
"s1",
".",
"length",
"(",
")",
";",
"}",
"// compare\r",
"}",
")",
";",
"}"
] | ordering to match CSV file names correctly. | [
"ordering",
"to",
"match",
"CSV",
"file",
"names",
"correctly",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L354-L366 |
138,102 | QSFT/Doradus | doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java | CSVLoader.loadCSVFile | private void loadCSVFile(TableDefinition tableDef, File file) throws IOException {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), Utils.UTF8_CHARSET))
) {
loadCSVFromReader(tableDef, file.getAbsolutePath(), file.length(), reader);
}
} | java | private void loadCSVFile(TableDefinition tableDef, File file) throws IOException {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), Utils.UTF8_CHARSET))
) {
loadCSVFromReader(tableDef, file.getAbsolutePath(), file.length(), reader);
}
} | [
"private",
"void",
"loadCSVFile",
"(",
"TableDefinition",
"tableDef",
",",
"File",
"file",
")",
"throws",
"IOException",
"{",
"try",
"(",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
",",
"Utils",
".",
"UTF8_CHARSET",
")",
")",
")",
"{",
"loadCSVFromReader",
"(",
"tableDef",
",",
"file",
".",
"getAbsolutePath",
"(",
")",
",",
"file",
".",
"length",
"(",
")",
",",
"reader",
")",
";",
"}",
"}"
] | Load the records in the given file into the given table. | [
"Load",
"the",
"records",
"in",
"the",
"given",
"file",
"into",
"the",
"given",
"table",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L369-L374 |
138,103 | QSFT/Doradus | doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java | CSVLoader.loadFolder | private void loadFolder(File folder) {
m_logger.info("Scanning for files in folder: {}", folder.getAbsolutePath());
File[] files = folder.listFiles();
if (files == null || files.length == 0) {
m_logger.error("No files found in folder: {}", folder.getAbsolutePath());
return;
}
for (File file : files) {
String fileName = file.getName().toLowerCase();
if (!fileName.endsWith(".csv") && !fileName.endsWith(".zip")) {
continue;
}
TableDefinition tableDef = determineTableFromFileName(file.getName());
if (tableDef == null) {
m_logger.error("Ignoring file; unknown corresponding table: {}", file.getName());
continue;
}
try {
if (fileName.endsWith(".csv")) {
loadCSVFile(tableDef, file);
} else {
loadZIPFile(tableDef, file);
}
} catch (IOException ex) {
m_logger.error("I/O error scanning file '{}': {}", file.getName(), ex);
}
}
} | java | private void loadFolder(File folder) {
m_logger.info("Scanning for files in folder: {}", folder.getAbsolutePath());
File[] files = folder.listFiles();
if (files == null || files.length == 0) {
m_logger.error("No files found in folder: {}", folder.getAbsolutePath());
return;
}
for (File file : files) {
String fileName = file.getName().toLowerCase();
if (!fileName.endsWith(".csv") && !fileName.endsWith(".zip")) {
continue;
}
TableDefinition tableDef = determineTableFromFileName(file.getName());
if (tableDef == null) {
m_logger.error("Ignoring file; unknown corresponding table: {}", file.getName());
continue;
}
try {
if (fileName.endsWith(".csv")) {
loadCSVFile(tableDef, file);
} else {
loadZIPFile(tableDef, file);
}
} catch (IOException ex) {
m_logger.error("I/O error scanning file '{}': {}", file.getName(), ex);
}
}
} | [
"private",
"void",
"loadFolder",
"(",
"File",
"folder",
")",
"{",
"m_logger",
".",
"info",
"(",
"\"Scanning for files in folder: {}\"",
",",
"folder",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"File",
"[",
"]",
"files",
"=",
"folder",
".",
"listFiles",
"(",
")",
";",
"if",
"(",
"files",
"==",
"null",
"||",
"files",
".",
"length",
"==",
"0",
")",
"{",
"m_logger",
".",
"error",
"(",
"\"No files found in folder: {}\"",
",",
"folder",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"return",
";",
"}",
"for",
"(",
"File",
"file",
":",
"files",
")",
"{",
"String",
"fileName",
"=",
"file",
".",
"getName",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"!",
"fileName",
".",
"endsWith",
"(",
"\".csv\"",
")",
"&&",
"!",
"fileName",
".",
"endsWith",
"(",
"\".zip\"",
")",
")",
"{",
"continue",
";",
"}",
"TableDefinition",
"tableDef",
"=",
"determineTableFromFileName",
"(",
"file",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"tableDef",
"==",
"null",
")",
"{",
"m_logger",
".",
"error",
"(",
"\"Ignoring file; unknown corresponding table: {}\"",
",",
"file",
".",
"getName",
"(",
")",
")",
";",
"continue",
";",
"}",
"try",
"{",
"if",
"(",
"fileName",
".",
"endsWith",
"(",
"\".csv\"",
")",
")",
"{",
"loadCSVFile",
"(",
"tableDef",
",",
"file",
")",
";",
"}",
"else",
"{",
"loadZIPFile",
"(",
"tableDef",
",",
"file",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"m_logger",
".",
"error",
"(",
"\"I/O error scanning file '{}': {}\"",
",",
"file",
".",
"getName",
"(",
")",
",",
"ex",
")",
";",
"}",
"}",
"}"
] | Load all files in the given folder whose name matches a known table. | [
"Load",
"all",
"files",
"in",
"the",
"given",
"folder",
"whose",
"name",
"matches",
"a",
"known",
"table",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L377-L405 |
138,104 | QSFT/Doradus | doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java | CSVLoader.openDatabase | private void openDatabase() {
m_client = new Client(m_config.host, m_config.port, m_config.getTLSParams());
m_client.setCredentials(m_config.getCredentials());
} | java | private void openDatabase() {
m_client = new Client(m_config.host, m_config.port, m_config.getTLSParams());
m_client.setCredentials(m_config.getCredentials());
} | [
"private",
"void",
"openDatabase",
"(",
")",
"{",
"m_client",
"=",
"new",
"Client",
"(",
"m_config",
".",
"host",
",",
"m_config",
".",
"port",
",",
"m_config",
".",
"getTLSParams",
"(",
")",
")",
";",
"m_client",
".",
"setCredentials",
"(",
"m_config",
".",
"getCredentials",
"(",
")",
")",
";",
"}"
] | Open Doradus database, setting m_client. | [
"Open",
"Doradus",
"database",
"setting",
"m_client",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L425-L428 |
138,105 | QSFT/Doradus | doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java | CSVLoader.parseArgs | private void parseArgs(String[] args) {
int index = 0;
while (index < args.length) {
String name = args[index];
if (name.equals("-?") || name.equalsIgnoreCase("-help")) {
usage();
}
if (name.charAt(0) != '-') {
m_logger.error("Unrecognized parameter: {}", name);
usage();
}
if (++index >= args.length) {
m_logger.error("Another parameter expected after '{}'", name);
usage();
}
String value = args[index];
try {
m_config.set(name.substring(1), value);
} catch (Exception e) {
m_logger.error(e.toString());
usage();
}
index++;
}
} | java | private void parseArgs(String[] args) {
int index = 0;
while (index < args.length) {
String name = args[index];
if (name.equals("-?") || name.equalsIgnoreCase("-help")) {
usage();
}
if (name.charAt(0) != '-') {
m_logger.error("Unrecognized parameter: {}", name);
usage();
}
if (++index >= args.length) {
m_logger.error("Another parameter expected after '{}'", name);
usage();
}
String value = args[index];
try {
m_config.set(name.substring(1), value);
} catch (Exception e) {
m_logger.error(e.toString());
usage();
}
index++;
}
} | [
"private",
"void",
"parseArgs",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"int",
"index",
"=",
"0",
";",
"while",
"(",
"index",
"<",
"args",
".",
"length",
")",
"{",
"String",
"name",
"=",
"args",
"[",
"index",
"]",
";",
"if",
"(",
"name",
".",
"equals",
"(",
"\"-?\"",
")",
"||",
"name",
".",
"equalsIgnoreCase",
"(",
"\"-help\"",
")",
")",
"{",
"usage",
"(",
")",
";",
"}",
"if",
"(",
"name",
".",
"charAt",
"(",
"0",
")",
"!=",
"'",
"'",
")",
"{",
"m_logger",
".",
"error",
"(",
"\"Unrecognized parameter: {}\"",
",",
"name",
")",
";",
"usage",
"(",
")",
";",
"}",
"if",
"(",
"++",
"index",
">=",
"args",
".",
"length",
")",
"{",
"m_logger",
".",
"error",
"(",
"\"Another parameter expected after '{}'\"",
",",
"name",
")",
";",
"usage",
"(",
")",
";",
"}",
"String",
"value",
"=",
"args",
"[",
"index",
"]",
";",
"try",
"{",
"m_config",
".",
"set",
"(",
"name",
".",
"substring",
"(",
"1",
")",
",",
"value",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"m_logger",
".",
"error",
"(",
"e",
".",
"toString",
"(",
")",
")",
";",
"usage",
"(",
")",
";",
"}",
"index",
"++",
";",
"}",
"}"
] | Parse args into CSVConfig object. | [
"Parse",
"args",
"into",
"CSVConfig",
"object",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L431-L455 |
138,106 | QSFT/Doradus | doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java | CSVLoader.loadCSVFromReader | private void loadCSVFromReader(TableDefinition tableDef,
String csvName,
long byteLength,
BufferedReader reader) {
m_logger.info("Loading CSV file: {}", csvName);
// Determine the order in which fields in this file appear. Wrap this in a CSVFile.
List<String> fieldList = getFieldListFromHeader(reader);
CSVFile csvFile = new CSVFile(csvName, tableDef, fieldList);
long startTime = System.currentTimeMillis();
long recsLoaded = 0;
int lineNo = 0;
while (true) {
Map<String, String> fieldMap = new HashMap<String, String>();
if (!tokenizeCSVLine(csvFile, reader, fieldMap)) {
break;
}
lineNo++;
m_totalLines++;
try {
m_workerQueue.put(new Record(csvFile, fieldMap));
} catch (InterruptedException e) {
logErrorThrow("Error posting to queue", e.toString());
}
if ((++recsLoaded % 10000) == 0) {
m_logger.info("...loaded {} records.", recsLoaded);
}
}
// Always close the file and display stats even if an error occurred.
m_totalFiles++;
m_totalBytes += byteLength;
long stopTime = System.currentTimeMillis();
long totalMillis = stopTime - startTime;
if (totalMillis == 0) {
totalMillis = 1; // You never know
}
m_logger.info("File '{}': time={} millis; lines={}",
new Object[]{csvFile.m_fileName, totalMillis, lineNo});
} | java | private void loadCSVFromReader(TableDefinition tableDef,
String csvName,
long byteLength,
BufferedReader reader) {
m_logger.info("Loading CSV file: {}", csvName);
// Determine the order in which fields in this file appear. Wrap this in a CSVFile.
List<String> fieldList = getFieldListFromHeader(reader);
CSVFile csvFile = new CSVFile(csvName, tableDef, fieldList);
long startTime = System.currentTimeMillis();
long recsLoaded = 0;
int lineNo = 0;
while (true) {
Map<String, String> fieldMap = new HashMap<String, String>();
if (!tokenizeCSVLine(csvFile, reader, fieldMap)) {
break;
}
lineNo++;
m_totalLines++;
try {
m_workerQueue.put(new Record(csvFile, fieldMap));
} catch (InterruptedException e) {
logErrorThrow("Error posting to queue", e.toString());
}
if ((++recsLoaded % 10000) == 0) {
m_logger.info("...loaded {} records.", recsLoaded);
}
}
// Always close the file and display stats even if an error occurred.
m_totalFiles++;
m_totalBytes += byteLength;
long stopTime = System.currentTimeMillis();
long totalMillis = stopTime - startTime;
if (totalMillis == 0) {
totalMillis = 1; // You never know
}
m_logger.info("File '{}': time={} millis; lines={}",
new Object[]{csvFile.m_fileName, totalMillis, lineNo});
} | [
"private",
"void",
"loadCSVFromReader",
"(",
"TableDefinition",
"tableDef",
",",
"String",
"csvName",
",",
"long",
"byteLength",
",",
"BufferedReader",
"reader",
")",
"{",
"m_logger",
".",
"info",
"(",
"\"Loading CSV file: {}\"",
",",
"csvName",
")",
";",
"// Determine the order in which fields in this file appear. Wrap this in a CSVFile.\r",
"List",
"<",
"String",
">",
"fieldList",
"=",
"getFieldListFromHeader",
"(",
"reader",
")",
";",
"CSVFile",
"csvFile",
"=",
"new",
"CSVFile",
"(",
"csvName",
",",
"tableDef",
",",
"fieldList",
")",
";",
"long",
"startTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"long",
"recsLoaded",
"=",
"0",
";",
"int",
"lineNo",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"fieldMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"!",
"tokenizeCSVLine",
"(",
"csvFile",
",",
"reader",
",",
"fieldMap",
")",
")",
"{",
"break",
";",
"}",
"lineNo",
"++",
";",
"m_totalLines",
"++",
";",
"try",
"{",
"m_workerQueue",
".",
"put",
"(",
"new",
"Record",
"(",
"csvFile",
",",
"fieldMap",
")",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"logErrorThrow",
"(",
"\"Error posting to queue\"",
",",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"if",
"(",
"(",
"++",
"recsLoaded",
"%",
"10000",
")",
"==",
"0",
")",
"{",
"m_logger",
".",
"info",
"(",
"\"...loaded {} records.\"",
",",
"recsLoaded",
")",
";",
"}",
"}",
"// Always close the file and display stats even if an error occurred.\r",
"m_totalFiles",
"++",
";",
"m_totalBytes",
"+=",
"byteLength",
";",
"long",
"stopTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"long",
"totalMillis",
"=",
"stopTime",
"-",
"startTime",
";",
"if",
"(",
"totalMillis",
"==",
"0",
")",
"{",
"totalMillis",
"=",
"1",
";",
"// You never know\r",
"}",
"m_logger",
".",
"info",
"(",
"\"File '{}': time={} millis; lines={}\"",
",",
"new",
"Object",
"[",
"]",
"{",
"csvFile",
".",
"m_fileName",
",",
"totalMillis",
",",
"lineNo",
"}",
")",
";",
"}"
] | CSVFile. The caller must pass an opened stream and close it. | [
"CSVFile",
".",
"The",
"caller",
"must",
"pass",
"an",
"opened",
"stream",
"and",
"close",
"it",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L459-L500 |
138,107 | QSFT/Doradus | doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java | CSVLoader.startWorkers | private void startWorkers() {
m_logger.info("Starting {} workers", m_config.workers);
for (int workerNo = 1; workerNo <= m_config.workers; workerNo++) {
LoadWorker loadWorker = new LoadWorker(workerNo);
loadWorker.start();
m_workerList.add(loadWorker);
}
} | java | private void startWorkers() {
m_logger.info("Starting {} workers", m_config.workers);
for (int workerNo = 1; workerNo <= m_config.workers; workerNo++) {
LoadWorker loadWorker = new LoadWorker(workerNo);
loadWorker.start();
m_workerList.add(loadWorker);
}
} | [
"private",
"void",
"startWorkers",
"(",
")",
"{",
"m_logger",
".",
"info",
"(",
"\"Starting {} workers\"",
",",
"m_config",
".",
"workers",
")",
";",
"for",
"(",
"int",
"workerNo",
"=",
"1",
";",
"workerNo",
"<=",
"m_config",
".",
"workers",
";",
"workerNo",
"++",
")",
"{",
"LoadWorker",
"loadWorker",
"=",
"new",
"LoadWorker",
"(",
"workerNo",
")",
";",
"loadWorker",
".",
"start",
"(",
")",
";",
"m_workerList",
".",
"add",
"(",
"loadWorker",
")",
";",
"}",
"}"
] | Launch the requested number of workers. Quit if any can't be started. | [
"Launch",
"the",
"requested",
"number",
"of",
"workers",
".",
"Quit",
"if",
"any",
"can",
"t",
"be",
"started",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L503-L510 |
138,108 | QSFT/Doradus | doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java | CSVLoader.stopWorkers | private void stopWorkers() {
Record sentinel = Record.SENTINEL;
for (int inx = 0; inx < m_workerList.size(); inx++) {
try {
m_workerQueue.put(sentinel);
} catch (InterruptedException e) {
// ignore
}
}
for (LoadWorker loadWorker : m_workerList) {
try {
loadWorker.join();
} catch (InterruptedException e) {
// ignore
}
}
} | java | private void stopWorkers() {
Record sentinel = Record.SENTINEL;
for (int inx = 0; inx < m_workerList.size(); inx++) {
try {
m_workerQueue.put(sentinel);
} catch (InterruptedException e) {
// ignore
}
}
for (LoadWorker loadWorker : m_workerList) {
try {
loadWorker.join();
} catch (InterruptedException e) {
// ignore
}
}
} | [
"private",
"void",
"stopWorkers",
"(",
")",
"{",
"Record",
"sentinel",
"=",
"Record",
".",
"SENTINEL",
";",
"for",
"(",
"int",
"inx",
"=",
"0",
";",
"inx",
"<",
"m_workerList",
".",
"size",
"(",
")",
";",
"inx",
"++",
")",
"{",
"try",
"{",
"m_workerQueue",
".",
"put",
"(",
"sentinel",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"// ignore\r",
"}",
"}",
"for",
"(",
"LoadWorker",
"loadWorker",
":",
"m_workerList",
")",
"{",
"try",
"{",
"loadWorker",
".",
"join",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"// ignore\r",
"}",
"}",
"}"
] | Add a sentinel to the queue for each worker and wait all to finish. | [
"Add",
"a",
"sentinel",
"to",
"the",
"queue",
"for",
"each",
"worker",
"and",
"wait",
"all",
"to",
"finish",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L513-L530 |
138,109 | QSFT/Doradus | doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java | CSVLoader.tokenizeCSVLine | private boolean tokenizeCSVLine(CSVFile csvFile,
BufferedReader reader,
Map<String, String> fieldMap) {
fieldMap.clear();
m_token.setLength(0);
// First build a list of tokens found in the order they are found.
List<String> tokenList = new ArrayList<String>();
boolean bInQuote = false;
int aChar = 0;
try {
while (true) {
aChar = reader.read();
if (aChar < 0) {
break;
}
if (!bInQuote && aChar == ',') {
tokenList.add(m_token.toString());
m_token.setLength(0);
} else if (!bInQuote && aChar == '\r') {
tokenList.add(m_token.toString());
m_token.setLength(0);
reader.mark(1);
aChar = reader.read();
if (aChar == -1) {
break;
}
if (aChar != '\n') {
reader.reset(); // put back non-LF
}
break;
} else if (!bInQuote && aChar == '\n') {
tokenList.add(m_token.toString());
m_token.setLength(0);
break;
} else if (aChar == '"') {
bInQuote = !bInQuote;
} else {
m_token.append((char)aChar);
}
}
} catch (IOException e) {
logErrorThrow("I/O error reading file", e.toString());
}
// If we hit EOF without a final EOL, we could have a token in the buffer.
if (m_token.length() > 0) {
tokenList.add(m_token.toString());
m_token.setLength(0);
}
if (tokenList.size() > 0) {
for (int index = 0; index < tokenList.size(); index++) {
String token = tokenList.get(index).trim();
if (token.length() > 0) {
String fieldName = csvFile.m_fieldList.get(index);
fieldMap.put(fieldName, token);
}
}
return true;
}
// No tokens found; return false if EOF.
return aChar != -1;
} | java | private boolean tokenizeCSVLine(CSVFile csvFile,
BufferedReader reader,
Map<String, String> fieldMap) {
fieldMap.clear();
m_token.setLength(0);
// First build a list of tokens found in the order they are found.
List<String> tokenList = new ArrayList<String>();
boolean bInQuote = false;
int aChar = 0;
try {
while (true) {
aChar = reader.read();
if (aChar < 0) {
break;
}
if (!bInQuote && aChar == ',') {
tokenList.add(m_token.toString());
m_token.setLength(0);
} else if (!bInQuote && aChar == '\r') {
tokenList.add(m_token.toString());
m_token.setLength(0);
reader.mark(1);
aChar = reader.read();
if (aChar == -1) {
break;
}
if (aChar != '\n') {
reader.reset(); // put back non-LF
}
break;
} else if (!bInQuote && aChar == '\n') {
tokenList.add(m_token.toString());
m_token.setLength(0);
break;
} else if (aChar == '"') {
bInQuote = !bInQuote;
} else {
m_token.append((char)aChar);
}
}
} catch (IOException e) {
logErrorThrow("I/O error reading file", e.toString());
}
// If we hit EOF without a final EOL, we could have a token in the buffer.
if (m_token.length() > 0) {
tokenList.add(m_token.toString());
m_token.setLength(0);
}
if (tokenList.size() > 0) {
for (int index = 0; index < tokenList.size(); index++) {
String token = tokenList.get(index).trim();
if (token.length() > 0) {
String fieldName = csvFile.m_fieldList.get(index);
fieldMap.put(fieldName, token);
}
}
return true;
}
// No tokens found; return false if EOF.
return aChar != -1;
} | [
"private",
"boolean",
"tokenizeCSVLine",
"(",
"CSVFile",
"csvFile",
",",
"BufferedReader",
"reader",
",",
"Map",
"<",
"String",
",",
"String",
">",
"fieldMap",
")",
"{",
"fieldMap",
".",
"clear",
"(",
")",
";",
"m_token",
".",
"setLength",
"(",
"0",
")",
";",
"// First build a list of tokens found in the order they are found.\r",
"List",
"<",
"String",
">",
"tokenList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"boolean",
"bInQuote",
"=",
"false",
";",
"int",
"aChar",
"=",
"0",
";",
"try",
"{",
"while",
"(",
"true",
")",
"{",
"aChar",
"=",
"reader",
".",
"read",
"(",
")",
";",
"if",
"(",
"aChar",
"<",
"0",
")",
"{",
"break",
";",
"}",
"if",
"(",
"!",
"bInQuote",
"&&",
"aChar",
"==",
"'",
"'",
")",
"{",
"tokenList",
".",
"add",
"(",
"m_token",
".",
"toString",
"(",
")",
")",
";",
"m_token",
".",
"setLength",
"(",
"0",
")",
";",
"}",
"else",
"if",
"(",
"!",
"bInQuote",
"&&",
"aChar",
"==",
"'",
"'",
")",
"{",
"tokenList",
".",
"add",
"(",
"m_token",
".",
"toString",
"(",
")",
")",
";",
"m_token",
".",
"setLength",
"(",
"0",
")",
";",
"reader",
".",
"mark",
"(",
"1",
")",
";",
"aChar",
"=",
"reader",
".",
"read",
"(",
")",
";",
"if",
"(",
"aChar",
"==",
"-",
"1",
")",
"{",
"break",
";",
"}",
"if",
"(",
"aChar",
"!=",
"'",
"'",
")",
"{",
"reader",
".",
"reset",
"(",
")",
";",
"// put back non-LF\r",
"}",
"break",
";",
"}",
"else",
"if",
"(",
"!",
"bInQuote",
"&&",
"aChar",
"==",
"'",
"'",
")",
"{",
"tokenList",
".",
"add",
"(",
"m_token",
".",
"toString",
"(",
")",
")",
";",
"m_token",
".",
"setLength",
"(",
"0",
")",
";",
"break",
";",
"}",
"else",
"if",
"(",
"aChar",
"==",
"'",
"'",
")",
"{",
"bInQuote",
"=",
"!",
"bInQuote",
";",
"}",
"else",
"{",
"m_token",
".",
"append",
"(",
"(",
"char",
")",
"aChar",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logErrorThrow",
"(",
"\"I/O error reading file\"",
",",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"// If we hit EOF without a final EOL, we could have a token in the buffer.\r",
"if",
"(",
"m_token",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"tokenList",
".",
"add",
"(",
"m_token",
".",
"toString",
"(",
")",
")",
";",
"m_token",
".",
"setLength",
"(",
"0",
")",
";",
"}",
"if",
"(",
"tokenList",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"tokenList",
".",
"size",
"(",
")",
";",
"index",
"++",
")",
"{",
"String",
"token",
"=",
"tokenList",
".",
"get",
"(",
"index",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"token",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"String",
"fieldName",
"=",
"csvFile",
".",
"m_fieldList",
".",
"get",
"(",
"index",
")",
";",
"fieldMap",
".",
"put",
"(",
"fieldName",
",",
"token",
")",
";",
"}",
"}",
"return",
"true",
";",
"}",
"// No tokens found; return false if EOF.\r",
"return",
"aChar",
"!=",
"-",
"1",
";",
"}"
] | into the given field map. | [
"into",
"the",
"given",
"field",
"map",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L534-L599 |
138,110 | QSFT/Doradus | doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java | CSVLoader.logErrorThrow | private void logErrorThrow(String format, Object... args) {
String msg = MessageFormatter.arrayFormat(format, args).getMessage();
m_logger.error(msg);
throw new RuntimeException(msg);
} | java | private void logErrorThrow(String format, Object... args) {
String msg = MessageFormatter.arrayFormat(format, args).getMessage();
m_logger.error(msg);
throw new RuntimeException(msg);
} | [
"private",
"void",
"logErrorThrow",
"(",
"String",
"format",
",",
"Object",
"...",
"args",
")",
"{",
"String",
"msg",
"=",
"MessageFormatter",
".",
"arrayFormat",
"(",
"format",
",",
"args",
")",
".",
"getMessage",
"(",
")",
";",
"m_logger",
".",
"error",
"(",
"msg",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"msg",
")",
";",
"}"
] | a RuntimeException. | [
"a",
"RuntimeException",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L603-L607 |
138,111 | QSFT/Doradus | doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java | CSVLoader.validateRootFolder | private void validateRootFolder() {
File rootDir = new File(m_config.root);
if (!rootDir.exists()) {
logErrorThrow("Root directory does not exist: {}", m_config.root);
} else if (!rootDir.isDirectory()) {
logErrorThrow("Root directory must be a folder: {}", m_config.root);
} else if (!m_config.root.endsWith(File.separator)) {
m_config.root = m_config.root + File.separator;
}
} | java | private void validateRootFolder() {
File rootDir = new File(m_config.root);
if (!rootDir.exists()) {
logErrorThrow("Root directory does not exist: {}", m_config.root);
} else if (!rootDir.isDirectory()) {
logErrorThrow("Root directory must be a folder: {}", m_config.root);
} else if (!m_config.root.endsWith(File.separator)) {
m_config.root = m_config.root + File.separator;
}
} | [
"private",
"void",
"validateRootFolder",
"(",
")",
"{",
"File",
"rootDir",
"=",
"new",
"File",
"(",
"m_config",
".",
"root",
")",
";",
"if",
"(",
"!",
"rootDir",
".",
"exists",
"(",
")",
")",
"{",
"logErrorThrow",
"(",
"\"Root directory does not exist: {}\"",
",",
"m_config",
".",
"root",
")",
";",
"}",
"else",
"if",
"(",
"!",
"rootDir",
".",
"isDirectory",
"(",
")",
")",
"{",
"logErrorThrow",
"(",
"\"Root directory must be a folder: {}\"",
",",
"m_config",
".",
"root",
")",
";",
"}",
"else",
"if",
"(",
"!",
"m_config",
".",
"root",
".",
"endsWith",
"(",
"File",
".",
"separator",
")",
")",
"{",
"m_config",
".",
"root",
"=",
"m_config",
".",
"root",
"+",
"File",
".",
"separator",
";",
"}",
"}"
] | Root directory must exist and be a folder | [
"Root",
"directory",
"must",
"exist",
"and",
"be",
"a",
"folder"
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L610-L619 |
138,112 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/management/IntervalHistogram.java | IntervalHistogram.add | public void add(long value) {
int index = Arrays.binarySearch(bins, value);
if (index < 0) {
// inexact match, take the first bin higher than value
index = -index - 1;
}
hits.incrementAndGet(index);
} | java | public void add(long value) {
int index = Arrays.binarySearch(bins, value);
if (index < 0) {
// inexact match, take the first bin higher than value
index = -index - 1;
}
hits.incrementAndGet(index);
} | [
"public",
"void",
"add",
"(",
"long",
"value",
")",
"{",
"int",
"index",
"=",
"Arrays",
".",
"binarySearch",
"(",
"bins",
",",
"value",
")",
";",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"// inexact match, take the first bin higher than value\r",
"index",
"=",
"-",
"index",
"-",
"1",
";",
"}",
"hits",
".",
"incrementAndGet",
"(",
"index",
")",
";",
"}"
] | Increments the hits in interval containing given 'value', rounding UP.
@param value | [
"Increments",
"the",
"hits",
"in",
"interval",
"containing",
"given",
"value",
"rounding",
"UP",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/management/IntervalHistogram.java#L71-L78 |
138,113 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/management/IntervalHistogram.java | IntervalHistogram.getMean | public long getMean() {
int n = bins.length;
if (hits.get(n) > 0) {
return Long.MAX_VALUE;
}
long cnt = 0;
long sum = 0;
for (int i = 0; i < n; i++) {
cnt += hits.get(i);
sum += hits.get(i) * bins[i];
}
return (long) Math.ceil((double) sum / cnt);
} | java | public long getMean() {
int n = bins.length;
if (hits.get(n) > 0) {
return Long.MAX_VALUE;
}
long cnt = 0;
long sum = 0;
for (int i = 0; i < n; i++) {
cnt += hits.get(i);
sum += hits.get(i) * bins[i];
}
return (long) Math.ceil((double) sum / cnt);
} | [
"public",
"long",
"getMean",
"(",
")",
"{",
"int",
"n",
"=",
"bins",
".",
"length",
";",
"if",
"(",
"hits",
".",
"get",
"(",
"n",
")",
">",
"0",
")",
"{",
"return",
"Long",
".",
"MAX_VALUE",
";",
"}",
"long",
"cnt",
"=",
"0",
";",
"long",
"sum",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"cnt",
"+=",
"hits",
".",
"get",
"(",
"i",
")",
";",
"sum",
"+=",
"hits",
".",
"get",
"(",
"i",
")",
"*",
"bins",
"[",
"i",
"]",
";",
"}",
"return",
"(",
"long",
")",
"Math",
".",
"ceil",
"(",
"(",
"double",
")",
"sum",
"/",
"cnt",
")",
";",
"}"
] | The mean histogram value. If the histogram overflowed, returns
Long.MAX_VALUE. | [
"The",
"mean",
"histogram",
"value",
".",
"If",
"the",
"histogram",
"overflowed",
"returns",
"Long",
".",
"MAX_VALUE",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/management/IntervalHistogram.java#L133-L147 |
138,114 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/management/IntervalHistogram.java | IntervalHistogram.getMin | public long getMin() {
for (int i = 0; i < hits.length(); i++) {
if (hits.get(i) > 0) {
return i == 0 ? 0 : 1 + bins[i - 1];
}
}
return 0;
} | java | public long getMin() {
for (int i = 0; i < hits.length(); i++) {
if (hits.get(i) > 0) {
return i == 0 ? 0 : 1 + bins[i - 1];
}
}
return 0;
} | [
"public",
"long",
"getMin",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"hits",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"hits",
".",
"get",
"(",
"i",
")",
">",
"0",
")",
"{",
"return",
"i",
"==",
"0",
"?",
"0",
":",
"1",
"+",
"bins",
"[",
"i",
"-",
"1",
"]",
";",
"}",
"}",
"return",
"0",
";",
"}"
] | The starting point of interval that contains the smallest value added to
this histogram. | [
"The",
"starting",
"point",
"of",
"interval",
"that",
"contains",
"the",
"smallest",
"value",
"added",
"to",
"this",
"histogram",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/management/IntervalHistogram.java#L153-L160 |
138,115 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/management/IntervalHistogram.java | IntervalHistogram.getMax | public long getMax() {
int lastBin = hits.length() - 1;
if (hits.get(lastBin) > 0) {
return Long.MAX_VALUE;
}
for (int i = lastBin - 1; i >= 0; i--) {
if (hits.get(i) > 0) {
return bins[i];
}
}
return 0;
} | java | public long getMax() {
int lastBin = hits.length() - 1;
if (hits.get(lastBin) > 0) {
return Long.MAX_VALUE;
}
for (int i = lastBin - 1; i >= 0; i--) {
if (hits.get(i) > 0) {
return bins[i];
}
}
return 0;
} | [
"public",
"long",
"getMax",
"(",
")",
"{",
"int",
"lastBin",
"=",
"hits",
".",
"length",
"(",
")",
"-",
"1",
";",
"if",
"(",
"hits",
".",
"get",
"(",
"lastBin",
")",
">",
"0",
")",
"{",
"return",
"Long",
".",
"MAX_VALUE",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"lastBin",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"hits",
".",
"get",
"(",
"i",
")",
">",
"0",
")",
"{",
"return",
"bins",
"[",
"i",
"]",
";",
"}",
"}",
"return",
"0",
";",
"}"
] | The end-point of interval that contains the largest value added to this
histogram. If the histogram overflowed, returns Long.MAX_VALUE. | [
"The",
"end",
"-",
"point",
"of",
"interval",
"that",
"contains",
"the",
"largest",
"value",
"added",
"to",
"this",
"histogram",
".",
"If",
"the",
"histogram",
"overflowed",
"returns",
"Long",
".",
"MAX_VALUE",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/management/IntervalHistogram.java#L166-L178 |
138,116 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/management/IntervalHistogram.java | IntervalHistogram.snapshot | public IntervalHistogram snapshot(boolean reset) {
if (reset) {
return new IntervalHistogram(bins, getAndResetHits());
}
return new IntervalHistogram(bins, getHits());
} | java | public IntervalHistogram snapshot(boolean reset) {
if (reset) {
return new IntervalHistogram(bins, getAndResetHits());
}
return new IntervalHistogram(bins, getHits());
} | [
"public",
"IntervalHistogram",
"snapshot",
"(",
"boolean",
"reset",
")",
"{",
"if",
"(",
"reset",
")",
"{",
"return",
"new",
"IntervalHistogram",
"(",
"bins",
",",
"getAndResetHits",
"(",
")",
")",
";",
"}",
"return",
"new",
"IntervalHistogram",
"(",
"bins",
",",
"getHits",
"(",
")",
")",
";",
"}"
] | Clones this histogram and zeroizes out hits afterwards if the 'reset' is
true.
@param reset
zero out hits
@return clone of this histogram's state | [
"Clones",
"this",
"histogram",
"and",
"zeroizes",
"out",
"hits",
"afterwards",
"if",
"the",
"reset",
"is",
"true",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/management/IntervalHistogram.java#L197-L202 |
138,117 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/TenantDefinition.java | TenantDefinition.getOptionMap | @SuppressWarnings("unchecked")
public Map<String, Object> getOptionMap(String optName) {
Object optValue = m_options.get(optName);
if (optValue == null) {
return null;
}
if (!(optValue instanceof Map)) {
throw new IllegalArgumentException("Tenant option '" + optName + "' should be a map: " + optValue);
}
return (Map<String, Object>)optValue;
} | java | @SuppressWarnings("unchecked")
public Map<String, Object> getOptionMap(String optName) {
Object optValue = m_options.get(optName);
if (optValue == null) {
return null;
}
if (!(optValue instanceof Map)) {
throw new IllegalArgumentException("Tenant option '" + optName + "' should be a map: " + optValue);
}
return (Map<String, Object>)optValue;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"getOptionMap",
"(",
"String",
"optName",
")",
"{",
"Object",
"optValue",
"=",
"m_options",
".",
"get",
"(",
"optName",
")",
";",
"if",
"(",
"optValue",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"(",
"optValue",
"instanceof",
"Map",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Tenant option '\"",
"+",
"optName",
"+",
"\"' should be a map: \"",
"+",
"optValue",
")",
";",
"}",
"return",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"optValue",
";",
"}"
] | Get the value of the option with the given name as a Map. If the option is not
defined, null is returned. If the option value is not a Map, an
IllegalArgumentException is thrown.
@param optName Name of option to fetch.
@return Option value as a String-to-Object map or null if not defined. | [
"Get",
"the",
"value",
"of",
"the",
"option",
"with",
"the",
"given",
"name",
"as",
"a",
"Map",
".",
"If",
"the",
"option",
"is",
"not",
"defined",
"null",
"is",
"returned",
".",
"If",
"the",
"option",
"value",
"is",
"not",
"a",
"Map",
"an",
"IllegalArgumentException",
"is",
"thrown",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/TenantDefinition.java#L135-L145 |
138,118 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/TenantDefinition.java | TenantDefinition.optionValueToUNode | @SuppressWarnings("unchecked")
private UNode optionValueToUNode(String optName, Object optValue) {
if (!(optValue instanceof Map)) {
if (optValue == null) {
optValue = "";
}
return UNode.createValueNode(optName, optValue.toString(), "option");
}
UNode optNode = UNode.createMapNode(optName, "option");
Map<String, Object> suboptMap = (Map<String,Object>)optValue;
for (String suboptName : suboptMap.keySet()) {
optNode.addChildNode(optionValueToUNode(suboptName, suboptMap.get(suboptName)));
}
return optNode;
} | java | @SuppressWarnings("unchecked")
private UNode optionValueToUNode(String optName, Object optValue) {
if (!(optValue instanceof Map)) {
if (optValue == null) {
optValue = "";
}
return UNode.createValueNode(optName, optValue.toString(), "option");
}
UNode optNode = UNode.createMapNode(optName, "option");
Map<String, Object> suboptMap = (Map<String,Object>)optValue;
for (String suboptName : suboptMap.keySet()) {
optNode.addChildNode(optionValueToUNode(suboptName, suboptMap.get(suboptName)));
}
return optNode;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"UNode",
"optionValueToUNode",
"(",
"String",
"optName",
",",
"Object",
"optValue",
")",
"{",
"if",
"(",
"!",
"(",
"optValue",
"instanceof",
"Map",
")",
")",
"{",
"if",
"(",
"optValue",
"==",
"null",
")",
"{",
"optValue",
"=",
"\"\"",
";",
"}",
"return",
"UNode",
".",
"createValueNode",
"(",
"optName",
",",
"optValue",
".",
"toString",
"(",
")",
",",
"\"option\"",
")",
";",
"}",
"UNode",
"optNode",
"=",
"UNode",
".",
"createMapNode",
"(",
"optName",
",",
"\"option\"",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"suboptMap",
"=",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"optValue",
";",
"for",
"(",
"String",
"suboptName",
":",
"suboptMap",
".",
"keySet",
"(",
")",
")",
"{",
"optNode",
".",
"addChildNode",
"(",
"optionValueToUNode",
"(",
"suboptName",
",",
"suboptMap",
".",
"get",
"(",
"suboptName",
")",
")",
")",
";",
"}",
"return",
"optNode",
";",
"}"
] | Return a UNode that represents the given option's serialized value. | [
"Return",
"a",
"UNode",
"that",
"represents",
"the",
"given",
"option",
"s",
"serialized",
"value",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/TenantDefinition.java#L198-L212 |
138,119 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/TenantDefinition.java | TenantDefinition.setOption | public void setOption(String optName, Object optValue) {
if (optValue == null) {
m_options.remove(optName);
} else {
m_options.put(optName, optValue);
}
} | java | public void setOption(String optName, Object optValue) {
if (optValue == null) {
m_options.remove(optName);
} else {
m_options.put(optName, optValue);
}
} | [
"public",
"void",
"setOption",
"(",
"String",
"optName",
",",
"Object",
"optValue",
")",
"{",
"if",
"(",
"optValue",
"==",
"null",
")",
"{",
"m_options",
".",
"remove",
"(",
"optName",
")",
";",
"}",
"else",
"{",
"m_options",
".",
"put",
"(",
"optName",
",",
"optValue",
")",
";",
"}",
"}"
] | Set the given option. If the option was previously defined, the value is
overwritten. If the given value is null, the existing option is removed.
@param optName Option name.
@param optValue Option value, which may be a String or Map<String,Object>. | [
"Set",
"the",
"given",
"option",
".",
"If",
"the",
"option",
"was",
"previously",
"defined",
"the",
"value",
"is",
"overwritten",
".",
"If",
"the",
"given",
"value",
"is",
"null",
"the",
"existing",
"option",
"is",
"removed",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/TenantDefinition.java#L253-L259 |
138,120 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/TenantDefinition.java | TenantDefinition.parse | public void parse(UNode tenantNode) {
assert tenantNode != null;
m_name = tenantNode.getName();
for (String childName : tenantNode.getMemberNames()) {
UNode childNode = tenantNode.getMember(childName);
switch (childNode.getName()) {
case "options":
for (UNode optNode : childNode.getMemberList()) {
m_options.put(optNode.getName(), parseOption(optNode));
}
break;
case "users":
for (UNode userNode : childNode.getMemberList()) {
UserDefinition userDef = new UserDefinition();
userDef.parse(userNode);
m_users.put(userDef.getID(), userDef);
}
break;
case "properties":
for (UNode propNode : childNode.getMemberList()) {
Utils.require(propNode.isValue(), "'property' must be a value: " + propNode);
m_properties.put(propNode.getName(), propNode.getValue());
}
break;
default:
Utils.require(false, "Unknown tenant property: " + childNode);
}
}
} | java | public void parse(UNode tenantNode) {
assert tenantNode != null;
m_name = tenantNode.getName();
for (String childName : tenantNode.getMemberNames()) {
UNode childNode = tenantNode.getMember(childName);
switch (childNode.getName()) {
case "options":
for (UNode optNode : childNode.getMemberList()) {
m_options.put(optNode.getName(), parseOption(optNode));
}
break;
case "users":
for (UNode userNode : childNode.getMemberList()) {
UserDefinition userDef = new UserDefinition();
userDef.parse(userNode);
m_users.put(userDef.getID(), userDef);
}
break;
case "properties":
for (UNode propNode : childNode.getMemberList()) {
Utils.require(propNode.isValue(), "'property' must be a value: " + propNode);
m_properties.put(propNode.getName(), propNode.getValue());
}
break;
default:
Utils.require(false, "Unknown tenant property: " + childNode);
}
}
} | [
"public",
"void",
"parse",
"(",
"UNode",
"tenantNode",
")",
"{",
"assert",
"tenantNode",
"!=",
"null",
";",
"m_name",
"=",
"tenantNode",
".",
"getName",
"(",
")",
";",
"for",
"(",
"String",
"childName",
":",
"tenantNode",
".",
"getMemberNames",
"(",
")",
")",
"{",
"UNode",
"childNode",
"=",
"tenantNode",
".",
"getMember",
"(",
"childName",
")",
";",
"switch",
"(",
"childNode",
".",
"getName",
"(",
")",
")",
"{",
"case",
"\"options\"",
":",
"for",
"(",
"UNode",
"optNode",
":",
"childNode",
".",
"getMemberList",
"(",
")",
")",
"{",
"m_options",
".",
"put",
"(",
"optNode",
".",
"getName",
"(",
")",
",",
"parseOption",
"(",
"optNode",
")",
")",
";",
"}",
"break",
";",
"case",
"\"users\"",
":",
"for",
"(",
"UNode",
"userNode",
":",
"childNode",
".",
"getMemberList",
"(",
")",
")",
"{",
"UserDefinition",
"userDef",
"=",
"new",
"UserDefinition",
"(",
")",
";",
"userDef",
".",
"parse",
"(",
"userNode",
")",
";",
"m_users",
".",
"put",
"(",
"userDef",
".",
"getID",
"(",
")",
",",
"userDef",
")",
";",
"}",
"break",
";",
"case",
"\"properties\"",
":",
"for",
"(",
"UNode",
"propNode",
":",
"childNode",
".",
"getMemberList",
"(",
")",
")",
"{",
"Utils",
".",
"require",
"(",
"propNode",
".",
"isValue",
"(",
")",
",",
"\"'property' must be a value: \"",
"+",
"propNode",
")",
";",
"m_properties",
".",
"put",
"(",
"propNode",
".",
"getName",
"(",
")",
",",
"propNode",
".",
"getValue",
"(",
")",
")",
";",
"}",
"break",
";",
"default",
":",
"Utils",
".",
"require",
"(",
"false",
",",
"\"Unknown tenant property: \"",
"+",
"childNode",
")",
";",
"}",
"}",
"}"
] | Parse the tenant definition rooted at given UNode tree and update this object to
match. The root node is the "tenant" object, so its name is the tenant name and its
child nodes are tenant definitions such as "users" and "options". An exception is
thrown if the definition contains an error.
@param tenantNode Root of a UNode tree that defines a tenant. | [
"Parse",
"the",
"tenant",
"definition",
"rooted",
"at",
"given",
"UNode",
"tree",
"and",
"update",
"this",
"object",
"to",
"match",
".",
"The",
"root",
"node",
"is",
"the",
"tenant",
"object",
"so",
"its",
"name",
"is",
"the",
"tenant",
"name",
"and",
"its",
"child",
"nodes",
"are",
"tenant",
"definitions",
"such",
"as",
"users",
"and",
"options",
".",
"An",
"exception",
"is",
"thrown",
"if",
"the",
"definition",
"contains",
"an",
"error",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/TenantDefinition.java#L280-L309 |
138,121 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/TenantDefinition.java | TenantDefinition.parseOption | private Object parseOption(UNode optionNode) {
if (optionNode.isValue()) {
return optionNode.getValue();
}
Map<String, Object> optValueMap = new HashMap<>();
for (UNode suboptNode : optionNode.getMemberList()) {
optValueMap.put(suboptNode.getName(), parseOption(suboptNode));
}
return optValueMap;
} | java | private Object parseOption(UNode optionNode) {
if (optionNode.isValue()) {
return optionNode.getValue();
}
Map<String, Object> optValueMap = new HashMap<>();
for (UNode suboptNode : optionNode.getMemberList()) {
optValueMap.put(suboptNode.getName(), parseOption(suboptNode));
}
return optValueMap;
} | [
"private",
"Object",
"parseOption",
"(",
"UNode",
"optionNode",
")",
"{",
"if",
"(",
"optionNode",
".",
"isValue",
"(",
")",
")",
"{",
"return",
"optionNode",
".",
"getValue",
"(",
")",
";",
"}",
"Map",
"<",
"String",
",",
"Object",
">",
"optValueMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"UNode",
"suboptNode",
":",
"optionNode",
".",
"getMemberList",
"(",
")",
")",
"{",
"optValueMap",
".",
"put",
"(",
"suboptNode",
".",
"getName",
"(",
")",
",",
"parseOption",
"(",
"suboptNode",
")",
")",
";",
"}",
"return",
"optValueMap",
";",
"}"
] | Parse an option UNode, which may be a value or a map. | [
"Parse",
"an",
"option",
"UNode",
"which",
"may",
"be",
"a",
"value",
"or",
"a",
"map",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/TenantDefinition.java#L312-L321 |
138,122 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/core/ServerConfig.java | ServerConfig.load | @SuppressWarnings("unchecked")
public static ServerConfig load(String[] args) throws ConfigurationException {
if(config != null) {
logger.warn("Configuration is loaded already. Use ServerConfig.getInstance() method. ");
return config;
}
try {
URL url = getConfigUrl();
logger.info("Trying to load settings from: " + url);
InputStream input = null;
try {
input = url.openStream();
} catch (IOException e) {
throw new AssertionError(e);
}
Yaml yaml = new Yaml();
LinkedHashMap<String, ?> dataColl = (LinkedHashMap<String, ?>)yaml.load(input);
config = new ServerConfig();
setParams(dataColl);
logger.info("Ok. Configuration loaded.");
} catch (ConfigurationException e) {
logger.warn(e.getMessage() + " -- Ignoring.");
} catch (YAMLException e) {
logger.warn(e.getMessage() + " -- Ignoring.");
}
if (config == null) {
logger.info("Initializing configuration by default settings.");
config = new ServerConfig();
}
try {
if (args != null && args.length > 0) {
logger.info("Parsing the command line arguments...");
parseCommandLineArgs(args);
logger.info("Ok. Arguments parsed.");
}
} catch (ConfigurationException e) {
logger.error("Fatal configuration error", e);
System.err.println(e.getMessage() + "\nFatal configuration error. Unable to start server. See log for stacktrace.");
throw e;
}
//overrides with params from the file
if (!Utils.isEmpty(config.param_override_filename)) {
try {
InputStream overrideFile = new FileInputStream(config.param_override_filename);
Yaml yaml = new Yaml();
LinkedHashMap<String, ?> overrideColl = (LinkedHashMap<String, ?>)yaml.load(overrideFile);
setParams(overrideColl);
} catch (Exception e) {
logger.warn(e.getMessage() + " -- Ignoring.");
}
}
return config;
} | java | @SuppressWarnings("unchecked")
public static ServerConfig load(String[] args) throws ConfigurationException {
if(config != null) {
logger.warn("Configuration is loaded already. Use ServerConfig.getInstance() method. ");
return config;
}
try {
URL url = getConfigUrl();
logger.info("Trying to load settings from: " + url);
InputStream input = null;
try {
input = url.openStream();
} catch (IOException e) {
throw new AssertionError(e);
}
Yaml yaml = new Yaml();
LinkedHashMap<String, ?> dataColl = (LinkedHashMap<String, ?>)yaml.load(input);
config = new ServerConfig();
setParams(dataColl);
logger.info("Ok. Configuration loaded.");
} catch (ConfigurationException e) {
logger.warn(e.getMessage() + " -- Ignoring.");
} catch (YAMLException e) {
logger.warn(e.getMessage() + " -- Ignoring.");
}
if (config == null) {
logger.info("Initializing configuration by default settings.");
config = new ServerConfig();
}
try {
if (args != null && args.length > 0) {
logger.info("Parsing the command line arguments...");
parseCommandLineArgs(args);
logger.info("Ok. Arguments parsed.");
}
} catch (ConfigurationException e) {
logger.error("Fatal configuration error", e);
System.err.println(e.getMessage() + "\nFatal configuration error. Unable to start server. See log for stacktrace.");
throw e;
}
//overrides with params from the file
if (!Utils.isEmpty(config.param_override_filename)) {
try {
InputStream overrideFile = new FileInputStream(config.param_override_filename);
Yaml yaml = new Yaml();
LinkedHashMap<String, ?> overrideColl = (LinkedHashMap<String, ?>)yaml.load(overrideFile);
setParams(overrideColl);
} catch (Exception e) {
logger.warn(e.getMessage() + " -- Ignoring.");
}
}
return config;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"ServerConfig",
"load",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"ConfigurationException",
"{",
"if",
"(",
"config",
"!=",
"null",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Configuration is loaded already. Use ServerConfig.getInstance() method. \"",
")",
";",
"return",
"config",
";",
"}",
"try",
"{",
"URL",
"url",
"=",
"getConfigUrl",
"(",
")",
";",
"logger",
".",
"info",
"(",
"\"Trying to load settings from: \"",
"+",
"url",
")",
";",
"InputStream",
"input",
"=",
"null",
";",
"try",
"{",
"input",
"=",
"url",
".",
"openStream",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"e",
")",
";",
"}",
"Yaml",
"yaml",
"=",
"new",
"Yaml",
"(",
")",
";",
"LinkedHashMap",
"<",
"String",
",",
"?",
">",
"dataColl",
"=",
"(",
"LinkedHashMap",
"<",
"String",
",",
"?",
">",
")",
"yaml",
".",
"load",
"(",
"input",
")",
";",
"config",
"=",
"new",
"ServerConfig",
"(",
")",
";",
"setParams",
"(",
"dataColl",
")",
";",
"logger",
".",
"info",
"(",
"\"Ok. Configuration loaded.\"",
")",
";",
"}",
"catch",
"(",
"ConfigurationException",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"e",
".",
"getMessage",
"(",
")",
"+",
"\" -- Ignoring.\"",
")",
";",
"}",
"catch",
"(",
"YAMLException",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"e",
".",
"getMessage",
"(",
")",
"+",
"\" -- Ignoring.\"",
")",
";",
"}",
"if",
"(",
"config",
"==",
"null",
")",
"{",
"logger",
".",
"info",
"(",
"\"Initializing configuration by default settings.\"",
")",
";",
"config",
"=",
"new",
"ServerConfig",
"(",
")",
";",
"}",
"try",
"{",
"if",
"(",
"args",
"!=",
"null",
"&&",
"args",
".",
"length",
">",
"0",
")",
"{",
"logger",
".",
"info",
"(",
"\"Parsing the command line arguments...\"",
")",
";",
"parseCommandLineArgs",
"(",
"args",
")",
";",
"logger",
".",
"info",
"(",
"\"Ok. Arguments parsed.\"",
")",
";",
"}",
"}",
"catch",
"(",
"ConfigurationException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Fatal configuration error\"",
",",
"e",
")",
";",
"System",
".",
"err",
".",
"println",
"(",
"e",
".",
"getMessage",
"(",
")",
"+",
"\"\\nFatal configuration error. Unable to start server. See log for stacktrace.\"",
")",
";",
"throw",
"e",
";",
"}",
"//overrides with params from the file\r",
"if",
"(",
"!",
"Utils",
".",
"isEmpty",
"(",
"config",
".",
"param_override_filename",
")",
")",
"{",
"try",
"{",
"InputStream",
"overrideFile",
"=",
"new",
"FileInputStream",
"(",
"config",
".",
"param_override_filename",
")",
";",
"Yaml",
"yaml",
"=",
"new",
"Yaml",
"(",
")",
";",
"LinkedHashMap",
"<",
"String",
",",
"?",
">",
"overrideColl",
"=",
"(",
"LinkedHashMap",
"<",
"String",
",",
"?",
">",
")",
"yaml",
".",
"load",
"(",
"overrideFile",
")",
";",
"setParams",
"(",
"overrideColl",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"e",
".",
"getMessage",
"(",
")",
"+",
"\" -- Ignoring.\"",
")",
";",
"}",
"}",
"return",
"config",
";",
"}"
] | Creates and initializes the ServerConfig singleton.
@param args The command line arguments.
@return
@throws ConfigurationException | [
"Creates",
"and",
"initializes",
"the",
"ServerConfig",
"singleton",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/ServerConfig.java#L140-L200 |
138,123 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/core/ServerConfig.java | ServerConfig.setCollectionParam | private static void setCollectionParam(String name, List<?> values) throws ConfigurationException {
try {
Field field = config.getClass().getDeclaredField(name);
Class<?> fieldClass = field.getType();
if (Map.class.isAssignableFrom(fieldClass)) {
setMapParam(field, values);
} else if (List.class.isAssignableFrom(fieldClass)) {
setListParam(field, values);
} else {
throw new ConfigurationException("Invalid value type for parameter: " + name);
}
} catch (SecurityException | NoSuchFieldException e) {
throw new ConfigurationException("Unknown configuration parameter: " + name);
}
} | java | private static void setCollectionParam(String name, List<?> values) throws ConfigurationException {
try {
Field field = config.getClass().getDeclaredField(name);
Class<?> fieldClass = field.getType();
if (Map.class.isAssignableFrom(fieldClass)) {
setMapParam(field, values);
} else if (List.class.isAssignableFrom(fieldClass)) {
setListParam(field, values);
} else {
throw new ConfigurationException("Invalid value type for parameter: " + name);
}
} catch (SecurityException | NoSuchFieldException e) {
throw new ConfigurationException("Unknown configuration parameter: " + name);
}
} | [
"private",
"static",
"void",
"setCollectionParam",
"(",
"String",
"name",
",",
"List",
"<",
"?",
">",
"values",
")",
"throws",
"ConfigurationException",
"{",
"try",
"{",
"Field",
"field",
"=",
"config",
".",
"getClass",
"(",
")",
".",
"getDeclaredField",
"(",
"name",
")",
";",
"Class",
"<",
"?",
">",
"fieldClass",
"=",
"field",
".",
"getType",
"(",
")",
";",
"if",
"(",
"Map",
".",
"class",
".",
"isAssignableFrom",
"(",
"fieldClass",
")",
")",
"{",
"setMapParam",
"(",
"field",
",",
"values",
")",
";",
"}",
"else",
"if",
"(",
"List",
".",
"class",
".",
"isAssignableFrom",
"(",
"fieldClass",
")",
")",
"{",
"setListParam",
"(",
"field",
",",
"values",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"\"Invalid value type for parameter: \"",
"+",
"name",
")",
";",
"}",
"}",
"catch",
"(",
"SecurityException",
"|",
"NoSuchFieldException",
"e",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"\"Unknown configuration parameter: \"",
"+",
"name",
")",
";",
"}",
"}"
] | Set a configuration parameter with a Collection type. | [
"Set",
"a",
"configuration",
"parameter",
"with",
"a",
"Collection",
"type",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/ServerConfig.java#L445-L459 |
138,124 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.modifyTenant | public TenantDefinition modifyTenant(String tenantName, TenantDefinition newTenantDef) {
checkServiceState();
TenantDefinition oldTenantDef = getTenantDef(tenantName);
Utils.require(oldTenantDef != null, "Tenant '%s' does not exist", tenantName);
modifyTenantProperties(oldTenantDef, newTenantDef);
validateTenantUsers(newTenantDef);
validateTenantUpdate(oldTenantDef, newTenantDef);
storeTenantDefinition(newTenantDef);
DBManagerService.instance().updateTenantDef(newTenantDef);
TenantDefinition updatedTenantDef = getTenantDef(tenantName);
if (updatedTenantDef == null) {
throw new RuntimeException("Tenant definition could not be retrieved after creation: " + tenantName);
}
removeUserHashes(updatedTenantDef);
return updatedTenantDef;
} | java | public TenantDefinition modifyTenant(String tenantName, TenantDefinition newTenantDef) {
checkServiceState();
TenantDefinition oldTenantDef = getTenantDef(tenantName);
Utils.require(oldTenantDef != null, "Tenant '%s' does not exist", tenantName);
modifyTenantProperties(oldTenantDef, newTenantDef);
validateTenantUsers(newTenantDef);
validateTenantUpdate(oldTenantDef, newTenantDef);
storeTenantDefinition(newTenantDef);
DBManagerService.instance().updateTenantDef(newTenantDef);
TenantDefinition updatedTenantDef = getTenantDef(tenantName);
if (updatedTenantDef == null) {
throw new RuntimeException("Tenant definition could not be retrieved after creation: " + tenantName);
}
removeUserHashes(updatedTenantDef);
return updatedTenantDef;
} | [
"public",
"TenantDefinition",
"modifyTenant",
"(",
"String",
"tenantName",
",",
"TenantDefinition",
"newTenantDef",
")",
"{",
"checkServiceState",
"(",
")",
";",
"TenantDefinition",
"oldTenantDef",
"=",
"getTenantDef",
"(",
"tenantName",
")",
";",
"Utils",
".",
"require",
"(",
"oldTenantDef",
"!=",
"null",
",",
"\"Tenant '%s' does not exist\"",
",",
"tenantName",
")",
";",
"modifyTenantProperties",
"(",
"oldTenantDef",
",",
"newTenantDef",
")",
";",
"validateTenantUsers",
"(",
"newTenantDef",
")",
";",
"validateTenantUpdate",
"(",
"oldTenantDef",
",",
"newTenantDef",
")",
";",
"storeTenantDefinition",
"(",
"newTenantDef",
")",
";",
"DBManagerService",
".",
"instance",
"(",
")",
".",
"updateTenantDef",
"(",
"newTenantDef",
")",
";",
"TenantDefinition",
"updatedTenantDef",
"=",
"getTenantDef",
"(",
"tenantName",
")",
";",
"if",
"(",
"updatedTenantDef",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Tenant definition could not be retrieved after creation: \"",
"+",
"tenantName",
")",
";",
"}",
"removeUserHashes",
"(",
"updatedTenantDef",
")",
";",
"return",
"updatedTenantDef",
";",
"}"
] | Modify the tenant with the given name to match the given definition, and return the
updated definition.
@param tenantName Name of tenant to be modified.
@param newTenantDef Updated {@link TenantDefinition} to apply to tenant.
@return Updated {@link TenantDefinition}. | [
"Modify",
"the",
"tenant",
"with",
"the",
"given",
"name",
"to",
"match",
"the",
"given",
"definition",
"and",
"return",
"the",
"updated",
"definition",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L279-L294 |
138,125 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.deleteTenant | public void deleteTenant(String tenantName, Map<String, String> options) {
checkServiceState();
TenantDefinition tenantDef = getTenantDef(tenantName);
if (tenantDef == null) {
return;
}
Tenant tenant = new Tenant(tenantDef);
try {
DBService.instance(tenant).dropNamespace();
} catch (RuntimeException e) {
if (options == null || !"true".equalsIgnoreCase(options.get("ignoreTenantDBNotAvailable"))) {
throw e;
}
m_logger.warn("Drop namespace skipped for tenant '{}'", tenantName);
}
// Delete tenant definition in default database.
Tenant defaultTenant = getDefaultTenant();
DBTransaction dbTran = new DBTransaction(defaultTenant);
dbTran.deleteRow(TENANTS_STORE_NAME, tenantName);
DBService.instance(defaultTenant).commit(dbTran);
DBManagerService.instance().deleteTenantDB(tenant);
} | java | public void deleteTenant(String tenantName, Map<String, String> options) {
checkServiceState();
TenantDefinition tenantDef = getTenantDef(tenantName);
if (tenantDef == null) {
return;
}
Tenant tenant = new Tenant(tenantDef);
try {
DBService.instance(tenant).dropNamespace();
} catch (RuntimeException e) {
if (options == null || !"true".equalsIgnoreCase(options.get("ignoreTenantDBNotAvailable"))) {
throw e;
}
m_logger.warn("Drop namespace skipped for tenant '{}'", tenantName);
}
// Delete tenant definition in default database.
Tenant defaultTenant = getDefaultTenant();
DBTransaction dbTran = new DBTransaction(defaultTenant);
dbTran.deleteRow(TENANTS_STORE_NAME, tenantName);
DBService.instance(defaultTenant).commit(dbTran);
DBManagerService.instance().deleteTenantDB(tenant);
} | [
"public",
"void",
"deleteTenant",
"(",
"String",
"tenantName",
",",
"Map",
"<",
"String",
",",
"String",
">",
"options",
")",
"{",
"checkServiceState",
"(",
")",
";",
"TenantDefinition",
"tenantDef",
"=",
"getTenantDef",
"(",
"tenantName",
")",
";",
"if",
"(",
"tenantDef",
"==",
"null",
")",
"{",
"return",
";",
"}",
"Tenant",
"tenant",
"=",
"new",
"Tenant",
"(",
"tenantDef",
")",
";",
"try",
"{",
"DBService",
".",
"instance",
"(",
"tenant",
")",
".",
"dropNamespace",
"(",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"if",
"(",
"options",
"==",
"null",
"||",
"!",
"\"true\"",
".",
"equalsIgnoreCase",
"(",
"options",
".",
"get",
"(",
"\"ignoreTenantDBNotAvailable\"",
")",
")",
")",
"{",
"throw",
"e",
";",
"}",
"m_logger",
".",
"warn",
"(",
"\"Drop namespace skipped for tenant '{}'\"",
",",
"tenantName",
")",
";",
"}",
"// Delete tenant definition in default database.",
"Tenant",
"defaultTenant",
"=",
"getDefaultTenant",
"(",
")",
";",
"DBTransaction",
"dbTran",
"=",
"new",
"DBTransaction",
"(",
"defaultTenant",
")",
";",
"dbTran",
".",
"deleteRow",
"(",
"TENANTS_STORE_NAME",
",",
"tenantName",
")",
";",
"DBService",
".",
"instance",
"(",
"defaultTenant",
")",
".",
"commit",
"(",
"dbTran",
")",
";",
"DBManagerService",
".",
"instance",
"(",
")",
".",
"deleteTenantDB",
"(",
"tenant",
")",
";",
"}"
] | Delete an existing tenant with the given options. The tenant's keyspace is dropped,
which deletes all user and system tables, and the tenant's users are deleted. The
given options are currently used for testing only. This method is a no-op if the
given tenant does not exist.
@param tenantName Name of tenant to delete. | [
"Delete",
"an",
"existing",
"tenant",
"with",
"the",
"given",
"options",
".",
"The",
"tenant",
"s",
"keyspace",
"is",
"dropped",
"which",
"deletes",
"all",
"user",
"and",
"system",
"tables",
"and",
"the",
"tenant",
"s",
"users",
"are",
"deleted",
".",
"The",
"given",
"options",
"are",
"currently",
"used",
"for",
"testing",
"only",
".",
"This",
"method",
"is",
"a",
"no",
"-",
"op",
"if",
"the",
"given",
"tenant",
"does",
"not",
"exist",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L315-L338 |
138,126 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.initializeDefaultTenant | private void initializeDefaultTenant() {
DBService dbService = DBService.instance();
dbService.createNamespace();
dbService.createStoreIfAbsent(SchemaService.APPS_STORE_NAME, false);
dbService.createStoreIfAbsent(TaskManagerService.TASKS_STORE_NAME, false);
dbService.createStoreIfAbsent(TENANTS_STORE_NAME, false);
storeInitialDefaultTenantDef();
} | java | private void initializeDefaultTenant() {
DBService dbService = DBService.instance();
dbService.createNamespace();
dbService.createStoreIfAbsent(SchemaService.APPS_STORE_NAME, false);
dbService.createStoreIfAbsent(TaskManagerService.TASKS_STORE_NAME, false);
dbService.createStoreIfAbsent(TENANTS_STORE_NAME, false);
storeInitialDefaultTenantDef();
} | [
"private",
"void",
"initializeDefaultTenant",
"(",
")",
"{",
"DBService",
"dbService",
"=",
"DBService",
".",
"instance",
"(",
")",
";",
"dbService",
".",
"createNamespace",
"(",
")",
";",
"dbService",
".",
"createStoreIfAbsent",
"(",
"SchemaService",
".",
"APPS_STORE_NAME",
",",
"false",
")",
";",
"dbService",
".",
"createStoreIfAbsent",
"(",
"TaskManagerService",
".",
"TASKS_STORE_NAME",
",",
"false",
")",
";",
"dbService",
".",
"createStoreIfAbsent",
"(",
"TENANTS_STORE_NAME",
",",
"false",
")",
";",
"storeInitialDefaultTenantDef",
"(",
")",
";",
"}"
] | Ensure that the default tenant and its required metadata tables exist. | [
"Ensure",
"that",
"the",
"default",
"tenant",
"and",
"its",
"required",
"metadata",
"tables",
"exist",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L381-L388 |
138,127 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.modifyTenantProperties | private void modifyTenantProperties(TenantDefinition oldTenantDef, TenantDefinition newTenantDef) {
// _CreatedOn must be the same. _ModifiedOn must be updated.
newTenantDef.setProperty(CREATED_ON_PROP, oldTenantDef.getProperty(CREATED_ON_PROP));
newTenantDef.setProperty(MODIFIED_ON_PROP, Utils.formatDate(new Date().getTime()));
} | java | private void modifyTenantProperties(TenantDefinition oldTenantDef, TenantDefinition newTenantDef) {
// _CreatedOn must be the same. _ModifiedOn must be updated.
newTenantDef.setProperty(CREATED_ON_PROP, oldTenantDef.getProperty(CREATED_ON_PROP));
newTenantDef.setProperty(MODIFIED_ON_PROP, Utils.formatDate(new Date().getTime()));
} | [
"private",
"void",
"modifyTenantProperties",
"(",
"TenantDefinition",
"oldTenantDef",
",",
"TenantDefinition",
"newTenantDef",
")",
"{",
"// _CreatedOn must be the same. _ModifiedOn must be updated.",
"newTenantDef",
".",
"setProperty",
"(",
"CREATED_ON_PROP",
",",
"oldTenantDef",
".",
"getProperty",
"(",
"CREATED_ON_PROP",
")",
")",
";",
"newTenantDef",
".",
"setProperty",
"(",
"MODIFIED_ON_PROP",
",",
"Utils",
".",
"formatDate",
"(",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
")",
")",
";",
"}"
] | Set required properties in a new Tenant Definition.
@param oldTenantDef Old {@link TenantDefinition}.
@param newTenantDef New {@link TenantDefinition}. | [
"Set",
"required",
"properties",
"in",
"a",
"new",
"Tenant",
"Definition",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L396-L400 |
138,128 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.storeInitialDefaultTenantDef | private void storeInitialDefaultTenantDef() {
TenantDefinition tenantDef = getTenantDef(m_defaultTenantName);
if (tenantDef == null) {
tenantDef = createDefaultTenantDefinition();
storeTenantDefinition(tenantDef);
}
} | java | private void storeInitialDefaultTenantDef() {
TenantDefinition tenantDef = getTenantDef(m_defaultTenantName);
if (tenantDef == null) {
tenantDef = createDefaultTenantDefinition();
storeTenantDefinition(tenantDef);
}
} | [
"private",
"void",
"storeInitialDefaultTenantDef",
"(",
")",
"{",
"TenantDefinition",
"tenantDef",
"=",
"getTenantDef",
"(",
"m_defaultTenantName",
")",
";",
"if",
"(",
"tenantDef",
"==",
"null",
")",
"{",
"tenantDef",
"=",
"createDefaultTenantDefinition",
"(",
")",
";",
"storeTenantDefinition",
"(",
"tenantDef",
")",
";",
"}",
"}"
] | Store a tenant definition for the default tenant if one doesn't already exist. | [
"Store",
"a",
"tenant",
"definition",
"for",
"the",
"default",
"tenant",
"if",
"one",
"doesn",
"t",
"already",
"exist",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L411-L417 |
138,129 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.migrateTenantDefinitions | private void migrateTenantDefinitions() {
DBService dbservice = DBService.instance();
List<String> keyspaces = null;
if (dbservice instanceof ThriftService) {
keyspaces = ((ThriftService)dbservice).getDoradusKeyspaces();
} else if (dbservice instanceof CQLService) {
keyspaces = ((CQLService)dbservice).getDoradusKeyspaces();
} else {
return;
}
for (String keyspace : keyspaces) {
migrateTenantDefinition(keyspace);
}
} | java | private void migrateTenantDefinitions() {
DBService dbservice = DBService.instance();
List<String> keyspaces = null;
if (dbservice instanceof ThriftService) {
keyspaces = ((ThriftService)dbservice).getDoradusKeyspaces();
} else if (dbservice instanceof CQLService) {
keyspaces = ((CQLService)dbservice).getDoradusKeyspaces();
} else {
return;
}
for (String keyspace : keyspaces) {
migrateTenantDefinition(keyspace);
}
} | [
"private",
"void",
"migrateTenantDefinitions",
"(",
")",
"{",
"DBService",
"dbservice",
"=",
"DBService",
".",
"instance",
"(",
")",
";",
"List",
"<",
"String",
">",
"keyspaces",
"=",
"null",
";",
"if",
"(",
"dbservice",
"instanceof",
"ThriftService",
")",
"{",
"keyspaces",
"=",
"(",
"(",
"ThriftService",
")",
"dbservice",
")",
".",
"getDoradusKeyspaces",
"(",
")",
";",
"}",
"else",
"if",
"(",
"dbservice",
"instanceof",
"CQLService",
")",
"{",
"keyspaces",
"=",
"(",
"(",
"CQLService",
")",
"dbservice",
")",
".",
"getDoradusKeyspaces",
"(",
")",
";",
"}",
"else",
"{",
"return",
";",
"}",
"for",
"(",
"String",
"keyspace",
":",
"keyspaces",
")",
"{",
"migrateTenantDefinition",
"(",
"keyspace",
")",
";",
"}",
"}"
] | default database. | [
"default",
"database",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L421-L434 |
138,130 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.migrateTenantDefinition | private void migrateTenantDefinition(String keyspace) {
TenantDefinition tempTenantDef = new TenantDefinition();
tempTenantDef.setName(keyspace);
Tenant migratingTenant = new Tenant(tempTenantDef);
DColumn col = DBService.instance(migratingTenant).getColumn("Applications", "_tenant", "Definition");
if (col == null) {
return;
}
m_logger.info("Migrating tenant definition from keyspace {}", keyspace);
TenantDefinition migratingTenantDef = new TenantDefinition();
try {
migratingTenantDef.parse(UNode.parseJSON(col.getValue()));
} catch (Exception e) {
m_logger.warn("Couldn't parse tenant definition; skipping migration of keyspace: " + keyspace, e);
return;
}
storeTenantDefinition(migratingTenantDef);
DBTransaction dbTran = new DBTransaction(migratingTenant);
dbTran.deleteRow("Applications", "_tenant");
DBService.instance(migratingTenant).commit(dbTran);
} | java | private void migrateTenantDefinition(String keyspace) {
TenantDefinition tempTenantDef = new TenantDefinition();
tempTenantDef.setName(keyspace);
Tenant migratingTenant = new Tenant(tempTenantDef);
DColumn col = DBService.instance(migratingTenant).getColumn("Applications", "_tenant", "Definition");
if (col == null) {
return;
}
m_logger.info("Migrating tenant definition from keyspace {}", keyspace);
TenantDefinition migratingTenantDef = new TenantDefinition();
try {
migratingTenantDef.parse(UNode.parseJSON(col.getValue()));
} catch (Exception e) {
m_logger.warn("Couldn't parse tenant definition; skipping migration of keyspace: " + keyspace, e);
return;
}
storeTenantDefinition(migratingTenantDef);
DBTransaction dbTran = new DBTransaction(migratingTenant);
dbTran.deleteRow("Applications", "_tenant");
DBService.instance(migratingTenant).commit(dbTran);
} | [
"private",
"void",
"migrateTenantDefinition",
"(",
"String",
"keyspace",
")",
"{",
"TenantDefinition",
"tempTenantDef",
"=",
"new",
"TenantDefinition",
"(",
")",
";",
"tempTenantDef",
".",
"setName",
"(",
"keyspace",
")",
";",
"Tenant",
"migratingTenant",
"=",
"new",
"Tenant",
"(",
"tempTenantDef",
")",
";",
"DColumn",
"col",
"=",
"DBService",
".",
"instance",
"(",
"migratingTenant",
")",
".",
"getColumn",
"(",
"\"Applications\"",
",",
"\"_tenant\"",
",",
"\"Definition\"",
")",
";",
"if",
"(",
"col",
"==",
"null",
")",
"{",
"return",
";",
"}",
"m_logger",
".",
"info",
"(",
"\"Migrating tenant definition from keyspace {}\"",
",",
"keyspace",
")",
";",
"TenantDefinition",
"migratingTenantDef",
"=",
"new",
"TenantDefinition",
"(",
")",
";",
"try",
"{",
"migratingTenantDef",
".",
"parse",
"(",
"UNode",
".",
"parseJSON",
"(",
"col",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"m_logger",
".",
"warn",
"(",
"\"Couldn't parse tenant definition; skipping migration of keyspace: \"",
"+",
"keyspace",
",",
"e",
")",
";",
"return",
";",
"}",
"storeTenantDefinition",
"(",
"migratingTenantDef",
")",
";",
"DBTransaction",
"dbTran",
"=",
"new",
"DBTransaction",
"(",
"migratingTenant",
")",
";",
"dbTran",
".",
"deleteRow",
"(",
"\"Applications\"",
",",
"\"_tenant\"",
")",
";",
"DBService",
".",
"instance",
"(",
"migratingTenant",
")",
".",
"commit",
"(",
"dbTran",
")",
";",
"}"
] | Migrate legacy "_tenant" row, if it exists to the Tenants table. | [
"Migrate",
"legacy",
"_tenant",
"row",
"if",
"it",
"exists",
"to",
"the",
"Tenants",
"table",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L437-L457 |
138,131 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.defineNewTenant | private void defineNewTenant(TenantDefinition tenantDef) {
validateTenantUsers(tenantDef);
addTenantOptions(tenantDef);
addTenantProperties(tenantDef);
Tenant tenant = new Tenant(tenantDef);
DBService dbService = DBService.instance(tenant);
dbService.createNamespace();
initializeTenantStores(tenant);
storeTenantDefinition(tenantDef);
} | java | private void defineNewTenant(TenantDefinition tenantDef) {
validateTenantUsers(tenantDef);
addTenantOptions(tenantDef);
addTenantProperties(tenantDef);
Tenant tenant = new Tenant(tenantDef);
DBService dbService = DBService.instance(tenant);
dbService.createNamespace();
initializeTenantStores(tenant);
storeTenantDefinition(tenantDef);
} | [
"private",
"void",
"defineNewTenant",
"(",
"TenantDefinition",
"tenantDef",
")",
"{",
"validateTenantUsers",
"(",
"tenantDef",
")",
";",
"addTenantOptions",
"(",
"tenantDef",
")",
";",
"addTenantProperties",
"(",
"tenantDef",
")",
";",
"Tenant",
"tenant",
"=",
"new",
"Tenant",
"(",
"tenantDef",
")",
";",
"DBService",
"dbService",
"=",
"DBService",
".",
"instance",
"(",
"tenant",
")",
";",
"dbService",
".",
"createNamespace",
"(",
")",
";",
"initializeTenantStores",
"(",
"tenant",
")",
";",
"storeTenantDefinition",
"(",
"tenantDef",
")",
";",
"}"
] | Define a new tenant | [
"Define",
"a",
"new",
"tenant"
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L460-L470 |
138,132 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.initializeTenantStores | private void initializeTenantStores(Tenant tenant) {
DBService.instance(tenant).createStoreIfAbsent(SchemaService.APPS_STORE_NAME, false);
DBService.instance(tenant).createStoreIfAbsent(TaskManagerService.TASKS_STORE_NAME, false);
} | java | private void initializeTenantStores(Tenant tenant) {
DBService.instance(tenant).createStoreIfAbsent(SchemaService.APPS_STORE_NAME, false);
DBService.instance(tenant).createStoreIfAbsent(TaskManagerService.TASKS_STORE_NAME, false);
} | [
"private",
"void",
"initializeTenantStores",
"(",
"Tenant",
"tenant",
")",
"{",
"DBService",
".",
"instance",
"(",
"tenant",
")",
".",
"createStoreIfAbsent",
"(",
"SchemaService",
".",
"APPS_STORE_NAME",
",",
"false",
")",
";",
"DBService",
".",
"instance",
"(",
"tenant",
")",
".",
"createStoreIfAbsent",
"(",
"TaskManagerService",
".",
"TASKS_STORE_NAME",
",",
"false",
")",
";",
"}"
] | Ensure required tenant stores exist. | [
"Ensure",
"required",
"tenant",
"stores",
"exist",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L473-L476 |
138,133 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.addTenantOptions | private void addTenantOptions(TenantDefinition tenantDef) {
if (tenantDef.getOption("namespace") == null) {
tenantDef.setOption("namespace", tenantDef.getName());
}
} | java | private void addTenantOptions(TenantDefinition tenantDef) {
if (tenantDef.getOption("namespace") == null) {
tenantDef.setOption("namespace", tenantDef.getName());
}
} | [
"private",
"void",
"addTenantOptions",
"(",
"TenantDefinition",
"tenantDef",
")",
"{",
"if",
"(",
"tenantDef",
".",
"getOption",
"(",
"\"namespace\"",
")",
"==",
"null",
")",
"{",
"tenantDef",
".",
"setOption",
"(",
"\"namespace\"",
",",
"tenantDef",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] | By default, each tenant's namespace is the same as their tenant name. | [
"By",
"default",
"each",
"tenant",
"s",
"namespace",
"is",
"the",
"same",
"as",
"their",
"tenant",
"name",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L479-L483 |
138,134 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.addTenantProperties | private void addTenantProperties(TenantDefinition tenantDef) {
tenantDef.setProperty(CREATED_ON_PROP, Utils.formatDate(new Date().getTime()));
tenantDef.setProperty(MODIFIED_ON_PROP, tenantDef.getProperty(CREATED_ON_PROP));
} | java | private void addTenantProperties(TenantDefinition tenantDef) {
tenantDef.setProperty(CREATED_ON_PROP, Utils.formatDate(new Date().getTime()));
tenantDef.setProperty(MODIFIED_ON_PROP, tenantDef.getProperty(CREATED_ON_PROP));
} | [
"private",
"void",
"addTenantProperties",
"(",
"TenantDefinition",
"tenantDef",
")",
"{",
"tenantDef",
".",
"setProperty",
"(",
"CREATED_ON_PROP",
",",
"Utils",
".",
"formatDate",
"(",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
")",
")",
";",
"tenantDef",
".",
"setProperty",
"(",
"MODIFIED_ON_PROP",
",",
"tenantDef",
".",
"getProperty",
"(",
"CREATED_ON_PROP",
")",
")",
";",
"}"
] | Set system-defined properties for a new tenant. | [
"Set",
"system",
"-",
"defined",
"properties",
"for",
"a",
"new",
"tenant",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L486-L489 |
138,135 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.validateTenantUsers | private void validateTenantUsers(TenantDefinition tenantDef) {
for (UserDefinition userDef : tenantDef.getUsers().values()) {
Utils.require(!Utils.isEmpty(userDef.getPassword()),
"Password is required; user ID=" + userDef.getID());
userDef.setHash(PasswordManager.hash(userDef.getPassword()));
userDef.setPassword(null);
}
} | java | private void validateTenantUsers(TenantDefinition tenantDef) {
for (UserDefinition userDef : tenantDef.getUsers().values()) {
Utils.require(!Utils.isEmpty(userDef.getPassword()),
"Password is required; user ID=" + userDef.getID());
userDef.setHash(PasswordManager.hash(userDef.getPassword()));
userDef.setPassword(null);
}
} | [
"private",
"void",
"validateTenantUsers",
"(",
"TenantDefinition",
"tenantDef",
")",
"{",
"for",
"(",
"UserDefinition",
"userDef",
":",
"tenantDef",
".",
"getUsers",
"(",
")",
".",
"values",
"(",
")",
")",
"{",
"Utils",
".",
"require",
"(",
"!",
"Utils",
".",
"isEmpty",
"(",
"userDef",
".",
"getPassword",
"(",
")",
")",
",",
"\"Password is required; user ID=\"",
"+",
"userDef",
".",
"getID",
"(",
")",
")",
";",
"userDef",
".",
"setHash",
"(",
"PasswordManager",
".",
"hash",
"(",
"userDef",
".",
"getPassword",
"(",
")",
")",
")",
";",
"userDef",
".",
"setPassword",
"(",
"null",
")",
";",
"}",
"}"
] | hashed format. | [
"hashed",
"format",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L493-L500 |
138,136 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.storeTenantDefinition | private void storeTenantDefinition(TenantDefinition tenantDef) {
String tenantDefJSON = tenantDef.toDoc().toJSON();
DBTransaction dbTran = DBService.instance().startTransaction();
dbTran.addColumn(TENANTS_STORE_NAME, tenantDef.getName(), TENANT_DEF_COL_NAME, tenantDefJSON);
DBService.instance().commit(dbTran);
} | java | private void storeTenantDefinition(TenantDefinition tenantDef) {
String tenantDefJSON = tenantDef.toDoc().toJSON();
DBTransaction dbTran = DBService.instance().startTransaction();
dbTran.addColumn(TENANTS_STORE_NAME, tenantDef.getName(), TENANT_DEF_COL_NAME, tenantDefJSON);
DBService.instance().commit(dbTran);
} | [
"private",
"void",
"storeTenantDefinition",
"(",
"TenantDefinition",
"tenantDef",
")",
"{",
"String",
"tenantDefJSON",
"=",
"tenantDef",
".",
"toDoc",
"(",
")",
".",
"toJSON",
"(",
")",
";",
"DBTransaction",
"dbTran",
"=",
"DBService",
".",
"instance",
"(",
")",
".",
"startTransaction",
"(",
")",
";",
"dbTran",
".",
"addColumn",
"(",
"TENANTS_STORE_NAME",
",",
"tenantDef",
".",
"getName",
"(",
")",
",",
"TENANT_DEF_COL_NAME",
",",
"tenantDefJSON",
")",
";",
"DBService",
".",
"instance",
"(",
")",
".",
"commit",
"(",
"dbTran",
")",
";",
"}"
] | Store the given tenant definition the Tenants table in the default database. | [
"Store",
"the",
"given",
"tenant",
"definition",
"the",
"Tenants",
"table",
"in",
"the",
"default",
"database",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L503-L508 |
138,137 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.isValidTenantUserAccess | private boolean isValidTenantUserAccess(Tenant tenant, String userid, String password, Permission permNeeded) {
TenantDefinition tenantDef = tenant.getDefinition();
assert tenantDef != null;
if (tenantDef.getUsers().size() == 0) {
// We allow access to the default tenant when it has no users defined.
return tenant.getName().equals(m_defaultTenantName);
}
UserDefinition userDef = tenantDef.getUser(userid);
if (userDef == null || Utils.isEmpty(password)) {
return false; // no such user or no password given
}
if (userDef.getHash() != null) {
if (!PasswordManager.checkPassword(password, userDef.getHash())) {
return false; // password is hashed but didn't match
}
} else {
if (!password.equals(userDef.getPassword())) {
return false; // password is plaintext but didn't match
}
}
return isValidUserAccess(userDef, permNeeded);
} | java | private boolean isValidTenantUserAccess(Tenant tenant, String userid, String password, Permission permNeeded) {
TenantDefinition tenantDef = tenant.getDefinition();
assert tenantDef != null;
if (tenantDef.getUsers().size() == 0) {
// We allow access to the default tenant when it has no users defined.
return tenant.getName().equals(m_defaultTenantName);
}
UserDefinition userDef = tenantDef.getUser(userid);
if (userDef == null || Utils.isEmpty(password)) {
return false; // no such user or no password given
}
if (userDef.getHash() != null) {
if (!PasswordManager.checkPassword(password, userDef.getHash())) {
return false; // password is hashed but didn't match
}
} else {
if (!password.equals(userDef.getPassword())) {
return false; // password is plaintext but didn't match
}
}
return isValidUserAccess(userDef, permNeeded);
} | [
"private",
"boolean",
"isValidTenantUserAccess",
"(",
"Tenant",
"tenant",
",",
"String",
"userid",
",",
"String",
"password",
",",
"Permission",
"permNeeded",
")",
"{",
"TenantDefinition",
"tenantDef",
"=",
"tenant",
".",
"getDefinition",
"(",
")",
";",
"assert",
"tenantDef",
"!=",
"null",
";",
"if",
"(",
"tenantDef",
".",
"getUsers",
"(",
")",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"// We allow access to the default tenant when it has no users defined.",
"return",
"tenant",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"m_defaultTenantName",
")",
";",
"}",
"UserDefinition",
"userDef",
"=",
"tenantDef",
".",
"getUser",
"(",
"userid",
")",
";",
"if",
"(",
"userDef",
"==",
"null",
"||",
"Utils",
".",
"isEmpty",
"(",
"password",
")",
")",
"{",
"return",
"false",
";",
"// no such user or no password given",
"}",
"if",
"(",
"userDef",
".",
"getHash",
"(",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"PasswordManager",
".",
"checkPassword",
"(",
"password",
",",
"userDef",
".",
"getHash",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"// password is hashed but didn't match",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"password",
".",
"equals",
"(",
"userDef",
".",
"getPassword",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"// password is plaintext but didn't match",
"}",
"}",
"return",
"isValidUserAccess",
"(",
"userDef",
",",
"permNeeded",
")",
";",
"}"
] | Validate the given user ID and password. | [
"Validate",
"the",
"given",
"user",
"ID",
"and",
"password",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L520-L541 |
138,138 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.isValidUserAccess | private boolean isValidUserAccess(UserDefinition userDef, Permission permNeeded) {
Set<Permission> permList = userDef.getPermissions();
if (permList.size() == 0 || permList.contains(Permission.ALL)) {
return true;
}
switch (permNeeded) {
case APPEND:
return permList.contains(Permission.APPEND) || permList.contains(Permission.UPDATE);
case READ:
return permList.contains(Permission.READ);
case UPDATE:
return permList.contains(Permission.UPDATE);
default:
return false;
}
} | java | private boolean isValidUserAccess(UserDefinition userDef, Permission permNeeded) {
Set<Permission> permList = userDef.getPermissions();
if (permList.size() == 0 || permList.contains(Permission.ALL)) {
return true;
}
switch (permNeeded) {
case APPEND:
return permList.contains(Permission.APPEND) || permList.contains(Permission.UPDATE);
case READ:
return permList.contains(Permission.READ);
case UPDATE:
return permList.contains(Permission.UPDATE);
default:
return false;
}
} | [
"private",
"boolean",
"isValidUserAccess",
"(",
"UserDefinition",
"userDef",
",",
"Permission",
"permNeeded",
")",
"{",
"Set",
"<",
"Permission",
">",
"permList",
"=",
"userDef",
".",
"getPermissions",
"(",
")",
";",
"if",
"(",
"permList",
".",
"size",
"(",
")",
"==",
"0",
"||",
"permList",
".",
"contains",
"(",
"Permission",
".",
"ALL",
")",
")",
"{",
"return",
"true",
";",
"}",
"switch",
"(",
"permNeeded",
")",
"{",
"case",
"APPEND",
":",
"return",
"permList",
".",
"contains",
"(",
"Permission",
".",
"APPEND",
")",
"||",
"permList",
".",
"contains",
"(",
"Permission",
".",
"UPDATE",
")",
";",
"case",
"READ",
":",
"return",
"permList",
".",
"contains",
"(",
"Permission",
".",
"READ",
")",
";",
"case",
"UPDATE",
":",
"return",
"permList",
".",
"contains",
"(",
"Permission",
".",
"UPDATE",
")",
";",
"default",
":",
"return",
"false",
";",
"}",
"}"
] | Validate user's permission vs. the given required permission. | [
"Validate",
"user",
"s",
"permission",
"vs",
".",
"the",
"given",
"required",
"permission",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L544-L559 |
138,139 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.getTenantDef | private TenantDefinition getTenantDef(String tenantName) {
DRow tenantDefRow = DBService.instance().getRow(TENANTS_STORE_NAME, tenantName);
if (tenantDefRow == null) {
return null;
}
return loadTenantDefinition(tenantDefRow);
} | java | private TenantDefinition getTenantDef(String tenantName) {
DRow tenantDefRow = DBService.instance().getRow(TENANTS_STORE_NAME, tenantName);
if (tenantDefRow == null) {
return null;
}
return loadTenantDefinition(tenantDefRow);
} | [
"private",
"TenantDefinition",
"getTenantDef",
"(",
"String",
"tenantName",
")",
"{",
"DRow",
"tenantDefRow",
"=",
"DBService",
".",
"instance",
"(",
")",
".",
"getRow",
"(",
"TENANTS_STORE_NAME",
",",
"tenantName",
")",
";",
"if",
"(",
"tenantDefRow",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"loadTenantDefinition",
"(",
"tenantDefRow",
")",
";",
"}"
] | Get the TenantDefinition for the given tenant. Return null if unknown. | [
"Get",
"the",
"TenantDefinition",
"for",
"the",
"given",
"tenant",
".",
"Return",
"null",
"if",
"unknown",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L562-L568 |
138,140 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.getAllTenantDefs | private Map<String, TenantDefinition> getAllTenantDefs() {
Map<String, TenantDefinition> tenantMap = new HashMap<>();
Iterable<DRow> rowIter = DBService.instance().getAllRows(TENANTS_STORE_NAME);
for (DRow row : rowIter) {
TenantDefinition tenantDef = loadTenantDefinition(row);
if (tenantDef != null) {
tenantMap.put(tenantDef.getName(), tenantDef);
}
}
return tenantMap;
} | java | private Map<String, TenantDefinition> getAllTenantDefs() {
Map<String, TenantDefinition> tenantMap = new HashMap<>();
Iterable<DRow> rowIter = DBService.instance().getAllRows(TENANTS_STORE_NAME);
for (DRow row : rowIter) {
TenantDefinition tenantDef = loadTenantDefinition(row);
if (tenantDef != null) {
tenantMap.put(tenantDef.getName(), tenantDef);
}
}
return tenantMap;
} | [
"private",
"Map",
"<",
"String",
",",
"TenantDefinition",
">",
"getAllTenantDefs",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"TenantDefinition",
">",
"tenantMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Iterable",
"<",
"DRow",
">",
"rowIter",
"=",
"DBService",
".",
"instance",
"(",
")",
".",
"getAllRows",
"(",
"TENANTS_STORE_NAME",
")",
";",
"for",
"(",
"DRow",
"row",
":",
"rowIter",
")",
"{",
"TenantDefinition",
"tenantDef",
"=",
"loadTenantDefinition",
"(",
"row",
")",
";",
"if",
"(",
"tenantDef",
"!=",
"null",
")",
"{",
"tenantMap",
".",
"put",
"(",
"tenantDef",
".",
"getName",
"(",
")",
",",
"tenantDef",
")",
";",
"}",
"}",
"return",
"tenantMap",
";",
"}"
] | Get all tenants, including the default tenant. | [
"Get",
"all",
"tenants",
"including",
"the",
"default",
"tenant",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L571-L581 |
138,141 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.loadTenantDefinition | private TenantDefinition loadTenantDefinition(DRow tenantDefRow) {
String tenantName = tenantDefRow.getKey();
m_logger.debug("Loading definition for tenant: {}", tenantName);
DColumn tenantDefCol = tenantDefRow.getColumn(TENANT_DEF_COL_NAME);
if (tenantDefCol == null) {
return null; // Not a valid Doradus tenant.
}
String tenantDefJSON = tenantDefCol.getValue();
TenantDefinition tenantDef = new TenantDefinition();
try {
tenantDef.parse(UNode.parseJSON(tenantDefJSON));
Utils.require(tenantDef.getName().equals(tenantName),
"Tenant definition (%s) did not match row name (%s)",
tenantDef.getName(), tenantName);
} catch (Exception e) {
m_logger.warn("Skipping malformed tenant definition; tenant=" + tenantName, e);
return null;
}
return tenantDef;
} | java | private TenantDefinition loadTenantDefinition(DRow tenantDefRow) {
String tenantName = tenantDefRow.getKey();
m_logger.debug("Loading definition for tenant: {}", tenantName);
DColumn tenantDefCol = tenantDefRow.getColumn(TENANT_DEF_COL_NAME);
if (tenantDefCol == null) {
return null; // Not a valid Doradus tenant.
}
String tenantDefJSON = tenantDefCol.getValue();
TenantDefinition tenantDef = new TenantDefinition();
try {
tenantDef.parse(UNode.parseJSON(tenantDefJSON));
Utils.require(tenantDef.getName().equals(tenantName),
"Tenant definition (%s) did not match row name (%s)",
tenantDef.getName(), tenantName);
} catch (Exception e) {
m_logger.warn("Skipping malformed tenant definition; tenant=" + tenantName, e);
return null;
}
return tenantDef;
} | [
"private",
"TenantDefinition",
"loadTenantDefinition",
"(",
"DRow",
"tenantDefRow",
")",
"{",
"String",
"tenantName",
"=",
"tenantDefRow",
".",
"getKey",
"(",
")",
";",
"m_logger",
".",
"debug",
"(",
"\"Loading definition for tenant: {}\"",
",",
"tenantName",
")",
";",
"DColumn",
"tenantDefCol",
"=",
"tenantDefRow",
".",
"getColumn",
"(",
"TENANT_DEF_COL_NAME",
")",
";",
"if",
"(",
"tenantDefCol",
"==",
"null",
")",
"{",
"return",
"null",
";",
"// Not a valid Doradus tenant.",
"}",
"String",
"tenantDefJSON",
"=",
"tenantDefCol",
".",
"getValue",
"(",
")",
";",
"TenantDefinition",
"tenantDef",
"=",
"new",
"TenantDefinition",
"(",
")",
";",
"try",
"{",
"tenantDef",
".",
"parse",
"(",
"UNode",
".",
"parseJSON",
"(",
"tenantDefJSON",
")",
")",
";",
"Utils",
".",
"require",
"(",
"tenantDef",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"tenantName",
")",
",",
"\"Tenant definition (%s) did not match row name (%s)\"",
",",
"tenantDef",
".",
"getName",
"(",
")",
",",
"tenantName",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"m_logger",
".",
"warn",
"(",
"\"Skipping malformed tenant definition; tenant=\"",
"+",
"tenantName",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"return",
"tenantDef",
";",
"}"
] | Load a TenantDefinition from the Applications table. | [
"Load",
"a",
"TenantDefinition",
"from",
"the",
"Applications",
"table",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L584-L603 |
138,142 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.validateTenantUpdate | private void validateTenantUpdate(TenantDefinition oldTenantDef,
TenantDefinition newTenantDef) {
Utils.require(oldTenantDef.getName().equals(newTenantDef.getName()),
"Tenant name cannot be changed: %s", newTenantDef.getName());
Map<String, Object> oldDBServiceOpts = oldTenantDef.getOptionMap("DBService");
String oldDBService = oldDBServiceOpts == null ? null : (String)oldDBServiceOpts.get("dbservice");
Map<String, Object> newDBServiceOpts = newTenantDef.getOptionMap("DBService");
String newDBService = newDBServiceOpts == null ? null : (String)newDBServiceOpts.get("dbservice");
Utils.require((oldDBService == null && newDBService == null) || oldDBService.equals(newDBService),
"'DBService.dbservice' parameter cannot be changed: tenant=%s, previous=%s, new=%s",
newTenantDef.getName(), oldDBService, newDBService);
} | java | private void validateTenantUpdate(TenantDefinition oldTenantDef,
TenantDefinition newTenantDef) {
Utils.require(oldTenantDef.getName().equals(newTenantDef.getName()),
"Tenant name cannot be changed: %s", newTenantDef.getName());
Map<String, Object> oldDBServiceOpts = oldTenantDef.getOptionMap("DBService");
String oldDBService = oldDBServiceOpts == null ? null : (String)oldDBServiceOpts.get("dbservice");
Map<String, Object> newDBServiceOpts = newTenantDef.getOptionMap("DBService");
String newDBService = newDBServiceOpts == null ? null : (String)newDBServiceOpts.get("dbservice");
Utils.require((oldDBService == null && newDBService == null) || oldDBService.equals(newDBService),
"'DBService.dbservice' parameter cannot be changed: tenant=%s, previous=%s, new=%s",
newTenantDef.getName(), oldDBService, newDBService);
} | [
"private",
"void",
"validateTenantUpdate",
"(",
"TenantDefinition",
"oldTenantDef",
",",
"TenantDefinition",
"newTenantDef",
")",
"{",
"Utils",
".",
"require",
"(",
"oldTenantDef",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"newTenantDef",
".",
"getName",
"(",
")",
")",
",",
"\"Tenant name cannot be changed: %s\"",
",",
"newTenantDef",
".",
"getName",
"(",
")",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"oldDBServiceOpts",
"=",
"oldTenantDef",
".",
"getOptionMap",
"(",
"\"DBService\"",
")",
";",
"String",
"oldDBService",
"=",
"oldDBServiceOpts",
"==",
"null",
"?",
"null",
":",
"(",
"String",
")",
"oldDBServiceOpts",
".",
"get",
"(",
"\"dbservice\"",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"newDBServiceOpts",
"=",
"newTenantDef",
".",
"getOptionMap",
"(",
"\"DBService\"",
")",
";",
"String",
"newDBService",
"=",
"newDBServiceOpts",
"==",
"null",
"?",
"null",
":",
"(",
"String",
")",
"newDBServiceOpts",
".",
"get",
"(",
"\"dbservice\"",
")",
";",
"Utils",
".",
"require",
"(",
"(",
"oldDBService",
"==",
"null",
"&&",
"newDBService",
"==",
"null",
")",
"||",
"oldDBService",
".",
"equals",
"(",
"newDBService",
")",
",",
"\"'DBService.dbservice' parameter cannot be changed: tenant=%s, previous=%s, new=%s\"",
",",
"newTenantDef",
".",
"getName",
"(",
")",
",",
"oldDBService",
",",
"newDBService",
")",
";",
"}"
] | Validate that the given modifications are allowed; throw any transgressions found. | [
"Validate",
"that",
"the",
"given",
"modifications",
"are",
"allowed",
";",
"throw",
"any",
"transgressions",
"found",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L606-L617 |
138,143 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java | TenantService.removeUserHashes | private void removeUserHashes(TenantDefinition tenantDef) {
for (UserDefinition userDef : tenantDef.getUsers().values()) {
userDef.setHash(null);
}
} | java | private void removeUserHashes(TenantDefinition tenantDef) {
for (UserDefinition userDef : tenantDef.getUsers().values()) {
userDef.setHash(null);
}
} | [
"private",
"void",
"removeUserHashes",
"(",
"TenantDefinition",
"tenantDef",
")",
"{",
"for",
"(",
"UserDefinition",
"userDef",
":",
"tenantDef",
".",
"getUsers",
"(",
")",
".",
"values",
"(",
")",
")",
"{",
"userDef",
".",
"setHash",
"(",
"null",
")",
";",
"}",
"}"
] | Remove hash value from user definitions. | [
"Remove",
"hash",
"value",
"from",
"user",
"definitions",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/tenant/TenantService.java#L620-L624 |
138,144 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.deleteApplication | @Override
public void deleteApplication(ApplicationDefinition appDef) {
checkServiceState();
deleteApplicationCFs(appDef);
m_shardCache.clear(appDef);
} | java | @Override
public void deleteApplication(ApplicationDefinition appDef) {
checkServiceState();
deleteApplicationCFs(appDef);
m_shardCache.clear(appDef);
} | [
"@",
"Override",
"public",
"void",
"deleteApplication",
"(",
"ApplicationDefinition",
"appDef",
")",
"{",
"checkServiceState",
"(",
")",
";",
"deleteApplicationCFs",
"(",
"appDef",
")",
";",
"m_shardCache",
".",
"clear",
"(",
"appDef",
")",
";",
"}"
] | Delete all CFs used by the given application. | [
"Delete",
"all",
"CFs",
"used",
"by",
"the",
"given",
"application",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L117-L122 |
138,145 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.initializeApplication | @Override
public void initializeApplication(ApplicationDefinition oldAppDef,
ApplicationDefinition appDef) {
checkServiceState();
verifyApplicationCFs(oldAppDef, appDef);
} | java | @Override
public void initializeApplication(ApplicationDefinition oldAppDef,
ApplicationDefinition appDef) {
checkServiceState();
verifyApplicationCFs(oldAppDef, appDef);
} | [
"@",
"Override",
"public",
"void",
"initializeApplication",
"(",
"ApplicationDefinition",
"oldAppDef",
",",
"ApplicationDefinition",
"appDef",
")",
"{",
"checkServiceState",
"(",
")",
";",
"verifyApplicationCFs",
"(",
"oldAppDef",
",",
"appDef",
")",
";",
"}"
] | Create all CFs needed for the given application. | [
"Create",
"all",
"CFs",
"needed",
"for",
"the",
"given",
"application",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L125-L130 |
138,146 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.getDataAgingFreq | private String getDataAgingFreq(TableDefinition tableDef) {
if (Utils.isEmpty(tableDef.getOption(CommonDefs.OPT_AGING_FIELD))) {
return null;
}
String dataAgingFreq = tableDef.getOption(CommonDefs.OPT_AGING_CHECK_FREQ);
if (!Utils.isEmpty(dataAgingFreq)) {
return dataAgingFreq;
}
return tableDef.getAppDef().getOption(CommonDefs.OPT_AGING_CHECK_FREQ);
} | java | private String getDataAgingFreq(TableDefinition tableDef) {
if (Utils.isEmpty(tableDef.getOption(CommonDefs.OPT_AGING_FIELD))) {
return null;
}
String dataAgingFreq = tableDef.getOption(CommonDefs.OPT_AGING_CHECK_FREQ);
if (!Utils.isEmpty(dataAgingFreq)) {
return dataAgingFreq;
}
return tableDef.getAppDef().getOption(CommonDefs.OPT_AGING_CHECK_FREQ);
} | [
"private",
"String",
"getDataAgingFreq",
"(",
"TableDefinition",
"tableDef",
")",
"{",
"if",
"(",
"Utils",
".",
"isEmpty",
"(",
"tableDef",
".",
"getOption",
"(",
"CommonDefs",
".",
"OPT_AGING_FIELD",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"String",
"dataAgingFreq",
"=",
"tableDef",
".",
"getOption",
"(",
"CommonDefs",
".",
"OPT_AGING_CHECK_FREQ",
")",
";",
"if",
"(",
"!",
"Utils",
".",
"isEmpty",
"(",
"dataAgingFreq",
")",
")",
"{",
"return",
"dataAgingFreq",
";",
"}",
"return",
"tableDef",
".",
"getAppDef",
"(",
")",
".",
"getOption",
"(",
"CommonDefs",
".",
"OPT_AGING_CHECK_FREQ",
")",
";",
"}"
] | frequency is defined at either the table or application level. | [
"frequency",
"is",
"defined",
"at",
"either",
"the",
"table",
"or",
"application",
"level",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L157-L166 |
138,147 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.getObject | public DBObject getObject(TableDefinition tableDef, String objID) {
checkServiceState();
String storeName = objectsStoreName(tableDef);
Tenant tenant = Tenant.getTenant(tableDef);
Iterator<DColumn> colIter = DBService.instance(tenant).getAllColumns(storeName, objID).iterator();
if (!colIter.hasNext()) {
return null;
}
DBObject dbObj = createObject(tableDef, objID, colIter);
addShardedLinkValues(tableDef, dbObj);
return dbObj;
} | java | public DBObject getObject(TableDefinition tableDef, String objID) {
checkServiceState();
String storeName = objectsStoreName(tableDef);
Tenant tenant = Tenant.getTenant(tableDef);
Iterator<DColumn> colIter = DBService.instance(tenant).getAllColumns(storeName, objID).iterator();
if (!colIter.hasNext()) {
return null;
}
DBObject dbObj = createObject(tableDef, objID, colIter);
addShardedLinkValues(tableDef, dbObj);
return dbObj;
} | [
"public",
"DBObject",
"getObject",
"(",
"TableDefinition",
"tableDef",
",",
"String",
"objID",
")",
"{",
"checkServiceState",
"(",
")",
";",
"String",
"storeName",
"=",
"objectsStoreName",
"(",
"tableDef",
")",
";",
"Tenant",
"tenant",
"=",
"Tenant",
".",
"getTenant",
"(",
"tableDef",
")",
";",
"Iterator",
"<",
"DColumn",
">",
"colIter",
"=",
"DBService",
".",
"instance",
"(",
"tenant",
")",
".",
"getAllColumns",
"(",
"storeName",
",",
"objID",
")",
".",
"iterator",
"(",
")",
";",
"if",
"(",
"!",
"colIter",
".",
"hasNext",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"DBObject",
"dbObj",
"=",
"createObject",
"(",
"tableDef",
",",
"objID",
",",
"colIter",
")",
";",
"addShardedLinkValues",
"(",
"tableDef",
",",
"dbObj",
")",
";",
"return",
"dbObj",
";",
"}"
] | Get all scalar and link fields for the object in the given table with the given ID.
@param tableDef {@link TableDefinition} in which object resides.
@param objID Object ID.
@return {@link DBObject} containing all object scalar and link fields, or
null if there is no such object. | [
"Get",
"all",
"scalar",
"and",
"link",
"fields",
"for",
"the",
"object",
"in",
"the",
"given",
"table",
"with",
"the",
"given",
"ID",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L176-L188 |
138,148 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.aggregateQuery | public AggregateResult aggregateQuery(TableDefinition tableDef, Aggregate aggParams) {
checkServiceState();
aggParams.execute();
return aggParams.getResult();
} | java | public AggregateResult aggregateQuery(TableDefinition tableDef, Aggregate aggParams) {
checkServiceState();
aggParams.execute();
return aggParams.getResult();
} | [
"public",
"AggregateResult",
"aggregateQuery",
"(",
"TableDefinition",
"tableDef",
",",
"Aggregate",
"aggParams",
")",
"{",
"checkServiceState",
"(",
")",
";",
"aggParams",
".",
"execute",
"(",
")",
";",
"return",
"aggParams",
".",
"getResult",
"(",
")",
";",
"}"
] | Perform an aggregate query on the given table using the given query parameters.
@param tableDef {@link TableDefinition} of table to query.
@param aggParams {@link Aggregate} containing query parameters.
@return {@link AggregateResult} containing search results. | [
"Perform",
"an",
"aggregate",
"query",
"on",
"the",
"given",
"table",
"using",
"the",
"given",
"query",
"parameters",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L209-L213 |
138,149 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.deleteBatch | public BatchResult deleteBatch(TableDefinition tableDef, DBObjectBatch batch) {
checkServiceState();
List<String> objIDs = new ArrayList<>();
for (DBObject dbObj : batch.getObjects()) {
Utils.require(!Utils.isEmpty(dbObj.getObjectID()), "All objects must have _ID defined");
objIDs.add(dbObj.getObjectID());
}
BatchObjectUpdater batchUpdater = new BatchObjectUpdater(tableDef);
return batchUpdater.deleteBatch(objIDs);
} | java | public BatchResult deleteBatch(TableDefinition tableDef, DBObjectBatch batch) {
checkServiceState();
List<String> objIDs = new ArrayList<>();
for (DBObject dbObj : batch.getObjects()) {
Utils.require(!Utils.isEmpty(dbObj.getObjectID()), "All objects must have _ID defined");
objIDs.add(dbObj.getObjectID());
}
BatchObjectUpdater batchUpdater = new BatchObjectUpdater(tableDef);
return batchUpdater.deleteBatch(objIDs);
} | [
"public",
"BatchResult",
"deleteBatch",
"(",
"TableDefinition",
"tableDef",
",",
"DBObjectBatch",
"batch",
")",
"{",
"checkServiceState",
"(",
")",
";",
"List",
"<",
"String",
">",
"objIDs",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"DBObject",
"dbObj",
":",
"batch",
".",
"getObjects",
"(",
")",
")",
"{",
"Utils",
".",
"require",
"(",
"!",
"Utils",
".",
"isEmpty",
"(",
"dbObj",
".",
"getObjectID",
"(",
")",
")",
",",
"\"All objects must have _ID defined\"",
")",
";",
"objIDs",
".",
"add",
"(",
"dbObj",
".",
"getObjectID",
"(",
")",
")",
";",
"}",
"BatchObjectUpdater",
"batchUpdater",
"=",
"new",
"BatchObjectUpdater",
"(",
"tableDef",
")",
";",
"return",
"batchUpdater",
".",
"deleteBatch",
"(",
"objIDs",
")",
";",
"}"
] | Delete a batch of objects from the given table. All objects must have an ID
assigned. Deleting an already-deleted object is a no-op.
@param tableDef Table containing objects to be deleted.
@param batch {@link DBObjectBatch} defining objects to be deleted. Only the
_ID field of each DBObject is used.
@return {@link BatchResult} indicating results of the delete. | [
"Delete",
"a",
"batch",
"of",
"objects",
"from",
"the",
"given",
"table",
".",
"All",
"objects",
"must",
"have",
"an",
"ID",
"assigned",
".",
"Deleting",
"an",
"already",
"-",
"deleted",
"object",
"is",
"a",
"no",
"-",
"op",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L254-L263 |
138,150 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.termIndexRowKey | public static String termIndexRowKey(TableDefinition tableDef, DBObject dbObj, String fieldName, String term) {
StringBuilder termRecKey = new StringBuilder();
int shardNumber = tableDef.getShardNumber(dbObj);
if (shardNumber > 0) {
termRecKey.append(shardNumber);
termRecKey.append("/");
}
termRecKey.append(FieldAnalyzer.makeTermKey(fieldName, term));
return termRecKey.toString();
} | java | public static String termIndexRowKey(TableDefinition tableDef, DBObject dbObj, String fieldName, String term) {
StringBuilder termRecKey = new StringBuilder();
int shardNumber = tableDef.getShardNumber(dbObj);
if (shardNumber > 0) {
termRecKey.append(shardNumber);
termRecKey.append("/");
}
termRecKey.append(FieldAnalyzer.makeTermKey(fieldName, term));
return termRecKey.toString();
} | [
"public",
"static",
"String",
"termIndexRowKey",
"(",
"TableDefinition",
"tableDef",
",",
"DBObject",
"dbObj",
",",
"String",
"fieldName",
",",
"String",
"term",
")",
"{",
"StringBuilder",
"termRecKey",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"int",
"shardNumber",
"=",
"tableDef",
".",
"getShardNumber",
"(",
"dbObj",
")",
";",
"if",
"(",
"shardNumber",
">",
"0",
")",
"{",
"termRecKey",
".",
"append",
"(",
"shardNumber",
")",
";",
"termRecKey",
".",
"append",
"(",
"\"/\"",
")",
";",
"}",
"termRecKey",
".",
"append",
"(",
"FieldAnalyzer",
".",
"makeTermKey",
"(",
"fieldName",
",",
"term",
")",
")",
";",
"return",
"termRecKey",
".",
"toString",
"(",
")",
";",
"}"
] | Create the Terms row key for the given table, object, field name, and term.
@param tableDef {@link TableDefinition} of table that owns object.
@param dbObj DBObject that owns field.
@param fieldName Field name.
@param term Term to be indexed.
@return | [
"Create",
"the",
"Terms",
"row",
"key",
"for",
"the",
"given",
"table",
"object",
"field",
"name",
"and",
"term",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L380-L389 |
138,151 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.verifyShard | public void verifyShard(TableDefinition tableDef, int shardNumber) {
assert tableDef.isSharded();
assert shardNumber > 0;
checkServiceState();
m_shardCache.verifyShard(tableDef, shardNumber);
} | java | public void verifyShard(TableDefinition tableDef, int shardNumber) {
assert tableDef.isSharded();
assert shardNumber > 0;
checkServiceState();
m_shardCache.verifyShard(tableDef, shardNumber);
} | [
"public",
"void",
"verifyShard",
"(",
"TableDefinition",
"tableDef",
",",
"int",
"shardNumber",
")",
"{",
"assert",
"tableDef",
".",
"isSharded",
"(",
")",
";",
"assert",
"shardNumber",
">",
"0",
";",
"checkServiceState",
"(",
")",
";",
"m_shardCache",
".",
"verifyShard",
"(",
"tableDef",
",",
"shardNumber",
")",
";",
"}"
] | Get the starting date of the shard with the given number in the given sharded
table. If the given table has not yet started the given shard, null is returned.
@param tableDef {@link TableDefinition} of a sharded table.
@param shardNumber Shard number (must be > 0).
@return Start date of the given shard or null if no objects have been
stored in the given shard yet. | [
"Get",
"the",
"starting",
"date",
"of",
"the",
"shard",
"with",
"the",
"given",
"number",
"in",
"the",
"given",
"sharded",
"table",
".",
"If",
"the",
"given",
"table",
"has",
"not",
"yet",
"started",
"the",
"given",
"shard",
"null",
"is",
"returned",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L484-L489 |
138,152 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.getShards | public Map<Integer, Date> getShards(TableDefinition tableDef) {
checkServiceState();
if (tableDef.isSharded()) {
return m_shardCache.getShardMap(tableDef);
} else {
return new HashMap<>();
}
} | java | public Map<Integer, Date> getShards(TableDefinition tableDef) {
checkServiceState();
if (tableDef.isSharded()) {
return m_shardCache.getShardMap(tableDef);
} else {
return new HashMap<>();
}
} | [
"public",
"Map",
"<",
"Integer",
",",
"Date",
">",
"getShards",
"(",
"TableDefinition",
"tableDef",
")",
"{",
"checkServiceState",
"(",
")",
";",
"if",
"(",
"tableDef",
".",
"isSharded",
"(",
")",
")",
"{",
"return",
"m_shardCache",
".",
"getShardMap",
"(",
"tableDef",
")",
";",
"}",
"else",
"{",
"return",
"new",
"HashMap",
"<>",
"(",
")",
";",
"}",
"}"
] | Get all known shards for the given table. Each shard is defined in a column in the
"_shards" row of the table's Terms store. If the given table is not sharded, an
empty map is returned.
@param tableDef Sharded table to get current shards for.
@return Map of shard numbers to shard start dates. May be empty but will
not be null. | [
"Get",
"all",
"known",
"shards",
"for",
"the",
"given",
"table",
".",
"Each",
"shard",
"is",
"defined",
"in",
"a",
"column",
"in",
"the",
"_shards",
"row",
"of",
"the",
"table",
"s",
"Terms",
"store",
".",
"If",
"the",
"given",
"table",
"is",
"not",
"sharded",
"an",
"empty",
"map",
"is",
"returned",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L500-L507 |
138,153 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.addAutoTable | private TableDefinition addAutoTable(ApplicationDefinition appDef, String tableName) {
m_logger.debug("Adding implicit table '{}' to application '{}'", tableName, appDef.getAppName());
Tenant tenant = Tenant.getTenant(appDef);
TableDefinition tableDef = new TableDefinition(appDef);
tableDef.setTableName(tableName);
appDef.addTable(tableDef);
SchemaService.instance().defineApplication(tenant, appDef);
appDef = SchemaService.instance().getApplication(tenant, appDef.getAppName());
return appDef.getTableDef(tableName);
} | java | private TableDefinition addAutoTable(ApplicationDefinition appDef, String tableName) {
m_logger.debug("Adding implicit table '{}' to application '{}'", tableName, appDef.getAppName());
Tenant tenant = Tenant.getTenant(appDef);
TableDefinition tableDef = new TableDefinition(appDef);
tableDef.setTableName(tableName);
appDef.addTable(tableDef);
SchemaService.instance().defineApplication(tenant, appDef);
appDef = SchemaService.instance().getApplication(tenant, appDef.getAppName());
return appDef.getTableDef(tableName);
} | [
"private",
"TableDefinition",
"addAutoTable",
"(",
"ApplicationDefinition",
"appDef",
",",
"String",
"tableName",
")",
"{",
"m_logger",
".",
"debug",
"(",
"\"Adding implicit table '{}' to application '{}'\"",
",",
"tableName",
",",
"appDef",
".",
"getAppName",
"(",
")",
")",
";",
"Tenant",
"tenant",
"=",
"Tenant",
".",
"getTenant",
"(",
"appDef",
")",
";",
"TableDefinition",
"tableDef",
"=",
"new",
"TableDefinition",
"(",
"appDef",
")",
";",
"tableDef",
".",
"setTableName",
"(",
"tableName",
")",
";",
"appDef",
".",
"addTable",
"(",
"tableDef",
")",
";",
"SchemaService",
".",
"instance",
"(",
")",
".",
"defineApplication",
"(",
"tenant",
",",
"appDef",
")",
";",
"appDef",
"=",
"SchemaService",
".",
"instance",
"(",
")",
".",
"getApplication",
"(",
"tenant",
",",
"appDef",
".",
"getAppName",
"(",
")",
")",
";",
"return",
"appDef",
".",
"getTableDef",
"(",
"tableName",
")",
";",
"}"
] | Add an implicit table to the given application and return its new TableDefinition. | [
"Add",
"an",
"implicit",
"table",
"to",
"the",
"given",
"application",
"and",
"return",
"its",
"new",
"TableDefinition",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L515-L524 |
138,154 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.addShardedLinkValues | private void addShardedLinkValues(TableDefinition tableDef, DBObject dbObj) {
for (FieldDefinition fieldDef : tableDef.getFieldDefinitions()) {
if (fieldDef.isLinkField() && fieldDef.isSharded()) {
TableDefinition extentTableDef = tableDef.getLinkExtentTableDef(fieldDef);
Set<Integer> shardNums = getShards(extentTableDef).keySet();
Set<String> values = getShardedLinkValues(dbObj.getObjectID(), fieldDef, shardNums);
dbObj.addFieldValues(fieldDef.getName(), values);
}
}
} | java | private void addShardedLinkValues(TableDefinition tableDef, DBObject dbObj) {
for (FieldDefinition fieldDef : tableDef.getFieldDefinitions()) {
if (fieldDef.isLinkField() && fieldDef.isSharded()) {
TableDefinition extentTableDef = tableDef.getLinkExtentTableDef(fieldDef);
Set<Integer> shardNums = getShards(extentTableDef).keySet();
Set<String> values = getShardedLinkValues(dbObj.getObjectID(), fieldDef, shardNums);
dbObj.addFieldValues(fieldDef.getName(), values);
}
}
} | [
"private",
"void",
"addShardedLinkValues",
"(",
"TableDefinition",
"tableDef",
",",
"DBObject",
"dbObj",
")",
"{",
"for",
"(",
"FieldDefinition",
"fieldDef",
":",
"tableDef",
".",
"getFieldDefinitions",
"(",
")",
")",
"{",
"if",
"(",
"fieldDef",
".",
"isLinkField",
"(",
")",
"&&",
"fieldDef",
".",
"isSharded",
"(",
")",
")",
"{",
"TableDefinition",
"extentTableDef",
"=",
"tableDef",
".",
"getLinkExtentTableDef",
"(",
"fieldDef",
")",
";",
"Set",
"<",
"Integer",
">",
"shardNums",
"=",
"getShards",
"(",
"extentTableDef",
")",
".",
"keySet",
"(",
")",
";",
"Set",
"<",
"String",
">",
"values",
"=",
"getShardedLinkValues",
"(",
"dbObj",
".",
"getObjectID",
"(",
")",
",",
"fieldDef",
",",
"shardNums",
")",
";",
"dbObj",
".",
"addFieldValues",
"(",
"fieldDef",
".",
"getName",
"(",
")",
",",
"values",
")",
";",
"}",
"}",
"}"
] | Add sharded link values, if any, to the given DBObject. | [
"Add",
"sharded",
"link",
"values",
"if",
"any",
"to",
"the",
"given",
"DBObject",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L527-L536 |
138,155 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.deleteApplicationCFs | private void deleteApplicationCFs(ApplicationDefinition appDef) {
Tenant tenant = Tenant.getTenant(appDef);
for (TableDefinition tableDef : appDef.getTableDefinitions().values()) {
DBService.instance(tenant).deleteStoreIfPresent(objectsStoreName(tableDef));
DBService.instance(tenant).deleteStoreIfPresent(termsStoreName(tableDef));
}
} | java | private void deleteApplicationCFs(ApplicationDefinition appDef) {
Tenant tenant = Tenant.getTenant(appDef);
for (TableDefinition tableDef : appDef.getTableDefinitions().values()) {
DBService.instance(tenant).deleteStoreIfPresent(objectsStoreName(tableDef));
DBService.instance(tenant).deleteStoreIfPresent(termsStoreName(tableDef));
}
} | [
"private",
"void",
"deleteApplicationCFs",
"(",
"ApplicationDefinition",
"appDef",
")",
"{",
"Tenant",
"tenant",
"=",
"Tenant",
".",
"getTenant",
"(",
"appDef",
")",
";",
"for",
"(",
"TableDefinition",
"tableDef",
":",
"appDef",
".",
"getTableDefinitions",
"(",
")",
".",
"values",
"(",
")",
")",
"{",
"DBService",
".",
"instance",
"(",
"tenant",
")",
".",
"deleteStoreIfPresent",
"(",
"objectsStoreName",
"(",
"tableDef",
")",
")",
";",
"DBService",
".",
"instance",
"(",
"tenant",
")",
".",
"deleteStoreIfPresent",
"(",
"termsStoreName",
"(",
"tableDef",
")",
")",
";",
"}",
"}"
] | actually exist in case a previous delete-app failed. | [
"actually",
"exist",
"in",
"case",
"a",
"previous",
"delete",
"-",
"app",
"failed",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L567-L573 |
138,156 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.getShardedLinkValues | private Set<String> getShardedLinkValues(String objID, FieldDefinition linkDef, Set<Integer> shardNums) {
Set<String> values = new HashSet<String>();
if (shardNums.size() == 0) {
return values;
}
// Construct row keys for the link's possible Terms records.
Set<String> termRowKeys = new HashSet<String>();
for (Integer shardNumber : shardNums) {
termRowKeys.add(shardedLinkTermRowKey(linkDef, objID, shardNumber));
}
TableDefinition tableDef = linkDef.getTableDef();
String termStore = termsStoreName(tableDef);
Tenant tenant = Tenant.getTenant(tableDef);
for(DRow row: DBService.instance(tenant).getRows(termStore, termRowKeys)) {
for(DColumn column: row.getAllColumns(1024)) {
values.add(column.getName());
}
}
return values;
} | java | private Set<String> getShardedLinkValues(String objID, FieldDefinition linkDef, Set<Integer> shardNums) {
Set<String> values = new HashSet<String>();
if (shardNums.size() == 0) {
return values;
}
// Construct row keys for the link's possible Terms records.
Set<String> termRowKeys = new HashSet<String>();
for (Integer shardNumber : shardNums) {
termRowKeys.add(shardedLinkTermRowKey(linkDef, objID, shardNumber));
}
TableDefinition tableDef = linkDef.getTableDef();
String termStore = termsStoreName(tableDef);
Tenant tenant = Tenant.getTenant(tableDef);
for(DRow row: DBService.instance(tenant).getRows(termStore, termRowKeys)) {
for(DColumn column: row.getAllColumns(1024)) {
values.add(column.getName());
}
}
return values;
} | [
"private",
"Set",
"<",
"String",
">",
"getShardedLinkValues",
"(",
"String",
"objID",
",",
"FieldDefinition",
"linkDef",
",",
"Set",
"<",
"Integer",
">",
"shardNums",
")",
"{",
"Set",
"<",
"String",
">",
"values",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"shardNums",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"values",
";",
"}",
"// Construct row keys for the link's possible Terms records.\r",
"Set",
"<",
"String",
">",
"termRowKeys",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"Integer",
"shardNumber",
":",
"shardNums",
")",
"{",
"termRowKeys",
".",
"add",
"(",
"shardedLinkTermRowKey",
"(",
"linkDef",
",",
"objID",
",",
"shardNumber",
")",
")",
";",
"}",
"TableDefinition",
"tableDef",
"=",
"linkDef",
".",
"getTableDef",
"(",
")",
";",
"String",
"termStore",
"=",
"termsStoreName",
"(",
"tableDef",
")",
";",
"Tenant",
"tenant",
"=",
"Tenant",
".",
"getTenant",
"(",
"tableDef",
")",
";",
"for",
"(",
"DRow",
"row",
":",
"DBService",
".",
"instance",
"(",
"tenant",
")",
".",
"getRows",
"(",
"termStore",
",",
"termRowKeys",
")",
")",
"{",
"for",
"(",
"DColumn",
"column",
":",
"row",
".",
"getAllColumns",
"(",
"1024",
")",
")",
"{",
"values",
".",
"add",
"(",
"column",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"return",
"values",
";",
"}"
] | Get all target object IDs for the given sharded link. | [
"Get",
"all",
"target",
"object",
"IDs",
"for",
"the",
"given",
"sharded",
"link",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L576-L596 |
138,157 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.isValidShardDate | private boolean isValidShardDate(String shardDate) {
try {
// If the format is invalid, a ParseException is thrown.
Utils.dateFromString(shardDate);
return true;
} catch (IllegalArgumentException ex) {
return false;
}
} | java | private boolean isValidShardDate(String shardDate) {
try {
// If the format is invalid, a ParseException is thrown.
Utils.dateFromString(shardDate);
return true;
} catch (IllegalArgumentException ex) {
return false;
}
} | [
"private",
"boolean",
"isValidShardDate",
"(",
"String",
"shardDate",
")",
"{",
"try",
"{",
"// If the format is invalid, a ParseException is thrown.\r",
"Utils",
".",
"dateFromString",
"(",
"shardDate",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"ex",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | is bad, just return false. | [
"is",
"bad",
"just",
"return",
"false",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L620-L628 |
138,158 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.validateBooleanOption | private void validateBooleanOption(String optName, String optValue) {
if (!optValue.equalsIgnoreCase("true") && !optValue.equalsIgnoreCase("false")) {
throw new IllegalArgumentException("Boolean value expected for '" + optName + "' option: " + optValue);
}
} | java | private void validateBooleanOption(String optName, String optValue) {
if (!optValue.equalsIgnoreCase("true") && !optValue.equalsIgnoreCase("false")) {
throw new IllegalArgumentException("Boolean value expected for '" + optName + "' option: " + optValue);
}
} | [
"private",
"void",
"validateBooleanOption",
"(",
"String",
"optName",
",",
"String",
"optValue",
")",
"{",
"if",
"(",
"!",
"optValue",
".",
"equalsIgnoreCase",
"(",
"\"true\"",
")",
"&&",
"!",
"optValue",
".",
"equalsIgnoreCase",
"(",
"\"false\"",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Boolean value expected for '\"",
"+",
"optName",
"+",
"\"' option: \"",
"+",
"optValue",
")",
";",
"}",
"}"
] | Validate that the given string is a valid Booleab value. | [
"Validate",
"that",
"the",
"given",
"string",
"is",
"a",
"valid",
"Booleab",
"value",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L665-L669 |
138,159 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.validateField | private void validateField(FieldDefinition fieldDef) {
Utils.require(!fieldDef.isXLinkField(), "Xlink fields are not allowed in Spider applications");
// Validate scalar field analyzer.
if (fieldDef.isScalarField()) {
String analyzerName = fieldDef.getAnalyzerName();
if (Utils.isEmpty(analyzerName)) {
analyzerName = FieldType.getDefaultAnalyzer(fieldDef.getType());
fieldDef.setAnalyzer(analyzerName);
}
FieldAnalyzer.verifyAnalyzer(fieldDef);
}
} | java | private void validateField(FieldDefinition fieldDef) {
Utils.require(!fieldDef.isXLinkField(), "Xlink fields are not allowed in Spider applications");
// Validate scalar field analyzer.
if (fieldDef.isScalarField()) {
String analyzerName = fieldDef.getAnalyzerName();
if (Utils.isEmpty(analyzerName)) {
analyzerName = FieldType.getDefaultAnalyzer(fieldDef.getType());
fieldDef.setAnalyzer(analyzerName);
}
FieldAnalyzer.verifyAnalyzer(fieldDef);
}
} | [
"private",
"void",
"validateField",
"(",
"FieldDefinition",
"fieldDef",
")",
"{",
"Utils",
".",
"require",
"(",
"!",
"fieldDef",
".",
"isXLinkField",
"(",
")",
",",
"\"Xlink fields are not allowed in Spider applications\"",
")",
";",
"// Validate scalar field analyzer.\r",
"if",
"(",
"fieldDef",
".",
"isScalarField",
"(",
")",
")",
"{",
"String",
"analyzerName",
"=",
"fieldDef",
".",
"getAnalyzerName",
"(",
")",
";",
"if",
"(",
"Utils",
".",
"isEmpty",
"(",
"analyzerName",
")",
")",
"{",
"analyzerName",
"=",
"FieldType",
".",
"getDefaultAnalyzer",
"(",
"fieldDef",
".",
"getType",
"(",
")",
")",
";",
"fieldDef",
".",
"setAnalyzer",
"(",
"analyzerName",
")",
";",
"}",
"FieldAnalyzer",
".",
"verifyAnalyzer",
"(",
"fieldDef",
")",
";",
"}",
"}"
] | Validate the given field against SpiderService-specific constraints. | [
"Validate",
"the",
"given",
"field",
"against",
"SpiderService",
"-",
"specific",
"constraints",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L672-L684 |
138,160 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.validateTable | private void validateTable(TableDefinition tableDef) {
for (String optName : tableDef.getOptionNames()) {
String optValue = tableDef.getOption(optName);
switch (optName) {
case CommonDefs.OPT_AGING_FIELD:
validateTableOptionAgingField(tableDef, optValue);
break;
case CommonDefs.OPT_RETENTION_AGE:
validateTableOptionRetentionAge(tableDef, optValue);
break;
case CommonDefs.OPT_SHARDING_FIELD:
validateTableOptionShardingField(tableDef, optValue);
break;
case CommonDefs.OPT_SHARDING_GRANULARITY:
validateTableOptionShardingGranularity(tableDef, optValue);
break;
case CommonDefs.OPT_SHARDING_START:
validateTableOptionShardingStart(tableDef, optValue);
break;
case CommonDefs.OPT_AGING_CHECK_FREQ:
validateTableOptionAgingCheckFrequency(tableDef, optValue);
break;
default:
Utils.require(false, "Unknown option for SpiderService table: " + optName);
}
}
for (FieldDefinition fieldDef : tableDef.getFieldDefinitions()) {
validateField(fieldDef);
}
if (tableDef.getOption(CommonDefs.OPT_AGING_FIELD) != null &&
tableDef.getOption(CommonDefs.OPT_AGING_CHECK_FREQ) == null) {
String agingCheckFreq = tableDef.getAppDef().getOption(CommonDefs.OPT_AGING_CHECK_FREQ);
if (Utils.isEmpty(agingCheckFreq)) {
agingCheckFreq = "1 DAY";
}
tableDef.setOption(CommonDefs.OPT_AGING_CHECK_FREQ, agingCheckFreq);
}
} | java | private void validateTable(TableDefinition tableDef) {
for (String optName : tableDef.getOptionNames()) {
String optValue = tableDef.getOption(optName);
switch (optName) {
case CommonDefs.OPT_AGING_FIELD:
validateTableOptionAgingField(tableDef, optValue);
break;
case CommonDefs.OPT_RETENTION_AGE:
validateTableOptionRetentionAge(tableDef, optValue);
break;
case CommonDefs.OPT_SHARDING_FIELD:
validateTableOptionShardingField(tableDef, optValue);
break;
case CommonDefs.OPT_SHARDING_GRANULARITY:
validateTableOptionShardingGranularity(tableDef, optValue);
break;
case CommonDefs.OPT_SHARDING_START:
validateTableOptionShardingStart(tableDef, optValue);
break;
case CommonDefs.OPT_AGING_CHECK_FREQ:
validateTableOptionAgingCheckFrequency(tableDef, optValue);
break;
default:
Utils.require(false, "Unknown option for SpiderService table: " + optName);
}
}
for (FieldDefinition fieldDef : tableDef.getFieldDefinitions()) {
validateField(fieldDef);
}
if (tableDef.getOption(CommonDefs.OPT_AGING_FIELD) != null &&
tableDef.getOption(CommonDefs.OPT_AGING_CHECK_FREQ) == null) {
String agingCheckFreq = tableDef.getAppDef().getOption(CommonDefs.OPT_AGING_CHECK_FREQ);
if (Utils.isEmpty(agingCheckFreq)) {
agingCheckFreq = "1 DAY";
}
tableDef.setOption(CommonDefs.OPT_AGING_CHECK_FREQ, agingCheckFreq);
}
} | [
"private",
"void",
"validateTable",
"(",
"TableDefinition",
"tableDef",
")",
"{",
"for",
"(",
"String",
"optName",
":",
"tableDef",
".",
"getOptionNames",
"(",
")",
")",
"{",
"String",
"optValue",
"=",
"tableDef",
".",
"getOption",
"(",
"optName",
")",
";",
"switch",
"(",
"optName",
")",
"{",
"case",
"CommonDefs",
".",
"OPT_AGING_FIELD",
":",
"validateTableOptionAgingField",
"(",
"tableDef",
",",
"optValue",
")",
";",
"break",
";",
"case",
"CommonDefs",
".",
"OPT_RETENTION_AGE",
":",
"validateTableOptionRetentionAge",
"(",
"tableDef",
",",
"optValue",
")",
";",
"break",
";",
"case",
"CommonDefs",
".",
"OPT_SHARDING_FIELD",
":",
"validateTableOptionShardingField",
"(",
"tableDef",
",",
"optValue",
")",
";",
"break",
";",
"case",
"CommonDefs",
".",
"OPT_SHARDING_GRANULARITY",
":",
"validateTableOptionShardingGranularity",
"(",
"tableDef",
",",
"optValue",
")",
";",
"break",
";",
"case",
"CommonDefs",
".",
"OPT_SHARDING_START",
":",
"validateTableOptionShardingStart",
"(",
"tableDef",
",",
"optValue",
")",
";",
"break",
";",
"case",
"CommonDefs",
".",
"OPT_AGING_CHECK_FREQ",
":",
"validateTableOptionAgingCheckFrequency",
"(",
"tableDef",
",",
"optValue",
")",
";",
"break",
";",
"default",
":",
"Utils",
".",
"require",
"(",
"false",
",",
"\"Unknown option for SpiderService table: \"",
"+",
"optName",
")",
";",
"}",
"}",
"for",
"(",
"FieldDefinition",
"fieldDef",
":",
"tableDef",
".",
"getFieldDefinitions",
"(",
")",
")",
"{",
"validateField",
"(",
"fieldDef",
")",
";",
"}",
"if",
"(",
"tableDef",
".",
"getOption",
"(",
"CommonDefs",
".",
"OPT_AGING_FIELD",
")",
"!=",
"null",
"&&",
"tableDef",
".",
"getOption",
"(",
"CommonDefs",
".",
"OPT_AGING_CHECK_FREQ",
")",
"==",
"null",
")",
"{",
"String",
"agingCheckFreq",
"=",
"tableDef",
".",
"getAppDef",
"(",
")",
".",
"getOption",
"(",
"CommonDefs",
".",
"OPT_AGING_CHECK_FREQ",
")",
";",
"if",
"(",
"Utils",
".",
"isEmpty",
"(",
"agingCheckFreq",
")",
")",
"{",
"agingCheckFreq",
"=",
"\"1 DAY\"",
";",
"}",
"tableDef",
".",
"setOption",
"(",
"CommonDefs",
".",
"OPT_AGING_CHECK_FREQ",
",",
"agingCheckFreq",
")",
";",
"}",
"}"
] | Validate the given table against SpiderService-specific constraints. | [
"Validate",
"the",
"given",
"table",
"against",
"SpiderService",
"-",
"specific",
"constraints",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L687-L726 |
138,161 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.validateTableOptionAgingCheckFrequency | private void validateTableOptionAgingCheckFrequency(TableDefinition tableDef,
String optValue) {
new TaskFrequency(optValue);
Utils.require(tableDef.getOption(CommonDefs.OPT_AGING_FIELD) != null,
"Option 'aging-check-frequency' requires option 'aging-field'");
} | java | private void validateTableOptionAgingCheckFrequency(TableDefinition tableDef,
String optValue) {
new TaskFrequency(optValue);
Utils.require(tableDef.getOption(CommonDefs.OPT_AGING_FIELD) != null,
"Option 'aging-check-frequency' requires option 'aging-field'");
} | [
"private",
"void",
"validateTableOptionAgingCheckFrequency",
"(",
"TableDefinition",
"tableDef",
",",
"String",
"optValue",
")",
"{",
"new",
"TaskFrequency",
"(",
"optValue",
")",
";",
"Utils",
".",
"require",
"(",
"tableDef",
".",
"getOption",
"(",
"CommonDefs",
".",
"OPT_AGING_FIELD",
")",
"!=",
"null",
",",
"\"Option 'aging-check-frequency' requires option 'aging-field'\"",
")",
";",
"}"
] | Validate the table option "aging-check-frequency" | [
"Validate",
"the",
"table",
"option",
"aging",
"-",
"check",
"-",
"frequency"
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L729-L734 |
138,162 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.validateTableOptionAgingField | private void validateTableOptionAgingField(TableDefinition tableDef, String optValue) {
FieldDefinition agingFieldDef = tableDef.getFieldDef(optValue);
Utils.require(agingFieldDef != null,
"Aging field has not been defined: " + optValue);
assert agingFieldDef != null; // Make FindBugs happy
Utils.require(agingFieldDef.getType() == FieldType.TIMESTAMP,
"Aging field must be a timestamp field: " + optValue);
Utils.require(tableDef.getOption(CommonDefs.OPT_RETENTION_AGE) != null,
"Option 'aging-field' requires option 'retention-age'");
} | java | private void validateTableOptionAgingField(TableDefinition tableDef, String optValue) {
FieldDefinition agingFieldDef = tableDef.getFieldDef(optValue);
Utils.require(agingFieldDef != null,
"Aging field has not been defined: " + optValue);
assert agingFieldDef != null; // Make FindBugs happy
Utils.require(agingFieldDef.getType() == FieldType.TIMESTAMP,
"Aging field must be a timestamp field: " + optValue);
Utils.require(tableDef.getOption(CommonDefs.OPT_RETENTION_AGE) != null,
"Option 'aging-field' requires option 'retention-age'");
} | [
"private",
"void",
"validateTableOptionAgingField",
"(",
"TableDefinition",
"tableDef",
",",
"String",
"optValue",
")",
"{",
"FieldDefinition",
"agingFieldDef",
"=",
"tableDef",
".",
"getFieldDef",
"(",
"optValue",
")",
";",
"Utils",
".",
"require",
"(",
"agingFieldDef",
"!=",
"null",
",",
"\"Aging field has not been defined: \"",
"+",
"optValue",
")",
";",
"assert",
"agingFieldDef",
"!=",
"null",
";",
"// Make FindBugs happy\r",
"Utils",
".",
"require",
"(",
"agingFieldDef",
".",
"getType",
"(",
")",
"==",
"FieldType",
".",
"TIMESTAMP",
",",
"\"Aging field must be a timestamp field: \"",
"+",
"optValue",
")",
";",
"Utils",
".",
"require",
"(",
"tableDef",
".",
"getOption",
"(",
"CommonDefs",
".",
"OPT_RETENTION_AGE",
")",
"!=",
"null",
",",
"\"Option 'aging-field' requires option 'retention-age'\"",
")",
";",
"}"
] | Validate the table option "aging-field". | [
"Validate",
"the",
"table",
"option",
"aging",
"-",
"field",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L737-L746 |
138,163 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.validateTableOptionRetentionAge | private void validateTableOptionRetentionAge(TableDefinition tableDef, String optValue) {
RetentionAge retAge = new RetentionAge(optValue); // throws if invalid format
optValue = retAge.toString();
tableDef.setOption(CommonDefs.OPT_RETENTION_AGE, optValue); // rewrite value
Utils.require(tableDef.getOption(CommonDefs.OPT_AGING_FIELD) != null,
"Option 'retention-age' requires option 'aging-field'");
} | java | private void validateTableOptionRetentionAge(TableDefinition tableDef, String optValue) {
RetentionAge retAge = new RetentionAge(optValue); // throws if invalid format
optValue = retAge.toString();
tableDef.setOption(CommonDefs.OPT_RETENTION_AGE, optValue); // rewrite value
Utils.require(tableDef.getOption(CommonDefs.OPT_AGING_FIELD) != null,
"Option 'retention-age' requires option 'aging-field'");
} | [
"private",
"void",
"validateTableOptionRetentionAge",
"(",
"TableDefinition",
"tableDef",
",",
"String",
"optValue",
")",
"{",
"RetentionAge",
"retAge",
"=",
"new",
"RetentionAge",
"(",
"optValue",
")",
";",
"// throws if invalid format\r",
"optValue",
"=",
"retAge",
".",
"toString",
"(",
")",
";",
"tableDef",
".",
"setOption",
"(",
"CommonDefs",
".",
"OPT_RETENTION_AGE",
",",
"optValue",
")",
";",
"// rewrite value\r",
"Utils",
".",
"require",
"(",
"tableDef",
".",
"getOption",
"(",
"CommonDefs",
".",
"OPT_AGING_FIELD",
")",
"!=",
"null",
",",
"\"Option 'retention-age' requires option 'aging-field'\"",
")",
";",
"}"
] | Validate the table option "retention-age". | [
"Validate",
"the",
"table",
"option",
"retention",
"-",
"age",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L749-L755 |
138,164 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.validateTableOptionShardingField | private void validateTableOptionShardingField(TableDefinition tableDef, String optValue) {
// Verify that the sharding-field exists and is a timestamp field.
FieldDefinition shardingFieldDef = tableDef.getFieldDef(optValue);
Utils.require(shardingFieldDef != null,
"Sharding field has not been defined: " + optValue);
assert shardingFieldDef != null; // Make FindBugs happy
Utils.require(shardingFieldDef.getType() == FieldType.TIMESTAMP,
"Sharding field must be a timestamp field: " + optValue);
Utils.require(!shardingFieldDef.isCollection(),
"Sharding field cannot be a collection: " + optValue);
// Default sharding-granularity to MONTH.
if (tableDef.getOption(CommonDefs.OPT_SHARDING_GRANULARITY) == null) {
tableDef.setOption(CommonDefs.OPT_SHARDING_GRANULARITY, "MONTH");
}
// Default sharding-start to "tomorrow".
if (tableDef.getOption(CommonDefs.OPT_SHARDING_START) == null) {
GregorianCalendar startDate = new GregorianCalendar(Utils.UTC_TIMEZONE);
startDate.add(Calendar.DAY_OF_MONTH, 1); // adds 1 day
String startOpt = String.format("%04d-%02d-%02d",
startDate.get(Calendar.YEAR),
startDate.get(Calendar.MONTH)+1, // 0-relative!
startDate.get(Calendar.DAY_OF_MONTH));
tableDef.setOption(CommonDefs.OPT_SHARDING_START, startOpt);
}
} | java | private void validateTableOptionShardingField(TableDefinition tableDef, String optValue) {
// Verify that the sharding-field exists and is a timestamp field.
FieldDefinition shardingFieldDef = tableDef.getFieldDef(optValue);
Utils.require(shardingFieldDef != null,
"Sharding field has not been defined: " + optValue);
assert shardingFieldDef != null; // Make FindBugs happy
Utils.require(shardingFieldDef.getType() == FieldType.TIMESTAMP,
"Sharding field must be a timestamp field: " + optValue);
Utils.require(!shardingFieldDef.isCollection(),
"Sharding field cannot be a collection: " + optValue);
// Default sharding-granularity to MONTH.
if (tableDef.getOption(CommonDefs.OPT_SHARDING_GRANULARITY) == null) {
tableDef.setOption(CommonDefs.OPT_SHARDING_GRANULARITY, "MONTH");
}
// Default sharding-start to "tomorrow".
if (tableDef.getOption(CommonDefs.OPT_SHARDING_START) == null) {
GregorianCalendar startDate = new GregorianCalendar(Utils.UTC_TIMEZONE);
startDate.add(Calendar.DAY_OF_MONTH, 1); // adds 1 day
String startOpt = String.format("%04d-%02d-%02d",
startDate.get(Calendar.YEAR),
startDate.get(Calendar.MONTH)+1, // 0-relative!
startDate.get(Calendar.DAY_OF_MONTH));
tableDef.setOption(CommonDefs.OPT_SHARDING_START, startOpt);
}
} | [
"private",
"void",
"validateTableOptionShardingField",
"(",
"TableDefinition",
"tableDef",
",",
"String",
"optValue",
")",
"{",
"// Verify that the sharding-field exists and is a timestamp field.\r",
"FieldDefinition",
"shardingFieldDef",
"=",
"tableDef",
".",
"getFieldDef",
"(",
"optValue",
")",
";",
"Utils",
".",
"require",
"(",
"shardingFieldDef",
"!=",
"null",
",",
"\"Sharding field has not been defined: \"",
"+",
"optValue",
")",
";",
"assert",
"shardingFieldDef",
"!=",
"null",
";",
"// Make FindBugs happy\r",
"Utils",
".",
"require",
"(",
"shardingFieldDef",
".",
"getType",
"(",
")",
"==",
"FieldType",
".",
"TIMESTAMP",
",",
"\"Sharding field must be a timestamp field: \"",
"+",
"optValue",
")",
";",
"Utils",
".",
"require",
"(",
"!",
"shardingFieldDef",
".",
"isCollection",
"(",
")",
",",
"\"Sharding field cannot be a collection: \"",
"+",
"optValue",
")",
";",
"// Default sharding-granularity to MONTH.\r",
"if",
"(",
"tableDef",
".",
"getOption",
"(",
"CommonDefs",
".",
"OPT_SHARDING_GRANULARITY",
")",
"==",
"null",
")",
"{",
"tableDef",
".",
"setOption",
"(",
"CommonDefs",
".",
"OPT_SHARDING_GRANULARITY",
",",
"\"MONTH\"",
")",
";",
"}",
"// Default sharding-start to \"tomorrow\".\r",
"if",
"(",
"tableDef",
".",
"getOption",
"(",
"CommonDefs",
".",
"OPT_SHARDING_START",
")",
"==",
"null",
")",
"{",
"GregorianCalendar",
"startDate",
"=",
"new",
"GregorianCalendar",
"(",
"Utils",
".",
"UTC_TIMEZONE",
")",
";",
"startDate",
".",
"add",
"(",
"Calendar",
".",
"DAY_OF_MONTH",
",",
"1",
")",
";",
"// adds 1 day\r",
"String",
"startOpt",
"=",
"String",
".",
"format",
"(",
"\"%04d-%02d-%02d\"",
",",
"startDate",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
",",
"startDate",
".",
"get",
"(",
"Calendar",
".",
"MONTH",
")",
"+",
"1",
",",
"// 0-relative!\r",
"startDate",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_MONTH",
")",
")",
";",
"tableDef",
".",
"setOption",
"(",
"CommonDefs",
".",
"OPT_SHARDING_START",
",",
"startOpt",
")",
";",
"}",
"}"
] | Validate the table option "sharding-field". | [
"Validate",
"the",
"table",
"option",
"sharding",
"-",
"field",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L758-L784 |
138,165 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.validateTableOptionShardingGranularity | private void validateTableOptionShardingGranularity(TableDefinition tableDef, String optValue) {
ShardingGranularity shardingGranularity = ShardingGranularity.fromString(optValue);
Utils.require(shardingGranularity != null,
"Unrecognized 'sharding-granularity' value: " + optValue);
// 'sharding-granularity' requires 'sharding-field'
Utils.require(tableDef.getOption(CommonDefs.OPT_SHARDING_FIELD) != null,
"Option 'sharding-granularity' requires option 'sharding-field'");
} | java | private void validateTableOptionShardingGranularity(TableDefinition tableDef, String optValue) {
ShardingGranularity shardingGranularity = ShardingGranularity.fromString(optValue);
Utils.require(shardingGranularity != null,
"Unrecognized 'sharding-granularity' value: " + optValue);
// 'sharding-granularity' requires 'sharding-field'
Utils.require(tableDef.getOption(CommonDefs.OPT_SHARDING_FIELD) != null,
"Option 'sharding-granularity' requires option 'sharding-field'");
} | [
"private",
"void",
"validateTableOptionShardingGranularity",
"(",
"TableDefinition",
"tableDef",
",",
"String",
"optValue",
")",
"{",
"ShardingGranularity",
"shardingGranularity",
"=",
"ShardingGranularity",
".",
"fromString",
"(",
"optValue",
")",
";",
"Utils",
".",
"require",
"(",
"shardingGranularity",
"!=",
"null",
",",
"\"Unrecognized 'sharding-granularity' value: \"",
"+",
"optValue",
")",
";",
"// 'sharding-granularity' requires 'sharding-field'\r",
"Utils",
".",
"require",
"(",
"tableDef",
".",
"getOption",
"(",
"CommonDefs",
".",
"OPT_SHARDING_FIELD",
")",
"!=",
"null",
",",
"\"Option 'sharding-granularity' requires option 'sharding-field'\"",
")",
";",
"}"
] | Validate the table option "sharding-granularity". | [
"Validate",
"the",
"table",
"option",
"sharding",
"-",
"granularity",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L787-L795 |
138,166 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.validateTableOptionShardingStart | private void validateTableOptionShardingStart(TableDefinition tableDef, String optValue) {
Utils.require(isValidShardDate(optValue),
"'sharding-start' must be YYYY-MM-DD: " + optValue);
GregorianCalendar shardingStartDate = new GregorianCalendar(Utils.UTC_TIMEZONE);
shardingStartDate.setTime(Utils.dateFromString(optValue));
// 'sharding-start' requires 'sharding-field'
Utils.require(tableDef.getOption(CommonDefs.OPT_SHARDING_FIELD) != null,
"Option 'sharding-start' requires option 'sharding-field'");
} | java | private void validateTableOptionShardingStart(TableDefinition tableDef, String optValue) {
Utils.require(isValidShardDate(optValue),
"'sharding-start' must be YYYY-MM-DD: " + optValue);
GregorianCalendar shardingStartDate = new GregorianCalendar(Utils.UTC_TIMEZONE);
shardingStartDate.setTime(Utils.dateFromString(optValue));
// 'sharding-start' requires 'sharding-field'
Utils.require(tableDef.getOption(CommonDefs.OPT_SHARDING_FIELD) != null,
"Option 'sharding-start' requires option 'sharding-field'");
} | [
"private",
"void",
"validateTableOptionShardingStart",
"(",
"TableDefinition",
"tableDef",
",",
"String",
"optValue",
")",
"{",
"Utils",
".",
"require",
"(",
"isValidShardDate",
"(",
"optValue",
")",
",",
"\"'sharding-start' must be YYYY-MM-DD: \"",
"+",
"optValue",
")",
";",
"GregorianCalendar",
"shardingStartDate",
"=",
"new",
"GregorianCalendar",
"(",
"Utils",
".",
"UTC_TIMEZONE",
")",
";",
"shardingStartDate",
".",
"setTime",
"(",
"Utils",
".",
"dateFromString",
"(",
"optValue",
")",
")",
";",
"// 'sharding-start' requires 'sharding-field'\r",
"Utils",
".",
"require",
"(",
"tableDef",
".",
"getOption",
"(",
"CommonDefs",
".",
"OPT_SHARDING_FIELD",
")",
"!=",
"null",
",",
"\"Option 'sharding-start' requires option 'sharding-field'\"",
")",
";",
"}"
] | Validate the table option "sharding-start". | [
"Validate",
"the",
"table",
"option",
"sharding",
"-",
"start",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L798-L807 |
138,167 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java | SpiderService.verifyApplicationCFs | private void verifyApplicationCFs(ApplicationDefinition oldAppDef,
ApplicationDefinition appDef) {
// Add new table-level CFs:
Tenant tenant = Tenant.getTenant(appDef);
DBService dbService = DBService.instance(tenant);
for (TableDefinition tableDef : appDef.getTableDefinitions().values()) {
dbService.createStoreIfAbsent(objectsStoreName(tableDef), true);
dbService.createStoreIfAbsent(termsStoreName(tableDef), true);
}
// Delete obsolete table-level CFs:
if (oldAppDef != null) {
for (TableDefinition oldTableDef : oldAppDef.getTableDefinitions().values()) {
if (appDef.getTableDef(oldTableDef.getTableName()) == null) {
dbService.deleteStoreIfPresent(objectsStoreName(oldTableDef));
dbService.deleteStoreIfPresent(termsStoreName(oldTableDef));
}
}
}
} | java | private void verifyApplicationCFs(ApplicationDefinition oldAppDef,
ApplicationDefinition appDef) {
// Add new table-level CFs:
Tenant tenant = Tenant.getTenant(appDef);
DBService dbService = DBService.instance(tenant);
for (TableDefinition tableDef : appDef.getTableDefinitions().values()) {
dbService.createStoreIfAbsent(objectsStoreName(tableDef), true);
dbService.createStoreIfAbsent(termsStoreName(tableDef), true);
}
// Delete obsolete table-level CFs:
if (oldAppDef != null) {
for (TableDefinition oldTableDef : oldAppDef.getTableDefinitions().values()) {
if (appDef.getTableDef(oldTableDef.getTableName()) == null) {
dbService.deleteStoreIfPresent(objectsStoreName(oldTableDef));
dbService.deleteStoreIfPresent(termsStoreName(oldTableDef));
}
}
}
} | [
"private",
"void",
"verifyApplicationCFs",
"(",
"ApplicationDefinition",
"oldAppDef",
",",
"ApplicationDefinition",
"appDef",
")",
"{",
"// Add new table-level CFs:\r",
"Tenant",
"tenant",
"=",
"Tenant",
".",
"getTenant",
"(",
"appDef",
")",
";",
"DBService",
"dbService",
"=",
"DBService",
".",
"instance",
"(",
"tenant",
")",
";",
"for",
"(",
"TableDefinition",
"tableDef",
":",
"appDef",
".",
"getTableDefinitions",
"(",
")",
".",
"values",
"(",
")",
")",
"{",
"dbService",
".",
"createStoreIfAbsent",
"(",
"objectsStoreName",
"(",
"tableDef",
")",
",",
"true",
")",
";",
"dbService",
".",
"createStoreIfAbsent",
"(",
"termsStoreName",
"(",
"tableDef",
")",
",",
"true",
")",
";",
"}",
"// Delete obsolete table-level CFs:\r",
"if",
"(",
"oldAppDef",
"!=",
"null",
")",
"{",
"for",
"(",
"TableDefinition",
"oldTableDef",
":",
"oldAppDef",
".",
"getTableDefinitions",
"(",
")",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"appDef",
".",
"getTableDef",
"(",
"oldTableDef",
".",
"getTableName",
"(",
")",
")",
"==",
"null",
")",
"{",
"dbService",
".",
"deleteStoreIfPresent",
"(",
"objectsStoreName",
"(",
"oldTableDef",
")",
")",
";",
"dbService",
".",
"deleteStoreIfPresent",
"(",
"termsStoreName",
"(",
"oldTableDef",
")",
")",
";",
"}",
"}",
"}",
"}"
] | Verify that all ColumnFamilies needed for the given application exist. | [
"Verify",
"that",
"all",
"ColumnFamilies",
"needed",
"for",
"the",
"given",
"application",
"exist",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderService.java#L810-L829 |
138,168 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/management/LongJob.java | LongJob.getDuration | public long getDuration() {
Status s = status;
if (s == Status.READY)
return 0;
if (s == Status.RUNNING)
return System.currentTimeMillis() - startTime;
return finishTime - startTime;
} | java | public long getDuration() {
Status s = status;
if (s == Status.READY)
return 0;
if (s == Status.RUNNING)
return System.currentTimeMillis() - startTime;
return finishTime - startTime;
} | [
"public",
"long",
"getDuration",
"(",
")",
"{",
"Status",
"s",
"=",
"status",
";",
"if",
"(",
"s",
"==",
"Status",
".",
"READY",
")",
"return",
"0",
";",
"if",
"(",
"s",
"==",
"Status",
".",
"RUNNING",
")",
"return",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"startTime",
";",
"return",
"finishTime",
"-",
"startTime",
";",
"}"
] | The current or final time, in milliseconds, during which the job either
is executed or was executed. | [
"The",
"current",
"or",
"final",
"time",
"in",
"milliseconds",
"during",
"which",
"the",
"job",
"either",
"is",
"executed",
"or",
"was",
"executed",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/management/LongJob.java#L93-L100 |
138,169 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/management/RequestsTracker.java | RequestsTracker.snapshot | public synchronized RequestsTracker snapshot(boolean reset) {
long t = executing.getCount();
long r = rejected.getCount();
long f = failed.getCount();
TimeCounter c = counter.snapshot(reset);
IntervalHistogram h = histogram.snapshot(reset);
if (reset) {
executing.reset();
rejected.reset();
failed.reset();
succeeded.reset();
}
return new RequestsTracker(t, r, f, c, h, lastFailureReason,
lastRejectReason);
} | java | public synchronized RequestsTracker snapshot(boolean reset) {
long t = executing.getCount();
long r = rejected.getCount();
long f = failed.getCount();
TimeCounter c = counter.snapshot(reset);
IntervalHistogram h = histogram.snapshot(reset);
if (reset) {
executing.reset();
rejected.reset();
failed.reset();
succeeded.reset();
}
return new RequestsTracker(t, r, f, c, h, lastFailureReason,
lastRejectReason);
} | [
"public",
"synchronized",
"RequestsTracker",
"snapshot",
"(",
"boolean",
"reset",
")",
"{",
"long",
"t",
"=",
"executing",
".",
"getCount",
"(",
")",
";",
"long",
"r",
"=",
"rejected",
".",
"getCount",
"(",
")",
";",
"long",
"f",
"=",
"failed",
".",
"getCount",
"(",
")",
";",
"TimeCounter",
"c",
"=",
"counter",
".",
"snapshot",
"(",
"reset",
")",
";",
"IntervalHistogram",
"h",
"=",
"histogram",
".",
"snapshot",
"(",
"reset",
")",
";",
"if",
"(",
"reset",
")",
"{",
"executing",
".",
"reset",
"(",
")",
";",
"rejected",
".",
"reset",
"(",
")",
";",
"failed",
".",
"reset",
"(",
")",
";",
"succeeded",
".",
"reset",
"(",
")",
";",
"}",
"return",
"new",
"RequestsTracker",
"(",
"t",
",",
"r",
",",
"f",
",",
"c",
",",
"h",
",",
"lastFailureReason",
",",
"lastRejectReason",
")",
";",
"}"
] | Clones this tracker and zeroizes out it afterwards if the 'reset' is
true.
@param reset
zero out this tracker
@return clone of this tracker | [
"Clones",
"this",
"tracker",
"and",
"zeroizes",
"out",
"it",
"afterwards",
"if",
"the",
"reset",
"is",
"true",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/management/RequestsTracker.java#L181-L197 |
138,170 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/management/RequestsTracker.java | RequestsTracker.reset | public synchronized void reset() {
executing.reset();
rejected.reset();
failed.reset();
succeeded.reset();
counter.reset();
histogram.reset();
lastFailureReason = null;
lastRejectReason = null;
} | java | public synchronized void reset() {
executing.reset();
rejected.reset();
failed.reset();
succeeded.reset();
counter.reset();
histogram.reset();
lastFailureReason = null;
lastRejectReason = null;
} | [
"public",
"synchronized",
"void",
"reset",
"(",
")",
"{",
"executing",
".",
"reset",
"(",
")",
";",
"rejected",
".",
"reset",
"(",
")",
";",
"failed",
".",
"reset",
"(",
")",
";",
"succeeded",
".",
"reset",
"(",
")",
";",
"counter",
".",
"reset",
"(",
")",
";",
"histogram",
".",
"reset",
"(",
")",
";",
"lastFailureReason",
"=",
"null",
";",
"lastRejectReason",
"=",
"null",
";",
"}"
] | Zeroizes out this tracker. | [
"Zeroizes",
"out",
"this",
"tracker",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/management/RequestsTracker.java#L202-L213 |
138,171 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/olap/aggregate/mr/MFCollectorSet.java | MFCollectorSet.getCommonPart | private int getCommonPart(List<AggregationGroup> groups) {
if(groups.size() < 2) return 0;
for(int i = 0; i < groups.size(); i++) {
if(groups.get(i).filter != null) return 0;
}
int itemsCount = groups.get(0).items.size() - 1;
for(int i = 1; i < groups.size(); i++) {
itemsCount = Math.min(itemsCount, groups.get(i).items.size() - 1);
}
if(itemsCount <= 0) return 0;
int itemIndex = 0;
for(; itemIndex < itemsCount; itemIndex++) {
boolean eq = true;
AggregationGroupItem item = groups.get(0).items.get(itemIndex);
if(item.xlinkContext != null) break;
for(int i = 1; i < groups.size(); i++) {
AggregationGroupItem item2 = groups.get(i).items.get(itemIndex);
if(!item.equals(item2) || item.xlinkContext != null) {
eq = false;
break;
}
}
if(!eq) break;
}
if(itemIndex > 0) {
LOG.info("Found common path for groups: " + itemIndex);
}
return itemIndex;
} | java | private int getCommonPart(List<AggregationGroup> groups) {
if(groups.size() < 2) return 0;
for(int i = 0; i < groups.size(); i++) {
if(groups.get(i).filter != null) return 0;
}
int itemsCount = groups.get(0).items.size() - 1;
for(int i = 1; i < groups.size(); i++) {
itemsCount = Math.min(itemsCount, groups.get(i).items.size() - 1);
}
if(itemsCount <= 0) return 0;
int itemIndex = 0;
for(; itemIndex < itemsCount; itemIndex++) {
boolean eq = true;
AggregationGroupItem item = groups.get(0).items.get(itemIndex);
if(item.xlinkContext != null) break;
for(int i = 1; i < groups.size(); i++) {
AggregationGroupItem item2 = groups.get(i).items.get(itemIndex);
if(!item.equals(item2) || item.xlinkContext != null) {
eq = false;
break;
}
}
if(!eq) break;
}
if(itemIndex > 0) {
LOG.info("Found common path for groups: " + itemIndex);
}
return itemIndex;
} | [
"private",
"int",
"getCommonPart",
"(",
"List",
"<",
"AggregationGroup",
">",
"groups",
")",
"{",
"if",
"(",
"groups",
".",
"size",
"(",
")",
"<",
"2",
")",
"return",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"groups",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"groups",
".",
"get",
"(",
"i",
")",
".",
"filter",
"!=",
"null",
")",
"return",
"0",
";",
"}",
"int",
"itemsCount",
"=",
"groups",
".",
"get",
"(",
"0",
")",
".",
"items",
".",
"size",
"(",
")",
"-",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"groups",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"itemsCount",
"=",
"Math",
".",
"min",
"(",
"itemsCount",
",",
"groups",
".",
"get",
"(",
"i",
")",
".",
"items",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"}",
"if",
"(",
"itemsCount",
"<=",
"0",
")",
"return",
"0",
";",
"int",
"itemIndex",
"=",
"0",
";",
"for",
"(",
";",
"itemIndex",
"<",
"itemsCount",
";",
"itemIndex",
"++",
")",
"{",
"boolean",
"eq",
"=",
"true",
";",
"AggregationGroupItem",
"item",
"=",
"groups",
".",
"get",
"(",
"0",
")",
".",
"items",
".",
"get",
"(",
"itemIndex",
")",
";",
"if",
"(",
"item",
".",
"xlinkContext",
"!=",
"null",
")",
"break",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"groups",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"AggregationGroupItem",
"item2",
"=",
"groups",
".",
"get",
"(",
"i",
")",
".",
"items",
".",
"get",
"(",
"itemIndex",
")",
";",
"if",
"(",
"!",
"item",
".",
"equals",
"(",
"item2",
")",
"||",
"item",
".",
"xlinkContext",
"!=",
"null",
")",
"{",
"eq",
"=",
"false",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"eq",
")",
"break",
";",
"}",
"if",
"(",
"itemIndex",
">",
"0",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Found common path for groups: \"",
"+",
"itemIndex",
")",
";",
"}",
"return",
"itemIndex",
";",
"}"
] | Support for common paths in groups | [
"Support",
"for",
"common",
"paths",
"in",
"groups"
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/olap/aggregate/mr/MFCollectorSet.java#L57-L88 |
138,172 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.addLinkValue | public void addLinkValue(String ownerObjID, FieldDefinition linkDef, String targetObjID) {
addColumn(SpiderService.objectsStoreName(linkDef.getTableDef()),
ownerObjID,
SpiderService.linkColumnName(linkDef, targetObjID));
} | java | public void addLinkValue(String ownerObjID, FieldDefinition linkDef, String targetObjID) {
addColumn(SpiderService.objectsStoreName(linkDef.getTableDef()),
ownerObjID,
SpiderService.linkColumnName(linkDef, targetObjID));
} | [
"public",
"void",
"addLinkValue",
"(",
"String",
"ownerObjID",
",",
"FieldDefinition",
"linkDef",
",",
"String",
"targetObjID",
")",
"{",
"addColumn",
"(",
"SpiderService",
".",
"objectsStoreName",
"(",
"linkDef",
".",
"getTableDef",
"(",
")",
")",
",",
"ownerObjID",
",",
"SpiderService",
".",
"linkColumnName",
"(",
"linkDef",
",",
"targetObjID",
")",
")",
";",
"}"
] | Add a link value column to the objects store of the given object ID.
@param ownerObjID Object ID of object owns the link field.
@param linkDef {@link FieldDefinition} of the link field.
@param targetObjID Referenced (target) object ID. | [
"Add",
"a",
"link",
"value",
"column",
"to",
"the",
"objects",
"store",
"of",
"the",
"given",
"object",
"ID",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L252-L256 |
138,173 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.addScalarValueColumn | public void addScalarValueColumn(TableDefinition tableDef, String objID, String fieldName, String fieldValue) {
addColumn(SpiderService.objectsStoreName(tableDef),
objID,
fieldName,
SpiderService.scalarValueToBinary(tableDef, fieldName, fieldValue));
} | java | public void addScalarValueColumn(TableDefinition tableDef, String objID, String fieldName, String fieldValue) {
addColumn(SpiderService.objectsStoreName(tableDef),
objID,
fieldName,
SpiderService.scalarValueToBinary(tableDef, fieldName, fieldValue));
} | [
"public",
"void",
"addScalarValueColumn",
"(",
"TableDefinition",
"tableDef",
",",
"String",
"objID",
",",
"String",
"fieldName",
",",
"String",
"fieldValue",
")",
"{",
"addColumn",
"(",
"SpiderService",
".",
"objectsStoreName",
"(",
"tableDef",
")",
",",
"objID",
",",
"fieldName",
",",
"SpiderService",
".",
"scalarValueToBinary",
"(",
"tableDef",
",",
"fieldName",
",",
"fieldValue",
")",
")",
";",
"}"
] | Add the column needed to add or replace the given scalar field belonging to the
object with the given ID in the given table.
@param tableDef {@link TableDefinition} of table that owns object.
@param objID ID of object.
@param fieldName Name of scalar field being added.
@param fieldValue Value being added in string form. | [
"Add",
"the",
"column",
"needed",
"to",
"add",
"or",
"replace",
"the",
"given",
"scalar",
"field",
"belonging",
"to",
"the",
"object",
"with",
"the",
"given",
"ID",
"in",
"the",
"given",
"table",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L267-L272 |
138,174 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.addShardedLinkValue | public void addShardedLinkValue(String ownerObjID, FieldDefinition linkDef, String targetObjID, int targetShardNo) {
assert linkDef.isSharded();
assert targetShardNo > 0;
addColumn(SpiderService.termsStoreName(linkDef.getTableDef()),
SpiderService.shardedLinkTermRowKey(linkDef, ownerObjID, targetShardNo),
targetObjID);
} | java | public void addShardedLinkValue(String ownerObjID, FieldDefinition linkDef, String targetObjID, int targetShardNo) {
assert linkDef.isSharded();
assert targetShardNo > 0;
addColumn(SpiderService.termsStoreName(linkDef.getTableDef()),
SpiderService.shardedLinkTermRowKey(linkDef, ownerObjID, targetShardNo),
targetObjID);
} | [
"public",
"void",
"addShardedLinkValue",
"(",
"String",
"ownerObjID",
",",
"FieldDefinition",
"linkDef",
",",
"String",
"targetObjID",
",",
"int",
"targetShardNo",
")",
"{",
"assert",
"linkDef",
".",
"isSharded",
"(",
")",
";",
"assert",
"targetShardNo",
">",
"0",
";",
"addColumn",
"(",
"SpiderService",
".",
"termsStoreName",
"(",
"linkDef",
".",
"getTableDef",
"(",
")",
")",
",",
"SpiderService",
".",
"shardedLinkTermRowKey",
"(",
"linkDef",
",",
"ownerObjID",
",",
"targetShardNo",
")",
",",
"targetObjID",
")",
";",
"}"
] | Add a link value column on behalf of the given owner object, referencing the given
target object ID. This is used when a link is sharded and the owner's shard number
is > 0. The link value column is added to a special term record.
@param ownerObjID Object ID of object owns the link field.
@param linkDef {@link FieldDefinition} of the link field.
@param targetObjID Referenced (target) object ID (owning table is sharded).
@param targetShardNo Shard number of the target object. Must be > 0. | [
"Add",
"a",
"link",
"value",
"column",
"on",
"behalf",
"of",
"the",
"given",
"owner",
"object",
"referencing",
"the",
"given",
"target",
"object",
"ID",
".",
"This",
"is",
"used",
"when",
"a",
"link",
"is",
"sharded",
"and",
"the",
"owner",
"s",
"shard",
"number",
"is",
">",
"0",
".",
"The",
"link",
"value",
"column",
"is",
"added",
"to",
"a",
"special",
"term",
"record",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L284-L290 |
138,175 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.deleteAllObjectsColumn | public void deleteAllObjectsColumn(TableDefinition tableDef, String objID, int shardNo) {
String rowKey = ALL_OBJECTS_ROW_KEY;
if (shardNo > 0) {
rowKey = shardNo + "/" + ALL_OBJECTS_ROW_KEY;
}
deleteColumn(SpiderService.termsStoreName(tableDef), rowKey, objID);
} | java | public void deleteAllObjectsColumn(TableDefinition tableDef, String objID, int shardNo) {
String rowKey = ALL_OBJECTS_ROW_KEY;
if (shardNo > 0) {
rowKey = shardNo + "/" + ALL_OBJECTS_ROW_KEY;
}
deleteColumn(SpiderService.termsStoreName(tableDef), rowKey, objID);
} | [
"public",
"void",
"deleteAllObjectsColumn",
"(",
"TableDefinition",
"tableDef",
",",
"String",
"objID",
",",
"int",
"shardNo",
")",
"{",
"String",
"rowKey",
"=",
"ALL_OBJECTS_ROW_KEY",
";",
"if",
"(",
"shardNo",
">",
"0",
")",
"{",
"rowKey",
"=",
"shardNo",
"+",
"\"/\"",
"+",
"ALL_OBJECTS_ROW_KEY",
";",
"}",
"deleteColumn",
"(",
"SpiderService",
".",
"termsStoreName",
"(",
"tableDef",
")",
",",
"rowKey",
",",
"objID",
")",
";",
"}"
] | Delete the "all objects" column with the given object ID from the given table.
@param tableDef {@link TableDefinition} of object's owning table.
@param objID ID of object being deleted.
@param shardNo Shard number of object being deleted.
@see #addAllObjectsColumn(TableDefinition, String, int) | [
"Delete",
"the",
"all",
"objects",
"column",
"with",
"the",
"given",
"object",
"ID",
"from",
"the",
"given",
"table",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L381-L387 |
138,176 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.deleteObjectRow | public void deleteObjectRow(TableDefinition tableDef, String objID) {
deleteRow(SpiderService.objectsStoreName(tableDef), objID);
} | java | public void deleteObjectRow(TableDefinition tableDef, String objID) {
deleteRow(SpiderService.objectsStoreName(tableDef), objID);
} | [
"public",
"void",
"deleteObjectRow",
"(",
"TableDefinition",
"tableDef",
",",
"String",
"objID",
")",
"{",
"deleteRow",
"(",
"SpiderService",
".",
"objectsStoreName",
"(",
"tableDef",
")",
",",
"objID",
")",
";",
"}"
] | Delete the primary field storage row for the given object. This usually called
when the object is being deleted.
@param tableDef {@link TableDefinition} that owns object.
@param objID ID of object whose "objects" row is to be deleted. | [
"Delete",
"the",
"primary",
"field",
"storage",
"row",
"for",
"the",
"given",
"object",
".",
"This",
"usually",
"called",
"when",
"the",
"object",
"is",
"being",
"deleted",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L396-L398 |
138,177 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.deleteScalarValueColumn | public void deleteScalarValueColumn(TableDefinition tableDef, String objID, String fieldName) {
deleteColumn(SpiderService.objectsStoreName(tableDef), objID, fieldName);
} | java | public void deleteScalarValueColumn(TableDefinition tableDef, String objID, String fieldName) {
deleteColumn(SpiderService.objectsStoreName(tableDef), objID, fieldName);
} | [
"public",
"void",
"deleteScalarValueColumn",
"(",
"TableDefinition",
"tableDef",
",",
"String",
"objID",
",",
"String",
"fieldName",
")",
"{",
"deleteColumn",
"(",
"SpiderService",
".",
"objectsStoreName",
"(",
"tableDef",
")",
",",
"objID",
",",
"fieldName",
")",
";",
"}"
] | Delete a scalar value column with the given field name for the given object ID
from the given table.
@param tableDef {@link TableDefinition} of scalar field.
@param objID ID of object.
@param fieldName Scalar field name. | [
"Delete",
"a",
"scalar",
"value",
"column",
"with",
"the",
"given",
"field",
"name",
"for",
"the",
"given",
"object",
"ID",
"from",
"the",
"given",
"table",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L408-L410 |
138,178 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.deleteTermIndexColumn | public void deleteTermIndexColumn(TableDefinition tableDef, DBObject dbObj, String fieldName, String term) {
deleteColumn(SpiderService.termsStoreName(tableDef),
SpiderService.termIndexRowKey(tableDef, dbObj, fieldName, term),
dbObj.getObjectID());
} | java | public void deleteTermIndexColumn(TableDefinition tableDef, DBObject dbObj, String fieldName, String term) {
deleteColumn(SpiderService.termsStoreName(tableDef),
SpiderService.termIndexRowKey(tableDef, dbObj, fieldName, term),
dbObj.getObjectID());
} | [
"public",
"void",
"deleteTermIndexColumn",
"(",
"TableDefinition",
"tableDef",
",",
"DBObject",
"dbObj",
",",
"String",
"fieldName",
",",
"String",
"term",
")",
"{",
"deleteColumn",
"(",
"SpiderService",
".",
"termsStoreName",
"(",
"tableDef",
")",
",",
"SpiderService",
".",
"termIndexRowKey",
"(",
"tableDef",
",",
"dbObj",
",",
"fieldName",
",",
"term",
")",
",",
"dbObj",
".",
"getObjectID",
"(",
")",
")",
";",
"}"
] | Un-index the given term by deleting the Terms column for the given DBObject, field
name, and term.
@param tableDef {@link TableDefinition} of table that owns object.
@param dbObj DBObject that owns field.
@param fieldName Field name.
@param term Term being un-indexed. | [
"Un",
"-",
"index",
"the",
"given",
"term",
"by",
"deleting",
"the",
"Terms",
"column",
"for",
"the",
"given",
"DBObject",
"field",
"name",
"and",
"term",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L421-L425 |
138,179 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.deleteLinkValue | public void deleteLinkValue(String ownerObjID, FieldDefinition linkDef, String targetObjID) {
deleteColumn(SpiderService.objectsStoreName(linkDef.getTableDef()),
ownerObjID,
SpiderService.linkColumnName(linkDef, targetObjID));
} | java | public void deleteLinkValue(String ownerObjID, FieldDefinition linkDef, String targetObjID) {
deleteColumn(SpiderService.objectsStoreName(linkDef.getTableDef()),
ownerObjID,
SpiderService.linkColumnName(linkDef, targetObjID));
} | [
"public",
"void",
"deleteLinkValue",
"(",
"String",
"ownerObjID",
",",
"FieldDefinition",
"linkDef",
",",
"String",
"targetObjID",
")",
"{",
"deleteColumn",
"(",
"SpiderService",
".",
"objectsStoreName",
"(",
"linkDef",
".",
"getTableDef",
"(",
")",
")",
",",
"ownerObjID",
",",
"SpiderService",
".",
"linkColumnName",
"(",
"linkDef",
",",
"targetObjID",
")",
")",
";",
"}"
] | Delete a link value column in the object table of the given owning object.
@param ownerObjID Object ID of object that owns the link field.
@param linkDef {@link FieldDefinition} of the link field.
@param targetObjID Referenced (target) object ID. | [
"Delete",
"a",
"link",
"value",
"column",
"in",
"the",
"object",
"table",
"of",
"the",
"given",
"owning",
"object",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L434-L438 |
138,180 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.deleteShardedLinkRow | public void deleteShardedLinkRow(FieldDefinition linkDef, String owningObjID, int shardNumber) {
assert linkDef.isSharded();
assert shardNumber > 0;
deleteRow(SpiderService.termsStoreName(linkDef.getTableDef()),
SpiderService.shardedLinkTermRowKey(linkDef, owningObjID, shardNumber));
} | java | public void deleteShardedLinkRow(FieldDefinition linkDef, String owningObjID, int shardNumber) {
assert linkDef.isSharded();
assert shardNumber > 0;
deleteRow(SpiderService.termsStoreName(linkDef.getTableDef()),
SpiderService.shardedLinkTermRowKey(linkDef, owningObjID, shardNumber));
} | [
"public",
"void",
"deleteShardedLinkRow",
"(",
"FieldDefinition",
"linkDef",
",",
"String",
"owningObjID",
",",
"int",
"shardNumber",
")",
"{",
"assert",
"linkDef",
".",
"isSharded",
"(",
")",
";",
"assert",
"shardNumber",
">",
"0",
";",
"deleteRow",
"(",
"SpiderService",
".",
"termsStoreName",
"(",
"linkDef",
".",
"getTableDef",
"(",
")",
")",
",",
"SpiderService",
".",
"shardedLinkTermRowKey",
"(",
"linkDef",
",",
"owningObjID",
",",
"shardNumber",
")",
")",
";",
"}"
] | Delete the shard row for the given sharded link and shard number.
@param linkDef {@link FieldDefinition} of a sharded link.
@param owningObjID ID of object that owns the link.
@param shardNumber Shard number of row to be deleted. Must be > 0.
@see #addShardedLinkValue(String, FieldDefinition, DBObject, int)
@see SpiderService#shardedLinkTermRowKey(FieldDefinition, String, int) | [
"Delete",
"the",
"shard",
"row",
"for",
"the",
"given",
"sharded",
"link",
"and",
"shard",
"number",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L449-L454 |
138,181 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.deleteShardedLinkValue | public void deleteShardedLinkValue(String objID, FieldDefinition linkDef, String targetObjID, int shardNo) {
assert linkDef.isSharded();
assert shardNo > 0;
deleteColumn(SpiderService.termsStoreName(linkDef.getTableDef()),
SpiderService.shardedLinkTermRowKey(linkDef, objID, shardNo),
targetObjID);
} | java | public void deleteShardedLinkValue(String objID, FieldDefinition linkDef, String targetObjID, int shardNo) {
assert linkDef.isSharded();
assert shardNo > 0;
deleteColumn(SpiderService.termsStoreName(linkDef.getTableDef()),
SpiderService.shardedLinkTermRowKey(linkDef, objID, shardNo),
targetObjID);
} | [
"public",
"void",
"deleteShardedLinkValue",
"(",
"String",
"objID",
",",
"FieldDefinition",
"linkDef",
",",
"String",
"targetObjID",
",",
"int",
"shardNo",
")",
"{",
"assert",
"linkDef",
".",
"isSharded",
"(",
")",
";",
"assert",
"shardNo",
">",
"0",
";",
"deleteColumn",
"(",
"SpiderService",
".",
"termsStoreName",
"(",
"linkDef",
".",
"getTableDef",
"(",
")",
")",
",",
"SpiderService",
".",
"shardedLinkTermRowKey",
"(",
"linkDef",
",",
"objID",
",",
"shardNo",
")",
",",
"targetObjID",
")",
";",
"}"
] | Delete a link value column in the Terms store for a sharded link.
@param objID ID of object that owns the link field.
@param linkDef {@link FieldDefinition} of (sharded) link field.
@param targetObjID ID of referenced object.
@param shardNo Shard number. Must be > 0. | [
"Delete",
"a",
"link",
"value",
"column",
"in",
"the",
"Terms",
"store",
"for",
"a",
"sharded",
"link",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L464-L470 |
138,182 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.addColumn | private void addColumn(String storeName, String rowKey, String colName) {
addColumn(storeName, rowKey, colName, null);
} | java | private void addColumn(String storeName, String rowKey, String colName) {
addColumn(storeName, rowKey, colName, null);
} | [
"private",
"void",
"addColumn",
"(",
"String",
"storeName",
",",
"String",
"rowKey",
",",
"String",
"colName",
")",
"{",
"addColumn",
"(",
"storeName",
",",
"rowKey",
",",
"colName",
",",
"null",
")",
";",
"}"
] | Add the given column update with a null column value. | [
"Add",
"the",
"given",
"column",
"update",
"with",
"a",
"null",
"column",
"value",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L475-L477 |
138,183 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.addColumn | private void addColumn(String storeName, String rowKey, String colName, byte[] colValue) {
Map<String, Map<String, byte[]>> rowMap = m_columnAdds.get(storeName);
if (rowMap == null) {
rowMap = new HashMap<>();
m_columnAdds.put(storeName, rowMap);
}
Map<String, byte[]> colMap = rowMap.get(rowKey);
if (colMap == null) {
colMap = new HashMap<>();
rowMap.put(rowKey, colMap);
}
byte[] oldValue = colMap.put(colName, colValue);
if (oldValue == null) {
m_totalUpdates++;
} else if (!Arrays.equals(oldValue, colValue)) {
m_logger.debug("Warning: duplicate column mutation with different value: " +
"store={}, row={}, col={}, old={}, new={}",
new Object[]{storeName, rowKey, colName, oldValue, colValue});
}
} | java | private void addColumn(String storeName, String rowKey, String colName, byte[] colValue) {
Map<String, Map<String, byte[]>> rowMap = m_columnAdds.get(storeName);
if (rowMap == null) {
rowMap = new HashMap<>();
m_columnAdds.put(storeName, rowMap);
}
Map<String, byte[]> colMap = rowMap.get(rowKey);
if (colMap == null) {
colMap = new HashMap<>();
rowMap.put(rowKey, colMap);
}
byte[] oldValue = colMap.put(colName, colValue);
if (oldValue == null) {
m_totalUpdates++;
} else if (!Arrays.equals(oldValue, colValue)) {
m_logger.debug("Warning: duplicate column mutation with different value: " +
"store={}, row={}, col={}, old={}, new={}",
new Object[]{storeName, rowKey, colName, oldValue, colValue});
}
} | [
"private",
"void",
"addColumn",
"(",
"String",
"storeName",
",",
"String",
"rowKey",
",",
"String",
"colName",
",",
"byte",
"[",
"]",
"colValue",
")",
"{",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"byte",
"[",
"]",
">",
">",
"rowMap",
"=",
"m_columnAdds",
".",
"get",
"(",
"storeName",
")",
";",
"if",
"(",
"rowMap",
"==",
"null",
")",
"{",
"rowMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"m_columnAdds",
".",
"put",
"(",
"storeName",
",",
"rowMap",
")",
";",
"}",
"Map",
"<",
"String",
",",
"byte",
"[",
"]",
">",
"colMap",
"=",
"rowMap",
".",
"get",
"(",
"rowKey",
")",
";",
"if",
"(",
"colMap",
"==",
"null",
")",
"{",
"colMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"rowMap",
".",
"put",
"(",
"rowKey",
",",
"colMap",
")",
";",
"}",
"byte",
"[",
"]",
"oldValue",
"=",
"colMap",
".",
"put",
"(",
"colName",
",",
"colValue",
")",
";",
"if",
"(",
"oldValue",
"==",
"null",
")",
"{",
"m_totalUpdates",
"++",
";",
"}",
"else",
"if",
"(",
"!",
"Arrays",
".",
"equals",
"(",
"oldValue",
",",
"colValue",
")",
")",
"{",
"m_logger",
".",
"debug",
"(",
"\"Warning: duplicate column mutation with different value: \"",
"+",
"\"store={}, row={}, col={}, old={}, new={}\"",
",",
"new",
"Object",
"[",
"]",
"{",
"storeName",
",",
"rowKey",
",",
"colName",
",",
"oldValue",
",",
"colValue",
"}",
")",
";",
"}",
"}"
] | Add the given column update; the value may be null. | [
"Add",
"the",
"given",
"column",
"update",
";",
"the",
"value",
"may",
"be",
"null",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L480-L501 |
138,184 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.deleteColumn | private void deleteColumn(String storeName, String rowKey, String colName) {
Map<String, List<String>> rowMap = m_columnDeletes.get(storeName);
if (rowMap == null) {
rowMap = new HashMap<>();
m_columnDeletes.put(storeName, rowMap);
}
List<String> colNames = rowMap.get(rowKey);
if (colNames == null) {
colNames = new ArrayList<>();
rowMap.put(rowKey, colNames);
}
colNames.add(colName);
m_totalUpdates++;
} | java | private void deleteColumn(String storeName, String rowKey, String colName) {
Map<String, List<String>> rowMap = m_columnDeletes.get(storeName);
if (rowMap == null) {
rowMap = new HashMap<>();
m_columnDeletes.put(storeName, rowMap);
}
List<String> colNames = rowMap.get(rowKey);
if (colNames == null) {
colNames = new ArrayList<>();
rowMap.put(rowKey, colNames);
}
colNames.add(colName);
m_totalUpdates++;
} | [
"private",
"void",
"deleteColumn",
"(",
"String",
"storeName",
",",
"String",
"rowKey",
",",
"String",
"colName",
")",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"rowMap",
"=",
"m_columnDeletes",
".",
"get",
"(",
"storeName",
")",
";",
"if",
"(",
"rowMap",
"==",
"null",
")",
"{",
"rowMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"m_columnDeletes",
".",
"put",
"(",
"storeName",
",",
"rowMap",
")",
";",
"}",
"List",
"<",
"String",
">",
"colNames",
"=",
"rowMap",
".",
"get",
"(",
"rowKey",
")",
";",
"if",
"(",
"colNames",
"==",
"null",
")",
"{",
"colNames",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"rowMap",
".",
"put",
"(",
"rowKey",
",",
"colNames",
")",
";",
"}",
"colNames",
".",
"add",
"(",
"colName",
")",
";",
"m_totalUpdates",
"++",
";",
"}"
] | Add the given column deletion. | [
"Add",
"the",
"given",
"column",
"deletion",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L504-L517 |
138,185 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.deleteColumns | private void deleteColumns(String storeName, String rowKey, Collection<String> colNames) {
Map<String, List<String>> rowMap = m_columnDeletes.get(storeName);
if (rowMap == null) {
rowMap = new HashMap<>();
m_columnDeletes.put(storeName, rowMap);
}
List<String> colList = rowMap.get(rowKey);
if (colList == null) {
colList = new ArrayList<>();
rowMap.put(rowKey, colList);
}
colList.addAll(colNames);
m_totalUpdates += colNames.size();
} | java | private void deleteColumns(String storeName, String rowKey, Collection<String> colNames) {
Map<String, List<String>> rowMap = m_columnDeletes.get(storeName);
if (rowMap == null) {
rowMap = new HashMap<>();
m_columnDeletes.put(storeName, rowMap);
}
List<String> colList = rowMap.get(rowKey);
if (colList == null) {
colList = new ArrayList<>();
rowMap.put(rowKey, colList);
}
colList.addAll(colNames);
m_totalUpdates += colNames.size();
} | [
"private",
"void",
"deleteColumns",
"(",
"String",
"storeName",
",",
"String",
"rowKey",
",",
"Collection",
"<",
"String",
">",
"colNames",
")",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"rowMap",
"=",
"m_columnDeletes",
".",
"get",
"(",
"storeName",
")",
";",
"if",
"(",
"rowMap",
"==",
"null",
")",
"{",
"rowMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"m_columnDeletes",
".",
"put",
"(",
"storeName",
",",
"rowMap",
")",
";",
"}",
"List",
"<",
"String",
">",
"colList",
"=",
"rowMap",
".",
"get",
"(",
"rowKey",
")",
";",
"if",
"(",
"colList",
"==",
"null",
")",
"{",
"colList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"rowMap",
".",
"put",
"(",
"rowKey",
",",
"colList",
")",
";",
"}",
"colList",
".",
"addAll",
"(",
"colNames",
")",
";",
"m_totalUpdates",
"+=",
"colNames",
".",
"size",
"(",
")",
";",
"}"
] | Add column deletions for all given column names. | [
"Add",
"column",
"deletions",
"for",
"all",
"given",
"column",
"names",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L520-L533 |
138,186 | QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java | SpiderTransaction.deleteRow | private void deleteRow(String storeName, String rowKey) {
List<String> rowKeys = m_rowDeletes.get(storeName);
if (rowKeys == null) {
rowKeys = new ArrayList<>();
m_rowDeletes.put(storeName, rowKeys);
}
rowKeys.add(rowKey);
m_totalUpdates++;
} | java | private void deleteRow(String storeName, String rowKey) {
List<String> rowKeys = m_rowDeletes.get(storeName);
if (rowKeys == null) {
rowKeys = new ArrayList<>();
m_rowDeletes.put(storeName, rowKeys);
}
rowKeys.add(rowKey);
m_totalUpdates++;
} | [
"private",
"void",
"deleteRow",
"(",
"String",
"storeName",
",",
"String",
"rowKey",
")",
"{",
"List",
"<",
"String",
">",
"rowKeys",
"=",
"m_rowDeletes",
".",
"get",
"(",
"storeName",
")",
";",
"if",
"(",
"rowKeys",
"==",
"null",
")",
"{",
"rowKeys",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"m_rowDeletes",
".",
"put",
"(",
"storeName",
",",
"rowKeys",
")",
";",
"}",
"rowKeys",
".",
"add",
"(",
"rowKey",
")",
";",
"m_totalUpdates",
"++",
";",
"}"
] | Add the following row deletion. | [
"Add",
"the",
"following",
"row",
"deletion",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/SpiderTransaction.java#L536-L544 |
138,187 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/UNode.java | UNode.createMapNode | public static UNode createMapNode(String name) {
return new UNode(name, NodeType.MAP, null, false, "");
} | java | public static UNode createMapNode(String name) {
return new UNode(name, NodeType.MAP, null, false, "");
} | [
"public",
"static",
"UNode",
"createMapNode",
"(",
"String",
"name",
")",
"{",
"return",
"new",
"UNode",
"(",
"name",
",",
"NodeType",
".",
"MAP",
",",
"null",
",",
"false",
",",
"\"\"",
")",
";",
"}"
] | Create a MAP UNode with the given node name.
@param name Name for new MAP node.
@return New MAP UNode. | [
"Create",
"a",
"MAP",
"UNode",
"with",
"the",
"given",
"node",
"name",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L167-L169 |
138,188 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/UNode.java | UNode.createArrayNode | public static UNode createArrayNode(String name) {
return new UNode(name, NodeType.ARRAY, null, false, "");
} | java | public static UNode createArrayNode(String name) {
return new UNode(name, NodeType.ARRAY, null, false, "");
} | [
"public",
"static",
"UNode",
"createArrayNode",
"(",
"String",
"name",
")",
"{",
"return",
"new",
"UNode",
"(",
"name",
",",
"NodeType",
".",
"ARRAY",
",",
"null",
",",
"false",
",",
"\"\"",
")",
";",
"}"
] | Create an ARRAY UNode with the given node name.
@param name Name for new ARRAY node.
@return New ARRAY UNode. | [
"Create",
"an",
"ARRAY",
"UNode",
"with",
"the",
"given",
"node",
"name",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L188-L190 |
138,189 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/UNode.java | UNode.createValueNode | public static UNode createValueNode(String name, String value) {
String nodeValue = value == null ? "" : value;
return new UNode(name, NodeType.VALUE, nodeValue, false, "");
} | java | public static UNode createValueNode(String name, String value) {
String nodeValue = value == null ? "" : value;
return new UNode(name, NodeType.VALUE, nodeValue, false, "");
} | [
"public",
"static",
"UNode",
"createValueNode",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"String",
"nodeValue",
"=",
"value",
"==",
"null",
"?",
"\"\"",
":",
"value",
";",
"return",
"new",
"UNode",
"(",
"name",
",",
"NodeType",
".",
"VALUE",
",",
"nodeValue",
",",
"false",
",",
"\"\"",
")",
";",
"}"
] | Create a VALUE UNode with the given node name and value.
@param name Node name.
@param value Node value.
@return New VALUE UNode. | [
"Create",
"a",
"VALUE",
"UNode",
"with",
"the",
"given",
"node",
"name",
"and",
"value",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L210-L213 |
138,190 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/UNode.java | UNode.parse | public static UNode parse(String text, ContentType contentType) throws IllegalArgumentException {
UNode result = null;
if (contentType.isJSON()) {
result = parseJSON(text);
} else if (contentType.isXML()) {
result = parseXML(text);
} else {
Utils.require(false, "Unsupported content-type: " + contentType);
}
return result;
} | java | public static UNode parse(String text, ContentType contentType) throws IllegalArgumentException {
UNode result = null;
if (contentType.isJSON()) {
result = parseJSON(text);
} else if (contentType.isXML()) {
result = parseXML(text);
} else {
Utils.require(false, "Unsupported content-type: " + contentType);
}
return result;
} | [
"public",
"static",
"UNode",
"parse",
"(",
"String",
"text",
",",
"ContentType",
"contentType",
")",
"throws",
"IllegalArgumentException",
"{",
"UNode",
"result",
"=",
"null",
";",
"if",
"(",
"contentType",
".",
"isJSON",
"(",
")",
")",
"{",
"result",
"=",
"parseJSON",
"(",
"text",
")",
";",
"}",
"else",
"if",
"(",
"contentType",
".",
"isXML",
"(",
")",
")",
"{",
"result",
"=",
"parseXML",
"(",
"text",
")",
";",
"}",
"else",
"{",
"Utils",
".",
"require",
"(",
"false",
",",
"\"Unsupported content-type: \"",
"+",
"contentType",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Parse the given text, formatted with the given content-type, into a UNode tree and
return the root node.
@param text Text to be parsed.
@param contentType {@link ContentType} of text. Only JSON and XML are supported.
@return Root node of parsed node tree.
@throws IllegalArgumentException If a parsing error occurs. | [
"Parse",
"the",
"given",
"text",
"formatted",
"with",
"the",
"given",
"content",
"-",
"type",
"into",
"a",
"UNode",
"tree",
"and",
"return",
"the",
"root",
"node",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L253-L263 |
138,191 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/UNode.java | UNode.parse | public static UNode parse(Reader reader, ContentType contentType) throws IllegalArgumentException {
UNode result = null;
if (contentType.isJSON()) {
result = parseJSON(reader);
} else if (contentType.isXML()) {
result = parseXML(reader);
} else {
Utils.require(false, "Unsupported content-type: " + contentType);
}
return result;
} | java | public static UNode parse(Reader reader, ContentType contentType) throws IllegalArgumentException {
UNode result = null;
if (contentType.isJSON()) {
result = parseJSON(reader);
} else if (contentType.isXML()) {
result = parseXML(reader);
} else {
Utils.require(false, "Unsupported content-type: " + contentType);
}
return result;
} | [
"public",
"static",
"UNode",
"parse",
"(",
"Reader",
"reader",
",",
"ContentType",
"contentType",
")",
"throws",
"IllegalArgumentException",
"{",
"UNode",
"result",
"=",
"null",
";",
"if",
"(",
"contentType",
".",
"isJSON",
"(",
")",
")",
"{",
"result",
"=",
"parseJSON",
"(",
"reader",
")",
";",
"}",
"else",
"if",
"(",
"contentType",
".",
"isXML",
"(",
")",
")",
"{",
"result",
"=",
"parseXML",
"(",
"reader",
")",
";",
"}",
"else",
"{",
"Utils",
".",
"require",
"(",
"false",
",",
"\"Unsupported content-type: \"",
"+",
"contentType",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Parse the text from the given character reader, formatted with the given content-type,
into a UNode tree and return the root node. The reader is closed when finished.
@param reader Reader providing source characters.
@param contentType {@link ContentType} of text. Only JSON and XML are supported.
@return Root node of parsed node tree.
@throws IllegalArgumentException If a parsing error occurs. | [
"Parse",
"the",
"text",
"from",
"the",
"given",
"character",
"reader",
"formatted",
"with",
"the",
"given",
"content",
"-",
"type",
"into",
"a",
"UNode",
"tree",
"and",
"return",
"the",
"root",
"node",
".",
"The",
"reader",
"is",
"closed",
"when",
"finished",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L274-L284 |
138,192 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/UNode.java | UNode.parseXML | public static UNode parseXML(String text) throws IllegalArgumentException {
assert text != null && text.length() > 0;
// This throws if the XML is malformed.
Element rootElem = Utils.parseXMLDocument(text);
return parseXMLElement(rootElem);
} | java | public static UNode parseXML(String text) throws IllegalArgumentException {
assert text != null && text.length() > 0;
// This throws if the XML is malformed.
Element rootElem = Utils.parseXMLDocument(text);
return parseXMLElement(rootElem);
} | [
"public",
"static",
"UNode",
"parseXML",
"(",
"String",
"text",
")",
"throws",
"IllegalArgumentException",
"{",
"assert",
"text",
"!=",
"null",
"&&",
"text",
".",
"length",
"(",
")",
">",
"0",
";",
"// This throws if the XML is malformed.\r",
"Element",
"rootElem",
"=",
"Utils",
".",
"parseXMLDocument",
"(",
"text",
")",
";",
"return",
"parseXMLElement",
"(",
"rootElem",
")",
";",
"}"
] | Parse the given XML text and return the appropriate UNode object. The UNode
returned is a MAP whose child nodes are built from the attributes and child
elements of the document's root element.
@param text XML text to be parsed.
@return UNode with type == {@link UNode.NodeType#MAP}.
@throws IllegalArgumentException If the XML is malformed. | [
"Parse",
"the",
"given",
"XML",
"text",
"and",
"return",
"the",
"appropriate",
"UNode",
"object",
".",
"The",
"UNode",
"returned",
"is",
"a",
"MAP",
"whose",
"child",
"nodes",
"are",
"built",
"from",
"the",
"attributes",
"and",
"child",
"elements",
"of",
"the",
"document",
"s",
"root",
"element",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L372-L378 |
138,193 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/UNode.java | UNode.parseXML | public static UNode parseXML(Reader reader) throws IllegalArgumentException {
assert reader != null;
// This throws if the XML is malformed.
Element rootElem = Utils.parseXMLDocument(reader);
// Parse the root element and ensure it elligible as a map.
UNode rootNode = parseXMLElement(rootElem);
return rootNode;
} | java | public static UNode parseXML(Reader reader) throws IllegalArgumentException {
assert reader != null;
// This throws if the XML is malformed.
Element rootElem = Utils.parseXMLDocument(reader);
// Parse the root element and ensure it elligible as a map.
UNode rootNode = parseXMLElement(rootElem);
return rootNode;
} | [
"public",
"static",
"UNode",
"parseXML",
"(",
"Reader",
"reader",
")",
"throws",
"IllegalArgumentException",
"{",
"assert",
"reader",
"!=",
"null",
";",
"// This throws if the XML is malformed.\r",
"Element",
"rootElem",
"=",
"Utils",
".",
"parseXMLDocument",
"(",
"reader",
")",
";",
"// Parse the root element and ensure it elligible as a map.\r",
"UNode",
"rootNode",
"=",
"parseXMLElement",
"(",
"rootElem",
")",
";",
"return",
"rootNode",
";",
"}"
] | Parse XML from the given Reader and return the appropriate UNode object. The UNode
returned is a MAP whose child nodes are built from the attributes and child
elements of the document's root element.
@param reader Reader contain XML text to parse.
@return UNode with type == {@link UNode.NodeType#MAP}.
@throws IllegalArgumentException If the XML is malformed. | [
"Parse",
"XML",
"from",
"the",
"given",
"Reader",
"and",
"return",
"the",
"appropriate",
"UNode",
"object",
".",
"The",
"UNode",
"returned",
"is",
"a",
"MAP",
"whose",
"child",
"nodes",
"are",
"built",
"from",
"the",
"attributes",
"and",
"child",
"elements",
"of",
"the",
"document",
"s",
"root",
"element",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L389-L398 |
138,194 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/UNode.java | UNode.getMember | public UNode getMember(int index) {
assert isCollection();
if (m_children == null || index >= m_children.size()) {
return null;
}
return m_children.get(index);
} | java | public UNode getMember(int index) {
assert isCollection();
if (m_children == null || index >= m_children.size()) {
return null;
}
return m_children.get(index);
} | [
"public",
"UNode",
"getMember",
"(",
"int",
"index",
")",
"{",
"assert",
"isCollection",
"(",
")",
";",
"if",
"(",
"m_children",
"==",
"null",
"||",
"index",
">=",
"m_children",
".",
"size",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"m_children",
".",
"get",
"(",
"index",
")",
";",
"}"
] | Get the child member with the given index. The node must be a MAP or ARRAY. Child
members are retained in the order they are added. If the given index is out of
bounds, null is returned.
@param index Zero-relative child node index.
@return The child member at the given index or null if there is no child
node with the given index. | [
"Get",
"the",
"child",
"member",
"with",
"the",
"given",
"index",
".",
"The",
"node",
"must",
"be",
"a",
"MAP",
"or",
"ARRAY",
".",
"Child",
"members",
"are",
"retained",
"in",
"the",
"order",
"they",
"are",
"added",
".",
"If",
"the",
"given",
"index",
"is",
"out",
"of",
"bounds",
"null",
"is",
"returned",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L469-L475 |
138,195 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/UNode.java | UNode.getMemberList | public Iterable<UNode> getMemberList() {
assert m_type == NodeType.MAP || m_type == NodeType.ARRAY;
if (m_children == null) {
m_children = new ArrayList<UNode>();
}
return m_children;
} | java | public Iterable<UNode> getMemberList() {
assert m_type == NodeType.MAP || m_type == NodeType.ARRAY;
if (m_children == null) {
m_children = new ArrayList<UNode>();
}
return m_children;
} | [
"public",
"Iterable",
"<",
"UNode",
">",
"getMemberList",
"(",
")",
"{",
"assert",
"m_type",
"==",
"NodeType",
".",
"MAP",
"||",
"m_type",
"==",
"NodeType",
".",
"ARRAY",
";",
"if",
"(",
"m_children",
"==",
"null",
")",
"{",
"m_children",
"=",
"new",
"ArrayList",
"<",
"UNode",
">",
"(",
")",
";",
"}",
"return",
"m_children",
";",
"}"
] | Get the list of child nodes of this collection UNode as an Iterable UNode object.
The UNode must be a MAP or an ARRAY.
@return An Iterable UNode object that iterates through this node's children. The
result will never be null, but there might not be any child nodes. | [
"Get",
"the",
"list",
"of",
"child",
"nodes",
"of",
"this",
"collection",
"UNode",
"as",
"an",
"Iterable",
"UNode",
"object",
".",
"The",
"UNode",
"must",
"be",
"a",
"MAP",
"or",
"an",
"ARRAY",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L538-L544 |
138,196 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/UNode.java | UNode.toJSON | public String toJSON() {
JSONEmitter json = new JSONEmitter();
json.startDocument();
toJSON(json);
json.endDocument();
return json.toString();
} | java | public String toJSON() {
JSONEmitter json = new JSONEmitter();
json.startDocument();
toJSON(json);
json.endDocument();
return json.toString();
} | [
"public",
"String",
"toJSON",
"(",
")",
"{",
"JSONEmitter",
"json",
"=",
"new",
"JSONEmitter",
"(",
")",
";",
"json",
".",
"startDocument",
"(",
")",
";",
"toJSON",
"(",
"json",
")",
";",
"json",
".",
"endDocument",
"(",
")",
";",
"return",
"json",
".",
"toString",
"(",
")",
";",
"}"
] | Convert the DOM tree rooted at this UNode into a JSON document.
@return JSON document for the DOM tree rooted at this UNode. | [
"Convert",
"the",
"DOM",
"tree",
"rooted",
"at",
"this",
"UNode",
"into",
"a",
"JSON",
"document",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L607-L613 |
138,197 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/UNode.java | UNode.toJSON | public String toJSON(boolean bPretty) {
int indent = bPretty ? 3 : 0;
JSONEmitter json = new JSONEmitter(indent);
json.startDocument();
toJSON(json);
json.endDocument();
return json.toString();
} | java | public String toJSON(boolean bPretty) {
int indent = bPretty ? 3 : 0;
JSONEmitter json = new JSONEmitter(indent);
json.startDocument();
toJSON(json);
json.endDocument();
return json.toString();
} | [
"public",
"String",
"toJSON",
"(",
"boolean",
"bPretty",
")",
"{",
"int",
"indent",
"=",
"bPretty",
"?",
"3",
":",
"0",
";",
"JSONEmitter",
"json",
"=",
"new",
"JSONEmitter",
"(",
"indent",
")",
";",
"json",
".",
"startDocument",
"(",
")",
";",
"toJSON",
"(",
"json",
")",
";",
"json",
".",
"endDocument",
"(",
")",
";",
"return",
"json",
".",
"toString",
"(",
")",
";",
"}"
] | Convert the DOM tree rooted at this UNode into a JSON document. Optionally format
the text with indenting to make it look pretty.
@param bPretty True to indent JSON output.
@return JSON document for the DOM tree rooted at this UNode. | [
"Convert",
"the",
"DOM",
"tree",
"rooted",
"at",
"this",
"UNode",
"into",
"a",
"JSON",
"document",
".",
"Optionally",
"format",
"the",
"text",
"with",
"indenting",
"to",
"make",
"it",
"look",
"pretty",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L622-L629 |
138,198 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/UNode.java | UNode.toCompressedJSON | public byte[] toCompressedJSON() throws IOException {
// Wrap a GZIPOuputStream around a ByteArrayOuputStream.
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
GZIPOutputStream gzipOut = new GZIPOutputStream(bytesOut);
// Wrap the GZIPOutputStream with an OutputStreamWriter that convers JSON Unicode
// text to bytes using UTF-8.
OutputStreamWriter writer = new OutputStreamWriter(gzipOut, Utils.UTF8_CHARSET);
// Create a JSONEmitter that will write its output to the writer above and generate
// the JSON output.
JSONEmitter json = new JSONEmitter(writer);
json.startDocument();
toJSON(json);
json.endDocument();
// Ensure the output stream is flushed and the GZIP is finished, then the output
// buffer is complete.
writer.flush();
gzipOut.finish();
return bytesOut.toByteArray();
} | java | public byte[] toCompressedJSON() throws IOException {
// Wrap a GZIPOuputStream around a ByteArrayOuputStream.
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
GZIPOutputStream gzipOut = new GZIPOutputStream(bytesOut);
// Wrap the GZIPOutputStream with an OutputStreamWriter that convers JSON Unicode
// text to bytes using UTF-8.
OutputStreamWriter writer = new OutputStreamWriter(gzipOut, Utils.UTF8_CHARSET);
// Create a JSONEmitter that will write its output to the writer above and generate
// the JSON output.
JSONEmitter json = new JSONEmitter(writer);
json.startDocument();
toJSON(json);
json.endDocument();
// Ensure the output stream is flushed and the GZIP is finished, then the output
// buffer is complete.
writer.flush();
gzipOut.finish();
return bytesOut.toByteArray();
} | [
"public",
"byte",
"[",
"]",
"toCompressedJSON",
"(",
")",
"throws",
"IOException",
"{",
"// Wrap a GZIPOuputStream around a ByteArrayOuputStream.\r",
"ByteArrayOutputStream",
"bytesOut",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"GZIPOutputStream",
"gzipOut",
"=",
"new",
"GZIPOutputStream",
"(",
"bytesOut",
")",
";",
"// Wrap the GZIPOutputStream with an OutputStreamWriter that convers JSON Unicode\r",
"// text to bytes using UTF-8.\r",
"OutputStreamWriter",
"writer",
"=",
"new",
"OutputStreamWriter",
"(",
"gzipOut",
",",
"Utils",
".",
"UTF8_CHARSET",
")",
";",
"// Create a JSONEmitter that will write its output to the writer above and generate\r",
"// the JSON output.\r",
"JSONEmitter",
"json",
"=",
"new",
"JSONEmitter",
"(",
"writer",
")",
";",
"json",
".",
"startDocument",
"(",
")",
";",
"toJSON",
"(",
"json",
")",
";",
"json",
".",
"endDocument",
"(",
")",
";",
"// Ensure the output stream is flushed and the GZIP is finished, then the output\r",
"// buffer is complete.\r",
"writer",
".",
"flush",
"(",
")",
";",
"gzipOut",
".",
"finish",
"(",
")",
";",
"return",
"bytesOut",
".",
"toByteArray",
"(",
")",
";",
"}"
] | Convert the DOM tree rooted at this UNode into a JSON document compressed with GZIP.
@return JSON document for the DOM tree rooted at this UNode compressed with GZIP.
@throws IOException If an error occurs writing to the GZIP stream. | [
"Convert",
"the",
"DOM",
"tree",
"rooted",
"at",
"this",
"UNode",
"into",
"a",
"JSON",
"document",
"compressed",
"with",
"GZIP",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L637-L658 |
138,199 | QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/UNode.java | UNode.toXML | public String toXML(boolean bPretty) throws IllegalArgumentException {
int indent = bPretty ? 3 : 0;
XMLBuilder xml = new XMLBuilder(indent);
xml.startDocument();
toXML(xml);
xml.endDocument();
return xml.toString();
} | java | public String toXML(boolean bPretty) throws IllegalArgumentException {
int indent = bPretty ? 3 : 0;
XMLBuilder xml = new XMLBuilder(indent);
xml.startDocument();
toXML(xml);
xml.endDocument();
return xml.toString();
} | [
"public",
"String",
"toXML",
"(",
"boolean",
"bPretty",
")",
"throws",
"IllegalArgumentException",
"{",
"int",
"indent",
"=",
"bPretty",
"?",
"3",
":",
"0",
";",
"XMLBuilder",
"xml",
"=",
"new",
"XMLBuilder",
"(",
"indent",
")",
";",
"xml",
".",
"startDocument",
"(",
")",
";",
"toXML",
"(",
"xml",
")",
";",
"xml",
".",
"endDocument",
"(",
")",
";",
"return",
"xml",
".",
"toString",
"(",
")",
";",
"}"
] | Convert the DOM tree rooted at this UNode into an XML document, optionally
indenting each XML level to product a "pretty" structured output.
@param bPretty True to indent XML output.
@return XML document for the DOM tree rooted at this UNode.
@throws IllegalArgumentException If an XML construction error occurs. | [
"Convert",
"the",
"DOM",
"tree",
"rooted",
"at",
"this",
"UNode",
"into",
"an",
"XML",
"document",
"optionally",
"indenting",
"each",
"XML",
"level",
"to",
"product",
"a",
"pretty",
"structured",
"output",
"."
] | ad64d3c37922eefda68ec8869ef089c1ca604b70 | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L682-L689 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.