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,200
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/UNode.java
UNode.toXML
public void toXML(XMLBuilder xml) throws IllegalArgumentException { assert xml != null; // Determine what tag name to use for the generated element. Map<String, String> attrMap = new LinkedHashMap<>(); String elemName = m_name; if (m_tagName.length() > 0) { // Place m_name into a "name" attribute and use m_tagName attrMap.put("name", m_name); elemName = m_tagName; } // Add child VALUE nodes marked as "attribute" in its own map. addXMLAttributes(attrMap); switch (m_type) { case ARRAY: // Start an element with or without attributes. if (attrMap.size() > 0) { xml.startElement(elemName, attrMap); } else { xml.startElement(elemName); } // Add XML for non-attribute child nodes. if (m_children != null) { for (UNode childNode : m_children) { if (childNode.m_type != NodeType.VALUE || !childNode.m_bAttribute) { childNode.toXML(xml); } } } xml.endElement(); break; case MAP: // Start an element with or without attributes. if (attrMap.size() > 0) { xml.startElement(elemName, attrMap); } else { xml.startElement(elemName); } // Add XML for non-attribute child nodes in name order. if (m_childNodeMap != null) { assert m_childNodeMap.size() == m_children.size(); for (UNode childNode : m_childNodeMap.values()) { if (childNode.m_type != NodeType.VALUE || !childNode.m_bAttribute) { childNode.toXML(xml); } } } xml.endElement(); break; case VALUE: // Map to a simple element. String value = m_value; if (Utils.containsIllegalXML(value)) { value = Utils.base64FromString(m_value); attrMap.put("encoding", "base64"); } if (attrMap.size() > 0) { xml.addDataElement(elemName, value, attrMap); } else { xml.addDataElement(elemName, value); } break; default: assert false : "Unexpected NodeType: " + m_type; } }
java
public void toXML(XMLBuilder xml) throws IllegalArgumentException { assert xml != null; // Determine what tag name to use for the generated element. Map<String, String> attrMap = new LinkedHashMap<>(); String elemName = m_name; if (m_tagName.length() > 0) { // Place m_name into a "name" attribute and use m_tagName attrMap.put("name", m_name); elemName = m_tagName; } // Add child VALUE nodes marked as "attribute" in its own map. addXMLAttributes(attrMap); switch (m_type) { case ARRAY: // Start an element with or without attributes. if (attrMap.size() > 0) { xml.startElement(elemName, attrMap); } else { xml.startElement(elemName); } // Add XML for non-attribute child nodes. if (m_children != null) { for (UNode childNode : m_children) { if (childNode.m_type != NodeType.VALUE || !childNode.m_bAttribute) { childNode.toXML(xml); } } } xml.endElement(); break; case MAP: // Start an element with or without attributes. if (attrMap.size() > 0) { xml.startElement(elemName, attrMap); } else { xml.startElement(elemName); } // Add XML for non-attribute child nodes in name order. if (m_childNodeMap != null) { assert m_childNodeMap.size() == m_children.size(); for (UNode childNode : m_childNodeMap.values()) { if (childNode.m_type != NodeType.VALUE || !childNode.m_bAttribute) { childNode.toXML(xml); } } } xml.endElement(); break; case VALUE: // Map to a simple element. String value = m_value; if (Utils.containsIllegalXML(value)) { value = Utils.base64FromString(m_value); attrMap.put("encoding", "base64"); } if (attrMap.size() > 0) { xml.addDataElement(elemName, value, attrMap); } else { xml.addDataElement(elemName, value); } break; default: assert false : "Unexpected NodeType: " + m_type; } }
[ "public", "void", "toXML", "(", "XMLBuilder", "xml", ")", "throws", "IllegalArgumentException", "{", "assert", "xml", "!=", "null", ";", "// Determine what tag name to use for the generated element. \r", "Map", "<", "String", ",", "String", ">", "attrMap", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "String", "elemName", "=", "m_name", ";", "if", "(", "m_tagName", ".", "length", "(", ")", ">", "0", ")", "{", "// Place m_name into a \"name\" attribute and use m_tagName\r", "attrMap", ".", "put", "(", "\"name\"", ",", "m_name", ")", ";", "elemName", "=", "m_tagName", ";", "}", "// Add child VALUE nodes marked as \"attribute\" in its own map.\r", "addXMLAttributes", "(", "attrMap", ")", ";", "switch", "(", "m_type", ")", "{", "case", "ARRAY", ":", "// Start an element with or without attributes.\r", "if", "(", "attrMap", ".", "size", "(", ")", ">", "0", ")", "{", "xml", ".", "startElement", "(", "elemName", ",", "attrMap", ")", ";", "}", "else", "{", "xml", ".", "startElement", "(", "elemName", ")", ";", "}", "// Add XML for non-attribute child nodes.\r", "if", "(", "m_children", "!=", "null", ")", "{", "for", "(", "UNode", "childNode", ":", "m_children", ")", "{", "if", "(", "childNode", ".", "m_type", "!=", "NodeType", ".", "VALUE", "||", "!", "childNode", ".", "m_bAttribute", ")", "{", "childNode", ".", "toXML", "(", "xml", ")", ";", "}", "}", "}", "xml", ".", "endElement", "(", ")", ";", "break", ";", "case", "MAP", ":", "// Start an element with or without attributes.\r", "if", "(", "attrMap", ".", "size", "(", ")", ">", "0", ")", "{", "xml", ".", "startElement", "(", "elemName", ",", "attrMap", ")", ";", "}", "else", "{", "xml", ".", "startElement", "(", "elemName", ")", ";", "}", "// Add XML for non-attribute child nodes in name order.\r", "if", "(", "m_childNodeMap", "!=", "null", ")", "{", "assert", "m_childNodeMap", ".", "size", "(", ")", "==", "m_children", ".", "size", "(", ")", ";", "for", "(", "UNode", "childNode", ":", "m_childNodeMap", ".", "values", "(", ")", ")", "{", "if", "(", "childNode", ".", "m_type", "!=", "NodeType", ".", "VALUE", "||", "!", "childNode", ".", "m_bAttribute", ")", "{", "childNode", ".", "toXML", "(", "xml", ")", ";", "}", "}", "}", "xml", ".", "endElement", "(", ")", ";", "break", ";", "case", "VALUE", ":", "// Map to a simple element.\r", "String", "value", "=", "m_value", ";", "if", "(", "Utils", ".", "containsIllegalXML", "(", "value", ")", ")", "{", "value", "=", "Utils", ".", "base64FromString", "(", "m_value", ")", ";", "attrMap", ".", "put", "(", "\"encoding\"", ",", "\"base64\"", ")", ";", "}", "if", "(", "attrMap", ".", "size", "(", ")", ">", "0", ")", "{", "xml", ".", "addDataElement", "(", "elemName", ",", "value", ",", "attrMap", ")", ";", "}", "else", "{", "xml", ".", "addDataElement", "(", "elemName", ",", "value", ")", ";", "}", "break", ";", "default", ":", "assert", "false", ":", "\"Unexpected NodeType: \"", "+", "m_type", ";", "}", "}" ]
Add the XML required for this node to the given XMLBuilder. @param xml An in-progress XMLBuilder. @throws IllegalArgumentException If an XML construction error occurs.
[ "Add", "the", "XML", "required", "for", "this", "node", "to", "the", "given", "XMLBuilder", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L697-L765
138,201
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/UNode.java
UNode.removeMember
public void removeMember(String childName) { assert isMap() : "'removeMember' allowed only for MAP nodes"; if (m_childNodeMap != null) { // Remove from child name map and then list if found. UNode removeNode = m_childNodeMap.remove(childName); if (removeNode != null) { m_children.remove(removeNode); } } }
java
public void removeMember(String childName) { assert isMap() : "'removeMember' allowed only for MAP nodes"; if (m_childNodeMap != null) { // Remove from child name map and then list if found. UNode removeNode = m_childNodeMap.remove(childName); if (removeNode != null) { m_children.remove(removeNode); } } }
[ "public", "void", "removeMember", "(", "String", "childName", ")", "{", "assert", "isMap", "(", ")", ":", "\"'removeMember' allowed only for MAP nodes\"", ";", "if", "(", "m_childNodeMap", "!=", "null", ")", "{", "// Remove from child name map and then list if found.\r", "UNode", "removeNode", "=", "m_childNodeMap", ".", "remove", "(", "childName", ")", ";", "if", "(", "removeNode", "!=", "null", ")", "{", "m_children", ".", "remove", "(", "removeNode", ")", ";", "}", "}", "}" ]
Delete the child node of this MAP node with the given name, if it exists. This node must be a MAP. The child node name may or may not exist. @param childName Name of child node to remove from this MAP node.
[ "Delete", "the", "child", "node", "of", "this", "MAP", "node", "with", "the", "given", "name", "if", "it", "exists", ".", "This", "node", "must", "be", "a", "MAP", ".", "The", "child", "node", "name", "may", "or", "may", "not", "exist", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L955-L964
138,202
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/UNode.java
UNode.toJSON
private void toJSON(JSONEmitter json) { switch (m_type) { case ARRAY: json.startArray(m_name); if (m_children != null) { for (UNode childNode : m_children) { if (childNode.isMap()) { json.startObject(); childNode.toJSON(json); json.endObject(); } else { childNode.toJSON(json); } } } json.endArray(); break; case MAP: // Return map child modes in name order. json.startGroup(m_name); if (m_childNodeMap != null) { assert m_childNodeMap.size() == m_children.size(); for (UNode childNode : m_childNodeMap.values()) { childNode.toJSON(json); } } json.endGroup(); break; case VALUE: if (m_bAltFormat && m_tagName != null) { // Generate as "<tag>: {"<name>": "<value>"} json.startGroup(m_tagName); json.addValue(m_name, m_value); json.endGroup(); } else if (m_parent != null && m_parent.isArray()) { if (m_name.equals("value")) { // nameless node: "<value>" json.addValue(m_value); } else { // value as an object: {"name": "value"} json.addObject(m_name, m_value); } } else { // Simple case: "<name>": "<value>" json.addValue(m_name, m_value); } break; default: assert false : "Unknown NodeType: " + m_type; } }
java
private void toJSON(JSONEmitter json) { switch (m_type) { case ARRAY: json.startArray(m_name); if (m_children != null) { for (UNode childNode : m_children) { if (childNode.isMap()) { json.startObject(); childNode.toJSON(json); json.endObject(); } else { childNode.toJSON(json); } } } json.endArray(); break; case MAP: // Return map child modes in name order. json.startGroup(m_name); if (m_childNodeMap != null) { assert m_childNodeMap.size() == m_children.size(); for (UNode childNode : m_childNodeMap.values()) { childNode.toJSON(json); } } json.endGroup(); break; case VALUE: if (m_bAltFormat && m_tagName != null) { // Generate as "<tag>: {"<name>": "<value>"} json.startGroup(m_tagName); json.addValue(m_name, m_value); json.endGroup(); } else if (m_parent != null && m_parent.isArray()) { if (m_name.equals("value")) { // nameless node: "<value>" json.addValue(m_value); } else { // value as an object: {"name": "value"} json.addObject(m_name, m_value); } } else { // Simple case: "<name>": "<value>" json.addValue(m_name, m_value); } break; default: assert false : "Unknown NodeType: " + m_type; } }
[ "private", "void", "toJSON", "(", "JSONEmitter", "json", ")", "{", "switch", "(", "m_type", ")", "{", "case", "ARRAY", ":", "json", ".", "startArray", "(", "m_name", ")", ";", "if", "(", "m_children", "!=", "null", ")", "{", "for", "(", "UNode", "childNode", ":", "m_children", ")", "{", "if", "(", "childNode", ".", "isMap", "(", ")", ")", "{", "json", ".", "startObject", "(", ")", ";", "childNode", ".", "toJSON", "(", "json", ")", ";", "json", ".", "endObject", "(", ")", ";", "}", "else", "{", "childNode", ".", "toJSON", "(", "json", ")", ";", "}", "}", "}", "json", ".", "endArray", "(", ")", ";", "break", ";", "case", "MAP", ":", "// Return map child modes in name order.\r", "json", ".", "startGroup", "(", "m_name", ")", ";", "if", "(", "m_childNodeMap", "!=", "null", ")", "{", "assert", "m_childNodeMap", ".", "size", "(", ")", "==", "m_children", ".", "size", "(", ")", ";", "for", "(", "UNode", "childNode", ":", "m_childNodeMap", ".", "values", "(", ")", ")", "{", "childNode", ".", "toJSON", "(", "json", ")", ";", "}", "}", "json", ".", "endGroup", "(", ")", ";", "break", ";", "case", "VALUE", ":", "if", "(", "m_bAltFormat", "&&", "m_tagName", "!=", "null", ")", "{", "// Generate as \"<tag>: {\"<name>\": \"<value>\"}\r", "json", ".", "startGroup", "(", "m_tagName", ")", ";", "json", ".", "addValue", "(", "m_name", ",", "m_value", ")", ";", "json", ".", "endGroup", "(", ")", ";", "}", "else", "if", "(", "m_parent", "!=", "null", "&&", "m_parent", ".", "isArray", "(", ")", ")", "{", "if", "(", "m_name", ".", "equals", "(", "\"value\"", ")", ")", "{", "// nameless node: \"<value>\"\r", "json", ".", "addValue", "(", "m_value", ")", ";", "}", "else", "{", "// value as an object: {\"name\": \"value\"}\r", "json", ".", "addObject", "(", "m_name", ",", "m_value", ")", ";", "}", "}", "else", "{", "// Simple case: \"<name>\": \"<value>\"\r", "json", ".", "addValue", "(", "m_name", ",", "m_value", ")", ";", "}", "break", ";", "default", ":", "assert", "false", ":", "\"Unknown NodeType: \"", "+", "m_type", ";", "}", "}" ]
Add the appropriate JSON syntax for this UNode to the given JSONEmitter.
[ "Add", "the", "appropriate", "JSON", "syntax", "for", "this", "UNode", "to", "the", "given", "JSONEmitter", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L1001-L1054
138,203
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/UNode.java
UNode.parseXMLAttributes
private static void parseXMLAttributes(NamedNodeMap attrMap, List<UNode> childUNodeList) { for (int index = 0; index < attrMap.getLength(); index++) { Attr attr = (Attr)attrMap.item(index); UNode childNode = createValueNode(attr.getName(), attr.getValue(), true); childUNodeList.add(childNode); } }
java
private static void parseXMLAttributes(NamedNodeMap attrMap, List<UNode> childUNodeList) { for (int index = 0; index < attrMap.getLength(); index++) { Attr attr = (Attr)attrMap.item(index); UNode childNode = createValueNode(attr.getName(), attr.getValue(), true); childUNodeList.add(childNode); } }
[ "private", "static", "void", "parseXMLAttributes", "(", "NamedNodeMap", "attrMap", ",", "List", "<", "UNode", ">", "childUNodeList", ")", "{", "for", "(", "int", "index", "=", "0", ";", "index", "<", "attrMap", ".", "getLength", "(", ")", ";", "index", "++", ")", "{", "Attr", "attr", "=", "(", "Attr", ")", "attrMap", ".", "item", "(", "index", ")", ";", "UNode", "childNode", "=", "createValueNode", "(", "attr", ".", "getName", "(", ")", ",", "attr", ".", "getValue", "(", ")", ",", "true", ")", ";", "childUNodeList", ".", "add", "(", "childNode", ")", ";", "}", "}" ]
if to the given child node list.
[ "if", "to", "the", "given", "child", "node", "list", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L1196-L1202
138,204
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/UNode.java
UNode.parseXMLChildElems
private static boolean parseXMLChildElems(Element elem, List<UNode> childUNodeList) { assert elem != null; assert childUNodeList != null; // Scan for Element nodes (there could be Comment and other nodes). boolean bDupNodeNames = false; Set<String> nodeNameSet = new HashSet<String>(); NodeList nodeList = elem.getChildNodes(); for (int index = 0; index < nodeList.getLength(); index++) { Node childNode = nodeList.item(index); if (childNode instanceof Element) { // Create the appropriate child UNode for this element. UNode childUNode = parseXMLElement((Element)childNode); childUNodeList.add(childUNode); if (nodeNameSet.contains(childUNode.getName())) { bDupNodeNames = true; } else { nodeNameSet.add(childUNode.getName()); } } } return bDupNodeNames; }
java
private static boolean parseXMLChildElems(Element elem, List<UNode> childUNodeList) { assert elem != null; assert childUNodeList != null; // Scan for Element nodes (there could be Comment and other nodes). boolean bDupNodeNames = false; Set<String> nodeNameSet = new HashSet<String>(); NodeList nodeList = elem.getChildNodes(); for (int index = 0; index < nodeList.getLength(); index++) { Node childNode = nodeList.item(index); if (childNode instanceof Element) { // Create the appropriate child UNode for this element. UNode childUNode = parseXMLElement((Element)childNode); childUNodeList.add(childUNode); if (nodeNameSet.contains(childUNode.getName())) { bDupNodeNames = true; } else { nodeNameSet.add(childUNode.getName()); } } } return bDupNodeNames; }
[ "private", "static", "boolean", "parseXMLChildElems", "(", "Element", "elem", ",", "List", "<", "UNode", ">", "childUNodeList", ")", "{", "assert", "elem", "!=", "null", ";", "assert", "childUNodeList", "!=", "null", ";", "// Scan for Element nodes (there could be Comment and other nodes).\r", "boolean", "bDupNodeNames", "=", "false", ";", "Set", "<", "String", ">", "nodeNameSet", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "NodeList", "nodeList", "=", "elem", ".", "getChildNodes", "(", ")", ";", "for", "(", "int", "index", "=", "0", ";", "index", "<", "nodeList", ".", "getLength", "(", ")", ";", "index", "++", ")", "{", "Node", "childNode", "=", "nodeList", ".", "item", "(", "index", ")", ";", "if", "(", "childNode", "instanceof", "Element", ")", "{", "// Create the appropriate child UNode for this element.\r", "UNode", "childUNode", "=", "parseXMLElement", "(", "(", "Element", ")", "childNode", ")", ";", "childUNodeList", ".", "add", "(", "childUNode", ")", ";", "if", "(", "nodeNameSet", ".", "contains", "(", "childUNode", ".", "getName", "(", ")", ")", ")", "{", "bDupNodeNames", "=", "true", ";", "}", "else", "{", "nodeNameSet", ".", "add", "(", "childUNode", ".", "getName", "(", ")", ")", ";", "}", "}", "}", "return", "bDupNodeNames", ";", "}" ]
are found while scanning.
[ "are", "found", "while", "scanning", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L1207-L1229
138,205
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/UNode.java
UNode.addXMLAttributes
private void addXMLAttributes(Map<String, String> attrMap) { if (m_children != null) { for (UNode childNode : m_children) { // A child node must not contain a tag name to be considered an attribute. if (childNode.m_type == NodeType.VALUE && childNode.m_bAttribute && Utils.isEmpty(childNode.m_tagName)) { assert m_name != null && m_name.length() > 0; attrMap.put(childNode.m_name, childNode.m_value); } } } }
java
private void addXMLAttributes(Map<String, String> attrMap) { if (m_children != null) { for (UNode childNode : m_children) { // A child node must not contain a tag name to be considered an attribute. if (childNode.m_type == NodeType.VALUE && childNode.m_bAttribute && Utils.isEmpty(childNode.m_tagName)) { assert m_name != null && m_name.length() > 0; attrMap.put(childNode.m_name, childNode.m_value); } } } }
[ "private", "void", "addXMLAttributes", "(", "Map", "<", "String", ",", "String", ">", "attrMap", ")", "{", "if", "(", "m_children", "!=", "null", ")", "{", "for", "(", "UNode", "childNode", ":", "m_children", ")", "{", "// A child node must not contain a tag name to be considered an attribute.\r", "if", "(", "childNode", ".", "m_type", "==", "NodeType", ".", "VALUE", "&&", "childNode", ".", "m_bAttribute", "&&", "Utils", ".", "isEmpty", "(", "childNode", ".", "m_tagName", ")", ")", "{", "assert", "m_name", "!=", "null", "&&", "m_name", ".", "length", "(", ")", ">", "0", ";", "attrMap", ".", "put", "(", "childNode", ".", "m_name", ",", "childNode", ".", "m_value", ")", ";", "}", "}", "}", "}" ]
Get the child nodes of this UNode that are VALUE nodes marked as attributes.
[ "Get", "the", "child", "nodes", "of", "this", "UNode", "that", "are", "VALUE", "nodes", "marked", "as", "attributes", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L1232-L1242
138,206
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/UNode.java
UNode.toStringTree
private void toStringTree(StringBuilder builder, int indent) { for (int count = 0; count < indent; count++) { builder.append(" "); } builder.append(this.toString()); builder.append("\n"); if (m_children != null) { for (UNode childNode : m_children) { childNode.toStringTree(builder, indent + 3); } } }
java
private void toStringTree(StringBuilder builder, int indent) { for (int count = 0; count < indent; count++) { builder.append(" "); } builder.append(this.toString()); builder.append("\n"); if (m_children != null) { for (UNode childNode : m_children) { childNode.toStringTree(builder, indent + 3); } } }
[ "private", "void", "toStringTree", "(", "StringBuilder", "builder", ",", "int", "indent", ")", "{", "for", "(", "int", "count", "=", "0", ";", "count", "<", "indent", ";", "count", "++", ")", "{", "builder", ".", "append", "(", "\" \"", ")", ";", "}", "builder", ".", "append", "(", "this", ".", "toString", "(", ")", ")", ";", "builder", ".", "append", "(", "\"\\n\"", ")", ";", "if", "(", "m_children", "!=", "null", ")", "{", "for", "(", "UNode", "childNode", ":", "m_children", ")", "{", "childNode", ".", "toStringTree", "(", "builder", ",", "indent", "+", "3", ")", ";", "}", "}", "}" ]
appended with a newline.
[ "appended", "with", "a", "newline", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UNode.java#L1248-L1259
138,207
QSFT/Doradus
doradus-dynamodb/src/main/java/com/dell/doradus/db/dynamodb/DynamoDBService.java
DynamoDBService.deleteRow
void deleteRow(String storeName, Map<String, AttributeValue> key) { String tableName = storeToTableName(storeName); m_logger.debug("Deleting row from table {}, key={}", tableName, DynamoDBService.getDDBKey(key)); Timer timer = new Timer(); boolean bSuccess = false; for (int attempts = 1; !bSuccess; attempts++) { try { m_ddbClient.deleteItem(tableName, key); if (attempts > 1) { m_logger.info("deleteRow() succeeded on attempt #{}", attempts); } bSuccess = true; m_logger.debug("Time to delete table {}, key={}: {}", new Object[]{tableName, DynamoDBService.getDDBKey(key), timer.toString()}); } catch (ProvisionedThroughputExceededException e) { if (attempts >= m_max_commit_attempts) { String errMsg = "All retries exceeded; abandoning deleteRow() for table: " + tableName; m_logger.error(errMsg, e); throw new RuntimeException(errMsg, e); } m_logger.warn("deleteRow() attempt #{} failed: {}", attempts, e); try { Thread.sleep(attempts * m_retry_wait_millis); } catch (InterruptedException ex2) { // ignore } } } }
java
void deleteRow(String storeName, Map<String, AttributeValue> key) { String tableName = storeToTableName(storeName); m_logger.debug("Deleting row from table {}, key={}", tableName, DynamoDBService.getDDBKey(key)); Timer timer = new Timer(); boolean bSuccess = false; for (int attempts = 1; !bSuccess; attempts++) { try { m_ddbClient.deleteItem(tableName, key); if (attempts > 1) { m_logger.info("deleteRow() succeeded on attempt #{}", attempts); } bSuccess = true; m_logger.debug("Time to delete table {}, key={}: {}", new Object[]{tableName, DynamoDBService.getDDBKey(key), timer.toString()}); } catch (ProvisionedThroughputExceededException e) { if (attempts >= m_max_commit_attempts) { String errMsg = "All retries exceeded; abandoning deleteRow() for table: " + tableName; m_logger.error(errMsg, e); throw new RuntimeException(errMsg, e); } m_logger.warn("deleteRow() attempt #{} failed: {}", attempts, e); try { Thread.sleep(attempts * m_retry_wait_millis); } catch (InterruptedException ex2) { // ignore } } } }
[ "void", "deleteRow", "(", "String", "storeName", ",", "Map", "<", "String", ",", "AttributeValue", ">", "key", ")", "{", "String", "tableName", "=", "storeToTableName", "(", "storeName", ")", ";", "m_logger", ".", "debug", "(", "\"Deleting row from table {}, key={}\"", ",", "tableName", ",", "DynamoDBService", ".", "getDDBKey", "(", "key", ")", ")", ";", "Timer", "timer", "=", "new", "Timer", "(", ")", ";", "boolean", "bSuccess", "=", "false", ";", "for", "(", "int", "attempts", "=", "1", ";", "!", "bSuccess", ";", "attempts", "++", ")", "{", "try", "{", "m_ddbClient", ".", "deleteItem", "(", "tableName", ",", "key", ")", ";", "if", "(", "attempts", ">", "1", ")", "{", "m_logger", ".", "info", "(", "\"deleteRow() succeeded on attempt #{}\"", ",", "attempts", ")", ";", "}", "bSuccess", "=", "true", ";", "m_logger", ".", "debug", "(", "\"Time to delete table {}, key={}: {}\"", ",", "new", "Object", "[", "]", "{", "tableName", ",", "DynamoDBService", ".", "getDDBKey", "(", "key", ")", ",", "timer", ".", "toString", "(", ")", "}", ")", ";", "}", "catch", "(", "ProvisionedThroughputExceededException", "e", ")", "{", "if", "(", "attempts", ">=", "m_max_commit_attempts", ")", "{", "String", "errMsg", "=", "\"All retries exceeded; abandoning deleteRow() for table: \"", "+", "tableName", ";", "m_logger", ".", "error", "(", "errMsg", ",", "e", ")", ";", "throw", "new", "RuntimeException", "(", "errMsg", ",", "e", ")", ";", "}", "m_logger", ".", "warn", "(", "\"deleteRow() attempt #{} failed: {}\"", ",", "attempts", ",", "e", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "attempts", "*", "m_retry_wait_millis", ")", ";", "}", "catch", "(", "InterruptedException", "ex2", ")", "{", "// ignore", "}", "}", "}", "}" ]
Delete row and back off if ProvisionedThroughputExceededException occurs.
[ "Delete", "row", "and", "back", "off", "if", "ProvisionedThroughputExceededException", "occurs", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-dynamodb/src/main/java/com/dell/doradus/db/dynamodb/DynamoDBService.java#L283-L312
138,208
QSFT/Doradus
doradus-dynamodb/src/main/java/com/dell/doradus/db/dynamodb/DynamoDBService.java
DynamoDBService.getCredentials
private AWSCredentials getCredentials() { String awsProfile = getParamString("aws_profile"); if (!Utils.isEmpty(awsProfile)) { m_logger.info("Using AWS profile: {}", awsProfile); ProfileCredentialsProvider credsProvider = null; String awsCredentialsFile = getParamString("aws_credentials_file"); if (!Utils.isEmpty(awsCredentialsFile)) { credsProvider = new ProfileCredentialsProvider(awsCredentialsFile, awsProfile); } else { credsProvider = new ProfileCredentialsProvider(awsProfile); } return credsProvider.getCredentials(); } String awsAccessKey = getParamString("aws_access_key"); Utils.require(!Utils.isEmpty(awsAccessKey), "Either 'aws_profile' or 'aws_access_key' must be defined for tenant: " + m_tenant.getName()); String awsSecretKey = getParamString("aws_secret_key"); Utils.require(!Utils.isEmpty(awsSecretKey), "'aws_secret_key' must be defined when 'aws_access_key' is defined. " + "'aws_profile' is preferred over aws_access_key/aws_secret_key. Tenant: " + m_tenant.getName()); return new BasicAWSCredentials(awsAccessKey, awsSecretKey); }
java
private AWSCredentials getCredentials() { String awsProfile = getParamString("aws_profile"); if (!Utils.isEmpty(awsProfile)) { m_logger.info("Using AWS profile: {}", awsProfile); ProfileCredentialsProvider credsProvider = null; String awsCredentialsFile = getParamString("aws_credentials_file"); if (!Utils.isEmpty(awsCredentialsFile)) { credsProvider = new ProfileCredentialsProvider(awsCredentialsFile, awsProfile); } else { credsProvider = new ProfileCredentialsProvider(awsProfile); } return credsProvider.getCredentials(); } String awsAccessKey = getParamString("aws_access_key"); Utils.require(!Utils.isEmpty(awsAccessKey), "Either 'aws_profile' or 'aws_access_key' must be defined for tenant: " + m_tenant.getName()); String awsSecretKey = getParamString("aws_secret_key"); Utils.require(!Utils.isEmpty(awsSecretKey), "'aws_secret_key' must be defined when 'aws_access_key' is defined. " + "'aws_profile' is preferred over aws_access_key/aws_secret_key. Tenant: " + m_tenant.getName()); return new BasicAWSCredentials(awsAccessKey, awsSecretKey); }
[ "private", "AWSCredentials", "getCredentials", "(", ")", "{", "String", "awsProfile", "=", "getParamString", "(", "\"aws_profile\"", ")", ";", "if", "(", "!", "Utils", ".", "isEmpty", "(", "awsProfile", ")", ")", "{", "m_logger", ".", "info", "(", "\"Using AWS profile: {}\"", ",", "awsProfile", ")", ";", "ProfileCredentialsProvider", "credsProvider", "=", "null", ";", "String", "awsCredentialsFile", "=", "getParamString", "(", "\"aws_credentials_file\"", ")", ";", "if", "(", "!", "Utils", ".", "isEmpty", "(", "awsCredentialsFile", ")", ")", "{", "credsProvider", "=", "new", "ProfileCredentialsProvider", "(", "awsCredentialsFile", ",", "awsProfile", ")", ";", "}", "else", "{", "credsProvider", "=", "new", "ProfileCredentialsProvider", "(", "awsProfile", ")", ";", "}", "return", "credsProvider", ".", "getCredentials", "(", ")", ";", "}", "String", "awsAccessKey", "=", "getParamString", "(", "\"aws_access_key\"", ")", ";", "Utils", ".", "require", "(", "!", "Utils", ".", "isEmpty", "(", "awsAccessKey", ")", ",", "\"Either 'aws_profile' or 'aws_access_key' must be defined for tenant: \"", "+", "m_tenant", ".", "getName", "(", ")", ")", ";", "String", "awsSecretKey", "=", "getParamString", "(", "\"aws_secret_key\"", ")", ";", "Utils", ".", "require", "(", "!", "Utils", ".", "isEmpty", "(", "awsSecretKey", ")", ",", "\"'aws_secret_key' must be defined when 'aws_access_key' is defined. \"", "+", "\"'aws_profile' is preferred over aws_access_key/aws_secret_key. Tenant: \"", "+", "m_tenant", ".", "getName", "(", ")", ")", ";", "return", "new", "BasicAWSCredentials", "(", "awsAccessKey", ",", "awsSecretKey", ")", ";", "}" ]
Set the AWS credentials in m_ddbClient
[ "Set", "the", "AWS", "credentials", "in", "m_ddbClient" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-dynamodb/src/main/java/com/dell/doradus/db/dynamodb/DynamoDBService.java#L356-L378
138,209
QSFT/Doradus
doradus-dynamodb/src/main/java/com/dell/doradus/db/dynamodb/DynamoDBService.java
DynamoDBService.setRegionOrEndPoint
private void setRegionOrEndPoint() { String regionName = getParamString("ddb_region"); if (regionName != null) { Regions regionEnum = Regions.fromName(regionName); Utils.require(regionEnum != null, "Unknown 'ddb_region': " + regionName); m_logger.info("Using region: {}", regionName); m_ddbClient.setRegion(Region.getRegion(regionEnum)); } else { String ddbEndpoint = getParamString("ddb_endpoint"); Utils.require(ddbEndpoint != null, "Either 'ddb_region' or 'ddb_endpoint' must be defined for tenant: " + m_tenant.getName()); m_logger.info("Using endpoint: {}", ddbEndpoint); m_ddbClient.setEndpoint(ddbEndpoint); } }
java
private void setRegionOrEndPoint() { String regionName = getParamString("ddb_region"); if (regionName != null) { Regions regionEnum = Regions.fromName(regionName); Utils.require(regionEnum != null, "Unknown 'ddb_region': " + regionName); m_logger.info("Using region: {}", regionName); m_ddbClient.setRegion(Region.getRegion(regionEnum)); } else { String ddbEndpoint = getParamString("ddb_endpoint"); Utils.require(ddbEndpoint != null, "Either 'ddb_region' or 'ddb_endpoint' must be defined for tenant: " + m_tenant.getName()); m_logger.info("Using endpoint: {}", ddbEndpoint); m_ddbClient.setEndpoint(ddbEndpoint); } }
[ "private", "void", "setRegionOrEndPoint", "(", ")", "{", "String", "regionName", "=", "getParamString", "(", "\"ddb_region\"", ")", ";", "if", "(", "regionName", "!=", "null", ")", "{", "Regions", "regionEnum", "=", "Regions", ".", "fromName", "(", "regionName", ")", ";", "Utils", ".", "require", "(", "regionEnum", "!=", "null", ",", "\"Unknown 'ddb_region': \"", "+", "regionName", ")", ";", "m_logger", ".", "info", "(", "\"Using region: {}\"", ",", "regionName", ")", ";", "m_ddbClient", ".", "setRegion", "(", "Region", ".", "getRegion", "(", "regionEnum", ")", ")", ";", "}", "else", "{", "String", "ddbEndpoint", "=", "getParamString", "(", "\"ddb_endpoint\"", ")", ";", "Utils", ".", "require", "(", "ddbEndpoint", "!=", "null", ",", "\"Either 'ddb_region' or 'ddb_endpoint' must be defined for tenant: \"", "+", "m_tenant", ".", "getName", "(", ")", ")", ";", "m_logger", ".", "info", "(", "\"Using endpoint: {}\"", ",", "ddbEndpoint", ")", ";", "m_ddbClient", ".", "setEndpoint", "(", "ddbEndpoint", ")", ";", "}", "}" ]
Set the region or endpoint in m_ddbClient
[ "Set", "the", "region", "or", "endpoint", "in", "m_ddbClient" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-dynamodb/src/main/java/com/dell/doradus/db/dynamodb/DynamoDBService.java#L381-L395
138,210
QSFT/Doradus
doradus-dynamodb/src/main/java/com/dell/doradus/db/dynamodb/DynamoDBService.java
DynamoDBService.setDefaultCapacity
private void setDefaultCapacity() { Object capacity = getParam("ddb_default_read_capacity"); if (capacity != null) { READ_CAPACITY_UNITS = Integer.parseInt(capacity.toString()); } capacity = getParam("ddb_default_write_capacity"); if (capacity != null) { WRITE_CAPACITY_UNITS = Integer.parseInt(capacity.toString()); } m_logger.info("Default table capacity: read={}, write={}", READ_CAPACITY_UNITS, WRITE_CAPACITY_UNITS); }
java
private void setDefaultCapacity() { Object capacity = getParam("ddb_default_read_capacity"); if (capacity != null) { READ_CAPACITY_UNITS = Integer.parseInt(capacity.toString()); } capacity = getParam("ddb_default_write_capacity"); if (capacity != null) { WRITE_CAPACITY_UNITS = Integer.parseInt(capacity.toString()); } m_logger.info("Default table capacity: read={}, write={}", READ_CAPACITY_UNITS, WRITE_CAPACITY_UNITS); }
[ "private", "void", "setDefaultCapacity", "(", ")", "{", "Object", "capacity", "=", "getParam", "(", "\"ddb_default_read_capacity\"", ")", ";", "if", "(", "capacity", "!=", "null", ")", "{", "READ_CAPACITY_UNITS", "=", "Integer", ".", "parseInt", "(", "capacity", ".", "toString", "(", ")", ")", ";", "}", "capacity", "=", "getParam", "(", "\"ddb_default_write_capacity\"", ")", ";", "if", "(", "capacity", "!=", "null", ")", "{", "WRITE_CAPACITY_UNITS", "=", "Integer", ".", "parseInt", "(", "capacity", ".", "toString", "(", ")", ")", ";", "}", "m_logger", ".", "info", "(", "\"Default table capacity: read={}, write={}\"", ",", "READ_CAPACITY_UNITS", ",", "WRITE_CAPACITY_UNITS", ")", ";", "}" ]
Set READ_CAPACITY_UNITS and WRITE_CAPACITY_UNITS if overridden.
[ "Set", "READ_CAPACITY_UNITS", "and", "WRITE_CAPACITY_UNITS", "if", "overridden", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-dynamodb/src/main/java/com/dell/doradus/db/dynamodb/DynamoDBService.java#L398-L408
138,211
QSFT/Doradus
doradus-dynamodb/src/main/java/com/dell/doradus/db/dynamodb/DynamoDBService.java
DynamoDBService.scan
private ScanResult scan(ScanRequest scanRequest) { m_logger.debug("Performing scan() request on table {}", scanRequest.getTableName()); Timer timer = new Timer(); boolean bSuccess = false; ScanResult scanResult = null; for (int attempts = 1; !bSuccess; attempts++) { try { scanResult = m_ddbClient.scan(scanRequest); if (attempts > 1) { m_logger.info("scan() succeeded on attempt #{}", attempts); } bSuccess = true; m_logger.debug("Time to scan table {}: {}", scanRequest.getTableName(), timer.toString()); } catch (ProvisionedThroughputExceededException e) { if (attempts >= m_max_read_attempts) { String errMsg = "All retries exceeded; abandoning scan() for table: " + scanRequest.getTableName(); m_logger.error(errMsg, e); throw new RuntimeException(errMsg, e); } m_logger.warn("scan() attempt #{} failed: {}", attempts, e); try { Thread.sleep(attempts * m_retry_wait_millis); } catch (InterruptedException ex2) { // ignore } } } return scanResult; }
java
private ScanResult scan(ScanRequest scanRequest) { m_logger.debug("Performing scan() request on table {}", scanRequest.getTableName()); Timer timer = new Timer(); boolean bSuccess = false; ScanResult scanResult = null; for (int attempts = 1; !bSuccess; attempts++) { try { scanResult = m_ddbClient.scan(scanRequest); if (attempts > 1) { m_logger.info("scan() succeeded on attempt #{}", attempts); } bSuccess = true; m_logger.debug("Time to scan table {}: {}", scanRequest.getTableName(), timer.toString()); } catch (ProvisionedThroughputExceededException e) { if (attempts >= m_max_read_attempts) { String errMsg = "All retries exceeded; abandoning scan() for table: " + scanRequest.getTableName(); m_logger.error(errMsg, e); throw new RuntimeException(errMsg, e); } m_logger.warn("scan() attempt #{} failed: {}", attempts, e); try { Thread.sleep(attempts * m_retry_wait_millis); } catch (InterruptedException ex2) { // ignore } } } return scanResult; }
[ "private", "ScanResult", "scan", "(", "ScanRequest", "scanRequest", ")", "{", "m_logger", ".", "debug", "(", "\"Performing scan() request on table {}\"", ",", "scanRequest", ".", "getTableName", "(", ")", ")", ";", "Timer", "timer", "=", "new", "Timer", "(", ")", ";", "boolean", "bSuccess", "=", "false", ";", "ScanResult", "scanResult", "=", "null", ";", "for", "(", "int", "attempts", "=", "1", ";", "!", "bSuccess", ";", "attempts", "++", ")", "{", "try", "{", "scanResult", "=", "m_ddbClient", ".", "scan", "(", "scanRequest", ")", ";", "if", "(", "attempts", ">", "1", ")", "{", "m_logger", ".", "info", "(", "\"scan() succeeded on attempt #{}\"", ",", "attempts", ")", ";", "}", "bSuccess", "=", "true", ";", "m_logger", ".", "debug", "(", "\"Time to scan table {}: {}\"", ",", "scanRequest", ".", "getTableName", "(", ")", ",", "timer", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "ProvisionedThroughputExceededException", "e", ")", "{", "if", "(", "attempts", ">=", "m_max_read_attempts", ")", "{", "String", "errMsg", "=", "\"All retries exceeded; abandoning scan() for table: \"", "+", "scanRequest", ".", "getTableName", "(", ")", ";", "m_logger", ".", "error", "(", "errMsg", ",", "e", ")", ";", "throw", "new", "RuntimeException", "(", "errMsg", ",", "e", ")", ";", "}", "m_logger", ".", "warn", "(", "\"scan() attempt #{} failed: {}\"", ",", "attempts", ",", "e", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "attempts", "*", "m_retry_wait_millis", ")", ";", "}", "catch", "(", "InterruptedException", "ex2", ")", "{", "// ignore", "}", "}", "}", "return", "scanResult", ";", "}" ]
Perform a scan request and retry if ProvisionedThroughputExceededException occurs.
[ "Perform", "a", "scan", "request", "and", "retry", "if", "ProvisionedThroughputExceededException", "occurs", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-dynamodb/src/main/java/com/dell/doradus/db/dynamodb/DynamoDBService.java#L411-L440
138,212
QSFT/Doradus
doradus-dynamodb/src/main/java/com/dell/doradus/db/dynamodb/DynamoDBService.java
DynamoDBService.loadAttributes
private List<DColumn> loadAttributes(Map<String, AttributeValue> attributeMap, Predicate<String> colNamePredicate) { List<DColumn> columns = new ArrayList<>(); if (attributeMap != null) { for (Map.Entry<String, AttributeValue> mapEntry : attributeMap.entrySet()) { String colName = mapEntry.getKey(); if (!colName.equals(DynamoDBService.ROW_KEY_ATTR_NAME) && // Don't add row key attribute as a column colNamePredicate.test(colName)) { AttributeValue attrValue = mapEntry.getValue(); if (attrValue.getB() != null) { columns.add(new DColumn(colName, Utils.getBytes(attrValue.getB()))); } else if (attrValue.getS() != null) { String value = attrValue.getS(); if (value.equals(DynamoDBService.NULL_COLUMN_MARKER)) { value = ""; } columns.add(new DColumn(colName, value)); } else { throw new RuntimeException("Unknown AttributeValue type: " + attrValue); } } } } // Sort or reverse sort column names. Collections.sort(columns, new Comparator<DColumn>() { @Override public int compare(DColumn col1, DColumn col2) { return col1.getName().compareTo(col2.getName()); } }); return columns; }
java
private List<DColumn> loadAttributes(Map<String, AttributeValue> attributeMap, Predicate<String> colNamePredicate) { List<DColumn> columns = new ArrayList<>(); if (attributeMap != null) { for (Map.Entry<String, AttributeValue> mapEntry : attributeMap.entrySet()) { String colName = mapEntry.getKey(); if (!colName.equals(DynamoDBService.ROW_KEY_ATTR_NAME) && // Don't add row key attribute as a column colNamePredicate.test(colName)) { AttributeValue attrValue = mapEntry.getValue(); if (attrValue.getB() != null) { columns.add(new DColumn(colName, Utils.getBytes(attrValue.getB()))); } else if (attrValue.getS() != null) { String value = attrValue.getS(); if (value.equals(DynamoDBService.NULL_COLUMN_MARKER)) { value = ""; } columns.add(new DColumn(colName, value)); } else { throw new RuntimeException("Unknown AttributeValue type: " + attrValue); } } } } // Sort or reverse sort column names. Collections.sort(columns, new Comparator<DColumn>() { @Override public int compare(DColumn col1, DColumn col2) { return col1.getName().compareTo(col2.getName()); } }); return columns; }
[ "private", "List", "<", "DColumn", ">", "loadAttributes", "(", "Map", "<", "String", ",", "AttributeValue", ">", "attributeMap", ",", "Predicate", "<", "String", ">", "colNamePredicate", ")", "{", "List", "<", "DColumn", ">", "columns", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "attributeMap", "!=", "null", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "AttributeValue", ">", "mapEntry", ":", "attributeMap", ".", "entrySet", "(", ")", ")", "{", "String", "colName", "=", "mapEntry", ".", "getKey", "(", ")", ";", "if", "(", "!", "colName", ".", "equals", "(", "DynamoDBService", ".", "ROW_KEY_ATTR_NAME", ")", "&&", "// Don't add row key attribute as a column", "colNamePredicate", ".", "test", "(", "colName", ")", ")", "{", "AttributeValue", "attrValue", "=", "mapEntry", ".", "getValue", "(", ")", ";", "if", "(", "attrValue", ".", "getB", "(", ")", "!=", "null", ")", "{", "columns", ".", "add", "(", "new", "DColumn", "(", "colName", ",", "Utils", ".", "getBytes", "(", "attrValue", ".", "getB", "(", ")", ")", ")", ")", ";", "}", "else", "if", "(", "attrValue", ".", "getS", "(", ")", "!=", "null", ")", "{", "String", "value", "=", "attrValue", ".", "getS", "(", ")", ";", "if", "(", "value", ".", "equals", "(", "DynamoDBService", ".", "NULL_COLUMN_MARKER", ")", ")", "{", "value", "=", "\"\"", ";", "}", "columns", ".", "add", "(", "new", "DColumn", "(", "colName", ",", "value", ")", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Unknown AttributeValue type: \"", "+", "attrValue", ")", ";", "}", "}", "}", "}", "// Sort or reverse sort column names.", "Collections", ".", "sort", "(", "columns", ",", "new", "Comparator", "<", "DColumn", ">", "(", ")", "{", "@", "Override", "public", "int", "compare", "(", "DColumn", "col1", ",", "DColumn", "col2", ")", "{", "return", "col1", ".", "getName", "(", ")", ".", "compareTo", "(", "col2", ".", "getName", "(", ")", ")", ";", "}", "}", ")", ";", "return", "columns", ";", "}" ]
Filter, store, and sort attributes from the given map.
[ "Filter", "store", "and", "sort", "attributes", "from", "the", "given", "map", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-dynamodb/src/main/java/com/dell/doradus/db/dynamodb/DynamoDBService.java#L443-L474
138,213
QSFT/Doradus
doradus-dynamodb/src/main/java/com/dell/doradus/db/dynamodb/DynamoDBService.java
DynamoDBService.deleteTable
private void deleteTable(String tableName) { m_logger.info("Deleting table: {}", tableName); try { m_ddbClient.deleteTable(new DeleteTableRequest(tableName)); for (int seconds = 0; seconds < 10; seconds++) { try { m_ddbClient.describeTable(tableName); Thread.sleep(1000); } catch (ResourceNotFoundException e) { break; // Success } // All other exceptions passed to outer try/catch } } catch (ResourceNotFoundException e) { // Already deleted. } catch (Exception e) { throw new RuntimeException("Error deleting table: " + tableName, e); } }
java
private void deleteTable(String tableName) { m_logger.info("Deleting table: {}", tableName); try { m_ddbClient.deleteTable(new DeleteTableRequest(tableName)); for (int seconds = 0; seconds < 10; seconds++) { try { m_ddbClient.describeTable(tableName); Thread.sleep(1000); } catch (ResourceNotFoundException e) { break; // Success } // All other exceptions passed to outer try/catch } } catch (ResourceNotFoundException e) { // Already deleted. } catch (Exception e) { throw new RuntimeException("Error deleting table: " + tableName, e); } }
[ "private", "void", "deleteTable", "(", "String", "tableName", ")", "{", "m_logger", ".", "info", "(", "\"Deleting table: {}\"", ",", "tableName", ")", ";", "try", "{", "m_ddbClient", ".", "deleteTable", "(", "new", "DeleteTableRequest", "(", "tableName", ")", ")", ";", "for", "(", "int", "seconds", "=", "0", ";", "seconds", "<", "10", ";", "seconds", "++", ")", "{", "try", "{", "m_ddbClient", ".", "describeTable", "(", "tableName", ")", ";", "Thread", ".", "sleep", "(", "1000", ")", ";", "}", "catch", "(", "ResourceNotFoundException", "e", ")", "{", "break", ";", "// Success", "}", "// All other exceptions passed to outer try/catch", "}", "}", "catch", "(", "ResourceNotFoundException", "e", ")", "{", "// Already deleted.", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error deleting table: \"", "+", "tableName", ",", "e", ")", ";", "}", "}" ]
Delete the given table and wait for it to be deleted.
[ "Delete", "the", "given", "table", "and", "wait", "for", "it", "to", "be", "deleted", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-dynamodb/src/main/java/com/dell/doradus/db/dynamodb/DynamoDBService.java#L477-L494
138,214
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/search/analyzer/SimpleText.java
SimpleText.tokenize
public List<String> tokenize(String text) { List<String> tokens = new ArrayList<String>(); text = text.toLowerCase(); char[] array = text.toCharArray(); //convert all apostrophes to 0x27 for(int i = 0; i < array.length; i++) { if(isApostrofe(array[i])) array[i] = 0x27; } int pos = 0; //term cycle while(pos < array.length) { //scan to the start of the term while(pos < array.length && !Character.isLetterOrDigit(array[pos])) pos++; int start = pos; if(start == array.length) break; //scan to the end of the term while(pos < array.length && isLetterOrDigitOrApostrofe(array[pos])) pos++; int newpos = pos; while(newpos > start && isApostrofe(array[newpos - 1])) newpos--; if(newpos > start) tokens.add(new String(array, start, newpos - start)); } return tokens; }
java
public List<String> tokenize(String text) { List<String> tokens = new ArrayList<String>(); text = text.toLowerCase(); char[] array = text.toCharArray(); //convert all apostrophes to 0x27 for(int i = 0; i < array.length; i++) { if(isApostrofe(array[i])) array[i] = 0x27; } int pos = 0; //term cycle while(pos < array.length) { //scan to the start of the term while(pos < array.length && !Character.isLetterOrDigit(array[pos])) pos++; int start = pos; if(start == array.length) break; //scan to the end of the term while(pos < array.length && isLetterOrDigitOrApostrofe(array[pos])) pos++; int newpos = pos; while(newpos > start && isApostrofe(array[newpos - 1])) newpos--; if(newpos > start) tokens.add(new String(array, start, newpos - start)); } return tokens; }
[ "public", "List", "<", "String", ">", "tokenize", "(", "String", "text", ")", "{", "List", "<", "String", ">", "tokens", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "text", "=", "text", ".", "toLowerCase", "(", ")", ";", "char", "[", "]", "array", "=", "text", ".", "toCharArray", "(", ")", ";", "//convert all apostrophes to 0x27\r", "for", "(", "int", "i", "=", "0", ";", "i", "<", "array", ".", "length", ";", "i", "++", ")", "{", "if", "(", "isApostrofe", "(", "array", "[", "i", "]", ")", ")", "array", "[", "i", "]", "=", "0x27", ";", "}", "int", "pos", "=", "0", ";", "//term cycle\r", "while", "(", "pos", "<", "array", ".", "length", ")", "{", "//scan to the start of the term\r", "while", "(", "pos", "<", "array", ".", "length", "&&", "!", "Character", ".", "isLetterOrDigit", "(", "array", "[", "pos", "]", ")", ")", "pos", "++", ";", "int", "start", "=", "pos", ";", "if", "(", "start", "==", "array", ".", "length", ")", "break", ";", "//scan to the end of the term\r", "while", "(", "pos", "<", "array", ".", "length", "&&", "isLetterOrDigitOrApostrofe", "(", "array", "[", "pos", "]", ")", ")", "pos", "++", ";", "int", "newpos", "=", "pos", ";", "while", "(", "newpos", ">", "start", "&&", "isApostrofe", "(", "array", "[", "newpos", "-", "1", "]", ")", ")", "newpos", "--", ";", "if", "(", "newpos", ">", "start", ")", "tokens", ".", "add", "(", "new", "String", "(", "array", ",", "start", ",", "newpos", "-", "start", ")", ")", ";", "}", "return", "tokens", ";", "}" ]
get list of tokens from the text for indexing
[ "get", "list", "of", "tokens", "from", "the", "text", "for", "indexing" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/search/analyzer/SimpleText.java#L43-L68
138,215
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBService.java
DBService.updateTenant
public void updateTenant(Tenant updatedTenant) { assert m_tenant.getName().equals(updatedTenant.getName()); m_tenant = updatedTenant; }
java
public void updateTenant(Tenant updatedTenant) { assert m_tenant.getName().equals(updatedTenant.getName()); m_tenant = updatedTenant; }
[ "public", "void", "updateTenant", "(", "Tenant", "updatedTenant", ")", "{", "assert", "m_tenant", ".", "getName", "(", ")", ".", "equals", "(", "updatedTenant", ".", "getName", "(", ")", ")", ";", "m_tenant", "=", "updatedTenant", ";", "}" ]
Update this DBService's Tenant with the given one. This is called when the tenant's definition has been updated in an upward-compatible way, such as adding or removing users. @param updatedTenant Updated {@link Tenant}.
[ "Update", "this", "DBService", "s", "Tenant", "with", "the", "given", "one", ".", "This", "is", "called", "when", "the", "tenant", "s", "definition", "has", "been", "updated", "in", "an", "upward", "-", "compatible", "way", "such", "as", "adding", "or", "removing", "users", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBService.java#L109-L112
138,216
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBService.java
DBService.isSystemTable
public static boolean isSystemTable(String storeName) { return storeName.equals(SchemaService.APPS_STORE_NAME) || storeName.equals(TaskManagerService.TASKS_STORE_NAME) || storeName.equals(TenantService.TENANTS_STORE_NAME); }
java
public static boolean isSystemTable(String storeName) { return storeName.equals(SchemaService.APPS_STORE_NAME) || storeName.equals(TaskManagerService.TASKS_STORE_NAME) || storeName.equals(TenantService.TENANTS_STORE_NAME); }
[ "public", "static", "boolean", "isSystemTable", "(", "String", "storeName", ")", "{", "return", "storeName", ".", "equals", "(", "SchemaService", ".", "APPS_STORE_NAME", ")", "||", "storeName", ".", "equals", "(", "TaskManagerService", ".", "TASKS_STORE_NAME", ")", "||", "storeName", ".", "equals", "(", "TenantService", ".", "TENANTS_STORE_NAME", ")", ";", "}" ]
Return true if the given store name is a system table, aka metadata table. System tables store column values as strings. All other tables use binary column values. @param storeName Store name to test. @return True if the store name is a system table.
[ "Return", "true", "if", "the", "given", "store", "name", "is", "a", "system", "table", "aka", "metadata", "table", ".", "System", "tables", "store", "column", "values", "as", "strings", ".", "All", "other", "tables", "use", "binary", "column", "values", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBService.java#L138-L142
138,217
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLService.java
CQLService.storeExists
private boolean storeExists(String tableName) { KeyspaceMetadata ksMetadata = m_cluster.getMetadata().getKeyspace(m_keyspace); return (ksMetadata != null) && (ksMetadata.getTable(tableName) != null); }
java
private boolean storeExists(String tableName) { KeyspaceMetadata ksMetadata = m_cluster.getMetadata().getKeyspace(m_keyspace); return (ksMetadata != null) && (ksMetadata.getTable(tableName) != null); }
[ "private", "boolean", "storeExists", "(", "String", "tableName", ")", "{", "KeyspaceMetadata", "ksMetadata", "=", "m_cluster", ".", "getMetadata", "(", ")", ".", "getKeyspace", "(", "m_keyspace", ")", ";", "return", "(", "ksMetadata", "!=", "null", ")", "&&", "(", "ksMetadata", ".", "getTable", "(", "tableName", ")", "!=", "null", ")", ";", "}" ]
Return true if the given table exists in the given keyspace.
[ "Return", "true", "if", "the", "given", "table", "exists", "in", "the", "given", "keyspace", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLService.java#L303-L306
138,218
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLService.java
CQLService.executeQuery
private ResultSet executeQuery(Query query, String tableName, Object... values) { m_logger.debug("Executing statement {} on table {}.{}; total params={}", new Object[]{query, m_keyspace, tableName, values.length}); try { PreparedStatement prepState = getPreparedQuery(query, tableName); BoundStatement boundState = prepState.bind(values); return m_session.execute(boundState); } catch (Exception e) { String params = "[" + Utils.concatenate(Arrays.asList(values), ",") + "]"; m_logger.error("Query failed: query={}, keyspace={}, table={}, params={}; error: {}", query, m_keyspace, tableName, params, e); throw e; } }
java
private ResultSet executeQuery(Query query, String tableName, Object... values) { m_logger.debug("Executing statement {} on table {}.{}; total params={}", new Object[]{query, m_keyspace, tableName, values.length}); try { PreparedStatement prepState = getPreparedQuery(query, tableName); BoundStatement boundState = prepState.bind(values); return m_session.execute(boundState); } catch (Exception e) { String params = "[" + Utils.concatenate(Arrays.asList(values), ",") + "]"; m_logger.error("Query failed: query={}, keyspace={}, table={}, params={}; error: {}", query, m_keyspace, tableName, params, e); throw e; } }
[ "private", "ResultSet", "executeQuery", "(", "Query", "query", ",", "String", "tableName", ",", "Object", "...", "values", ")", "{", "m_logger", ".", "debug", "(", "\"Executing statement {} on table {}.{}; total params={}\"", ",", "new", "Object", "[", "]", "{", "query", ",", "m_keyspace", ",", "tableName", ",", "values", ".", "length", "}", ")", ";", "try", "{", "PreparedStatement", "prepState", "=", "getPreparedQuery", "(", "query", ",", "tableName", ")", ";", "BoundStatement", "boundState", "=", "prepState", ".", "bind", "(", "values", ")", ";", "return", "m_session", ".", "execute", "(", "boundState", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "String", "params", "=", "\"[\"", "+", "Utils", ".", "concatenate", "(", "Arrays", ".", "asList", "(", "values", ")", ",", "\",\"", ")", "+", "\"]\"", ";", "m_logger", ".", "error", "(", "\"Query failed: query={}, keyspace={}, table={}, params={}; error: {}\"", ",", "query", ",", "m_keyspace", ",", "tableName", ",", "params", ",", "e", ")", ";", "throw", "e", ";", "}", "}" ]
Execute the given query for the given table using the given values.
[ "Execute", "the", "given", "query", "for", "the", "given", "table", "using", "the", "given", "values", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLService.java#L309-L322
138,219
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLService.java
CQLService.buildClusterSpecs
private Cluster buildClusterSpecs() { Cluster.Builder builder = Cluster.builder(); // dbhost String dbhost = getParamString("dbhost"); String[] nodeAddresses = dbhost.split(","); for (String address : nodeAddresses) { builder.addContactPoint(address); } // dbport builder.withPort(getParamInt("dbport", 9042)); // db_timeout_millis and db_connect_retry_wait_millis SocketOptions socketOpts = new SocketOptions(); socketOpts.setReadTimeoutMillis(getParamInt("db_timeout_millis", 10000)); socketOpts.setConnectTimeoutMillis(getParamInt("db_connect_retry_wait_millis", 5000)); builder.withSocketOptions(socketOpts); // dbuser/dbpassword String dbuser = getParamString("dbuser"); if (!Utils.isEmpty(dbuser)) { builder.withCredentials(dbuser, getParamString("dbpassword")); } // compression builder.withCompression(Compression.SNAPPY); // TLS/SSL if (getParamBoolean("dbtls")) { builder.withSSL(getSSLOptions()); } return builder.build(); }
java
private Cluster buildClusterSpecs() { Cluster.Builder builder = Cluster.builder(); // dbhost String dbhost = getParamString("dbhost"); String[] nodeAddresses = dbhost.split(","); for (String address : nodeAddresses) { builder.addContactPoint(address); } // dbport builder.withPort(getParamInt("dbport", 9042)); // db_timeout_millis and db_connect_retry_wait_millis SocketOptions socketOpts = new SocketOptions(); socketOpts.setReadTimeoutMillis(getParamInt("db_timeout_millis", 10000)); socketOpts.setConnectTimeoutMillis(getParamInt("db_connect_retry_wait_millis", 5000)); builder.withSocketOptions(socketOpts); // dbuser/dbpassword String dbuser = getParamString("dbuser"); if (!Utils.isEmpty(dbuser)) { builder.withCredentials(dbuser, getParamString("dbpassword")); } // compression builder.withCompression(Compression.SNAPPY); // TLS/SSL if (getParamBoolean("dbtls")) { builder.withSSL(getSSLOptions()); } return builder.build(); }
[ "private", "Cluster", "buildClusterSpecs", "(", ")", "{", "Cluster", ".", "Builder", "builder", "=", "Cluster", ".", "builder", "(", ")", ";", "// dbhost", "String", "dbhost", "=", "getParamString", "(", "\"dbhost\"", ")", ";", "String", "[", "]", "nodeAddresses", "=", "dbhost", ".", "split", "(", "\",\"", ")", ";", "for", "(", "String", "address", ":", "nodeAddresses", ")", "{", "builder", ".", "addContactPoint", "(", "address", ")", ";", "}", "// dbport", "builder", ".", "withPort", "(", "getParamInt", "(", "\"dbport\"", ",", "9042", ")", ")", ";", "// db_timeout_millis and db_connect_retry_wait_millis", "SocketOptions", "socketOpts", "=", "new", "SocketOptions", "(", ")", ";", "socketOpts", ".", "setReadTimeoutMillis", "(", "getParamInt", "(", "\"db_timeout_millis\"", ",", "10000", ")", ")", ";", "socketOpts", ".", "setConnectTimeoutMillis", "(", "getParamInt", "(", "\"db_connect_retry_wait_millis\"", ",", "5000", ")", ")", ";", "builder", ".", "withSocketOptions", "(", "socketOpts", ")", ";", "// dbuser/dbpassword", "String", "dbuser", "=", "getParamString", "(", "\"dbuser\"", ")", ";", "if", "(", "!", "Utils", ".", "isEmpty", "(", "dbuser", ")", ")", "{", "builder", ".", "withCredentials", "(", "dbuser", ",", "getParamString", "(", "\"dbpassword\"", ")", ")", ";", "}", "// compression", "builder", ".", "withCompression", "(", "Compression", ".", "SNAPPY", ")", ";", "// TLS/SSL", "if", "(", "getParamBoolean", "(", "\"dbtls\"", ")", ")", "{", "builder", ".", "withSSL", "(", "getSSLOptions", "(", ")", ")", ";", "}", "return", "builder", ".", "build", "(", ")", ";", "}" ]
Build Cluster object from ServerConfig settings.
[ "Build", "Cluster", "object", "from", "ServerConfig", "settings", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLService.java#L325-L359
138,220
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLService.java
CQLService.getSSLContext
private SSLContext getSSLContext(String truststorePath, String truststorePassword, String keystorePath, String keystorePassword) throws Exception { FileInputStream tsf = new FileInputStream(truststorePath); KeyStore ts = KeyStore.getInstance("JKS"); ts.load(tsf, truststorePassword.toCharArray()); TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(ts); FileInputStream ksf = new FileInputStream(keystorePath); KeyStore ks = KeyStore.getInstance("JKS"); ks.load(ksf, keystorePassword.toCharArray()); KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(ks, keystorePassword.toCharArray()); SSLContext ctx = SSLContext.getInstance("SSL"); ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), new SecureRandom()); return ctx; }
java
private SSLContext getSSLContext(String truststorePath, String truststorePassword, String keystorePath, String keystorePassword) throws Exception { FileInputStream tsf = new FileInputStream(truststorePath); KeyStore ts = KeyStore.getInstance("JKS"); ts.load(tsf, truststorePassword.toCharArray()); TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(ts); FileInputStream ksf = new FileInputStream(keystorePath); KeyStore ks = KeyStore.getInstance("JKS"); ks.load(ksf, keystorePassword.toCharArray()); KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(ks, keystorePassword.toCharArray()); SSLContext ctx = SSLContext.getInstance("SSL"); ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), new SecureRandom()); return ctx; }
[ "private", "SSLContext", "getSSLContext", "(", "String", "truststorePath", ",", "String", "truststorePassword", ",", "String", "keystorePath", ",", "String", "keystorePassword", ")", "throws", "Exception", "{", "FileInputStream", "tsf", "=", "new", "FileInputStream", "(", "truststorePath", ")", ";", "KeyStore", "ts", "=", "KeyStore", ".", "getInstance", "(", "\"JKS\"", ")", ";", "ts", ".", "load", "(", "tsf", ",", "truststorePassword", ".", "toCharArray", "(", ")", ")", ";", "TrustManagerFactory", "tmf", "=", "TrustManagerFactory", ".", "getInstance", "(", "TrustManagerFactory", ".", "getDefaultAlgorithm", "(", ")", ")", ";", "tmf", ".", "init", "(", "ts", ")", ";", "FileInputStream", "ksf", "=", "new", "FileInputStream", "(", "keystorePath", ")", ";", "KeyStore", "ks", "=", "KeyStore", ".", "getInstance", "(", "\"JKS\"", ")", ";", "ks", ".", "load", "(", "ksf", ",", "keystorePassword", ".", "toCharArray", "(", ")", ")", ";", "KeyManagerFactory", "kmf", "=", "KeyManagerFactory", ".", "getInstance", "(", "KeyManagerFactory", ".", "getDefaultAlgorithm", "(", ")", ")", ";", "kmf", ".", "init", "(", "ks", ",", "keystorePassword", ".", "toCharArray", "(", ")", ")", ";", "SSLContext", "ctx", "=", "SSLContext", ".", "getInstance", "(", "\"SSL\"", ")", ";", "ctx", ".", "init", "(", "kmf", ".", "getKeyManagers", "(", ")", ",", "tmf", ".", "getTrustManagers", "(", ")", ",", "new", "SecureRandom", "(", ")", ")", ";", "return", "ctx", ";", "}" ]
Build an SSLContext from the given truststore and keystore parameters.
[ "Build", "an", "SSLContext", "from", "the", "given", "truststore", "and", "keystore", "parameters", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLService.java#L380-L400
138,221
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLService.java
CQLService.connectToCluster
private void connectToCluster() { assert m_cluster != null; try { m_cluster.init(); // force connection and throw if unavailable m_session = m_cluster.connect(); displayClusterInfo(); } catch (Exception e) { m_logger.error("Could not connect to Cassandra cluster", e); throw new DBNotAvailableException(e); } }
java
private void connectToCluster() { assert m_cluster != null; try { m_cluster.init(); // force connection and throw if unavailable m_session = m_cluster.connect(); displayClusterInfo(); } catch (Exception e) { m_logger.error("Could not connect to Cassandra cluster", e); throw new DBNotAvailableException(e); } }
[ "private", "void", "connectToCluster", "(", ")", "{", "assert", "m_cluster", "!=", "null", ";", "try", "{", "m_cluster", ".", "init", "(", ")", ";", "// force connection and throw if unavailable", "m_session", "=", "m_cluster", ".", "connect", "(", ")", ";", "displayClusterInfo", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "m_logger", ".", "error", "(", "\"Could not connect to Cassandra cluster\"", ",", "e", ")", ";", "throw", "new", "DBNotAvailableException", "(", "e", ")", ";", "}", "}" ]
Attempt to connect to the given cluster and throw if it is unavailable.
[ "Attempt", "to", "connect", "to", "the", "given", "cluster", "and", "throw", "if", "it", "is", "unavailable", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLService.java#L403-L413
138,222
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLService.java
CQLService.displayClusterInfo
private void displayClusterInfo() { Metadata metadata = m_cluster.getMetadata(); m_logger.info("Connected to cluster with topography:"); RoundRobinPolicy policy = new RoundRobinPolicy(); for (Host host : metadata.getAllHosts()) { m_logger.info(" Host {}: datacenter: {}, rack: {}, distance: {}", new Object[]{host.getAddress(), host.getDatacenter(), host.getRack(), policy.distance(host)}); } m_logger.info("Database contains {} keyspaces", metadata.getKeyspaces().size()); }
java
private void displayClusterInfo() { Metadata metadata = m_cluster.getMetadata(); m_logger.info("Connected to cluster with topography:"); RoundRobinPolicy policy = new RoundRobinPolicy(); for (Host host : metadata.getAllHosts()) { m_logger.info(" Host {}: datacenter: {}, rack: {}, distance: {}", new Object[]{host.getAddress(), host.getDatacenter(), host.getRack(), policy.distance(host)}); } m_logger.info("Database contains {} keyspaces", metadata.getKeyspaces().size()); }
[ "private", "void", "displayClusterInfo", "(", ")", "{", "Metadata", "metadata", "=", "m_cluster", ".", "getMetadata", "(", ")", ";", "m_logger", ".", "info", "(", "\"Connected to cluster with topography:\"", ")", ";", "RoundRobinPolicy", "policy", "=", "new", "RoundRobinPolicy", "(", ")", ";", "for", "(", "Host", "host", ":", "metadata", ".", "getAllHosts", "(", ")", ")", "{", "m_logger", ".", "info", "(", "\" Host {}: datacenter: {}, rack: {}, distance: {}\"", ",", "new", "Object", "[", "]", "{", "host", ".", "getAddress", "(", ")", ",", "host", ".", "getDatacenter", "(", ")", ",", "host", ".", "getRack", "(", ")", ",", "policy", ".", "distance", "(", "host", ")", "}", ")", ";", "}", "m_logger", ".", "info", "(", "\"Database contains {} keyspaces\"", ",", "metadata", ".", "getKeyspaces", "(", ")", ".", "size", "(", ")", ")", ";", "}" ]
Display configuration information for the given cluster.
[ "Display", "configuration", "information", "for", "the", "given", "cluster", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLService.java#L416-L426
138,223
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRequest.java
RESTRequest.getContentType
private ContentType getContentType() { String contentTypeValue = m_request.getContentType(); if (contentTypeValue == null) { return ContentType.TEXT_XML; } return new ContentType(contentTypeValue); }
java
private ContentType getContentType() { String contentTypeValue = m_request.getContentType(); if (contentTypeValue == null) { return ContentType.TEXT_XML; } return new ContentType(contentTypeValue); }
[ "private", "ContentType", "getContentType", "(", ")", "{", "String", "contentTypeValue", "=", "m_request", ".", "getContentType", "(", ")", ";", "if", "(", "contentTypeValue", "==", "null", ")", "{", "return", "ContentType", ".", "TEXT_XML", ";", "}", "return", "new", "ContentType", "(", "contentTypeValue", ")", ";", "}" ]
Get the request's content-type, using XML as the default.
[ "Get", "the", "request", "s", "content", "-", "type", "using", "XML", "as", "the", "default", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRequest.java#L291-L297
138,224
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRequest.java
RESTRequest.getAcceptType
private ContentType getAcceptType() { // If the format header is present, it overrides the ACCEPT header. String format = m_variableMap.get("format"); if (format != null) { return new ContentType(format); } String acceptParts = m_request.getHeader(HttpDefs.ACCEPT); if (!Utils.isEmpty(acceptParts)) { for (String acceptPart : acceptParts.split(",")) { ContentType acceptType = new ContentType(acceptPart); if (acceptType.isJSON() || acceptType.isXML() || acceptType.isPlainText()) { return acceptType; } } } return getContentType(); }
java
private ContentType getAcceptType() { // If the format header is present, it overrides the ACCEPT header. String format = m_variableMap.get("format"); if (format != null) { return new ContentType(format); } String acceptParts = m_request.getHeader(HttpDefs.ACCEPT); if (!Utils.isEmpty(acceptParts)) { for (String acceptPart : acceptParts.split(",")) { ContentType acceptType = new ContentType(acceptPart); if (acceptType.isJSON() || acceptType.isXML() || acceptType.isPlainText()) { return acceptType; } } } return getContentType(); }
[ "private", "ContentType", "getAcceptType", "(", ")", "{", "// If the format header is present, it overrides the ACCEPT header.\r", "String", "format", "=", "m_variableMap", ".", "get", "(", "\"format\"", ")", ";", "if", "(", "format", "!=", "null", ")", "{", "return", "new", "ContentType", "(", "format", ")", ";", "}", "String", "acceptParts", "=", "m_request", ".", "getHeader", "(", "HttpDefs", ".", "ACCEPT", ")", ";", "if", "(", "!", "Utils", ".", "isEmpty", "(", "acceptParts", ")", ")", "{", "for", "(", "String", "acceptPart", ":", "acceptParts", ".", "split", "(", "\",\"", ")", ")", "{", "ContentType", "acceptType", "=", "new", "ContentType", "(", "acceptPart", ")", ";", "if", "(", "acceptType", ".", "isJSON", "(", ")", "||", "acceptType", ".", "isXML", "(", ")", "||", "acceptType", ".", "isPlainText", "(", ")", ")", "{", "return", "acceptType", ";", "}", "}", "}", "return", "getContentType", "(", ")", ";", "}" ]
Get the request's accept type, defaulting to content-type if none is specified.
[ "Get", "the", "request", "s", "accept", "type", "defaulting", "to", "content", "-", "type", "if", "none", "is", "specified", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRequest.java#L300-L316
138,225
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRequest.java
RESTRequest.isMessageCompressed
private boolean isMessageCompressed() { String contentEncoding = m_request.getHeader(HttpDefs.CONTENT_ENCODING); if (contentEncoding != null) { if (!contentEncoding.equalsIgnoreCase("gzip")) { throw new IllegalArgumentException("Unsupported Content-Encoding: " + contentEncoding); } return true; } return false; }
java
private boolean isMessageCompressed() { String contentEncoding = m_request.getHeader(HttpDefs.CONTENT_ENCODING); if (contentEncoding != null) { if (!contentEncoding.equalsIgnoreCase("gzip")) { throw new IllegalArgumentException("Unsupported Content-Encoding: " + contentEncoding); } return true; } return false; }
[ "private", "boolean", "isMessageCompressed", "(", ")", "{", "String", "contentEncoding", "=", "m_request", ".", "getHeader", "(", "HttpDefs", ".", "CONTENT_ENCODING", ")", ";", "if", "(", "contentEncoding", "!=", "null", ")", "{", "if", "(", "!", "contentEncoding", ".", "equalsIgnoreCase", "(", "\"gzip\"", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Unsupported Content-Encoding: \"", "+", "contentEncoding", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
If Content-Encoding is included, verify that we support it and return true.
[ "If", "Content", "-", "Encoding", "is", "included", "verify", "that", "we", "support", "it", "and", "return", "true", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRequest.java#L319-L328
138,226
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/utilities/Timer.java
Timer.stop
public long stop(long time) { m_nesting--; // not started and stopped if (m_nesting < 0){ m_nesting = 0; } if (m_nesting == 0){ long elapsedTime = time - m_startTime; m_elapsedTime += elapsedTime; return elapsedTime; } return 0; }
java
public long stop(long time) { m_nesting--; // not started and stopped if (m_nesting < 0){ m_nesting = 0; } if (m_nesting == 0){ long elapsedTime = time - m_startTime; m_elapsedTime += elapsedTime; return elapsedTime; } return 0; }
[ "public", "long", "stop", "(", "long", "time", ")", "{", "m_nesting", "--", ";", "// not started and stopped\r", "if", "(", "m_nesting", "<", "0", ")", "{", "m_nesting", "=", "0", ";", "}", "if", "(", "m_nesting", "==", "0", ")", "{", "long", "elapsedTime", "=", "time", "-", "m_startTime", ";", "m_elapsedTime", "+=", "elapsedTime", ";", "return", "elapsedTime", ";", "}", "return", "0", ";", "}" ]
Stop the timer. If timer was started, update the elapsed time.
[ "Stop", "the", "timer", ".", "If", "timer", "was", "started", "update", "the", "elapsed", "time", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/utilities/Timer.java#L52-L64
138,227
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java
ScalarFieldUpdater.addValuesForField
@Override public void addValuesForField() { FieldDefinition fieldDef = m_tableDef.getFieldDef(m_fieldName); if (fieldDef == null || !fieldDef.isCollection()) { addSVScalar(); } else { addMVScalar(); } }
java
@Override public void addValuesForField() { FieldDefinition fieldDef = m_tableDef.getFieldDef(m_fieldName); if (fieldDef == null || !fieldDef.isCollection()) { addSVScalar(); } else { addMVScalar(); } }
[ "@", "Override", "public", "void", "addValuesForField", "(", ")", "{", "FieldDefinition", "fieldDef", "=", "m_tableDef", ".", "getFieldDef", "(", "m_fieldName", ")", ";", "if", "(", "fieldDef", "==", "null", "||", "!", "fieldDef", ".", "isCollection", "(", ")", ")", "{", "addSVScalar", "(", ")", ";", "}", "else", "{", "addMVScalar", "(", ")", ";", "}", "}" ]
Add scalar value to object record; add term columns for indexed tokens.
[ "Add", "scalar", "value", "to", "object", "record", ";", "add", "term", "columns", "for", "indexed", "tokens", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java#L42-L50
138,228
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java
ScalarFieldUpdater.mergeMVFieldValues
public static Set<String> mergeMVFieldValues(Collection<String> currValueSet, Collection<String> removeValueSet, Collection<String> newValueSet) { Set<String> resultSet = new HashSet<>(); if (currValueSet != null) { resultSet.addAll(currValueSet); } if (removeValueSet != null) { resultSet.removeAll(removeValueSet); } if (newValueSet != null) { resultSet.addAll(newValueSet); } return resultSet; }
java
public static Set<String> mergeMVFieldValues(Collection<String> currValueSet, Collection<String> removeValueSet, Collection<String> newValueSet) { Set<String> resultSet = new HashSet<>(); if (currValueSet != null) { resultSet.addAll(currValueSet); } if (removeValueSet != null) { resultSet.removeAll(removeValueSet); } if (newValueSet != null) { resultSet.addAll(newValueSet); } return resultSet; }
[ "public", "static", "Set", "<", "String", ">", "mergeMVFieldValues", "(", "Collection", "<", "String", ">", "currValueSet", ",", "Collection", "<", "String", ">", "removeValueSet", ",", "Collection", "<", "String", ">", "newValueSet", ")", "{", "Set", "<", "String", ">", "resultSet", "=", "new", "HashSet", "<>", "(", ")", ";", "if", "(", "currValueSet", "!=", "null", ")", "{", "resultSet", ".", "addAll", "(", "currValueSet", ")", ";", "}", "if", "(", "removeValueSet", "!=", "null", ")", "{", "resultSet", ".", "removeAll", "(", "removeValueSet", ")", ";", "}", "if", "(", "newValueSet", "!=", "null", ")", "{", "resultSet", ".", "addAll", "(", "newValueSet", ")", ";", "}", "return", "resultSet", ";", "}" ]
Merge the given current, remove, and new MV field values into a new set.
[ "Merge", "the", "given", "current", "remove", "and", "new", "MV", "field", "values", "into", "a", "new", "set", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java#L71-L85
138,229
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java
ScalarFieldUpdater.addFieldTermReferences
private void addFieldTermReferences(Set<String> termSet) { Map<String, Set<String>> fieldTermRefsMap = new HashMap<String, Set<String>>(); fieldTermRefsMap.put(m_fieldName, termSet); m_dbTran.addTermReferences(m_tableDef, m_tableDef.getShardNumber(m_dbObj), fieldTermRefsMap); }
java
private void addFieldTermReferences(Set<String> termSet) { Map<String, Set<String>> fieldTermRefsMap = new HashMap<String, Set<String>>(); fieldTermRefsMap.put(m_fieldName, termSet); m_dbTran.addTermReferences(m_tableDef, m_tableDef.getShardNumber(m_dbObj), fieldTermRefsMap); }
[ "private", "void", "addFieldTermReferences", "(", "Set", "<", "String", ">", "termSet", ")", "{", "Map", "<", "String", ",", "Set", "<", "String", ">", ">", "fieldTermRefsMap", "=", "new", "HashMap", "<", "String", ",", "Set", "<", "String", ">", ">", "(", ")", ";", "fieldTermRefsMap", ".", "put", "(", "m_fieldName", ",", "termSet", ")", ";", "m_dbTran", ".", "addTermReferences", "(", "m_tableDef", ",", "m_tableDef", ".", "getShardNumber", "(", "m_dbObj", ")", ",", "fieldTermRefsMap", ")", ";", "}" ]
Add references to the given terms for used for this field.
[ "Add", "references", "to", "the", "given", "terms", "for", "used", "for", "this", "field", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java#L95-L99
138,230
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java
ScalarFieldUpdater.addMVScalar
private void addMVScalar() { Set<String> values = new HashSet<>(m_dbObj.getFieldValues(m_fieldName)); String fieldValue = Utils.concatenate(values, CommonDefs.MV_SCALAR_SEP_CHAR); m_dbTran.addScalarValueColumn(m_tableDef, m_dbObj.getObjectID(), m_fieldName, fieldValue); addTermColumns(fieldValue); }
java
private void addMVScalar() { Set<String> values = new HashSet<>(m_dbObj.getFieldValues(m_fieldName)); String fieldValue = Utils.concatenate(values, CommonDefs.MV_SCALAR_SEP_CHAR); m_dbTran.addScalarValueColumn(m_tableDef, m_dbObj.getObjectID(), m_fieldName, fieldValue); addTermColumns(fieldValue); }
[ "private", "void", "addMVScalar", "(", ")", "{", "Set", "<", "String", ">", "values", "=", "new", "HashSet", "<>", "(", "m_dbObj", ".", "getFieldValues", "(", "m_fieldName", ")", ")", ";", "String", "fieldValue", "=", "Utils", ".", "concatenate", "(", "values", ",", "CommonDefs", ".", "MV_SCALAR_SEP_CHAR", ")", ";", "m_dbTran", ".", "addScalarValueColumn", "(", "m_tableDef", ",", "m_dbObj", ".", "getObjectID", "(", ")", ",", "m_fieldName", ",", "fieldValue", ")", ";", "addTermColumns", "(", "fieldValue", ")", ";", "}" ]
Add new MV scalar field.
[ "Add", "new", "MV", "scalar", "field", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java#L102-L107
138,231
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java
ScalarFieldUpdater.addSVScalar
private void addSVScalar() { String fieldValue = m_dbObj.getFieldValue(m_fieldName); m_dbTran.addScalarValueColumn(m_tableDef, m_dbObj.getObjectID(), m_fieldName, fieldValue); addTermColumns(fieldValue); }
java
private void addSVScalar() { String fieldValue = m_dbObj.getFieldValue(m_fieldName); m_dbTran.addScalarValueColumn(m_tableDef, m_dbObj.getObjectID(), m_fieldName, fieldValue); addTermColumns(fieldValue); }
[ "private", "void", "addSVScalar", "(", ")", "{", "String", "fieldValue", "=", "m_dbObj", ".", "getFieldValue", "(", "m_fieldName", ")", ";", "m_dbTran", ".", "addScalarValueColumn", "(", "m_tableDef", ",", "m_dbObj", ".", "getObjectID", "(", ")", ",", "m_fieldName", ",", "fieldValue", ")", ";", "addTermColumns", "(", "fieldValue", ")", ";", "}" ]
Add new SV scalar field.
[ "Add", "new", "SV", "scalar", "field", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java#L110-L114
138,232
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java
ScalarFieldUpdater.addTermColumns
private void addTermColumns(String fieldValue) { Set<String> termSet = tokenize(fieldValue); indexTerms(termSet); addFieldTermReferences(termSet); addFieldReference(); }
java
private void addTermColumns(String fieldValue) { Set<String> termSet = tokenize(fieldValue); indexTerms(termSet); addFieldTermReferences(termSet); addFieldReference(); }
[ "private", "void", "addTermColumns", "(", "String", "fieldValue", ")", "{", "Set", "<", "String", ">", "termSet", "=", "tokenize", "(", "fieldValue", ")", ";", "indexTerms", "(", "termSet", ")", ";", "addFieldTermReferences", "(", "termSet", ")", ";", "addFieldReference", "(", ")", ";", "}" ]
Add all Terms columns needed for our scalar field.
[ "Add", "all", "Terms", "columns", "needed", "for", "our", "scalar", "field", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java#L117-L122
138,233
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java
ScalarFieldUpdater.indexTerms
private void indexTerms(Set<String> termSet) { for (String term : termSet) { m_dbTran.addTermIndexColumn(m_tableDef, m_dbObj, m_fieldName, term); } }
java
private void indexTerms(Set<String> termSet) { for (String term : termSet) { m_dbTran.addTermIndexColumn(m_tableDef, m_dbObj, m_fieldName, term); } }
[ "private", "void", "indexTerms", "(", "Set", "<", "String", ">", "termSet", ")", "{", "for", "(", "String", "term", ":", "termSet", ")", "{", "m_dbTran", ".", "addTermIndexColumn", "(", "m_tableDef", ",", "m_dbObj", ",", "m_fieldName", ",", "term", ")", ";", "}", "}" ]
Tokenize the given field with the appropriate analyzer and add Terms columns for each term.
[ "Tokenize", "the", "given", "field", "with", "the", "appropriate", "analyzer", "and", "add", "Terms", "columns", "for", "each", "term", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java#L125-L129
138,234
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java
ScalarFieldUpdater.tokenize
private Set<String> tokenize(String fieldValue) { FieldAnalyzer analyzer = FieldAnalyzer.findAnalyzer(m_tableDef, m_fieldName); return analyzer.extractTerms(fieldValue); }
java
private Set<String> tokenize(String fieldValue) { FieldAnalyzer analyzer = FieldAnalyzer.findAnalyzer(m_tableDef, m_fieldName); return analyzer.extractTerms(fieldValue); }
[ "private", "Set", "<", "String", ">", "tokenize", "(", "String", "fieldValue", ")", "{", "FieldAnalyzer", "analyzer", "=", "FieldAnalyzer", ".", "findAnalyzer", "(", "m_tableDef", ",", "m_fieldName", ")", ";", "return", "analyzer", ".", "extractTerms", "(", "fieldValue", ")", ";", "}" ]
Tokenize the given field value with the appropriate analyzer.
[ "Tokenize", "the", "given", "field", "value", "with", "the", "appropriate", "analyzer", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java#L149-L152
138,235
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java
ScalarFieldUpdater.updateSVScalar
private boolean updateSVScalar(String currentValue) { String newValue = m_dbObj.getFieldValue(m_fieldName); boolean bUpdated = false; if (Utils.isEmpty(newValue)) { if (!Utils.isEmpty(currentValue)) { m_dbTran.deleteScalarValueColumn(m_tableDef, m_dbObj.getObjectID(), m_fieldName); unindexTerms(currentValue); bUpdated = true; } } else if (!newValue.equals(currentValue)) { updateScalarReplaceValue(currentValue, newValue); bUpdated = true; } return bUpdated; }
java
private boolean updateSVScalar(String currentValue) { String newValue = m_dbObj.getFieldValue(m_fieldName); boolean bUpdated = false; if (Utils.isEmpty(newValue)) { if (!Utils.isEmpty(currentValue)) { m_dbTran.deleteScalarValueColumn(m_tableDef, m_dbObj.getObjectID(), m_fieldName); unindexTerms(currentValue); bUpdated = true; } } else if (!newValue.equals(currentValue)) { updateScalarReplaceValue(currentValue, newValue); bUpdated = true; } return bUpdated; }
[ "private", "boolean", "updateSVScalar", "(", "String", "currentValue", ")", "{", "String", "newValue", "=", "m_dbObj", ".", "getFieldValue", "(", "m_fieldName", ")", ";", "boolean", "bUpdated", "=", "false", ";", "if", "(", "Utils", ".", "isEmpty", "(", "newValue", ")", ")", "{", "if", "(", "!", "Utils", ".", "isEmpty", "(", "currentValue", ")", ")", "{", "m_dbTran", ".", "deleteScalarValueColumn", "(", "m_tableDef", ",", "m_dbObj", ".", "getObjectID", "(", ")", ",", "m_fieldName", ")", ";", "unindexTerms", "(", "currentValue", ")", ";", "bUpdated", "=", "true", ";", "}", "}", "else", "if", "(", "!", "newValue", ".", "equals", "(", "currentValue", ")", ")", "{", "updateScalarReplaceValue", "(", "currentValue", ",", "newValue", ")", ";", "bUpdated", "=", "true", ";", "}", "return", "bUpdated", ";", "}" ]
Replace our SV scalar's value.
[ "Replace", "our", "SV", "scalar", "s", "value", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java#L155-L169
138,236
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java
ScalarFieldUpdater.updateMVScalar
private boolean updateMVScalar(String currentValue) { boolean bUpdated = false; Set<String> currentValues = Utils.split(currentValue, CommonDefs.MV_SCALAR_SEP_CHAR); Set<String> newValueSet = mergeMVFieldValues(currentValues, m_dbObj.getRemoveValues(m_fieldName), m_dbObj.getFieldValues(m_fieldName)); String newValue = Utils.concatenate(newValueSet, CommonDefs.MV_SCALAR_SEP_CHAR); if (!newValue.equals(currentValue)) { if (newValue.length() == 0) { m_dbTran.deleteScalarValueColumn(m_tableDef, m_dbObj.getObjectID(), m_fieldName); unindexTerms(currentValue); } else { updateScalarReplaceValue(currentValue, newValue); } bUpdated = true; } return bUpdated; }
java
private boolean updateMVScalar(String currentValue) { boolean bUpdated = false; Set<String> currentValues = Utils.split(currentValue, CommonDefs.MV_SCALAR_SEP_CHAR); Set<String> newValueSet = mergeMVFieldValues(currentValues, m_dbObj.getRemoveValues(m_fieldName), m_dbObj.getFieldValues(m_fieldName)); String newValue = Utils.concatenate(newValueSet, CommonDefs.MV_SCALAR_SEP_CHAR); if (!newValue.equals(currentValue)) { if (newValue.length() == 0) { m_dbTran.deleteScalarValueColumn(m_tableDef, m_dbObj.getObjectID(), m_fieldName); unindexTerms(currentValue); } else { updateScalarReplaceValue(currentValue, newValue); } bUpdated = true; } return bUpdated; }
[ "private", "boolean", "updateMVScalar", "(", "String", "currentValue", ")", "{", "boolean", "bUpdated", "=", "false", ";", "Set", "<", "String", ">", "currentValues", "=", "Utils", ".", "split", "(", "currentValue", ",", "CommonDefs", ".", "MV_SCALAR_SEP_CHAR", ")", ";", "Set", "<", "String", ">", "newValueSet", "=", "mergeMVFieldValues", "(", "currentValues", ",", "m_dbObj", ".", "getRemoveValues", "(", "m_fieldName", ")", ",", "m_dbObj", ".", "getFieldValues", "(", "m_fieldName", ")", ")", ";", "String", "newValue", "=", "Utils", ".", "concatenate", "(", "newValueSet", ",", "CommonDefs", ".", "MV_SCALAR_SEP_CHAR", ")", ";", "if", "(", "!", "newValue", ".", "equals", "(", "currentValue", ")", ")", "{", "if", "(", "newValue", ".", "length", "(", ")", "==", "0", ")", "{", "m_dbTran", ".", "deleteScalarValueColumn", "(", "m_tableDef", ",", "m_dbObj", ".", "getObjectID", "(", ")", ",", "m_fieldName", ")", ";", "unindexTerms", "(", "currentValue", ")", ";", "}", "else", "{", "updateScalarReplaceValue", "(", "currentValue", ",", "newValue", ")", ";", "}", "bUpdated", "=", "true", ";", "}", "return", "bUpdated", ";", "}" ]
where ~ is the MV value separator.
[ "where", "~", "is", "the", "MV", "value", "separator", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java#L174-L191
138,237
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java
ScalarFieldUpdater.updateScalarReplaceValue
private void updateScalarReplaceValue(String currentValue, String newValue) { m_dbTran.addScalarValueColumn(m_tableDef, m_dbObj.getObjectID(), m_fieldName, newValue); Set<String> currTermSet = tokenize(Utils.isEmpty(currentValue) ? "" : currentValue); Set<String> newTermSet = tokenize(newValue); for (String term : currTermSet) { if (!newTermSet.remove(term)) { unindexTerm(term); } } indexTerms(newTermSet); addFieldTermReferences(newTermSet); if (Utils.isEmpty(currentValue)) { addFieldReference(); } }
java
private void updateScalarReplaceValue(String currentValue, String newValue) { m_dbTran.addScalarValueColumn(m_tableDef, m_dbObj.getObjectID(), m_fieldName, newValue); Set<String> currTermSet = tokenize(Utils.isEmpty(currentValue) ? "" : currentValue); Set<String> newTermSet = tokenize(newValue); for (String term : currTermSet) { if (!newTermSet.remove(term)) { unindexTerm(term); } } indexTerms(newTermSet); addFieldTermReferences(newTermSet); if (Utils.isEmpty(currentValue)) { addFieldReference(); } }
[ "private", "void", "updateScalarReplaceValue", "(", "String", "currentValue", ",", "String", "newValue", ")", "{", "m_dbTran", ".", "addScalarValueColumn", "(", "m_tableDef", ",", "m_dbObj", ".", "getObjectID", "(", ")", ",", "m_fieldName", ",", "newValue", ")", ";", "Set", "<", "String", ">", "currTermSet", "=", "tokenize", "(", "Utils", ".", "isEmpty", "(", "currentValue", ")", "?", "\"\"", ":", "currentValue", ")", ";", "Set", "<", "String", ">", "newTermSet", "=", "tokenize", "(", "newValue", ")", ";", "for", "(", "String", "term", ":", "currTermSet", ")", "{", "if", "(", "!", "newTermSet", ".", "remove", "(", "term", ")", ")", "{", "unindexTerm", "(", "term", ")", ";", "}", "}", "indexTerms", "(", "newTermSet", ")", ";", "addFieldTermReferences", "(", "newTermSet", ")", ";", "if", "(", "Utils", ".", "isEmpty", "(", "currentValue", ")", ")", "{", "addFieldReference", "(", ")", ";", "}", "}" ]
This works for both SV and MV scalar fields
[ "This", "works", "for", "both", "SV", "and", "MV", "scalar", "fields" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ScalarFieldUpdater.java#L195-L209
138,238
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/FieldDefinition.java
FieldDefinition.isValidFieldName
public static boolean isValidFieldName(String fieldName) { return fieldName != null && fieldName.length() > 0 && Utils.isLetter(fieldName.charAt(0)) && Utils.allAlphaNumUnderscore(fieldName); }
java
public static boolean isValidFieldName(String fieldName) { return fieldName != null && fieldName.length() > 0 && Utils.isLetter(fieldName.charAt(0)) && Utils.allAlphaNumUnderscore(fieldName); }
[ "public", "static", "boolean", "isValidFieldName", "(", "String", "fieldName", ")", "{", "return", "fieldName", "!=", "null", "&&", "fieldName", ".", "length", "(", ")", ">", "0", "&&", "Utils", ".", "isLetter", "(", "fieldName", ".", "charAt", "(", "0", ")", ")", "&&", "Utils", ".", "allAlphaNumUnderscore", "(", "fieldName", ")", ";", "}" ]
Indicate if the given field name is valid. Currently, field names must begin with a letter and consist of all letters, digits, and underscores. @param fieldName Candidate field name. @return True if the given name is valid for fields.
[ "Indicate", "if", "the", "given", "field", "name", "is", "valid", ".", "Currently", "field", "names", "must", "begin", "with", "a", "letter", "and", "consist", "of", "all", "letters", "digits", "and", "underscores", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/FieldDefinition.java#L56-L61
138,239
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/FieldDefinition.java
FieldDefinition.setTableDefinition
public void setTableDefinition(TableDefinition tableDef) { m_tableDef = tableDef; // LINK and XLINK 'table' defaults to owning table. if (m_type.isLinkType() && Utils.isEmpty(m_linkExtent)) { m_linkExtent = tableDef.getTableName(); } }
java
public void setTableDefinition(TableDefinition tableDef) { m_tableDef = tableDef; // LINK and XLINK 'table' defaults to owning table. if (m_type.isLinkType() && Utils.isEmpty(m_linkExtent)) { m_linkExtent = tableDef.getTableName(); } }
[ "public", "void", "setTableDefinition", "(", "TableDefinition", "tableDef", ")", "{", "m_tableDef", "=", "tableDef", ";", "// LINK and XLINK 'table' defaults to owning table.\r", "if", "(", "m_type", ".", "isLinkType", "(", ")", "&&", "Utils", ".", "isEmpty", "(", "m_linkExtent", ")", ")", "{", "m_linkExtent", "=", "tableDef", ".", "getTableName", "(", ")", ";", "}", "}" ]
Make the given table the owner of this field definition and any nested fields it owns. @param tableDef {@link TableDefinition} that owns this field.
[ "Make", "the", "given", "table", "the", "owner", "of", "this", "field", "definition", "and", "any", "nested", "fields", "it", "owns", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/FieldDefinition.java#L212-L219
138,240
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/FieldDefinition.java
FieldDefinition.hasNestedField
public boolean hasNestedField(String fieldName) { if (m_type != FieldType.GROUP) { return false; } return m_nestedFieldMap.containsKey(fieldName); }
java
public boolean hasNestedField(String fieldName) { if (m_type != FieldType.GROUP) { return false; } return m_nestedFieldMap.containsKey(fieldName); }
[ "public", "boolean", "hasNestedField", "(", "String", "fieldName", ")", "{", "if", "(", "m_type", "!=", "FieldType", ".", "GROUP", ")", "{", "return", "false", ";", "}", "return", "m_nestedFieldMap", ".", "containsKey", "(", "fieldName", ")", ";", "}" ]
Indicate if this group field contains an immediated-nested field with the given name. If this field is not a group, false is returned. @param fieldName Name of candidate nested field. @return True if this is a group field that contains the given name as an immediated nested field.
[ "Indicate", "if", "this", "group", "field", "contains", "an", "immediated", "-", "nested", "field", "with", "the", "given", "name", ".", "If", "this", "field", "is", "not", "a", "group", "false", "is", "returned", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/FieldDefinition.java#L495-L500
138,241
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/FieldDefinition.java
FieldDefinition.setName
public void setName(String fieldName) { if (m_name != null) { throw new IllegalArgumentException("Field name is already set: " + m_name); } if (!isValidFieldName(fieldName)) { throw new IllegalArgumentException("Invalid field name: " + fieldName); } m_name = fieldName; }
java
public void setName(String fieldName) { if (m_name != null) { throw new IllegalArgumentException("Field name is already set: " + m_name); } if (!isValidFieldName(fieldName)) { throw new IllegalArgumentException("Invalid field name: " + fieldName); } m_name = fieldName; }
[ "public", "void", "setName", "(", "String", "fieldName", ")", "{", "if", "(", "m_name", "!=", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Field name is already set: \"", "+", "m_name", ")", ";", "}", "if", "(", "!", "isValidFieldName", "(", "fieldName", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid field name: \"", "+", "fieldName", ")", ";", "}", "m_name", "=", "fieldName", ";", "}" ]
Set this field's name to the given valid. An IllegalArgumentException is thrown if the name is already assigned or is not valid. @param fieldName New name for field.
[ "Set", "this", "field", "s", "name", "to", "the", "given", "valid", ".", "An", "IllegalArgumentException", "is", "thrown", "if", "the", "name", "is", "already", "assigned", "or", "is", "not", "valid", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/FieldDefinition.java#L577-L585
138,242
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/FieldDefinition.java
FieldDefinition.verify
private void verify() { Utils.require(!Utils.isEmpty(m_name), "Field name is required"); Utils.require(m_type != null, "Field type is required"); // If an 'inverse' or 'table' was specified, type must be LINK or XLINK. Utils.require(m_linkInverse == null || m_type.isLinkType(), "'inverse' not allowed for this field type: " + m_name); Utils.require(m_linkExtent == null || m_type.isLinkType(), "'table' not allowed for this field type: " + m_name); // LINK and XLINK require an 'inverse'. Utils.require(!m_type.isLinkType() || m_linkInverse != null, "Missing 'inverse' option: " + m_name); // XLINK requires a junction field: default is "_ID". if (!Utils.isEmpty(m_junctionField)) { Utils.require(m_type == FieldType.XLINK, "'junction' is only allowed for xlinks"); } else if (m_type == FieldType.XLINK) { m_junctionField = "_ID"; } // If collection was not explicitly set, set to true for links and false for scalars if (!m_bIsCollection && m_type.isLinkType()) { m_bIsCollection = true; } // 'analyzer' can only be set for scalar field types, but don't verify value here. Utils.require(m_analyzerName == null || m_type.isScalarType(), "'analyzer' can only be specified for scalar field types: " + m_analyzerName); // If this is a binary field, ensure "encoding" is set. if (m_encoding != null) { Utils.require(m_type == FieldType.BINARY, "'encoding' is only valid for binary fields"); } else if (m_type == FieldType.BINARY) { m_encoding = EncodingType.getDefaultEncoding(); } // Binary fields cannot be collections. Utils.require(m_type != FieldType.BINARY || !m_bIsCollection, "Binary fields cannot be collections (multi-valued)"); }
java
private void verify() { Utils.require(!Utils.isEmpty(m_name), "Field name is required"); Utils.require(m_type != null, "Field type is required"); // If an 'inverse' or 'table' was specified, type must be LINK or XLINK. Utils.require(m_linkInverse == null || m_type.isLinkType(), "'inverse' not allowed for this field type: " + m_name); Utils.require(m_linkExtent == null || m_type.isLinkType(), "'table' not allowed for this field type: " + m_name); // LINK and XLINK require an 'inverse'. Utils.require(!m_type.isLinkType() || m_linkInverse != null, "Missing 'inverse' option: " + m_name); // XLINK requires a junction field: default is "_ID". if (!Utils.isEmpty(m_junctionField)) { Utils.require(m_type == FieldType.XLINK, "'junction' is only allowed for xlinks"); } else if (m_type == FieldType.XLINK) { m_junctionField = "_ID"; } // If collection was not explicitly set, set to true for links and false for scalars if (!m_bIsCollection && m_type.isLinkType()) { m_bIsCollection = true; } // 'analyzer' can only be set for scalar field types, but don't verify value here. Utils.require(m_analyzerName == null || m_type.isScalarType(), "'analyzer' can only be specified for scalar field types: " + m_analyzerName); // If this is a binary field, ensure "encoding" is set. if (m_encoding != null) { Utils.require(m_type == FieldType.BINARY, "'encoding' is only valid for binary fields"); } else if (m_type == FieldType.BINARY) { m_encoding = EncodingType.getDefaultEncoding(); } // Binary fields cannot be collections. Utils.require(m_type != FieldType.BINARY || !m_bIsCollection, "Binary fields cannot be collections (multi-valued)"); }
[ "private", "void", "verify", "(", ")", "{", "Utils", ".", "require", "(", "!", "Utils", ".", "isEmpty", "(", "m_name", ")", ",", "\"Field name is required\"", ")", ";", "Utils", ".", "require", "(", "m_type", "!=", "null", ",", "\"Field type is required\"", ")", ";", "// If an 'inverse' or 'table' was specified, type must be LINK or XLINK.\r", "Utils", ".", "require", "(", "m_linkInverse", "==", "null", "||", "m_type", ".", "isLinkType", "(", ")", ",", "\"'inverse' not allowed for this field type: \"", "+", "m_name", ")", ";", "Utils", ".", "require", "(", "m_linkExtent", "==", "null", "||", "m_type", ".", "isLinkType", "(", ")", ",", "\"'table' not allowed for this field type: \"", "+", "m_name", ")", ";", "// LINK and XLINK require an 'inverse'.\r", "Utils", ".", "require", "(", "!", "m_type", ".", "isLinkType", "(", ")", "||", "m_linkInverse", "!=", "null", ",", "\"Missing 'inverse' option: \"", "+", "m_name", ")", ";", "// XLINK requires a junction field: default is \"_ID\".\r", "if", "(", "!", "Utils", ".", "isEmpty", "(", "m_junctionField", ")", ")", "{", "Utils", ".", "require", "(", "m_type", "==", "FieldType", ".", "XLINK", ",", "\"'junction' is only allowed for xlinks\"", ")", ";", "}", "else", "if", "(", "m_type", "==", "FieldType", ".", "XLINK", ")", "{", "m_junctionField", "=", "\"_ID\"", ";", "}", "// If collection was not explicitly set, set to true for links and false for scalars\r", "if", "(", "!", "m_bIsCollection", "&&", "m_type", ".", "isLinkType", "(", ")", ")", "{", "m_bIsCollection", "=", "true", ";", "}", "// 'analyzer' can only be set for scalar field types, but don't verify value here.\r", "Utils", ".", "require", "(", "m_analyzerName", "==", "null", "||", "m_type", ".", "isScalarType", "(", ")", ",", "\"'analyzer' can only be specified for scalar field types: \"", "+", "m_analyzerName", ")", ";", "// If this is a binary field, ensure \"encoding\" is set.\r", "if", "(", "m_encoding", "!=", "null", ")", "{", "Utils", ".", "require", "(", "m_type", "==", "FieldType", ".", "BINARY", ",", "\"'encoding' is only valid for binary fields\"", ")", ";", "}", "else", "if", "(", "m_type", "==", "FieldType", ".", "BINARY", ")", "{", "m_encoding", "=", "EncodingType", ".", "getDefaultEncoding", "(", ")", ";", "}", "// Binary fields cannot be collections.\r", "Utils", ".", "require", "(", "m_type", "!=", "FieldType", ".", "BINARY", "||", "!", "m_bIsCollection", ",", "\"Binary fields cannot be collections (multi-valued)\"", ")", ";", "}" ]
Verify that this field definition is complete and coherent.
[ "Verify", "that", "this", "field", "definition", "is", "complete", "and", "coherent", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/FieldDefinition.java#L816-L856
138,243
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/utilities/BigSet.java
BigSet.delete
public void delete() { for(int i = 1; i < m_nextNo; i++) { new File(m_fileName + "_" + i).delete(); } m_nextNo = 1; }
java
public void delete() { for(int i = 1; i < m_nextNo; i++) { new File(m_fileName + "_" + i).delete(); } m_nextNo = 1; }
[ "public", "void", "delete", "(", ")", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<", "m_nextNo", ";", "i", "++", ")", "{", "new", "File", "(", "m_fileName", "+", "\"_\"", "+", "i", ")", ".", "delete", "(", ")", ";", "}", "m_nextNo", "=", "1", ";", "}" ]
Deleting data files.
[ "Deleting", "data", "files", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/utilities/BigSet.java#L106-L111
138,244
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/olap/Olap.java
Olap.getApplicationDefinition
public ApplicationDefinition getApplicationDefinition(Tenant tenant, String applicationName) { if(tenant == null) tenant = TenantService.instance().getDefaultTenant(); ApplicationDefinition appDef = SchemaService.instance().getApplication(tenant, applicationName); return appDef; }
java
public ApplicationDefinition getApplicationDefinition(Tenant tenant, String applicationName) { if(tenant == null) tenant = TenantService.instance().getDefaultTenant(); ApplicationDefinition appDef = SchemaService.instance().getApplication(tenant, applicationName); return appDef; }
[ "public", "ApplicationDefinition", "getApplicationDefinition", "(", "Tenant", "tenant", ",", "String", "applicationName", ")", "{", "if", "(", "tenant", "==", "null", ")", "tenant", "=", "TenantService", ".", "instance", "(", ")", ".", "getDefaultTenant", "(", ")", ";", "ApplicationDefinition", "appDef", "=", "SchemaService", ".", "instance", "(", ")", ".", "getApplication", "(", "tenant", ",", "applicationName", ")", ";", "return", "appDef", ";", "}" ]
If tenant is null then default tenant is used.
[ "If", "tenant", "is", "null", "then", "default", "tenant", "is", "used", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/olap/Olap.java#L148-L152
138,245
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/SSLTransportParameters.java
SSLTransportParameters.setKeyStore
public void setKeyStore(String keyStore, String keyPass, String keyManagerType, String keyStoreType) { if((keyStore == null) || (keyPass == null)) { this.keyStore = System.getProperty("javax.net.ssl.keyStore"); this.keyPass = System.getProperty("javax.net.ssl.keyStorePassword"); } else { this.keyStore = keyStore; this.keyPass = keyPass; } if (keyManagerType != null) { this.keyManagerType = keyManagerType; } if (keyStoreType != null) { this.keyStoreType = keyStoreType; } isKeyStoreSet = (keyStore != null) && (keyPass != null); }
java
public void setKeyStore(String keyStore, String keyPass, String keyManagerType, String keyStoreType) { if((keyStore == null) || (keyPass == null)) { this.keyStore = System.getProperty("javax.net.ssl.keyStore"); this.keyPass = System.getProperty("javax.net.ssl.keyStorePassword"); } else { this.keyStore = keyStore; this.keyPass = keyPass; } if (keyManagerType != null) { this.keyManagerType = keyManagerType; } if (keyStoreType != null) { this.keyStoreType = keyStoreType; } isKeyStoreSet = (keyStore != null) && (keyPass != null); }
[ "public", "void", "setKeyStore", "(", "String", "keyStore", ",", "String", "keyPass", ",", "String", "keyManagerType", ",", "String", "keyStoreType", ")", "{", "if", "(", "(", "keyStore", "==", "null", ")", "||", "(", "keyPass", "==", "null", ")", ")", "{", "this", ".", "keyStore", "=", "System", ".", "getProperty", "(", "\"javax.net.ssl.keyStore\"", ")", ";", "this", ".", "keyPass", "=", "System", ".", "getProperty", "(", "\"javax.net.ssl.keyStorePassword\"", ")", ";", "}", "else", "{", "this", ".", "keyStore", "=", "keyStore", ";", "this", ".", "keyPass", "=", "keyPass", ";", "}", "if", "(", "keyManagerType", "!=", "null", ")", "{", "this", ".", "keyManagerType", "=", "keyManagerType", ";", "}", "if", "(", "keyStoreType", "!=", "null", ")", "{", "this", ".", "keyStoreType", "=", "keyStoreType", ";", "}", "isKeyStoreSet", "=", "(", "keyStore", "!=", "null", ")", "&&", "(", "keyPass", "!=", "null", ")", ";", "}" ]
Set the keystore, password, certificate type and the store type @param keyStore Location of the Keystore on disk @param keyPass Keystore password @param keyManagerType The default is X509 @param keyStoreType The default is JKS
[ "Set", "the", "keystore", "password", "certificate", "type", "and", "the", "store", "type" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/SSLTransportParameters.java#L185-L205
138,246
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/SSLTransportParameters.java
SSLTransportParameters.setKeyStore
public void setKeyStore(String keyStore, String keyPass) { setKeyStore(keyStore, keyPass, null, null); }
java
public void setKeyStore(String keyStore, String keyPass) { setKeyStore(keyStore, keyPass, null, null); }
[ "public", "void", "setKeyStore", "(", "String", "keyStore", ",", "String", "keyPass", ")", "{", "setKeyStore", "(", "keyStore", ",", "keyPass", ",", "null", ",", "null", ")", ";", "}" ]
Set the keystore and password @param keyStore Location of the Keystore on disk @param keyPass Keystore password
[ "Set", "the", "keystore", "and", "password" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/SSLTransportParameters.java#L213-L216
138,247
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/SSLTransportParameters.java
SSLTransportParameters.setTrustStore
public void setTrustStore(String trustStore, String trustPass, String trustManagerType, String trustStoreType) { if((trustStore == null) || (trustPass == null)) { this.trustStore = System.getProperty("javax.net.ssl.trustStore"); this.trustPass = System.getProperty("javax.net.ssl.trustStorePassword"); } else { this.trustStore = trustStore; this.trustPass = trustPass; } if (trustManagerType != null) { this.trustManagerType = trustManagerType; } if (trustStoreType != null) { this.trustStoreType = trustStoreType; } isTrustStoreSet = (trustStore != null) && (trustPass != null); }
java
public void setTrustStore(String trustStore, String trustPass, String trustManagerType, String trustStoreType) { if((trustStore == null) || (trustPass == null)) { this.trustStore = System.getProperty("javax.net.ssl.trustStore"); this.trustPass = System.getProperty("javax.net.ssl.trustStorePassword"); } else { this.trustStore = trustStore; this.trustPass = trustPass; } if (trustManagerType != null) { this.trustManagerType = trustManagerType; } if (trustStoreType != null) { this.trustStoreType = trustStoreType; } isTrustStoreSet = (trustStore != null) && (trustPass != null); }
[ "public", "void", "setTrustStore", "(", "String", "trustStore", ",", "String", "trustPass", ",", "String", "trustManagerType", ",", "String", "trustStoreType", ")", "{", "if", "(", "(", "trustStore", "==", "null", ")", "||", "(", "trustPass", "==", "null", ")", ")", "{", "this", ".", "trustStore", "=", "System", ".", "getProperty", "(", "\"javax.net.ssl.trustStore\"", ")", ";", "this", ".", "trustPass", "=", "System", ".", "getProperty", "(", "\"javax.net.ssl.trustStorePassword\"", ")", ";", "}", "else", "{", "this", ".", "trustStore", "=", "trustStore", ";", "this", ".", "trustPass", "=", "trustPass", ";", "}", "if", "(", "trustManagerType", "!=", "null", ")", "{", "this", ".", "trustManagerType", "=", "trustManagerType", ";", "}", "if", "(", "trustStoreType", "!=", "null", ")", "{", "this", ".", "trustStoreType", "=", "trustStoreType", ";", "}", "isTrustStoreSet", "=", "(", "trustStore", "!=", "null", ")", "&&", "(", "trustPass", "!=", "null", ")", ";", "}" ]
Set the truststore, password, certificate type and the store type @param trustStore Location of the Truststore on disk @param trustPass Truststore password @param trustManagerType The default is X509 @param trustStoreType The default is JKS
[ "Set", "the", "truststore", "password", "certificate", "type", "and", "the", "store", "type" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/SSLTransportParameters.java#L226-L246
138,248
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/SSLTransportParameters.java
SSLTransportParameters.setTrustStore
public void setTrustStore(String trustStore, String trustPass) { setTrustStore(trustStore, trustPass, null, null); }
java
public void setTrustStore(String trustStore, String trustPass) { setTrustStore(trustStore, trustPass, null, null); }
[ "public", "void", "setTrustStore", "(", "String", "trustStore", ",", "String", "trustPass", ")", "{", "setTrustStore", "(", "trustStore", ",", "trustPass", ",", "null", ",", "null", ")", ";", "}" ]
Set the truststore and password @param trustStore Location of the Truststore on disk @param trustPass Truststore password
[ "Set", "the", "truststore", "and", "password" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/SSLTransportParameters.java#L254-L256
138,249
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RegisteredCommand.java
RegisteredCommand.compareNodes
private static int compareNodes(String node1, String node2) { assert node1 != null; assert node2 != null; if (node1.equals(node2)) { return 0; } if (node1.length() > 0 && node1.charAt(0) == '{') { if (node2.length() > 0 && node2.charAt(0) == '{') { return 0; // Both nodes are parameters; names are irrelevant } return 1; // r1 is a parameter but r2 is not, so r2 should come first } if (node2.length() > 0 && node2.charAt(0) == '{') { return -1; // r2 is a parameter but r1 is not, so r1 should come first } return node1.compareTo(node2); // neither node is a parameter }
java
private static int compareNodes(String node1, String node2) { assert node1 != null; assert node2 != null; if (node1.equals(node2)) { return 0; } if (node1.length() > 0 && node1.charAt(0) == '{') { if (node2.length() > 0 && node2.charAt(0) == '{') { return 0; // Both nodes are parameters; names are irrelevant } return 1; // r1 is a parameter but r2 is not, so r2 should come first } if (node2.length() > 0 && node2.charAt(0) == '{') { return -1; // r2 is a parameter but r1 is not, so r1 should come first } return node1.compareTo(node2); // neither node is a parameter }
[ "private", "static", "int", "compareNodes", "(", "String", "node1", ",", "String", "node2", ")", "{", "assert", "node1", "!=", "null", ";", "assert", "node2", "!=", "null", ";", "if", "(", "node1", ".", "equals", "(", "node2", ")", ")", "{", "return", "0", ";", "}", "if", "(", "node1", ".", "length", "(", ")", ">", "0", "&&", "node1", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "if", "(", "node2", ".", "length", "(", ")", ">", "0", "&&", "node2", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "return", "0", ";", "// Both nodes are parameters; names are irrelevant", "}", "return", "1", ";", "// r1 is a parameter but r2 is not, so r2 should come first", "}", "if", "(", "node2", ".", "length", "(", ")", ">", "0", "&&", "node2", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "return", "-", "1", ";", "// r2 is a parameter but r1 is not, so r1 should come first", "}", "return", "node1", ".", "compareTo", "(", "node2", ")", ";", "// neither node is a parameter", "}" ]
path nodes are query parameters. Either node can be empty, but not null.
[ "path", "nodes", "are", "query", "parameters", ".", "Either", "node", "can", "be", "empty", "but", "not", "null", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RegisteredCommand.java#L223-L240
138,250
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RegisteredCommand.java
RegisteredCommand.matches
private static boolean matches(String value, String component, Map<String, String> variableMap) { if (Utils.isEmpty(component)) { return Utils.isEmpty(value); } if (component.charAt(0) == '{') { // The component is a variable, so it always matches. if (!Utils.isEmpty(value)) { String varName = getVariableName(component); variableMap.put(varName, value); } return true; } return component.equals(value); }
java
private static boolean matches(String value, String component, Map<String, String> variableMap) { if (Utils.isEmpty(component)) { return Utils.isEmpty(value); } if (component.charAt(0) == '{') { // The component is a variable, so it always matches. if (!Utils.isEmpty(value)) { String varName = getVariableName(component); variableMap.put(varName, value); } return true; } return component.equals(value); }
[ "private", "static", "boolean", "matches", "(", "String", "value", ",", "String", "component", ",", "Map", "<", "String", ",", "String", ">", "variableMap", ")", "{", "if", "(", "Utils", ".", "isEmpty", "(", "component", ")", ")", "{", "return", "Utils", ".", "isEmpty", "(", "value", ")", ";", "}", "if", "(", "component", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "// The component is a variable, so it always matches.", "if", "(", "!", "Utils", ".", "isEmpty", "(", "value", ")", ")", "{", "String", "varName", "=", "getVariableName", "(", "component", ")", ";", "variableMap", ".", "put", "(", "varName", ",", "value", ")", ";", "}", "return", "true", ";", "}", "return", "component", ".", "equals", "(", "value", ")", ";", "}" ]
variable value is extracted and added to the given map.
[ "variable", "value", "is", "extracted", "and", "added", "to", "the", "given", "map", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RegisteredCommand.java#L245-L258
138,251
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RegisteredCommand.java
RegisteredCommand.getVariableName
private static String getVariableName(String value) { assert value.charAt(0) == '{'; assert value.charAt(value.length() - 1) == '}'; return value.substring(1, value.length() - 1); }
java
private static String getVariableName(String value) { assert value.charAt(0) == '{'; assert value.charAt(value.length() - 1) == '}'; return value.substring(1, value.length() - 1); }
[ "private", "static", "String", "getVariableName", "(", "String", "value", ")", "{", "assert", "value", ".", "charAt", "(", "0", ")", "==", "'", "'", ";", "assert", "value", ".", "charAt", "(", "value", ".", "length", "(", ")", "-", "1", ")", "==", "'", "'", ";", "return", "value", ".", "substring", "(", "1", ",", "value", ".", "length", "(", ")", "-", "1", ")", ";", "}" ]
thrown if the trailing '}' is missing.
[ "thrown", "if", "the", "trailing", "}", "is", "missing", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RegisteredCommand.java#L263-L267
138,252
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RegisteredCommand.java
RegisteredCommand.findParamDescMethods
private void findParamDescMethods() { for (Method method : m_commandClass.getMethods()) { if (method.isAnnotationPresent(ParamDescription.class)) { try { RESTParameter cmdParam = (RESTParameter) method.invoke(null, (Object[])null); addParameter(cmdParam); } catch (Exception e) { LOGGER.warn("Method '{}' for class '{}' could not be invoked: {}", new Object[]{method.getName(), m_commandClass.getName(), e.toString()}); } } } }
java
private void findParamDescMethods() { for (Method method : m_commandClass.getMethods()) { if (method.isAnnotationPresent(ParamDescription.class)) { try { RESTParameter cmdParam = (RESTParameter) method.invoke(null, (Object[])null); addParameter(cmdParam); } catch (Exception e) { LOGGER.warn("Method '{}' for class '{}' could not be invoked: {}", new Object[]{method.getName(), m_commandClass.getName(), e.toString()}); } } } }
[ "private", "void", "findParamDescMethods", "(", ")", "{", "for", "(", "Method", "method", ":", "m_commandClass", ".", "getMethods", "(", ")", ")", "{", "if", "(", "method", ".", "isAnnotationPresent", "(", "ParamDescription", ".", "class", ")", ")", "{", "try", "{", "RESTParameter", "cmdParam", "=", "(", "RESTParameter", ")", "method", ".", "invoke", "(", "null", ",", "(", "Object", "[", "]", ")", "null", ")", ";", "addParameter", "(", "cmdParam", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOGGER", ".", "warn", "(", "\"Method '{}' for class '{}' could not be invoked: {}\"", ",", "new", "Object", "[", "]", "{", "method", ".", "getName", "(", ")", ",", "m_commandClass", ".", "getName", "(", ")", ",", "e", ".", "toString", "(", ")", "}", ")", ";", "}", "}", "}", "}" ]
Look for ParamDescription annotations and attempt to call each annotated method.
[ "Look", "for", "ParamDescription", "annotations", "and", "attempt", "to", "call", "each", "annotated", "method", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RegisteredCommand.java#L276-L288
138,253
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RegisteredCommand.java
RegisteredCommand.createCommandDescription
private void createCommandDescription(Description descAnnotation) { setName(descAnnotation.name()); setSummary(descAnnotation.summary()); setMethods(descAnnotation.methods()); setURI(descAnnotation.uri()); setInputEntity(descAnnotation.inputEntity()); setOutputEntity(descAnnotation.outputEntity()); setPrivileged(descAnnotation.privileged()); setVisibility(descAnnotation.visible()); }
java
private void createCommandDescription(Description descAnnotation) { setName(descAnnotation.name()); setSummary(descAnnotation.summary()); setMethods(descAnnotation.methods()); setURI(descAnnotation.uri()); setInputEntity(descAnnotation.inputEntity()); setOutputEntity(descAnnotation.outputEntity()); setPrivileged(descAnnotation.privileged()); setVisibility(descAnnotation.visible()); }
[ "private", "void", "createCommandDescription", "(", "Description", "descAnnotation", ")", "{", "setName", "(", "descAnnotation", ".", "name", "(", ")", ")", ";", "setSummary", "(", "descAnnotation", ".", "summary", "(", ")", ")", ";", "setMethods", "(", "descAnnotation", ".", "methods", "(", ")", ")", ";", "setURI", "(", "descAnnotation", ".", "uri", "(", ")", ")", ";", "setInputEntity", "(", "descAnnotation", ".", "inputEntity", "(", ")", ")", ";", "setOutputEntity", "(", "descAnnotation", ".", "outputEntity", "(", ")", ")", ";", "setPrivileged", "(", "descAnnotation", ".", "privileged", "(", ")", ")", ";", "setVisibility", "(", "descAnnotation", ".", "visible", "(", ")", ")", ";", "}" ]
Create a CommandDescription object for the given Description annotation.
[ "Create", "a", "CommandDescription", "object", "for", "the", "given", "Description", "annotation", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RegisteredCommand.java#L303-L312
138,254
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java
DoradusClient.open
public static DoradusClient open(String host, int port, Credentials credentials, String applicationName) { DoradusClient doradusClient = new DoradusClient(host, port, null, credentials, applicationName); doradusClient.setCredentials(credentials); String storageService = lookupStorageServiceByApp(doradusClient.getRestClient(), applicationName); doradusClient.setStorageService(storageService); return doradusClient; }
java
public static DoradusClient open(String host, int port, Credentials credentials, String applicationName) { DoradusClient doradusClient = new DoradusClient(host, port, null, credentials, applicationName); doradusClient.setCredentials(credentials); String storageService = lookupStorageServiceByApp(doradusClient.getRestClient(), applicationName); doradusClient.setStorageService(storageService); return doradusClient; }
[ "public", "static", "DoradusClient", "open", "(", "String", "host", ",", "int", "port", ",", "Credentials", "credentials", ",", "String", "applicationName", ")", "{", "DoradusClient", "doradusClient", "=", "new", "DoradusClient", "(", "host", ",", "port", ",", "null", ",", "credentials", ",", "applicationName", ")", ";", "doradusClient", ".", "setCredentials", "(", "credentials", ")", ";", "String", "storageService", "=", "lookupStorageServiceByApp", "(", "doradusClient", ".", "getRestClient", "(", ")", ",", "applicationName", ")", ";", "doradusClient", ".", "setStorageService", "(", "storageService", ")", ";", "return", "doradusClient", ";", "}" ]
Static factory method to open a 'dory' client session @param host Doradus Server host name or IP address. @param port Doradus Server port number. @param applicationName @return the instance of the DoradusClient session
[ "Static", "factory", "method", "to", "open", "a", "dory", "client", "session" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java#L79-L85
138,255
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java
DoradusClient.setApplication
public void setApplication(String appName) { applicationName = appName; String storageService = lookupStorageServiceByApp(getRestClient(), applicationName); setStorageService(storageService); }
java
public void setApplication(String appName) { applicationName = appName; String storageService = lookupStorageServiceByApp(getRestClient(), applicationName); setStorageService(storageService); }
[ "public", "void", "setApplication", "(", "String", "appName", ")", "{", "applicationName", "=", "appName", ";", "String", "storageService", "=", "lookupStorageServiceByApp", "(", "getRestClient", "(", ")", ",", "applicationName", ")", ";", "setStorageService", "(", "storageService", ")", ";", "}" ]
Set the given application name as context for all future commands. This method can be used when an application name was not given in a constructor. @param appName Application name that is used for application-specific commands called from this point forward.
[ "Set", "the", "given", "application", "name", "as", "context", "for", "all", "future", "commands", ".", "This", "method", "can", "be", "used", "when", "an", "application", "name", "was", "not", "given", "in", "a", "constructor", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java#L94-L98
138,256
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java
DoradusClient.setCredentials
public void setCredentials(String tenant, String username, String userpassword) { Credentials credentials = new Credentials(tenant, username, userpassword); restClient.setCredentials(credentials); }
java
public void setCredentials(String tenant, String username, String userpassword) { Credentials credentials = new Credentials(tenant, username, userpassword); restClient.setCredentials(credentials); }
[ "public", "void", "setCredentials", "(", "String", "tenant", ",", "String", "username", ",", "String", "userpassword", ")", "{", "Credentials", "credentials", "=", "new", "Credentials", "(", "tenant", ",", "username", ",", "userpassword", ")", ";", "restClient", ".", "setCredentials", "(", "credentials", ")", ";", "}" ]
Set credentials such as tenant, username, password for use with a Doradus application. @param tenant tenant name @param username user name use when accessing applications within the specified tenant. @param userpassword user password
[ "Set", "credentials", "such", "as", "tenant", "username", "password", "for", "use", "with", "a", "Doradus", "application", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java#L114-L117
138,257
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java
DoradusClient.listCommands
public Map<String, List<String>> listCommands() { Map<String, List<String>> result = new HashMap<String, List<String>>(); for (String cat : restMetadataJson.keySet()) { JsonObject commands = restMetadataJson.getJsonObject(cat); List<String> names = new ArrayList<String>(); for (String commandName: commands.keySet()) { names.add(commandName); } result.put(cat, names); } return result; }
java
public Map<String, List<String>> listCommands() { Map<String, List<String>> result = new HashMap<String, List<String>>(); for (String cat : restMetadataJson.keySet()) { JsonObject commands = restMetadataJson.getJsonObject(cat); List<String> names = new ArrayList<String>(); for (String commandName: commands.keySet()) { names.add(commandName); } result.put(cat, names); } return result; }
[ "public", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "listCommands", "(", ")", "{", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "result", "=", "new", "HashMap", "<", "String", ",", "List", "<", "String", ">", ">", "(", ")", ";", "for", "(", "String", "cat", ":", "restMetadataJson", ".", "keySet", "(", ")", ")", "{", "JsonObject", "commands", "=", "restMetadataJson", ".", "getJsonObject", "(", "cat", ")", ";", "List", "<", "String", ">", "names", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "commandName", ":", "commands", ".", "keySet", "(", ")", ")", "{", "names", ".", "add", "(", "commandName", ")", ";", "}", "result", ".", "put", "(", "cat", ",", "names", ")", ";", "}", "return", "result", ";", "}" ]
Retrieve the map of commands keyed by service name @return map of commands
[ "Retrieve", "the", "map", "of", "commands", "keyed", "by", "service", "name" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java#L131-L142
138,258
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java
DoradusClient.describeCommand
public JsonObject describeCommand(String service, String command) { return Command.matchCommand(restMetadataJson, command, service); }
java
public JsonObject describeCommand(String service, String command) { return Command.matchCommand(restMetadataJson, command, service); }
[ "public", "JsonObject", "describeCommand", "(", "String", "service", ",", "String", "command", ")", "{", "return", "Command", ".", "matchCommand", "(", "restMetadataJson", ",", "command", ",", "service", ")", ";", "}" ]
Describe command that helps give the idea what client needs to build the command @param service service name such as 'SpiderService' for application commands or '_systems' for system commands @param command command name @return JsonObject result in JSON that contains the description of the command
[ "Describe", "command", "that", "helps", "give", "the", "idea", "what", "client", "needs", "to", "build", "the", "command" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java#L151-L154
138,259
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java
DoradusClient.lookupStorageServiceByApp
private static String lookupStorageServiceByApp(RESTClient restClient, String applicationName) { Utils.require(applicationName != null, "Missing application name"); if (applicationName != null) { ApplicationDefinition appDef = Command.getAppDef(restClient, applicationName); Utils.require(appDef != null, "Unknown application: %s", applicationName); return appDef.getStorageService(); } return null; }
java
private static String lookupStorageServiceByApp(RESTClient restClient, String applicationName) { Utils.require(applicationName != null, "Missing application name"); if (applicationName != null) { ApplicationDefinition appDef = Command.getAppDef(restClient, applicationName); Utils.require(appDef != null, "Unknown application: %s", applicationName); return appDef.getStorageService(); } return null; }
[ "private", "static", "String", "lookupStorageServiceByApp", "(", "RESTClient", "restClient", ",", "String", "applicationName", ")", "{", "Utils", ".", "require", "(", "applicationName", "!=", "null", ",", "\"Missing application name\"", ")", ";", "if", "(", "applicationName", "!=", "null", ")", "{", "ApplicationDefinition", "appDef", "=", "Command", ".", "getAppDef", "(", "restClient", ",", "applicationName", ")", ";", "Utils", ".", "require", "(", "appDef", "!=", "null", ",", "\"Unknown application: %s\"", ",", "applicationName", ")", ";", "return", "appDef", ".", "getStorageService", "(", ")", ";", "}", "return", "null", ";", "}" ]
Convenient method to lookup storageService of the application @param restClient @param applicationName @return storage service name
[ "Convenient", "method", "to", "lookup", "storageService", "of", "the", "application" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java#L208-L216
138,260
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java
DoradusClient.loadRESTRulesIfNotExist
private synchronized void loadRESTRulesIfNotExist(RESTClient restClient) { if (restMetadataJson == null || restMetadataJson.isEmpty()) { restMetadataJson = loadRESTCommandsFromServer(restClient); } }
java
private synchronized void loadRESTRulesIfNotExist(RESTClient restClient) { if (restMetadataJson == null || restMetadataJson.isEmpty()) { restMetadataJson = loadRESTCommandsFromServer(restClient); } }
[ "private", "synchronized", "void", "loadRESTRulesIfNotExist", "(", "RESTClient", "restClient", ")", "{", "if", "(", "restMetadataJson", "==", "null", "||", "restMetadataJson", ".", "isEmpty", "(", ")", ")", "{", "restMetadataJson", "=", "loadRESTCommandsFromServer", "(", "restClient", ")", ";", "}", "}" ]
Load RESTRules once @param restClient
[ "Load", "RESTRules", "once" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java#L231-L235
138,261
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java
DoradusClient.loadRESTCommandsFromServer
private JsonObject loadRESTCommandsFromServer(RESTClient restClient) { RESTResponse response = null; try { response = restClient.sendRequest(HttpMethod.GET, _DESCRIBE_URI, ContentType.APPLICATION_JSON, null); } catch (IOException e) { throw new RuntimeException(e); } if (!response.getCode().isError()) { JsonReader jsonReader = Json.createReader(new StringReader(response.getBody())); JsonObject result = jsonReader.readObject().getJsonObject("commands"); jsonReader.close(); return result; } else { throw new RuntimeException("Describe command error: " + response.getBody()); } }
java
private JsonObject loadRESTCommandsFromServer(RESTClient restClient) { RESTResponse response = null; try { response = restClient.sendRequest(HttpMethod.GET, _DESCRIBE_URI, ContentType.APPLICATION_JSON, null); } catch (IOException e) { throw new RuntimeException(e); } if (!response.getCode().isError()) { JsonReader jsonReader = Json.createReader(new StringReader(response.getBody())); JsonObject result = jsonReader.readObject().getJsonObject("commands"); jsonReader.close(); return result; } else { throw new RuntimeException("Describe command error: " + response.getBody()); } }
[ "private", "JsonObject", "loadRESTCommandsFromServer", "(", "RESTClient", "restClient", ")", "{", "RESTResponse", "response", "=", "null", ";", "try", "{", "response", "=", "restClient", ".", "sendRequest", "(", "HttpMethod", ".", "GET", ",", "_DESCRIBE_URI", ",", "ContentType", ".", "APPLICATION_JSON", ",", "null", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "if", "(", "!", "response", ".", "getCode", "(", ")", ".", "isError", "(", ")", ")", "{", "JsonReader", "jsonReader", "=", "Json", ".", "createReader", "(", "new", "StringReader", "(", "response", ".", "getBody", "(", ")", ")", ")", ";", "JsonObject", "result", "=", "jsonReader", ".", "readObject", "(", ")", ".", "getJsonObject", "(", "\"commands\"", ")", ";", "jsonReader", ".", "close", "(", ")", ";", "return", "result", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Describe command error: \"", "+", "response", ".", "getBody", "(", ")", ")", ";", "}", "}" ]
Load REST commands by calling describe command @param restClient @return JsonObject that contains all the descriptions of all REST commands
[ "Load", "REST", "commands", "by", "calling", "describe", "command" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/DoradusClient.java#L243-L259
138,262
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/rest/RESTCommand.java
RESTCommand.setMethods
private void setMethods(String methodList) { String[] methodNames = methodList.trim().split(","); for (String methodName : methodNames) { HttpMethod method = HttpMethod.valueOf(methodName.trim().toUpperCase()); Utils.require(method != null, "Unknown REST method: " + methodName); m_methods.add(method); } }
java
private void setMethods(String methodList) { String[] methodNames = methodList.trim().split(","); for (String methodName : methodNames) { HttpMethod method = HttpMethod.valueOf(methodName.trim().toUpperCase()); Utils.require(method != null, "Unknown REST method: " + methodName); m_methods.add(method); } }
[ "private", "void", "setMethods", "(", "String", "methodList", ")", "{", "String", "[", "]", "methodNames", "=", "methodList", ".", "trim", "(", ")", ".", "split", "(", "\",\"", ")", ";", "for", "(", "String", "methodName", ":", "methodNames", ")", "{", "HttpMethod", "method", "=", "HttpMethod", ".", "valueOf", "(", "methodName", ".", "trim", "(", ")", ".", "toUpperCase", "(", ")", ")", ";", "Utils", ".", "require", "(", "method", "!=", "null", ",", "\"Unknown REST method: \"", "+", "methodName", ")", ";", "m_methods", ".", "add", "(", "method", ")", ";", "}", "}" ]
Set methods from a CSV list.
[ "Set", "methods", "from", "a", "CSV", "list", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/rest/RESTCommand.java#L384-L391
138,263
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/DBObject.java
DBObject.makeCopy
public DBObject makeCopy(String objID) { DBObject newObj = new DBObject(); newObj.m_valueMap.putAll(m_valueMap); newObj.setObjectID(objID); newObj.m_valueRemoveMap.putAll(m_valueRemoveMap); return newObj; }
java
public DBObject makeCopy(String objID) { DBObject newObj = new DBObject(); newObj.m_valueMap.putAll(m_valueMap); newObj.setObjectID(objID); newObj.m_valueRemoveMap.putAll(m_valueRemoveMap); return newObj; }
[ "public", "DBObject", "makeCopy", "(", "String", "objID", ")", "{", "DBObject", "newObj", "=", "new", "DBObject", "(", ")", ";", "newObj", ".", "m_valueMap", ".", "putAll", "(", "m_valueMap", ")", ";", "newObj", ".", "setObjectID", "(", "objID", ")", ";", "newObj", ".", "m_valueRemoveMap", ".", "putAll", "(", "m_valueRemoveMap", ")", ";", "return", "newObj", ";", "}" ]
Make a copy of this object with the same updates and values but with a new object ID. @param objID Object IF of new object. @return Copy of this object except for the object ID.
[ "Make", "a", "copy", "of", "this", "object", "with", "the", "same", "updates", "and", "values", "but", "with", "a", "new", "object", "ID", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/DBObject.java#L131-L137
138,264
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/DBObject.java
DBObject.getFieldNames
public Set<String> getFieldNames() { HashSet<String> result = new LinkedHashSet<>(m_valueMap.keySet()); return result; }
java
public Set<String> getFieldNames() { HashSet<String> result = new LinkedHashSet<>(m_valueMap.keySet()); return result; }
[ "public", "Set", "<", "String", ">", "getFieldNames", "(", ")", "{", "HashSet", "<", "String", ">", "result", "=", "new", "LinkedHashSet", "<>", "(", "m_valueMap", ".", "keySet", "(", ")", ")", ";", "return", "result", ";", "}" ]
Return the field names for which this DBObject has a value. The set does not include fields that have "remove" values stored. The set is copied. @return Field names for which this DBObject has a value. Empty if there are no field values for this object. @see #getUpdatedFieldNames()
[ "Return", "the", "field", "names", "for", "which", "this", "DBObject", "has", "a", "value", ".", "The", "set", "does", "not", "include", "fields", "that", "have", "remove", "values", "stored", ".", "The", "set", "is", "copied", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/DBObject.java#L149-L152
138,265
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/DBObject.java
DBObject.getRemoveValues
public Set<String> getRemoveValues(String fieldName) { Utils.require(!Utils.isEmpty(fieldName), "fieldName"); if (!m_valueRemoveMap.containsKey(fieldName)) { return null; } return new HashSet<>(m_valueRemoveMap.get(fieldName)); }
java
public Set<String> getRemoveValues(String fieldName) { Utils.require(!Utils.isEmpty(fieldName), "fieldName"); if (!m_valueRemoveMap.containsKey(fieldName)) { return null; } return new HashSet<>(m_valueRemoveMap.get(fieldName)); }
[ "public", "Set", "<", "String", ">", "getRemoveValues", "(", "String", "fieldName", ")", "{", "Utils", ".", "require", "(", "!", "Utils", ".", "isEmpty", "(", "fieldName", ")", ",", "\"fieldName\"", ")", ";", "if", "(", "!", "m_valueRemoveMap", ".", "containsKey", "(", "fieldName", ")", ")", "{", "return", "null", ";", "}", "return", "new", "HashSet", "<>", "(", "m_valueRemoveMap", ".", "get", "(", "fieldName", ")", ")", ";", "}" ]
Get all values marked for removal for the given field. The result will be null if the given field has no values to remove. Otherwise, the set is copied. @param fieldName Name of link field. @return Set of all values to be removed for the given link field, or null if there are none.
[ "Get", "all", "values", "marked", "for", "removal", "for", "the", "given", "field", ".", "The", "result", "will", "be", "null", "if", "the", "given", "field", "has", "no", "values", "to", "remove", ".", "Otherwise", "the", "set", "is", "copied", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/DBObject.java#L162-L168
138,266
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/DBObject.java
DBObject.getFieldValue
public String getFieldValue(String fieldName) { Utils.require(!Utils.isEmpty(fieldName), "fieldName"); List<String> values = m_valueMap.get(fieldName); if (values == null || values.size() == 0) { return null; } Utils.require(values.size() == 1, "Field has more than 1 value: %s", fieldName); return values.get(0); }
java
public String getFieldValue(String fieldName) { Utils.require(!Utils.isEmpty(fieldName), "fieldName"); List<String> values = m_valueMap.get(fieldName); if (values == null || values.size() == 0) { return null; } Utils.require(values.size() == 1, "Field has more than 1 value: %s", fieldName); return values.get(0); }
[ "public", "String", "getFieldValue", "(", "String", "fieldName", ")", "{", "Utils", ".", "require", "(", "!", "Utils", ".", "isEmpty", "(", "fieldName", ")", ",", "\"fieldName\"", ")", ";", "List", "<", "String", ">", "values", "=", "m_valueMap", ".", "get", "(", "fieldName", ")", ";", "if", "(", "values", "==", "null", "||", "values", ".", "size", "(", ")", "==", "0", ")", "{", "return", "null", ";", "}", "Utils", ".", "require", "(", "values", ".", "size", "(", ")", "==", "1", ",", "\"Field has more than 1 value: %s\"", ",", "fieldName", ")", ";", "return", "values", ".", "get", "(", "0", ")", ";", "}" ]
Get the single value of the field with the given name or null if no value is assigned to the given field. This method is intended to be used for fields expected to have a single value. An exception is thrown if it is called for a field with multiple values. @param fieldName Name of a field. @return Value of field for this object or null if there is none.
[ "Get", "the", "single", "value", "of", "the", "field", "with", "the", "given", "name", "or", "null", "if", "no", "value", "is", "assigned", "to", "the", "given", "field", ".", "This", "method", "is", "intended", "to", "be", "used", "for", "fields", "expected", "to", "have", "a", "single", "value", ".", "An", "exception", "is", "thrown", "if", "it", "is", "called", "for", "a", "field", "with", "multiple", "values", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/DBObject.java#L241-L250
138,267
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/DBObject.java
DBObject.isDeleted
public boolean isDeleted() { String value = getSystemField(_DELETED); return value == null ? false : Boolean.parseBoolean(value); }
java
public boolean isDeleted() { String value = getSystemField(_DELETED); return value == null ? false : Boolean.parseBoolean(value); }
[ "public", "boolean", "isDeleted", "(", ")", "{", "String", "value", "=", "getSystemField", "(", "_DELETED", ")", ";", "return", "value", "==", "null", "?", "false", ":", "Boolean", ".", "parseBoolean", "(", "value", ")", ";", "}" ]
Get this object's deleted flag, if set. @return This DBObject's deleted flag, if set through {@link #setDeleted(boolean)} or parsed from a UNode tree.
[ "Get", "this", "object", "s", "deleted", "flag", "if", "set", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/DBObject.java#L272-L275
138,268
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/DBObject.java
DBObject.addFieldValue
public void addFieldValue(String fieldName, String value) { Utils.require(!Utils.isEmpty(fieldName), "fieldName"); if (fieldName.charAt(0) == '_') { setSystemField(fieldName, value); } else { List<String> currValues = m_valueMap.get(fieldName); if (currValues == null) { currValues = new ArrayList<>(); m_valueMap.put(fieldName, currValues); } currValues.add(value); } }
java
public void addFieldValue(String fieldName, String value) { Utils.require(!Utils.isEmpty(fieldName), "fieldName"); if (fieldName.charAt(0) == '_') { setSystemField(fieldName, value); } else { List<String> currValues = m_valueMap.get(fieldName); if (currValues == null) { currValues = new ArrayList<>(); m_valueMap.put(fieldName, currValues); } currValues.add(value); } }
[ "public", "void", "addFieldValue", "(", "String", "fieldName", ",", "String", "value", ")", "{", "Utils", ".", "require", "(", "!", "Utils", ".", "isEmpty", "(", "fieldName", ")", ",", "\"fieldName\"", ")", ";", "if", "(", "fieldName", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "setSystemField", "(", "fieldName", ",", "value", ")", ";", "}", "else", "{", "List", "<", "String", ">", "currValues", "=", "m_valueMap", ".", "get", "(", "fieldName", ")", ";", "if", "(", "currValues", "==", "null", ")", "{", "currValues", "=", "new", "ArrayList", "<>", "(", ")", ";", "m_valueMap", ".", "put", "(", "fieldName", ",", "currValues", ")", ";", "}", "currValues", ".", "add", "(", "value", ")", ";", "}", "}" ]
Add the given value to the field with the given name. For a system field, its existing value, if any, is replaced. If a null or empty field is added for an SV scalar, the field is nullified. @param fieldName Name of a field. @param value Value to add to field. Ignored if null or empty.
[ "Add", "the", "given", "value", "to", "the", "field", "with", "the", "given", "name", ".", "For", "a", "system", "field", "its", "existing", "value", "if", "any", "is", "replaced", ".", "If", "a", "null", "or", "empty", "field", "is", "added", "for", "an", "SV", "scalar", "the", "field", "is", "nullified", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/DBObject.java#L403-L416
138,269
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/DBObject.java
DBObject.clearValues
public void clearValues(String fieldName) { Utils.require(!Utils.isEmpty(fieldName), "fieldName"); m_valueMap.remove(fieldName); m_valueRemoveMap.remove(fieldName); }
java
public void clearValues(String fieldName) { Utils.require(!Utils.isEmpty(fieldName), "fieldName"); m_valueMap.remove(fieldName); m_valueRemoveMap.remove(fieldName); }
[ "public", "void", "clearValues", "(", "String", "fieldName", ")", "{", "Utils", ".", "require", "(", "!", "Utils", ".", "isEmpty", "(", "fieldName", ")", ",", "\"fieldName\"", ")", ";", "m_valueMap", ".", "remove", "(", "fieldName", ")", ";", "m_valueRemoveMap", ".", "remove", "(", "fieldName", ")", ";", "}" ]
Clear all values for the given field. Both "add" and "remove" values, if any, are deleted. @param fieldName Name of a field.
[ "Clear", "all", "values", "for", "the", "given", "field", ".", "Both", "add", "and", "remove", "values", "if", "any", "are", "deleted", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/DBObject.java#L424-L428
138,270
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/DBObject.java
DBObject.parse
public DBObject parse(UNode docNode) { Utils.require(docNode != null, "docNode"); Utils.require(docNode.getName().equals("doc"), "'doc' node expected: %s", docNode.getName()); for (String fieldName : docNode.getMemberNames()) { UNode fieldValue = docNode.getMember(fieldName); parseFieldUpdate(fieldName, fieldValue); } return this; }
java
public DBObject parse(UNode docNode) { Utils.require(docNode != null, "docNode"); Utils.require(docNode.getName().equals("doc"), "'doc' node expected: %s", docNode.getName()); for (String fieldName : docNode.getMemberNames()) { UNode fieldValue = docNode.getMember(fieldName); parseFieldUpdate(fieldName, fieldValue); } return this; }
[ "public", "DBObject", "parse", "(", "UNode", "docNode", ")", "{", "Utils", ".", "require", "(", "docNode", "!=", "null", ",", "\"docNode\"", ")", ";", "Utils", ".", "require", "(", "docNode", ".", "getName", "(", ")", ".", "equals", "(", "\"doc\"", ")", ",", "\"'doc' node expected: %s\"", ",", "docNode", ".", "getName", "(", ")", ")", ";", "for", "(", "String", "fieldName", ":", "docNode", ".", "getMemberNames", "(", ")", ")", "{", "UNode", "fieldValue", "=", "docNode", ".", "getMember", "(", "fieldName", ")", ";", "parseFieldUpdate", "(", "fieldName", ",", "fieldValue", ")", ";", "}", "return", "this", ";", "}" ]
Parse an object rooted at the given "doc" UNode. All values parsed are stored in the object. An exception is thrown if the node structure is incorrect or a field has an invalid value. @param docNode Root node of a "doc" UNode structure. @return This object.
[ "Parse", "an", "object", "rooted", "at", "the", "given", "doc", "UNode", ".", "All", "values", "parsed", "are", "stored", "in", "the", "object", ".", "An", "exception", "is", "thrown", "if", "the", "node", "structure", "is", "incorrect", "or", "a", "field", "has", "an", "invalid", "value", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/DBObject.java#L438-L447
138,271
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/DBObject.java
DBObject.removeFieldValues
public void removeFieldValues(String fieldName, Collection<String> values) { Utils.require(!Utils.isEmpty(fieldName), "fieldName"); if (values != null && values.size() > 0) { List<String> valueSet = m_valueRemoveMap.get(fieldName); if (valueSet == null) { valueSet = new ArrayList<String>(); m_valueRemoveMap.put(fieldName, valueSet); } valueSet.addAll(values); } }
java
public void removeFieldValues(String fieldName, Collection<String> values) { Utils.require(!Utils.isEmpty(fieldName), "fieldName"); if (values != null && values.size() > 0) { List<String> valueSet = m_valueRemoveMap.get(fieldName); if (valueSet == null) { valueSet = new ArrayList<String>(); m_valueRemoveMap.put(fieldName, valueSet); } valueSet.addAll(values); } }
[ "public", "void", "removeFieldValues", "(", "String", "fieldName", ",", "Collection", "<", "String", ">", "values", ")", "{", "Utils", ".", "require", "(", "!", "Utils", ".", "isEmpty", "(", "fieldName", ")", ",", "\"fieldName\"", ")", ";", "if", "(", "values", "!=", "null", "&&", "values", ".", "size", "(", ")", ">", "0", ")", "{", "List", "<", "String", ">", "valueSet", "=", "m_valueRemoveMap", ".", "get", "(", "fieldName", ")", ";", "if", "(", "valueSet", "==", "null", ")", "{", "valueSet", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "m_valueRemoveMap", ".", "put", "(", "fieldName", ",", "valueSet", ")", ";", "}", "valueSet", ".", "addAll", "(", "values", ")", ";", "}", "}" ]
Add "remove" values for the given field. This method should only be called for MV scalar and link fields. When the updates in this DBObject are applied to the database, the given set of values are removed for the object. An exception is thrown if the field is not MV. If the given set of values is null or empty, this method is a no-op. @param fieldName Name of an MV field to remove" values for. @param values Collection values to remove for the field.
[ "Add", "remove", "values", "for", "the", "given", "field", ".", "This", "method", "should", "only", "be", "called", "for", "MV", "scalar", "and", "link", "fields", ".", "When", "the", "updates", "in", "this", "DBObject", "are", "applied", "to", "the", "database", "the", "given", "set", "of", "values", "are", "removed", "for", "the", "object", ".", "An", "exception", "is", "thrown", "if", "the", "field", "is", "not", "MV", ".", "If", "the", "given", "set", "of", "values", "is", "null", "or", "empty", "this", "method", "is", "a", "no", "-", "op", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/DBObject.java#L459-L469
138,272
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/DBObject.java
DBObject.leafFieldtoDoc
private void leafFieldtoDoc(UNode parentNode, String fieldName) { assert parentNode != null; Set<String> addSet = null; if (m_valueMap.containsKey(fieldName)) { addSet = new TreeSet<String>(m_valueMap.get(fieldName)); } List<String> removeSet = m_valueRemoveMap.get(fieldName); if (addSet != null && addSet.size() == 1 && removeSet == null) { parentNode.addValueNode(fieldName, addSet.iterator().next(), "field"); } else { UNode fieldNode = parentNode.addMapNode(fieldName, "field"); if (addSet != null && addSet.size() > 0) { UNode addNode = fieldNode.addArrayNode("add"); for (String value : addSet) { addNode.addValueNode("value", value); } } if (removeSet != null && removeSet.size() > 0) { UNode addNode = fieldNode.addArrayNode("remove"); for (String value : removeSet) { addNode.addValueNode("value", value); } } } }
java
private void leafFieldtoDoc(UNode parentNode, String fieldName) { assert parentNode != null; Set<String> addSet = null; if (m_valueMap.containsKey(fieldName)) { addSet = new TreeSet<String>(m_valueMap.get(fieldName)); } List<String> removeSet = m_valueRemoveMap.get(fieldName); if (addSet != null && addSet.size() == 1 && removeSet == null) { parentNode.addValueNode(fieldName, addSet.iterator().next(), "field"); } else { UNode fieldNode = parentNode.addMapNode(fieldName, "field"); if (addSet != null && addSet.size() > 0) { UNode addNode = fieldNode.addArrayNode("add"); for (String value : addSet) { addNode.addValueNode("value", value); } } if (removeSet != null && removeSet.size() > 0) { UNode addNode = fieldNode.addArrayNode("remove"); for (String value : removeSet) { addNode.addValueNode("value", value); } } } }
[ "private", "void", "leafFieldtoDoc", "(", "UNode", "parentNode", ",", "String", "fieldName", ")", "{", "assert", "parentNode", "!=", "null", ";", "Set", "<", "String", ">", "addSet", "=", "null", ";", "if", "(", "m_valueMap", ".", "containsKey", "(", "fieldName", ")", ")", "{", "addSet", "=", "new", "TreeSet", "<", "String", ">", "(", "m_valueMap", ".", "get", "(", "fieldName", ")", ")", ";", "}", "List", "<", "String", ">", "removeSet", "=", "m_valueRemoveMap", ".", "get", "(", "fieldName", ")", ";", "if", "(", "addSet", "!=", "null", "&&", "addSet", ".", "size", "(", ")", "==", "1", "&&", "removeSet", "==", "null", ")", "{", "parentNode", ".", "addValueNode", "(", "fieldName", ",", "addSet", ".", "iterator", "(", ")", ".", "next", "(", ")", ",", "\"field\"", ")", ";", "}", "else", "{", "UNode", "fieldNode", "=", "parentNode", ".", "addMapNode", "(", "fieldName", ",", "\"field\"", ")", ";", "if", "(", "addSet", "!=", "null", "&&", "addSet", ".", "size", "(", ")", ">", "0", ")", "{", "UNode", "addNode", "=", "fieldNode", ".", "addArrayNode", "(", "\"add\"", ")", ";", "for", "(", "String", "value", ":", "addSet", ")", "{", "addNode", ".", "addValueNode", "(", "\"value\"", ",", "value", ")", ";", "}", "}", "if", "(", "removeSet", "!=", "null", "&&", "removeSet", ".", "size", "(", ")", ">", "0", ")", "{", "UNode", "addNode", "=", "fieldNode", ".", "addArrayNode", "(", "\"remove\"", ")", ";", "for", "(", "String", "value", ":", "removeSet", ")", "{", "addNode", ".", "addValueNode", "(", "\"value\"", ",", "value", ")", ";", "}", "}", "}", "}" ]
parent node.
[ "parent", "node", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/DBObject.java#L515-L540
138,273
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/DBObject.java
DBObject.groupFieldtoDoc
private void groupFieldtoDoc(UNode parentNode, FieldDefinition groupFieldDef, Set<FieldDefinition> deferredFields) { // Prerequisities: assert parentNode != null; assert groupFieldDef != null && groupFieldDef.isGroupField(); assert deferredFields != null && deferredFields.size() > 0; UNode groupNode = parentNode.addMapNode(groupFieldDef.getName(), "field"); for (FieldDefinition nestedFieldDef : groupFieldDef.getNestedFields()) { if (!deferredFields.contains(nestedFieldDef)) { continue; } if (nestedFieldDef.isGroupField()) { groupFieldtoDoc(groupNode, nestedFieldDef, deferredFields); } else { leafFieldtoDoc(groupNode, nestedFieldDef.getName()); } } }
java
private void groupFieldtoDoc(UNode parentNode, FieldDefinition groupFieldDef, Set<FieldDefinition> deferredFields) { // Prerequisities: assert parentNode != null; assert groupFieldDef != null && groupFieldDef.isGroupField(); assert deferredFields != null && deferredFields.size() > 0; UNode groupNode = parentNode.addMapNode(groupFieldDef.getName(), "field"); for (FieldDefinition nestedFieldDef : groupFieldDef.getNestedFields()) { if (!deferredFields.contains(nestedFieldDef)) { continue; } if (nestedFieldDef.isGroupField()) { groupFieldtoDoc(groupNode, nestedFieldDef, deferredFields); } else { leafFieldtoDoc(groupNode, nestedFieldDef.getName()); } } }
[ "private", "void", "groupFieldtoDoc", "(", "UNode", "parentNode", ",", "FieldDefinition", "groupFieldDef", ",", "Set", "<", "FieldDefinition", ">", "deferredFields", ")", "{", "// Prerequisities:\r", "assert", "parentNode", "!=", "null", ";", "assert", "groupFieldDef", "!=", "null", "&&", "groupFieldDef", ".", "isGroupField", "(", ")", ";", "assert", "deferredFields", "!=", "null", "&&", "deferredFields", ".", "size", "(", ")", ">", "0", ";", "UNode", "groupNode", "=", "parentNode", ".", "addMapNode", "(", "groupFieldDef", ".", "getName", "(", ")", ",", "\"field\"", ")", ";", "for", "(", "FieldDefinition", "nestedFieldDef", ":", "groupFieldDef", ".", "getNestedFields", "(", ")", ")", "{", "if", "(", "!", "deferredFields", ".", "contains", "(", "nestedFieldDef", ")", ")", "{", "continue", ";", "}", "if", "(", "nestedFieldDef", ".", "isGroupField", "(", ")", ")", "{", "groupFieldtoDoc", "(", "groupNode", ",", "nestedFieldDef", ",", "deferredFields", ")", ";", "}", "else", "{", "leafFieldtoDoc", "(", "groupNode", ",", "nestedFieldDef", ".", "getName", "(", ")", ")", ";", "}", "}", "}" ]
given deferred-field map. Recurse is any child fields are also groups.
[ "given", "deferred", "-", "field", "map", ".", "Recurse", "is", "any", "child", "fields", "are", "also", "groups", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/DBObject.java#L545-L564
138,274
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/DBObject.java
DBObject.parseFieldUpdate
private void parseFieldUpdate(String fieldName, UNode valueNode) { if (valueNode.isValue()) { addFieldValue(fieldName, valueNode.getValue()); } else if (valueNode.childrenAreValues()) { parseFieldAdd(fieldName, valueNode); } else { for (UNode childNode : valueNode.getMemberList()) { if (childNode.isCollection() && childNode.getName().equals("add") && childNode.childrenAreValues()) { // "add" for an MV field parseFieldAdd(fieldName, childNode); } else if (childNode.isCollection() && childNode.getName().equals("remove") && childNode.childrenAreValues()) { // "remove" for an MV field parseFieldRemove(fieldName, childNode); } else { parseFieldUpdate(childNode.getName(), childNode); } } } }
java
private void parseFieldUpdate(String fieldName, UNode valueNode) { if (valueNode.isValue()) { addFieldValue(fieldName, valueNode.getValue()); } else if (valueNode.childrenAreValues()) { parseFieldAdd(fieldName, valueNode); } else { for (UNode childNode : valueNode.getMemberList()) { if (childNode.isCollection() && childNode.getName().equals("add") && childNode.childrenAreValues()) { // "add" for an MV field parseFieldAdd(fieldName, childNode); } else if (childNode.isCollection() && childNode.getName().equals("remove") && childNode.childrenAreValues()) { // "remove" for an MV field parseFieldRemove(fieldName, childNode); } else { parseFieldUpdate(childNode.getName(), childNode); } } } }
[ "private", "void", "parseFieldUpdate", "(", "String", "fieldName", ",", "UNode", "valueNode", ")", "{", "if", "(", "valueNode", ".", "isValue", "(", ")", ")", "{", "addFieldValue", "(", "fieldName", ",", "valueNode", ".", "getValue", "(", ")", ")", ";", "}", "else", "if", "(", "valueNode", ".", "childrenAreValues", "(", ")", ")", "{", "parseFieldAdd", "(", "fieldName", ",", "valueNode", ")", ";", "}", "else", "{", "for", "(", "UNode", "childNode", ":", "valueNode", ".", "getMemberList", "(", ")", ")", "{", "if", "(", "childNode", ".", "isCollection", "(", ")", "&&", "childNode", ".", "getName", "(", ")", ".", "equals", "(", "\"add\"", ")", "&&", "childNode", ".", "childrenAreValues", "(", ")", ")", "{", "// \"add\" for an MV field\r", "parseFieldAdd", "(", "fieldName", ",", "childNode", ")", ";", "}", "else", "if", "(", "childNode", ".", "isCollection", "(", ")", "&&", "childNode", ".", "getName", "(", ")", ".", "equals", "(", "\"remove\"", ")", "&&", "childNode", ".", "childrenAreValues", "(", ")", ")", "{", "// \"remove\" for an MV field\r", "parseFieldRemove", "(", "fieldName", ",", "childNode", ")", ";", "}", "else", "{", "parseFieldUpdate", "(", "childNode", ".", "getName", "(", ")", ",", "childNode", ")", ";", "}", "}", "}", "}" ]
Parse update to outer or nested field.
[ "Parse", "update", "to", "outer", "or", "nested", "field", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/DBObject.java#L567-L585
138,275
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/DBObject.java
DBObject.getSystemField
private String getSystemField(String fieldName) { List<String> values = m_valueMap.get(fieldName); return values == null ? null : values.get(0); }
java
private String getSystemField(String fieldName) { List<String> values = m_valueMap.get(fieldName); return values == null ? null : values.get(0); }
[ "private", "String", "getSystemField", "(", "String", "fieldName", ")", "{", "List", "<", "String", ">", "values", "=", "m_valueMap", ".", "get", "(", "fieldName", ")", ";", "return", "values", "==", "null", "?", "null", ":", "values", ".", "get", "(", "0", ")", ";", "}" ]
Get the first value of the given field, or null if there is no value.
[ "Get", "the", "first", "value", "of", "the", "given", "field", "or", "null", "if", "there", "is", "no", "value", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/DBObject.java#L610-L613
138,276
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/AliasDefinition.java
AliasDefinition.parse
public void parse(UNode aliasNode) { assert aliasNode != null; // Ensure the alias name is valid and save it. setName(aliasNode.getName()); // The only child element we expect is "expression". for (String childName : aliasNode.getMemberNames()) { // All child nodes must be values. UNode childNode = aliasNode.getMember(childName); Utils.require(childNode.isValue(), "Value of alias attribute must be a string: " + childNode); Utils.require(childName.equals("expression"), "'expression' expected: " + childName); Utils.require(m_expression == null, "'expression' can only be specified once"); setExpression(childNode.getValue()); } // Ensure expression was specified. Utils.require(m_expression != null, "Alias definition missing 'expression': " + aliasNode); }
java
public void parse(UNode aliasNode) { assert aliasNode != null; // Ensure the alias name is valid and save it. setName(aliasNode.getName()); // The only child element we expect is "expression". for (String childName : aliasNode.getMemberNames()) { // All child nodes must be values. UNode childNode = aliasNode.getMember(childName); Utils.require(childNode.isValue(), "Value of alias attribute must be a string: " + childNode); Utils.require(childName.equals("expression"), "'expression' expected: " + childName); Utils.require(m_expression == null, "'expression' can only be specified once"); setExpression(childNode.getValue()); } // Ensure expression was specified. Utils.require(m_expression != null, "Alias definition missing 'expression': " + aliasNode); }
[ "public", "void", "parse", "(", "UNode", "aliasNode", ")", "{", "assert", "aliasNode", "!=", "null", ";", "// Ensure the alias name is valid and save it.\r", "setName", "(", "aliasNode", ".", "getName", "(", ")", ")", ";", "// The only child element we expect is \"expression\".\r", "for", "(", "String", "childName", ":", "aliasNode", ".", "getMemberNames", "(", ")", ")", "{", "// All child nodes must be values.\r", "UNode", "childNode", "=", "aliasNode", ".", "getMember", "(", "childName", ")", ";", "Utils", ".", "require", "(", "childNode", ".", "isValue", "(", ")", ",", "\"Value of alias attribute must be a string: \"", "+", "childNode", ")", ";", "Utils", ".", "require", "(", "childName", ".", "equals", "(", "\"expression\"", ")", ",", "\"'expression' expected: \"", "+", "childName", ")", ";", "Utils", ".", "require", "(", "m_expression", "==", "null", ",", "\"'expression' can only be specified once\"", ")", ";", "setExpression", "(", "childNode", ".", "getValue", "(", ")", ")", ";", "}", "// Ensure expression was specified.\r", "Utils", ".", "require", "(", "m_expression", "!=", "null", ",", "\"Alias definition missing 'expression': \"", "+", "aliasNode", ")", ";", "}" ]
Parse the alias definition rooted at the given UNode, copying its properties into this object. @param aliasNode Root of an alias definition.
[ "Parse", "the", "alias", "definition", "rooted", "at", "the", "given", "UNode", "copying", "its", "properties", "into", "this", "object", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/AliasDefinition.java#L62-L83
138,277
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/AliasDefinition.java
AliasDefinition.update
public void update(AliasDefinition newAliasDef) { assert m_aliasName.equals(newAliasDef.m_aliasName); assert m_tableName.equals(newAliasDef.m_tableName); // Currently, all we have to do is copy over the "expression" property. m_expression = newAliasDef.m_expression; }
java
public void update(AliasDefinition newAliasDef) { assert m_aliasName.equals(newAliasDef.m_aliasName); assert m_tableName.equals(newAliasDef.m_tableName); // Currently, all we have to do is copy over the "expression" property. m_expression = newAliasDef.m_expression; }
[ "public", "void", "update", "(", "AliasDefinition", "newAliasDef", ")", "{", "assert", "m_aliasName", ".", "equals", "(", "newAliasDef", ".", "m_aliasName", ")", ";", "assert", "m_tableName", ".", "equals", "(", "newAliasDef", ".", "m_tableName", ")", ";", "// Currently, all we have to do is copy over the \"expression\" property.\r", "m_expression", "=", "newAliasDef", ".", "m_expression", ";", "}" ]
Update this alias definition to match the given updated one. The updated alias must have the same name and table name. @param newAliasDef Updated alias definition.
[ "Update", "this", "alias", "definition", "to", "match", "the", "given", "updated", "one", ".", "The", "updated", "alias", "must", "have", "the", "same", "name", "and", "table", "name", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/AliasDefinition.java#L134-L140
138,278
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/IDFieldUpdater.java
IDFieldUpdater.addValuesForField
@Override public void addValuesForField() { String objID = m_dbObj.getObjectID(); assert !Utils.isEmpty(objID); m_dbTran.addIDValueColumn(m_tableDef, objID); m_dbTran.addAllObjectsColumn(m_tableDef, objID, m_tableDef.getShardNumber(m_dbObj)); }
java
@Override public void addValuesForField() { String objID = m_dbObj.getObjectID(); assert !Utils.isEmpty(objID); m_dbTran.addIDValueColumn(m_tableDef, objID); m_dbTran.addAllObjectsColumn(m_tableDef, objID, m_tableDef.getShardNumber(m_dbObj)); }
[ "@", "Override", "public", "void", "addValuesForField", "(", ")", "{", "String", "objID", "=", "m_dbObj", ".", "getObjectID", "(", ")", ";", "assert", "!", "Utils", ".", "isEmpty", "(", "objID", ")", ";", "m_dbTran", ".", "addIDValueColumn", "(", "m_tableDef", ",", "objID", ")", ";", "m_dbTran", ".", "addAllObjectsColumn", "(", "m_tableDef", ",", "objID", ",", "m_tableDef", ".", "getShardNumber", "(", "m_dbObj", ")", ")", ";", "}" ]
and the encoded object ID as the value.
[ "and", "the", "encoded", "object", "ID", "as", "the", "value", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/IDFieldUpdater.java#L35-L41
138,279
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/IDFieldUpdater.java
IDFieldUpdater.deleteValuesForField
@Override public void deleteValuesForField() { int shardNo = m_tableDef.getShardNumber(m_dbObj); m_dbTran.deleteAllObjectsColumn(m_tableDef, m_dbObj.getObjectID(), shardNo); }
java
@Override public void deleteValuesForField() { int shardNo = m_tableDef.getShardNumber(m_dbObj); m_dbTran.deleteAllObjectsColumn(m_tableDef, m_dbObj.getObjectID(), shardNo); }
[ "@", "Override", "public", "void", "deleteValuesForField", "(", ")", "{", "int", "shardNo", "=", "m_tableDef", ".", "getShardNumber", "(", "m_dbObj", ")", ";", "m_dbTran", ".", "deleteAllObjectsColumn", "(", "m_tableDef", ",", "m_dbObj", ".", "getObjectID", "(", ")", ",", "shardNo", ")", ";", "}" ]
Object is being deleted. Just delete column in "all objects" row.
[ "Object", "is", "being", "deleted", ".", "Just", "delete", "column", "in", "all", "objects", "row", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/IDFieldUpdater.java#L44-L48
138,280
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/IDFieldUpdater.java
IDFieldUpdater.updateValuesForField
@Override public boolean updateValuesForField(String currentValue) { Utils.require(m_dbObj.getObjectID().equals(currentValue), "Object ID cannot be changed"); return false; }
java
@Override public boolean updateValuesForField(String currentValue) { Utils.require(m_dbObj.getObjectID().equals(currentValue), "Object ID cannot be changed"); return false; }
[ "@", "Override", "public", "boolean", "updateValuesForField", "(", "String", "currentValue", ")", "{", "Utils", ".", "require", "(", "m_dbObj", ".", "getObjectID", "(", ")", ".", "equals", "(", "currentValue", ")", ",", "\"Object ID cannot be changed\"", ")", ";", "return", "false", ";", "}" ]
Object is being updated, but _ID field cannot be changed.
[ "Object", "is", "being", "updated", "but", "_ID", "field", "cannot", "be", "changed", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/IDFieldUpdater.java#L51-L55
138,281
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.findStorageService
public StorageService findStorageService(String serviceName) { Utils.require(m_bInitialized, "DoradusService has not yet initialized"); for (StorageService service : m_storageServices) { if (service.getClass().getSimpleName().equals(serviceName)) { return service; } } return null; }
java
public StorageService findStorageService(String serviceName) { Utils.require(m_bInitialized, "DoradusService has not yet initialized"); for (StorageService service : m_storageServices) { if (service.getClass().getSimpleName().equals(serviceName)) { return service; } } return null; }
[ "public", "StorageService", "findStorageService", "(", "String", "serviceName", ")", "{", "Utils", ".", "require", "(", "m_bInitialized", ",", "\"DoradusService has not yet initialized\"", ")", ";", "for", "(", "StorageService", "service", ":", "m_storageServices", ")", "{", "if", "(", "service", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ".", "equals", "(", "serviceName", ")", ")", "{", "return", "service", ";", "}", "}", "return", "null", ";", "}" ]
Find a registered storage service with the given name. If there is no storage service with the registered name, null is returned. This method can only be called after the DoradusServer has initialized. @param serviceName Name of the storage service to find. This is the same as the class's "simple" name. For example, if the class name is "com.dell.doradus.service.spider.SpiderService", the service name is just "SpiderService". @return Singleton instance of the given service name if it is registered, otherwise null.
[ "Find", "a", "registered", "storage", "service", "with", "the", "given", "name", ".", "If", "there", "is", "no", "storage", "service", "with", "the", "registered", "name", "null", "is", "returned", ".", "This", "method", "can", "only", "be", "called", "after", "the", "DoradusServer", "has", "initialized", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L214-L222
138,282
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.getDoradusVersion
public static String getDoradusVersion() { String version = null; try { //first read from the local git repository Git git = Git.open(new File("../.git")); String url = git.getRepository().getConfig().getString("remote", "origin", "url"); instance().m_logger.info("Remote.origin.url: {}", url); if (!Utils.isEmpty(url) && url.contains("dell-oss/Doradus.git")) { DescribeCommand cmd = git.describe(); version = cmd.call(); instance().m_logger.info("Doradus version found from git repo: {}", version); writeVersionToVerFile(version); } } catch (Throwable e) { instance().m_logger.info("failed to read version from git repo"); } //if not found, reading from local file if (Utils.isEmpty(version)) { try { version = getVersionFromVerFile(); instance().m_logger.info("Doradus version found from doradus.ver file {}", version); } catch (IOException e1) { version = null; } } return version; }
java
public static String getDoradusVersion() { String version = null; try { //first read from the local git repository Git git = Git.open(new File("../.git")); String url = git.getRepository().getConfig().getString("remote", "origin", "url"); instance().m_logger.info("Remote.origin.url: {}", url); if (!Utils.isEmpty(url) && url.contains("dell-oss/Doradus.git")) { DescribeCommand cmd = git.describe(); version = cmd.call(); instance().m_logger.info("Doradus version found from git repo: {}", version); writeVersionToVerFile(version); } } catch (Throwable e) { instance().m_logger.info("failed to read version from git repo"); } //if not found, reading from local file if (Utils.isEmpty(version)) { try { version = getVersionFromVerFile(); instance().m_logger.info("Doradus version found from doradus.ver file {}", version); } catch (IOException e1) { version = null; } } return version; }
[ "public", "static", "String", "getDoradusVersion", "(", ")", "{", "String", "version", "=", "null", ";", "try", "{", "//first read from the local git repository\r", "Git", "git", "=", "Git", ".", "open", "(", "new", "File", "(", "\"../.git\"", ")", ")", ";", "String", "url", "=", "git", ".", "getRepository", "(", ")", ".", "getConfig", "(", ")", ".", "getString", "(", "\"remote\"", ",", "\"origin\"", ",", "\"url\"", ")", ";", "instance", "(", ")", ".", "m_logger", ".", "info", "(", "\"Remote.origin.url: {}\"", ",", "url", ")", ";", "if", "(", "!", "Utils", ".", "isEmpty", "(", "url", ")", "&&", "url", ".", "contains", "(", "\"dell-oss/Doradus.git\"", ")", ")", "{", "DescribeCommand", "cmd", "=", "git", ".", "describe", "(", ")", ";", "version", "=", "cmd", ".", "call", "(", ")", ";", "instance", "(", ")", ".", "m_logger", ".", "info", "(", "\"Doradus version found from git repo: {}\"", ",", "version", ")", ";", "writeVersionToVerFile", "(", "version", ")", ";", "}", "}", "catch", "(", "Throwable", "e", ")", "{", "instance", "(", ")", ".", "m_logger", ".", "info", "(", "\"failed to read version from git repo\"", ")", ";", "}", "//if not found, reading from local file\r", "if", "(", "Utils", ".", "isEmpty", "(", "version", ")", ")", "{", "try", "{", "version", "=", "getVersionFromVerFile", "(", ")", ";", "instance", "(", ")", ".", "m_logger", ".", "info", "(", "\"Doradus version found from doradus.ver file {}\"", ",", "version", ")", ";", "}", "catch", "(", "IOException", "e1", ")", "{", "version", "=", "null", ";", "}", "}", "return", "version", ";", "}" ]
Get Doradus Version from git repo if it exists; otherwise get it from the local doradus.ver file @return version
[ "Get", "Doradus", "Version", "from", "git", "repo", "if", "it", "exists", ";", "otherwise", "get", "it", "from", "the", "local", "doradus", ".", "ver", "file" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L228-L254
138,283
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.writeVersionToVerFile
private static void writeVersionToVerFile(String version) throws IOException { //declared in a try-with-resource statement, it will be closed regardless of it completes normally or not try (PrintWriter writer = new PrintWriter(new File(DoradusServer.class.getResource("/" + VERSION_FILE).getPath()))) { writer.write(version); } }
java
private static void writeVersionToVerFile(String version) throws IOException { //declared in a try-with-resource statement, it will be closed regardless of it completes normally or not try (PrintWriter writer = new PrintWriter(new File(DoradusServer.class.getResource("/" + VERSION_FILE).getPath()))) { writer.write(version); } }
[ "private", "static", "void", "writeVersionToVerFile", "(", "String", "version", ")", "throws", "IOException", "{", "//declared in a try-with-resource statement, it will be closed regardless of it completes normally or not \r", "try", "(", "PrintWriter", "writer", "=", "new", "PrintWriter", "(", "new", "File", "(", "DoradusServer", ".", "class", ".", "getResource", "(", "\"/\"", "+", "VERSION_FILE", ")", ".", "getPath", "(", ")", ")", ")", ")", "{", "writer", ".", "write", "(", "version", ")", ";", "}", "}" ]
Write version to local file
[ "Write", "version", "to", "local", "file" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L257-L263
138,284
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.getVersionFromVerFile
private static String getVersionFromVerFile() throws IOException { //declared in a try-with-resource statement, it will be closed regardless of it completes normally or not try (BufferedReader br = new BufferedReader(new InputStreamReader(DoradusServer.class.getResourceAsStream("/" + VERSION_FILE), "UTF-8"))) { return br.readLine(); } }
java
private static String getVersionFromVerFile() throws IOException { //declared in a try-with-resource statement, it will be closed regardless of it completes normally or not try (BufferedReader br = new BufferedReader(new InputStreamReader(DoradusServer.class.getResourceAsStream("/" + VERSION_FILE), "UTF-8"))) { return br.readLine(); } }
[ "private", "static", "String", "getVersionFromVerFile", "(", ")", "throws", "IOException", "{", "//declared in a try-with-resource statement, it will be closed regardless of it completes normally or not\r", "try", "(", "BufferedReader", "br", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "DoradusServer", ".", "class", ".", "getResourceAsStream", "(", "\"/\"", "+", "VERSION_FILE", ")", ",", "\"UTF-8\"", ")", ")", ")", "{", "return", "br", ".", "readLine", "(", ")", ";", "}", "}" ]
Get version from local file
[ "Get", "version", "from", "local", "file" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L265-L271
138,285
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.addConfiguredStorageServices
private void addConfiguredStorageServices(Set<String> serviceSet) { List<String> ssList = ServerParams.instance().getModuleParamList("DoradusServer", "storage_services"); if (ssList != null) { serviceSet.addAll(ssList); } }
java
private void addConfiguredStorageServices(Set<String> serviceSet) { List<String> ssList = ServerParams.instance().getModuleParamList("DoradusServer", "storage_services"); if (ssList != null) { serviceSet.addAll(ssList); } }
[ "private", "void", "addConfiguredStorageServices", "(", "Set", "<", "String", ">", "serviceSet", ")", "{", "List", "<", "String", ">", "ssList", "=", "ServerParams", ".", "instance", "(", ")", ".", "getModuleParamList", "(", "\"DoradusServer\"", ",", "\"storage_services\"", ")", ";", "if", "(", "ssList", "!=", "null", ")", "{", "serviceSet", ".", "addAll", "(", "ssList", ")", ";", "}", "}" ]
Add configured storage_services to the given set.
[ "Add", "configured", "storage_services", "to", "the", "given", "set", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L279-L284
138,286
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.addDefaultServices
private void addDefaultServices(Set<String> serviceSet) { List<String> defaultServices = ServerParams.instance().getModuleParamList("DoradusServer", "default_services"); if (defaultServices != null) { serviceSet.addAll(defaultServices); } }
java
private void addDefaultServices(Set<String> serviceSet) { List<String> defaultServices = ServerParams.instance().getModuleParamList("DoradusServer", "default_services"); if (defaultServices != null) { serviceSet.addAll(defaultServices); } }
[ "private", "void", "addDefaultServices", "(", "Set", "<", "String", ">", "serviceSet", ")", "{", "List", "<", "String", ">", "defaultServices", "=", "ServerParams", ".", "instance", "(", ")", ".", "getModuleParamList", "(", "\"DoradusServer\"", ",", "\"default_services\"", ")", ";", "if", "(", "defaultServices", "!=", "null", ")", "{", "serviceSet", ".", "addAll", "(", "defaultServices", ")", ";", "}", "}" ]
Add configured default_services to the given set.
[ "Add", "configured", "default_services", "to", "the", "given", "set", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L287-L292
138,287
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.initEmbedded
private void initEmbedded(String[] args, String[] services) { if (m_bInitialized) { m_logger.warn("initEmbedded: Already initialized -- ignoring"); return; } m_logger.info("Initializing embedded mode"); initConfig(args); initEmbeddedServices(services); RESTService.instance().registerCommands(CMD_CLASSES); m_bInitialized = true; }
java
private void initEmbedded(String[] args, String[] services) { if (m_bInitialized) { m_logger.warn("initEmbedded: Already initialized -- ignoring"); return; } m_logger.info("Initializing embedded mode"); initConfig(args); initEmbeddedServices(services); RESTService.instance().registerCommands(CMD_CLASSES); m_bInitialized = true; }
[ "private", "void", "initEmbedded", "(", "String", "[", "]", "args", ",", "String", "[", "]", "services", ")", "{", "if", "(", "m_bInitialized", ")", "{", "m_logger", ".", "warn", "(", "\"initEmbedded: Already initialized -- ignoring\"", ")", ";", "return", ";", "}", "m_logger", ".", "info", "(", "\"Initializing embedded mode\"", ")", ";", "initConfig", "(", "args", ")", ";", "initEmbeddedServices", "(", "services", ")", ";", "RESTService", ".", "instance", "(", ")", ".", "registerCommands", "(", "CMD_CLASSES", ")", ";", "m_bInitialized", "=", "true", ";", "}" ]
Initialize server configuration and given+required services for embedded running.
[ "Initialize", "server", "configuration", "and", "given", "+", "required", "services", "for", "embedded", "running", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L305-L315
138,288
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.initEmbeddedServices
private void initEmbeddedServices(String[] requestedServices) { Set<String> serviceSet = new LinkedHashSet<>(); if (requestedServices != null) { serviceSet.addAll(Arrays.asList(requestedServices)); } addRequiredServices(serviceSet); initServices(serviceSet); }
java
private void initEmbeddedServices(String[] requestedServices) { Set<String> serviceSet = new LinkedHashSet<>(); if (requestedServices != null) { serviceSet.addAll(Arrays.asList(requestedServices)); } addRequiredServices(serviceSet); initServices(serviceSet); }
[ "private", "void", "initEmbeddedServices", "(", "String", "[", "]", "requestedServices", ")", "{", "Set", "<", "String", ">", "serviceSet", "=", "new", "LinkedHashSet", "<>", "(", ")", ";", "if", "(", "requestedServices", "!=", "null", ")", "{", "serviceSet", ".", "addAll", "(", "Arrays", ".", "asList", "(", "requestedServices", ")", ")", ";", "}", "addRequiredServices", "(", "serviceSet", ")", ";", "initServices", "(", "serviceSet", ")", ";", "}" ]
Initialize services required for embedded start.
[ "Initialize", "services", "required", "for", "embedded", "start", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L318-L325
138,289
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.initStandAlone
private void initStandAlone(String[] args) { if (m_bInitialized) { m_logger.warn("initStandAlone: Already initialized -- ignoring"); return; } m_logger.info("Initializing standalone mode"); initConfig(args); initStandaAloneServices(); RESTService.instance().registerCommands(CMD_CLASSES); m_bInitialized = true; }
java
private void initStandAlone(String[] args) { if (m_bInitialized) { m_logger.warn("initStandAlone: Already initialized -- ignoring"); return; } m_logger.info("Initializing standalone mode"); initConfig(args); initStandaAloneServices(); RESTService.instance().registerCommands(CMD_CLASSES); m_bInitialized = true; }
[ "private", "void", "initStandAlone", "(", "String", "[", "]", "args", ")", "{", "if", "(", "m_bInitialized", ")", "{", "m_logger", ".", "warn", "(", "\"initStandAlone: Already initialized -- ignoring\"", ")", ";", "return", ";", "}", "m_logger", ".", "info", "(", "\"Initializing standalone mode\"", ")", ";", "initConfig", "(", "args", ")", ";", "initStandaAloneServices", "(", ")", ";", "RESTService", ".", "instance", "(", ")", ".", "registerCommands", "(", "CMD_CLASSES", ")", ";", "m_bInitialized", "=", "true", ";", "}" ]
Initialize server configuration and all services for stand-alone running.
[ "Initialize", "server", "configuration", "and", "all", "services", "for", "stand", "-", "alone", "running", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L328-L338
138,290
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.initStandaAloneServices
private void initStandaAloneServices() { Set<String> serviceSet = new LinkedHashSet<>(); addDefaultServices(serviceSet); addRequiredServices(serviceSet); addConfiguredStorageServices(serviceSet); initServices(serviceSet); }
java
private void initStandaAloneServices() { Set<String> serviceSet = new LinkedHashSet<>(); addDefaultServices(serviceSet); addRequiredServices(serviceSet); addConfiguredStorageServices(serviceSet); initServices(serviceSet); }
[ "private", "void", "initStandaAloneServices", "(", ")", "{", "Set", "<", "String", ">", "serviceSet", "=", "new", "LinkedHashSet", "<>", "(", ")", ";", "addDefaultServices", "(", "serviceSet", ")", ";", "addRequiredServices", "(", "serviceSet", ")", ";", "addConfiguredStorageServices", "(", "serviceSet", ")", ";", "initServices", "(", "serviceSet", ")", ";", "}" ]
Initialize services configured+needed for stand-alone operation.
[ "Initialize", "services", "configured", "+", "needed", "for", "stand", "-", "alone", "operation", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L341-L347
138,291
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.initConfig
private void initConfig(String[] args) { try { ServerParams.load(args); if (Utils.isEmpty(ServerParams.instance().getModuleParamString("DoradusServer", "super_user"))) { m_logger.warn("'DoradusServer.super_user' parameter is not defined. " + "Privileged commands will be available without authentication."); } } catch (ConfigurationException e) { throw new RuntimeException("Failed to initialize server configuration", e); } }
java
private void initConfig(String[] args) { try { ServerParams.load(args); if (Utils.isEmpty(ServerParams.instance().getModuleParamString("DoradusServer", "super_user"))) { m_logger.warn("'DoradusServer.super_user' parameter is not defined. " + "Privileged commands will be available without authentication."); } } catch (ConfigurationException e) { throw new RuntimeException("Failed to initialize server configuration", e); } }
[ "private", "void", "initConfig", "(", "String", "[", "]", "args", ")", "{", "try", "{", "ServerParams", ".", "load", "(", "args", ")", ";", "if", "(", "Utils", ".", "isEmpty", "(", "ServerParams", ".", "instance", "(", ")", ".", "getModuleParamString", "(", "\"DoradusServer\"", ",", "\"super_user\"", ")", ")", ")", "{", "m_logger", ".", "warn", "(", "\"'DoradusServer.super_user' parameter is not defined. \"", "+", "\"Privileged commands will be available without authentication.\"", ")", ";", "}", "}", "catch", "(", "ConfigurationException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed to initialize server configuration\"", ",", "e", ")", ";", "}", "}" ]
Initialize the ServerParams module, which loads the doradus.yaml file.
[ "Initialize", "the", "ServerParams", "module", "which", "loads", "the", "doradus", ".", "yaml", "file", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L350-L360
138,292
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.initServices
private void initServices(Set<String> serviceSet) { for (String serviceName : serviceSet) { Service service = initService(serviceName); m_initializedServices.add(service); if (service instanceof StorageService) { m_storageServices.add((StorageService) service); } } if (m_storageServices.size() == 0) { throw new RuntimeException("No storage services were configured"); } }
java
private void initServices(Set<String> serviceSet) { for (String serviceName : serviceSet) { Service service = initService(serviceName); m_initializedServices.add(service); if (service instanceof StorageService) { m_storageServices.add((StorageService) service); } } if (m_storageServices.size() == 0) { throw new RuntimeException("No storage services were configured"); } }
[ "private", "void", "initServices", "(", "Set", "<", "String", ">", "serviceSet", ")", "{", "for", "(", "String", "serviceName", ":", "serviceSet", ")", "{", "Service", "service", "=", "initService", "(", "serviceName", ")", ";", "m_initializedServices", ".", "add", "(", "service", ")", ";", "if", "(", "service", "instanceof", "StorageService", ")", "{", "m_storageServices", ".", "add", "(", "(", "StorageService", ")", "service", ")", ";", "}", "}", "if", "(", "m_storageServices", ".", "size", "(", ")", "==", "0", ")", "{", "throw", "new", "RuntimeException", "(", "\"No storage services were configured\"", ")", ";", "}", "}" ]
StorageService objects. Throw if a storage service is not requested.
[ "StorageService", "objects", ".", "Throw", "if", "a", "storage", "service", "is", "not", "requested", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L364-L375
138,293
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.initService
private Service initService(String serviceName) { m_logger.debug("Initializing service: " + serviceName); try { @SuppressWarnings("unchecked") Class<Service> serviceClass = (Class<Service>) Class.forName(serviceName); Method instanceMethod = serviceClass.getMethod("instance", (Class<?>[])null); Service instance = (Service)instanceMethod.invoke(null, (Object[])null); instance.initialize(); return instance; } catch (Exception e) { throw new RuntimeException("Error initializing service: " + serviceName, e); } }
java
private Service initService(String serviceName) { m_logger.debug("Initializing service: " + serviceName); try { @SuppressWarnings("unchecked") Class<Service> serviceClass = (Class<Service>) Class.forName(serviceName); Method instanceMethod = serviceClass.getMethod("instance", (Class<?>[])null); Service instance = (Service)instanceMethod.invoke(null, (Object[])null); instance.initialize(); return instance; } catch (Exception e) { throw new RuntimeException("Error initializing service: " + serviceName, e); } }
[ "private", "Service", "initService", "(", "String", "serviceName", ")", "{", "m_logger", ".", "debug", "(", "\"Initializing service: \"", "+", "serviceName", ")", ";", "try", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Class", "<", "Service", ">", "serviceClass", "=", "(", "Class", "<", "Service", ">", ")", "Class", ".", "forName", "(", "serviceName", ")", ";", "Method", "instanceMethod", "=", "serviceClass", ".", "getMethod", "(", "\"instance\"", ",", "(", "Class", "<", "?", ">", "[", "]", ")", "null", ")", ";", "Service", "instance", "=", "(", "Service", ")", "instanceMethod", ".", "invoke", "(", "null", ",", "(", "Object", "[", "]", ")", "null", ")", ";", "instance", ".", "initialize", "(", ")", ";", "return", "instance", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error initializing service: \"", "+", "serviceName", ",", "e", ")", ";", "}", "}" ]
Initialize the service with the given package name.
[ "Initialize", "the", "service", "with", "the", "given", "package", "name", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L378-L390
138,294
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.start
private void start() { if (m_bRunning) { m_logger.warn("start: Already started -- ignoring"); return; } Locale.setDefault(Locale.ROOT); m_logger.info("Doradus Version: {}", getDoradusVersion()); hookShutdownEvent(); startServices(); m_bRunning = true; }
java
private void start() { if (m_bRunning) { m_logger.warn("start: Already started -- ignoring"); return; } Locale.setDefault(Locale.ROOT); m_logger.info("Doradus Version: {}", getDoradusVersion()); hookShutdownEvent(); startServices(); m_bRunning = true; }
[ "private", "void", "start", "(", ")", "{", "if", "(", "m_bRunning", ")", "{", "m_logger", ".", "warn", "(", "\"start: Already started -- ignoring\"", ")", ";", "return", ";", "}", "Locale", ".", "setDefault", "(", "Locale", ".", "ROOT", ")", ";", "m_logger", ".", "info", "(", "\"Doradus Version: {}\"", ",", "getDoradusVersion", "(", ")", ")", ";", "hookShutdownEvent", "(", ")", ";", "startServices", "(", ")", ";", "m_bRunning", "=", "true", ";", "}" ]
Start the DoradusServer services.
[ "Start", "the", "DoradusServer", "services", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L398-L408
138,295
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.startServices
private void startServices() { m_logger.info("Starting services: {}", simpleServiceNames(m_initializedServices)); for (Service service : m_initializedServices) { m_logger.debug("Starting service: " + service.getClass().getSimpleName()); service.start(); m_startedServices.add(service); } }
java
private void startServices() { m_logger.info("Starting services: {}", simpleServiceNames(m_initializedServices)); for (Service service : m_initializedServices) { m_logger.debug("Starting service: " + service.getClass().getSimpleName()); service.start(); m_startedServices.add(service); } }
[ "private", "void", "startServices", "(", ")", "{", "m_logger", ".", "info", "(", "\"Starting services: {}\"", ",", "simpleServiceNames", "(", "m_initializedServices", ")", ")", ";", "for", "(", "Service", "service", ":", "m_initializedServices", ")", "{", "m_logger", ".", "debug", "(", "\"Starting service: \"", "+", "service", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "service", ".", "start", "(", ")", ";", "m_startedServices", ".", "add", "(", "service", ")", ";", "}", "}" ]
Start all registered services.
[ "Start", "all", "registered", "services", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L411-L418
138,296
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.simpleServiceNames
private String simpleServiceNames(Collection<Service> services) { StringBuilder buffer = new StringBuilder(); for (Service service : services) { if (buffer.length() > 0) { buffer.append(","); } buffer.append(service.getClass().getSimpleName()); } return buffer.toString(); }
java
private String simpleServiceNames(Collection<Service> services) { StringBuilder buffer = new StringBuilder(); for (Service service : services) { if (buffer.length() > 0) { buffer.append(","); } buffer.append(service.getClass().getSimpleName()); } return buffer.toString(); }
[ "private", "String", "simpleServiceNames", "(", "Collection", "<", "Service", ">", "services", ")", "{", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Service", "service", ":", "services", ")", "{", "if", "(", "buffer", ".", "length", "(", ")", ">", "0", ")", "{", "buffer", ".", "append", "(", "\",\"", ")", ";", "}", "buffer", ".", "append", "(", "service", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "}", "return", "buffer", ".", "toString", "(", ")", ";", "}" ]
Get simple service names as a comma-separated list.
[ "Get", "simple", "service", "names", "as", "a", "comma", "-", "separated", "list", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L421-L430
138,297
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.stopServices
private void stopServices() { // Stop services in reverse order of starting. m_logger.debug("Stopping all services"); ListIterator<Service> iter = m_startedServices.listIterator(m_startedServices.size()); while (iter.hasPrevious()) { Service service = iter.previous(); m_logger.debug("Stopping service: " + service.getClass().getSimpleName()); service.stop(); iter.remove(); } m_initializedServices.clear(); m_storageServices.clear(); }
java
private void stopServices() { // Stop services in reverse order of starting. m_logger.debug("Stopping all services"); ListIterator<Service> iter = m_startedServices.listIterator(m_startedServices.size()); while (iter.hasPrevious()) { Service service = iter.previous(); m_logger.debug("Stopping service: " + service.getClass().getSimpleName()); service.stop(); iter.remove(); } m_initializedServices.clear(); m_storageServices.clear(); }
[ "private", "void", "stopServices", "(", ")", "{", "// Stop services in reverse order of starting.\r", "m_logger", ".", "debug", "(", "\"Stopping all services\"", ")", ";", "ListIterator", "<", "Service", ">", "iter", "=", "m_startedServices", ".", "listIterator", "(", "m_startedServices", ".", "size", "(", ")", ")", ";", "while", "(", "iter", ".", "hasPrevious", "(", ")", ")", "{", "Service", "service", "=", "iter", ".", "previous", "(", ")", ";", "m_logger", ".", "debug", "(", "\"Stopping service: \"", "+", "service", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "service", ".", "stop", "(", ")", ";", "iter", ".", "remove", "(", ")", ";", "}", "m_initializedServices", ".", "clear", "(", ")", ";", "m_storageServices", ".", "clear", "(", ")", ";", "}" ]
Stop all registered services.
[ "Stop", "all", "registered", "services", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L433-L445
138,298
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java
DoradusServer.stop
private void stop() { if (m_bRunning) { instance().m_logger.info("Doradus Server shutting down"); stopServices(); ServerParams.unload(); m_bRunning = false; m_bInitialized = false; } }
java
private void stop() { if (m_bRunning) { instance().m_logger.info("Doradus Server shutting down"); stopServices(); ServerParams.unload(); m_bRunning = false; m_bInitialized = false; } }
[ "private", "void", "stop", "(", ")", "{", "if", "(", "m_bRunning", ")", "{", "instance", "(", ")", ".", "m_logger", ".", "info", "(", "\"Doradus Server shutting down\"", ")", ";", "stopServices", "(", ")", ";", "ServerParams", ".", "unload", "(", ")", ";", "m_bRunning", "=", "false", ";", "m_bInitialized", "=", "false", ";", "}", "}" ]
Shutdown all services and terminate.
[ "Shutdown", "all", "services", "and", "terminate", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/DoradusServer.java#L448-L456
138,299
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/FieldUpdater.java
FieldUpdater.createFieldUpdater
public static FieldUpdater createFieldUpdater(ObjectUpdater objUpdater, DBObject dbObj, String fieldName) { if (fieldName.charAt(0) == '_') { if (fieldName.equals(CommonDefs.ID_FIELD)) { return new IDFieldUpdater(objUpdater, dbObj); } else { // Allow but skip all other system fields (e.g., "_table") return new NullFieldUpdater(objUpdater, dbObj, fieldName); } } TableDefinition tableDef = objUpdater.getTableDef(); if (tableDef.isLinkField(fieldName)) { return new LinkFieldUpdater(objUpdater, dbObj, fieldName); } else { Utils.require(FieldDefinition.isValidFieldName(fieldName), "Invalid field name: %s", fieldName); return new ScalarFieldUpdater(objUpdater, dbObj, fieldName); } }
java
public static FieldUpdater createFieldUpdater(ObjectUpdater objUpdater, DBObject dbObj, String fieldName) { if (fieldName.charAt(0) == '_') { if (fieldName.equals(CommonDefs.ID_FIELD)) { return new IDFieldUpdater(objUpdater, dbObj); } else { // Allow but skip all other system fields (e.g., "_table") return new NullFieldUpdater(objUpdater, dbObj, fieldName); } } TableDefinition tableDef = objUpdater.getTableDef(); if (tableDef.isLinkField(fieldName)) { return new LinkFieldUpdater(objUpdater, dbObj, fieldName); } else { Utils.require(FieldDefinition.isValidFieldName(fieldName), "Invalid field name: %s", fieldName); return new ScalarFieldUpdater(objUpdater, dbObj, fieldName); } }
[ "public", "static", "FieldUpdater", "createFieldUpdater", "(", "ObjectUpdater", "objUpdater", ",", "DBObject", "dbObj", ",", "String", "fieldName", ")", "{", "if", "(", "fieldName", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "if", "(", "fieldName", ".", "equals", "(", "CommonDefs", ".", "ID_FIELD", ")", ")", "{", "return", "new", "IDFieldUpdater", "(", "objUpdater", ",", "dbObj", ")", ";", "}", "else", "{", "// Allow but skip all other system fields (e.g., \"_table\")\r", "return", "new", "NullFieldUpdater", "(", "objUpdater", ",", "dbObj", ",", "fieldName", ")", ";", "}", "}", "TableDefinition", "tableDef", "=", "objUpdater", ".", "getTableDef", "(", ")", ";", "if", "(", "tableDef", ".", "isLinkField", "(", "fieldName", ")", ")", "{", "return", "new", "LinkFieldUpdater", "(", "objUpdater", ",", "dbObj", ",", "fieldName", ")", ";", "}", "else", "{", "Utils", ".", "require", "(", "FieldDefinition", ".", "isValidFieldName", "(", "fieldName", ")", ",", "\"Invalid field name: %s\"", ",", "fieldName", ")", ";", "return", "new", "ScalarFieldUpdater", "(", "objUpdater", ",", "dbObj", ",", "fieldName", ")", ";", "}", "}" ]
Create a FieldUpdater that will handle updates for the given object and field. @param tableDef {@link TableDefinition} of table in which object resides. @param dbObj {@link DBObject} of object being added, updated, or deleted. @param fieldName Name of field the new FieldUpdater will handle. Can be the _ID field, a declared or undeclared scalar field, or a link field. @return A FieldUpdater that can perform updates for the given object and field.
[ "Create", "a", "FieldUpdater", "that", "will", "handle", "updates", "for", "the", "given", "object", "and", "field", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/FieldUpdater.java#L54-L70