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
160,800
kiegroup/jbpm-designer
jbpm-designer-client/src/main/java/org/jbpm/designer/client/popup/ActivityDataIOEditorWidget.java
ActivityDataIOEditorWidget.isDuplicateName
public boolean isDuplicateName(String name) { if (name == null || name.trim().isEmpty()) { return false; } List<AssignmentRow> as = view.getAssignmentRows(); if (as != null && !as.isEmpty()) { int nameCount = 0; for (AssignmentRow row : as) { if (name.trim().compareTo(row.getName()) == 0) { nameCount++; if (nameCount > 1) { return true; } } } } return false; }
java
public boolean isDuplicateName(String name) { if (name == null || name.trim().isEmpty()) { return false; } List<AssignmentRow> as = view.getAssignmentRows(); if (as != null && !as.isEmpty()) { int nameCount = 0; for (AssignmentRow row : as) { if (name.trim().compareTo(row.getName()) == 0) { nameCount++; if (nameCount > 1) { return true; } } } } return false; }
[ "public", "boolean", "isDuplicateName", "(", "String", "name", ")", "{", "if", "(", "name", "==", "null", "||", "name", ".", "trim", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "List", "<", "AssignmentRow", ">", "as", "=", "view", ".", "getAssignmentRows", "(", ")", ";", "if", "(", "as", "!=", "null", "&&", "!", "as", ".", "isEmpty", "(", ")", ")", "{", "int", "nameCount", "=", "0", ";", "for", "(", "AssignmentRow", "row", ":", "as", ")", "{", "if", "(", "name", ".", "trim", "(", ")", ".", "compareTo", "(", "row", ".", "getName", "(", ")", ")", "==", "0", ")", "{", "nameCount", "++", ";", "if", "(", "nameCount", ">", "1", ")", "{", "return", "true", ";", "}", "}", "}", "}", "return", "false", ";", "}" ]
Tests whether a Row name occurs more than once in the list of rows @param name @return
[ "Tests", "whether", "a", "Row", "name", "occurs", "more", "than", "once", "in", "the", "list", "of", "rows" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/popup/ActivityDataIOEditorWidget.java#L221-L238
160,801
kiegroup/jbpm-designer
jbpm-designer-client/src/main/java/org/jbpm/designer/client/util/ListBoxValues.java
ListBoxValues.getValueForDisplayValue
public String getValueForDisplayValue(final String key) { if (mapDisplayValuesToValues.containsKey(key)) { return mapDisplayValuesToValues.get(key); } return key; }
java
public String getValueForDisplayValue(final String key) { if (mapDisplayValuesToValues.containsKey(key)) { return mapDisplayValuesToValues.get(key); } return key; }
[ "public", "String", "getValueForDisplayValue", "(", "final", "String", "key", ")", "{", "if", "(", "mapDisplayValuesToValues", ".", "containsKey", "(", "key", ")", ")", "{", "return", "mapDisplayValuesToValues", ".", "get", "(", "key", ")", ";", "}", "return", "key", ";", "}" ]
Returns real unquoted value for a DisplayValue @param key @return
[ "Returns", "real", "unquoted", "value", "for", "a", "DisplayValue" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/util/ListBoxValues.java#L275-L280
160,802
kiegroup/jbpm-designer
jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/AssignmentData.java
AssignmentData.getAssignmentRows
public List<AssignmentRow> getAssignmentRows(VariableType varType) { List<AssignmentRow> rows = new ArrayList<AssignmentRow>(); List<Variable> handledVariables = new ArrayList<Variable>(); // Create an AssignmentRow for each Assignment for (Assignment assignment : assignments) { if (assignment.getVariableType() == varType) { String dataType = getDisplayNameFromDataType(assignment.getDataType()); AssignmentRow row = new AssignmentRow(assignment.getName(), assignment.getVariableType(), dataType, assignment.getCustomDataType(), assignment.getProcessVarName(), assignment.getConstant()); rows.add(row); handledVariables.add(assignment.getVariable()); } } List<Variable> vars = null; if (varType == VariableType.INPUT) { vars = inputVariables; } else { vars = outputVariables; } // Create an AssignmentRow for each Variable that doesn't have an Assignment for (Variable var : vars) { if (!handledVariables.contains(var)) { AssignmentRow row = new AssignmentRow(var.getName(), var.getVariableType(), var.getDataType(), var.getCustomDataType(), null, null); rows.add(row); } } return rows; }
java
public List<AssignmentRow> getAssignmentRows(VariableType varType) { List<AssignmentRow> rows = new ArrayList<AssignmentRow>(); List<Variable> handledVariables = new ArrayList<Variable>(); // Create an AssignmentRow for each Assignment for (Assignment assignment : assignments) { if (assignment.getVariableType() == varType) { String dataType = getDisplayNameFromDataType(assignment.getDataType()); AssignmentRow row = new AssignmentRow(assignment.getName(), assignment.getVariableType(), dataType, assignment.getCustomDataType(), assignment.getProcessVarName(), assignment.getConstant()); rows.add(row); handledVariables.add(assignment.getVariable()); } } List<Variable> vars = null; if (varType == VariableType.INPUT) { vars = inputVariables; } else { vars = outputVariables; } // Create an AssignmentRow for each Variable that doesn't have an Assignment for (Variable var : vars) { if (!handledVariables.contains(var)) { AssignmentRow row = new AssignmentRow(var.getName(), var.getVariableType(), var.getDataType(), var.getCustomDataType(), null, null); rows.add(row); } } return rows; }
[ "public", "List", "<", "AssignmentRow", ">", "getAssignmentRows", "(", "VariableType", "varType", ")", "{", "List", "<", "AssignmentRow", ">", "rows", "=", "new", "ArrayList", "<", "AssignmentRow", ">", "(", ")", ";", "List", "<", "Variable", ">", "handledVariables", "=", "new", "ArrayList", "<", "Variable", ">", "(", ")", ";", "// Create an AssignmentRow for each Assignment", "for", "(", "Assignment", "assignment", ":", "assignments", ")", "{", "if", "(", "assignment", ".", "getVariableType", "(", ")", "==", "varType", ")", "{", "String", "dataType", "=", "getDisplayNameFromDataType", "(", "assignment", ".", "getDataType", "(", ")", ")", ";", "AssignmentRow", "row", "=", "new", "AssignmentRow", "(", "assignment", ".", "getName", "(", ")", ",", "assignment", ".", "getVariableType", "(", ")", ",", "dataType", ",", "assignment", ".", "getCustomDataType", "(", ")", ",", "assignment", ".", "getProcessVarName", "(", ")", ",", "assignment", ".", "getConstant", "(", ")", ")", ";", "rows", ".", "add", "(", "row", ")", ";", "handledVariables", ".", "add", "(", "assignment", ".", "getVariable", "(", ")", ")", ";", "}", "}", "List", "<", "Variable", ">", "vars", "=", "null", ";", "if", "(", "varType", "==", "VariableType", ".", "INPUT", ")", "{", "vars", "=", "inputVariables", ";", "}", "else", "{", "vars", "=", "outputVariables", ";", "}", "// Create an AssignmentRow for each Variable that doesn't have an Assignment", "for", "(", "Variable", "var", ":", "vars", ")", "{", "if", "(", "!", "handledVariables", ".", "contains", "(", "var", ")", ")", "{", "AssignmentRow", "row", "=", "new", "AssignmentRow", "(", "var", ".", "getName", "(", ")", ",", "var", ".", "getVariableType", "(", ")", ",", "var", ".", "getDataType", "(", ")", ",", "var", ".", "getCustomDataType", "(", ")", ",", "null", ",", "null", ")", ";", "rows", ".", "add", "(", "row", ")", ";", "}", "}", "return", "rows", ";", "}" ]
Gets a list of AssignmentRows based on the current Assignments @return
[ "Gets", "a", "list", "of", "AssignmentRows", "based", "on", "the", "current", "Assignments" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/AssignmentData.java#L530-L567
160,803
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java
DiagramBuilder.parseJson
public static Diagram parseJson(String json, Boolean keepGlossaryLink) throws JSONException { JSONObject modelJSON = new JSONObject(json); return parseJson(modelJSON, keepGlossaryLink); }
java
public static Diagram parseJson(String json, Boolean keepGlossaryLink) throws JSONException { JSONObject modelJSON = new JSONObject(json); return parseJson(modelJSON, keepGlossaryLink); }
[ "public", "static", "Diagram", "parseJson", "(", "String", "json", ",", "Boolean", "keepGlossaryLink", ")", "throws", "JSONException", "{", "JSONObject", "modelJSON", "=", "new", "JSONObject", "(", "json", ")", ";", "return", "parseJson", "(", "modelJSON", ",", "keepGlossaryLink", ")", ";", "}" ]
Parse the json string to the diagram model, assumes that the json is hierarchical ordered @param json @return Model with all shapes defined in JSON @throws org.json.JSONException
[ "Parse", "the", "json", "string", "to", "the", "diagram", "model", "assumes", "that", "the", "json", "is", "hierarchical", "ordered" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L49-L54
160,804
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java
DiagramBuilder.parseJson
public static Diagram parseJson(JSONObject json, Boolean keepGlossaryLink) throws JSONException { ArrayList<Shape> shapes = new ArrayList<Shape>(); HashMap<String, JSONObject> flatJSON = flatRessources(json); for (String resourceId : flatJSON.keySet()) { parseRessource(shapes, flatJSON, resourceId, keepGlossaryLink); } String id = "canvas"; if (json.has("resourceId")) { id = json.getString("resourceId"); shapes.remove(new Shape(id)); } ; Diagram diagram = new Diagram(id); // remove Diagram // (Diagram)getShapeWithId(json.getString("resourceId"), shapes); parseStencilSet(json, diagram); parseSsextensions(json, diagram); parseStencil(json, diagram); parseProperties(json, diagram, keepGlossaryLink); parseChildShapes(shapes, json, diagram); parseBounds(json, diagram); diagram.setShapes(shapes); return diagram; }
java
public static Diagram parseJson(JSONObject json, Boolean keepGlossaryLink) throws JSONException { ArrayList<Shape> shapes = new ArrayList<Shape>(); HashMap<String, JSONObject> flatJSON = flatRessources(json); for (String resourceId : flatJSON.keySet()) { parseRessource(shapes, flatJSON, resourceId, keepGlossaryLink); } String id = "canvas"; if (json.has("resourceId")) { id = json.getString("resourceId"); shapes.remove(new Shape(id)); } ; Diagram diagram = new Diagram(id); // remove Diagram // (Diagram)getShapeWithId(json.getString("resourceId"), shapes); parseStencilSet(json, diagram); parseSsextensions(json, diagram); parseStencil(json, diagram); parseProperties(json, diagram, keepGlossaryLink); parseChildShapes(shapes, json, diagram); parseBounds(json, diagram); diagram.setShapes(shapes); return diagram; }
[ "public", "static", "Diagram", "parseJson", "(", "JSONObject", "json", ",", "Boolean", "keepGlossaryLink", ")", "throws", "JSONException", "{", "ArrayList", "<", "Shape", ">", "shapes", "=", "new", "ArrayList", "<", "Shape", ">", "(", ")", ";", "HashMap", "<", "String", ",", "JSONObject", ">", "flatJSON", "=", "flatRessources", "(", "json", ")", ";", "for", "(", "String", "resourceId", ":", "flatJSON", ".", "keySet", "(", ")", ")", "{", "parseRessource", "(", "shapes", ",", "flatJSON", ",", "resourceId", ",", "keepGlossaryLink", ")", ";", "}", "String", "id", "=", "\"canvas\"", ";", "if", "(", "json", ".", "has", "(", "\"resourceId\"", ")", ")", "{", "id", "=", "json", ".", "getString", "(", "\"resourceId\"", ")", ";", "shapes", ".", "remove", "(", "new", "Shape", "(", "id", ")", ")", ";", "}", ";", "Diagram", "diagram", "=", "new", "Diagram", "(", "id", ")", ";", "// remove Diagram", "// (Diagram)getShapeWithId(json.getString(\"resourceId\"), shapes);", "parseStencilSet", "(", "json", ",", "diagram", ")", ";", "parseSsextensions", "(", "json", ",", "diagram", ")", ";", "parseStencil", "(", "json", ",", "diagram", ")", ";", "parseProperties", "(", "json", ",", "diagram", ",", "keepGlossaryLink", ")", ";", "parseChildShapes", "(", "shapes", ",", "json", ",", "diagram", ")", ";", "parseBounds", "(", "json", ",", "diagram", ")", ";", "diagram", ".", "setShapes", "(", "shapes", ")", ";", "return", "diagram", ";", "}" ]
do the parsing on an JSONObject, assumes that the json is hierarchical ordered, so all shapes are reachable over child relations @param json hierarchical JSON object @return Model with all shapes defined in JSON @throws org.json.JSONException
[ "do", "the", "parsing", "on", "an", "JSONObject", "assumes", "that", "the", "json", "is", "hierarchical", "ordered", "so", "all", "shapes", "are", "reachable", "over", "child", "relations" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L68-L105
160,805
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java
DiagramBuilder.parseRessource
private static void parseRessource(ArrayList<Shape> shapes, HashMap<String, JSONObject> flatJSON, String resourceId, Boolean keepGlossaryLink) throws JSONException { JSONObject modelJSON = flatJSON.get(resourceId); Shape current = getShapeWithId(modelJSON.getString("resourceId"), shapes); parseStencil(modelJSON, current); parseProperties(modelJSON, current, keepGlossaryLink); parseOutgoings(shapes, modelJSON, current); parseChildShapes(shapes, modelJSON, current); parseDockers(modelJSON, current); parseBounds(modelJSON, current); parseTarget(shapes, modelJSON, current); }
java
private static void parseRessource(ArrayList<Shape> shapes, HashMap<String, JSONObject> flatJSON, String resourceId, Boolean keepGlossaryLink) throws JSONException { JSONObject modelJSON = flatJSON.get(resourceId); Shape current = getShapeWithId(modelJSON.getString("resourceId"), shapes); parseStencil(modelJSON, current); parseProperties(modelJSON, current, keepGlossaryLink); parseOutgoings(shapes, modelJSON, current); parseChildShapes(shapes, modelJSON, current); parseDockers(modelJSON, current); parseBounds(modelJSON, current); parseTarget(shapes, modelJSON, current); }
[ "private", "static", "void", "parseRessource", "(", "ArrayList", "<", "Shape", ">", "shapes", ",", "HashMap", "<", "String", ",", "JSONObject", ">", "flatJSON", ",", "String", "resourceId", ",", "Boolean", "keepGlossaryLink", ")", "throws", "JSONException", "{", "JSONObject", "modelJSON", "=", "flatJSON", ".", "get", "(", "resourceId", ")", ";", "Shape", "current", "=", "getShapeWithId", "(", "modelJSON", ".", "getString", "(", "\"resourceId\"", ")", ",", "shapes", ")", ";", "parseStencil", "(", "modelJSON", ",", "current", ")", ";", "parseProperties", "(", "modelJSON", ",", "current", ",", "keepGlossaryLink", ")", ";", "parseOutgoings", "(", "shapes", ",", "modelJSON", ",", "current", ")", ";", "parseChildShapes", "(", "shapes", ",", "modelJSON", ",", "current", ")", ";", "parseDockers", "(", "modelJSON", ",", "current", ")", ";", "parseBounds", "(", "modelJSON", ",", "current", ")", ";", "parseTarget", "(", "shapes", ",", "modelJSON", ",", "current", ")", ";", "}" ]
Parse one resource to a shape object and add it to the shapes array @param shapes @param flatJSON @param resourceId @throws org.json.JSONException
[ "Parse", "one", "resource", "to", "a", "shape", "object", "and", "add", "it", "to", "the", "shapes", "array" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L114-L142
160,806
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java
DiagramBuilder.parseStencil
private static void parseStencil(JSONObject modelJSON, Shape current) throws JSONException { // get stencil type if (modelJSON.has("stencil")) { JSONObject stencil = modelJSON.getJSONObject("stencil"); // TODO other attributes of stencil String stencilString = ""; if (stencil.has("id")) { stencilString = stencil.getString("id"); } current.setStencil(new StencilType(stencilString)); } }
java
private static void parseStencil(JSONObject modelJSON, Shape current) throws JSONException { // get stencil type if (modelJSON.has("stencil")) { JSONObject stencil = modelJSON.getJSONObject("stencil"); // TODO other attributes of stencil String stencilString = ""; if (stencil.has("id")) { stencilString = stencil.getString("id"); } current.setStencil(new StencilType(stencilString)); } }
[ "private", "static", "void", "parseStencil", "(", "JSONObject", "modelJSON", ",", "Shape", "current", ")", "throws", "JSONException", "{", "// get stencil type", "if", "(", "modelJSON", ".", "has", "(", "\"stencil\"", ")", ")", "{", "JSONObject", "stencil", "=", "modelJSON", ".", "getJSONObject", "(", "\"stencil\"", ")", ";", "// TODO other attributes of stencil", "String", "stencilString", "=", "\"\"", ";", "if", "(", "stencil", ".", "has", "(", "\"id\"", ")", ")", "{", "stencilString", "=", "stencil", ".", "getString", "(", "\"id\"", ")", ";", "}", "current", ".", "setStencil", "(", "new", "StencilType", "(", "stencilString", ")", ")", ";", "}", "}" ]
parse the stencil out of a JSONObject and set it to the current shape @param modelJSON @param current @throws org.json.JSONException
[ "parse", "the", "stencil", "out", "of", "a", "JSONObject", "and", "set", "it", "to", "the", "current", "shape" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L150-L162
160,807
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java
DiagramBuilder.parseStencilSet
private static void parseStencilSet(JSONObject modelJSON, Diagram current) throws JSONException { // get stencil type if (modelJSON.has("stencilset")) { JSONObject object = modelJSON.getJSONObject("stencilset"); String url = null; String namespace = null; if (object.has("url")) { url = object.getString("url"); } if (object.has("namespace")) { namespace = object.getString("namespace"); } current.setStencilset(new StencilSet(url, namespace)); } }
java
private static void parseStencilSet(JSONObject modelJSON, Diagram current) throws JSONException { // get stencil type if (modelJSON.has("stencilset")) { JSONObject object = modelJSON.getJSONObject("stencilset"); String url = null; String namespace = null; if (object.has("url")) { url = object.getString("url"); } if (object.has("namespace")) { namespace = object.getString("namespace"); } current.setStencilset(new StencilSet(url, namespace)); } }
[ "private", "static", "void", "parseStencilSet", "(", "JSONObject", "modelJSON", ",", "Diagram", "current", ")", "throws", "JSONException", "{", "// get stencil type", "if", "(", "modelJSON", ".", "has", "(", "\"stencilset\"", ")", ")", "{", "JSONObject", "object", "=", "modelJSON", ".", "getJSONObject", "(", "\"stencilset\"", ")", ";", "String", "url", "=", "null", ";", "String", "namespace", "=", "null", ";", "if", "(", "object", ".", "has", "(", "\"url\"", ")", ")", "{", "url", "=", "object", ".", "getString", "(", "\"url\"", ")", ";", "}", "if", "(", "object", ".", "has", "(", "\"namespace\"", ")", ")", "{", "namespace", "=", "object", ".", "getString", "(", "\"namespace\"", ")", ";", "}", "current", ".", "setStencilset", "(", "new", "StencilSet", "(", "url", ",", "namespace", ")", ")", ";", "}", "}" ]
crates a StencilSet object and add it to the current diagram @param modelJSON @param current @throws org.json.JSONException
[ "crates", "a", "StencilSet", "object", "and", "add", "it", "to", "the", "current", "diagram" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L170-L189
160,808
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java
DiagramBuilder.parseProperties
@SuppressWarnings("unchecked") private static void parseProperties(JSONObject modelJSON, Shape current, Boolean keepGlossaryLink) throws JSONException { if (modelJSON.has("properties")) { JSONObject propsObject = modelJSON.getJSONObject("properties"); Iterator<String> keys = propsObject.keys(); Pattern pattern = Pattern.compile(jsonPattern); while (keys.hasNext()) { StringBuilder result = new StringBuilder(); int lastIndex = 0; String key = keys.next(); String value = propsObject.getString(key); if (!keepGlossaryLink) { Matcher matcher = pattern.matcher(value); while (matcher.find()) { String id = matcher.group(1); current.addGlossaryIds(id); String text = matcher.group(2); result.append(text); lastIndex = matcher.end(); } result.append(value.substring(lastIndex)); value = result.toString(); } current.putProperty(key, value); } } }
java
@SuppressWarnings("unchecked") private static void parseProperties(JSONObject modelJSON, Shape current, Boolean keepGlossaryLink) throws JSONException { if (modelJSON.has("properties")) { JSONObject propsObject = modelJSON.getJSONObject("properties"); Iterator<String> keys = propsObject.keys(); Pattern pattern = Pattern.compile(jsonPattern); while (keys.hasNext()) { StringBuilder result = new StringBuilder(); int lastIndex = 0; String key = keys.next(); String value = propsObject.getString(key); if (!keepGlossaryLink) { Matcher matcher = pattern.matcher(value); while (matcher.find()) { String id = matcher.group(1); current.addGlossaryIds(id); String text = matcher.group(2); result.append(text); lastIndex = matcher.end(); } result.append(value.substring(lastIndex)); value = result.toString(); } current.putProperty(key, value); } } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "static", "void", "parseProperties", "(", "JSONObject", "modelJSON", ",", "Shape", "current", ",", "Boolean", "keepGlossaryLink", ")", "throws", "JSONException", "{", "if", "(", "modelJSON", ".", "has", "(", "\"properties\"", ")", ")", "{", "JSONObject", "propsObject", "=", "modelJSON", ".", "getJSONObject", "(", "\"properties\"", ")", ";", "Iterator", "<", "String", ">", "keys", "=", "propsObject", ".", "keys", "(", ")", ";", "Pattern", "pattern", "=", "Pattern", ".", "compile", "(", "jsonPattern", ")", ";", "while", "(", "keys", ".", "hasNext", "(", ")", ")", "{", "StringBuilder", "result", "=", "new", "StringBuilder", "(", ")", ";", "int", "lastIndex", "=", "0", ";", "String", "key", "=", "keys", ".", "next", "(", ")", ";", "String", "value", "=", "propsObject", ".", "getString", "(", "key", ")", ";", "if", "(", "!", "keepGlossaryLink", ")", "{", "Matcher", "matcher", "=", "pattern", ".", "matcher", "(", "value", ")", ";", "while", "(", "matcher", ".", "find", "(", ")", ")", "{", "String", "id", "=", "matcher", ".", "group", "(", "1", ")", ";", "current", ".", "addGlossaryIds", "(", "id", ")", ";", "String", "text", "=", "matcher", ".", "group", "(", "2", ")", ";", "result", ".", "append", "(", "text", ")", ";", "lastIndex", "=", "matcher", ".", "end", "(", ")", ";", "}", "result", ".", "append", "(", "value", ".", "substring", "(", "lastIndex", ")", ")", ";", "value", "=", "result", ".", "toString", "(", ")", ";", "}", "current", ".", "putProperty", "(", "key", ",", "value", ")", ";", "}", "}", "}" ]
create a HashMap form the json properties and add it to the shape @param modelJSON @param current @throws org.json.JSONException
[ "create", "a", "HashMap", "form", "the", "json", "properties", "and", "add", "it", "to", "the", "shape" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L197-L229
160,809
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java
DiagramBuilder.parseSsextensions
private static void parseSsextensions(JSONObject modelJSON, Diagram current) throws JSONException { if (modelJSON.has("ssextensions")) { JSONArray array = modelJSON.getJSONArray("ssextensions"); for (int i = 0; i < array.length(); i++) { current.addSsextension(array.getString(i)); } } }
java
private static void parseSsextensions(JSONObject modelJSON, Diagram current) throws JSONException { if (modelJSON.has("ssextensions")) { JSONArray array = modelJSON.getJSONArray("ssextensions"); for (int i = 0; i < array.length(); i++) { current.addSsextension(array.getString(i)); } } }
[ "private", "static", "void", "parseSsextensions", "(", "JSONObject", "modelJSON", ",", "Diagram", "current", ")", "throws", "JSONException", "{", "if", "(", "modelJSON", ".", "has", "(", "\"ssextensions\"", ")", ")", "{", "JSONArray", "array", "=", "modelJSON", ".", "getJSONArray", "(", "\"ssextensions\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "array", ".", "length", "(", ")", ";", "i", "++", ")", "{", "current", ".", "addSsextension", "(", "array", ".", "getString", "(", "i", ")", ")", ";", "}", "}", "}" ]
adds all json extension to an diagram @param modelJSON @param current @throws org.json.JSONException
[ "adds", "all", "json", "extension", "to", "an", "diagram" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L237-L245
160,810
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java
DiagramBuilder.parseOutgoings
private static void parseOutgoings(ArrayList<Shape> shapes, JSONObject modelJSON, Shape current) throws JSONException { if (modelJSON.has("outgoing")) { ArrayList<Shape> outgoings = new ArrayList<Shape>(); JSONArray outgoingObject = modelJSON.getJSONArray("outgoing"); for (int i = 0; i < outgoingObject.length(); i++) { Shape out = getShapeWithId(outgoingObject.getJSONObject(i).getString("resourceId"), shapes); outgoings.add(out); out.addIncoming(current); } if (outgoings.size() > 0) { current.setOutgoings(outgoings); } } }
java
private static void parseOutgoings(ArrayList<Shape> shapes, JSONObject modelJSON, Shape current) throws JSONException { if (modelJSON.has("outgoing")) { ArrayList<Shape> outgoings = new ArrayList<Shape>(); JSONArray outgoingObject = modelJSON.getJSONArray("outgoing"); for (int i = 0; i < outgoingObject.length(); i++) { Shape out = getShapeWithId(outgoingObject.getJSONObject(i).getString("resourceId"), shapes); outgoings.add(out); out.addIncoming(current); } if (outgoings.size() > 0) { current.setOutgoings(outgoings); } } }
[ "private", "static", "void", "parseOutgoings", "(", "ArrayList", "<", "Shape", ">", "shapes", ",", "JSONObject", "modelJSON", ",", "Shape", "current", ")", "throws", "JSONException", "{", "if", "(", "modelJSON", ".", "has", "(", "\"outgoing\"", ")", ")", "{", "ArrayList", "<", "Shape", ">", "outgoings", "=", "new", "ArrayList", "<", "Shape", ">", "(", ")", ";", "JSONArray", "outgoingObject", "=", "modelJSON", ".", "getJSONArray", "(", "\"outgoing\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "outgoingObject", ".", "length", "(", ")", ";", "i", "++", ")", "{", "Shape", "out", "=", "getShapeWithId", "(", "outgoingObject", ".", "getJSONObject", "(", "i", ")", ".", "getString", "(", "\"resourceId\"", ")", ",", "shapes", ")", ";", "outgoings", ".", "add", "(", "out", ")", ";", "out", ".", "addIncoming", "(", "current", ")", ";", "}", "if", "(", "outgoings", ".", "size", "(", ")", ">", "0", ")", "{", "current", ".", "setOutgoings", "(", "outgoings", ")", ";", "}", "}", "}" ]
parse the outgoings form an json object and add all shape references to the current shapes, add new shapes to the shape array @param shapes @param modelJSON @param current @throws org.json.JSONException
[ "parse", "the", "outgoings", "form", "an", "json", "object", "and", "add", "all", "shape", "references", "to", "the", "current", "shapes", "add", "new", "shapes", "to", "the", "shape", "array" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L255-L271
160,811
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java
DiagramBuilder.parseChildShapes
private static void parseChildShapes(ArrayList<Shape> shapes, JSONObject modelJSON, Shape current) throws JSONException { if (modelJSON.has("childShapes")) { ArrayList<Shape> childShapes = new ArrayList<Shape>(); JSONArray childShapeObject = modelJSON.getJSONArray("childShapes"); for (int i = 0; i < childShapeObject.length(); i++) { childShapes.add(getShapeWithId(childShapeObject.getJSONObject(i).getString("resourceId"), shapes)); } if (childShapes.size() > 0) { for (Shape each : childShapes) { each.setParent(current); } current.setChildShapes(childShapes); } ; } }
java
private static void parseChildShapes(ArrayList<Shape> shapes, JSONObject modelJSON, Shape current) throws JSONException { if (modelJSON.has("childShapes")) { ArrayList<Shape> childShapes = new ArrayList<Shape>(); JSONArray childShapeObject = modelJSON.getJSONArray("childShapes"); for (int i = 0; i < childShapeObject.length(); i++) { childShapes.add(getShapeWithId(childShapeObject.getJSONObject(i).getString("resourceId"), shapes)); } if (childShapes.size() > 0) { for (Shape each : childShapes) { each.setParent(current); } current.setChildShapes(childShapes); } ; } }
[ "private", "static", "void", "parseChildShapes", "(", "ArrayList", "<", "Shape", ">", "shapes", ",", "JSONObject", "modelJSON", ",", "Shape", "current", ")", "throws", "JSONException", "{", "if", "(", "modelJSON", ".", "has", "(", "\"childShapes\"", ")", ")", "{", "ArrayList", "<", "Shape", ">", "childShapes", "=", "new", "ArrayList", "<", "Shape", ">", "(", ")", ";", "JSONArray", "childShapeObject", "=", "modelJSON", ".", "getJSONArray", "(", "\"childShapes\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "childShapeObject", ".", "length", "(", ")", ";", "i", "++", ")", "{", "childShapes", ".", "add", "(", "getShapeWithId", "(", "childShapeObject", ".", "getJSONObject", "(", "i", ")", ".", "getString", "(", "\"resourceId\"", ")", ",", "shapes", ")", ")", ";", "}", "if", "(", "childShapes", ".", "size", "(", ")", ">", "0", ")", "{", "for", "(", "Shape", "each", ":", "childShapes", ")", "{", "each", ".", "setParent", "(", "current", ")", ";", "}", "current", ".", "setChildShapes", "(", "childShapes", ")", ";", "}", ";", "}", "}" ]
creates a shape list containing all child shapes and set it to the current shape new shape get added to the shape array @param shapes @param modelJSON @param current @throws org.json.JSONException
[ "creates", "a", "shape", "list", "containing", "all", "child", "shapes", "and", "set", "it", "to", "the", "current", "shape", "new", "shape", "get", "added", "to", "the", "shape", "array" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L281-L300
160,812
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java
DiagramBuilder.parseDockers
private static void parseDockers(JSONObject modelJSON, Shape current) throws JSONException { if (modelJSON.has("dockers")) { ArrayList<Point> dockers = new ArrayList<Point>(); JSONArray dockersObject = modelJSON.getJSONArray("dockers"); for (int i = 0; i < dockersObject.length(); i++) { Double x = dockersObject.getJSONObject(i).getDouble("x"); Double y = dockersObject.getJSONObject(i).getDouble("y"); dockers.add(new Point(x, y)); } if (dockers.size() > 0) { current.setDockers(dockers); } } }
java
private static void parseDockers(JSONObject modelJSON, Shape current) throws JSONException { if (modelJSON.has("dockers")) { ArrayList<Point> dockers = new ArrayList<Point>(); JSONArray dockersObject = modelJSON.getJSONArray("dockers"); for (int i = 0; i < dockersObject.length(); i++) { Double x = dockersObject.getJSONObject(i).getDouble("x"); Double y = dockersObject.getJSONObject(i).getDouble("y"); dockers.add(new Point(x, y)); } if (dockers.size() > 0) { current.setDockers(dockers); } } }
[ "private", "static", "void", "parseDockers", "(", "JSONObject", "modelJSON", ",", "Shape", "current", ")", "throws", "JSONException", "{", "if", "(", "modelJSON", ".", "has", "(", "\"dockers\"", ")", ")", "{", "ArrayList", "<", "Point", ">", "dockers", "=", "new", "ArrayList", "<", "Point", ">", "(", ")", ";", "JSONArray", "dockersObject", "=", "modelJSON", ".", "getJSONArray", "(", "\"dockers\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dockersObject", ".", "length", "(", ")", ";", "i", "++", ")", "{", "Double", "x", "=", "dockersObject", ".", "getJSONObject", "(", "i", ")", ".", "getDouble", "(", "\"x\"", ")", ";", "Double", "y", "=", "dockersObject", ".", "getJSONObject", "(", "i", ")", ".", "getDouble", "(", "\"y\"", ")", ";", "dockers", ".", "add", "(", "new", "Point", "(", "x", ",", "y", ")", ")", ";", "}", "if", "(", "dockers", ".", "size", "(", ")", ">", "0", ")", "{", "current", ".", "setDockers", "(", "dockers", ")", ";", "}", "}", "}" ]
creates a point array of all dockers and add it to the current shape @param modelJSON @param current @throws org.json.JSONException
[ "creates", "a", "point", "array", "of", "all", "dockers", "and", "add", "it", "to", "the", "current", "shape" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L308-L324
160,813
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java
DiagramBuilder.parseBounds
private static void parseBounds(JSONObject modelJSON, Shape current) throws JSONException { if (modelJSON.has("bounds")) { JSONObject boundsObject = modelJSON.getJSONObject("bounds"); current.setBounds(new Bounds(new Point(boundsObject.getJSONObject("lowerRight").getDouble("x"), boundsObject.getJSONObject("lowerRight").getDouble( "y")), new Point(boundsObject.getJSONObject("upperLeft").getDouble("x"), boundsObject.getJSONObject("upperLeft").getDouble("y")))); } }
java
private static void parseBounds(JSONObject modelJSON, Shape current) throws JSONException { if (modelJSON.has("bounds")) { JSONObject boundsObject = modelJSON.getJSONObject("bounds"); current.setBounds(new Bounds(new Point(boundsObject.getJSONObject("lowerRight").getDouble("x"), boundsObject.getJSONObject("lowerRight").getDouble( "y")), new Point(boundsObject.getJSONObject("upperLeft").getDouble("x"), boundsObject.getJSONObject("upperLeft").getDouble("y")))); } }
[ "private", "static", "void", "parseBounds", "(", "JSONObject", "modelJSON", ",", "Shape", "current", ")", "throws", "JSONException", "{", "if", "(", "modelJSON", ".", "has", "(", "\"bounds\"", ")", ")", "{", "JSONObject", "boundsObject", "=", "modelJSON", ".", "getJSONObject", "(", "\"bounds\"", ")", ";", "current", ".", "setBounds", "(", "new", "Bounds", "(", "new", "Point", "(", "boundsObject", ".", "getJSONObject", "(", "\"lowerRight\"", ")", ".", "getDouble", "(", "\"x\"", ")", ",", "boundsObject", ".", "getJSONObject", "(", "\"lowerRight\"", ")", ".", "getDouble", "(", "\"y\"", ")", ")", ",", "new", "Point", "(", "boundsObject", ".", "getJSONObject", "(", "\"upperLeft\"", ")", ".", "getDouble", "(", "\"x\"", ")", ",", "boundsObject", ".", "getJSONObject", "(", "\"upperLeft\"", ")", ".", "getDouble", "(", "\"y\"", ")", ")", ")", ")", ";", "}", "}" ]
creates a bounds object with both point parsed from the json and set it to the current shape @param modelJSON @param current @throws org.json.JSONException
[ "creates", "a", "bounds", "object", "with", "both", "point", "parsed", "from", "the", "json", "and", "set", "it", "to", "the", "current", "shape" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L333-L343
160,814
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java
DiagramBuilder.parseTarget
private static void parseTarget(ArrayList<Shape> shapes, JSONObject modelJSON, Shape current) throws JSONException { if (modelJSON.has("target")) { JSONObject targetObject = modelJSON.getJSONObject("target"); if (targetObject.has("resourceId")) { current.setTarget(getShapeWithId(targetObject.getString("resourceId"), shapes)); } } }
java
private static void parseTarget(ArrayList<Shape> shapes, JSONObject modelJSON, Shape current) throws JSONException { if (modelJSON.has("target")) { JSONObject targetObject = modelJSON.getJSONObject("target"); if (targetObject.has("resourceId")) { current.setTarget(getShapeWithId(targetObject.getString("resourceId"), shapes)); } } }
[ "private", "static", "void", "parseTarget", "(", "ArrayList", "<", "Shape", ">", "shapes", ",", "JSONObject", "modelJSON", ",", "Shape", "current", ")", "throws", "JSONException", "{", "if", "(", "modelJSON", ".", "has", "(", "\"target\"", ")", ")", "{", "JSONObject", "targetObject", "=", "modelJSON", ".", "getJSONObject", "(", "\"target\"", ")", ";", "if", "(", "targetObject", ".", "has", "(", "\"resourceId\"", ")", ")", "{", "current", ".", "setTarget", "(", "getShapeWithId", "(", "targetObject", ".", "getString", "(", "\"resourceId\"", ")", ",", "shapes", ")", ")", ";", "}", "}", "}" ]
parse the target resource and add it to the current shape @param shapes @param modelJSON @param current @throws org.json.JSONException
[ "parse", "the", "target", "resource", "and", "add", "it", "to", "the", "current", "shape" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L352-L362
160,815
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java
DiagramBuilder.flatRessources
public static HashMap<String, JSONObject> flatRessources(JSONObject object) throws JSONException { HashMap<String, JSONObject> result = new HashMap<String, JSONObject>(); // no cycle in hierarchies!! if (object.has("resourceId") && object.has("childShapes")) { result.put(object.getString("resourceId"), object); JSONArray childShapes = object.getJSONArray("childShapes"); for (int i = 0; i < childShapes.length(); i++) { result.putAll(flatRessources(childShapes.getJSONObject(i))); } } ; return result; }
java
public static HashMap<String, JSONObject> flatRessources(JSONObject object) throws JSONException { HashMap<String, JSONObject> result = new HashMap<String, JSONObject>(); // no cycle in hierarchies!! if (object.has("resourceId") && object.has("childShapes")) { result.put(object.getString("resourceId"), object); JSONArray childShapes = object.getJSONArray("childShapes"); for (int i = 0; i < childShapes.length(); i++) { result.putAll(flatRessources(childShapes.getJSONObject(i))); } } ; return result; }
[ "public", "static", "HashMap", "<", "String", ",", "JSONObject", ">", "flatRessources", "(", "JSONObject", "object", ")", "throws", "JSONException", "{", "HashMap", "<", "String", ",", "JSONObject", ">", "result", "=", "new", "HashMap", "<", "String", ",", "JSONObject", ">", "(", ")", ";", "// no cycle in hierarchies!!", "if", "(", "object", ".", "has", "(", "\"resourceId\"", ")", "&&", "object", ".", "has", "(", "\"childShapes\"", ")", ")", "{", "result", ".", "put", "(", "object", ".", "getString", "(", "\"resourceId\"", ")", ",", "object", ")", ";", "JSONArray", "childShapes", "=", "object", ".", "getJSONArray", "(", "\"childShapes\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "childShapes", ".", "length", "(", ")", ";", "i", "++", ")", "{", "result", ".", "putAll", "(", "flatRessources", "(", "childShapes", ".", "getJSONObject", "(", "i", ")", ")", ")", ";", "}", "}", ";", "return", "result", ";", "}" ]
Prepare a model JSON for analyze, resolves the hierarchical structure creates a HashMap which contains all resourceIds as keys and for each key the JSONObject, all id are keys of this map @param object @return a HashMap keys: all ressourceIds values: all child JSONObjects @throws org.json.JSONException
[ "Prepare", "a", "model", "JSON", "for", "analyze", "resolves", "the", "hierarchical", "structure", "creates", "a", "HashMap", "which", "contains", "all", "resourceIds", "as", "keys", "and", "for", "each", "key", "the", "JSONObject", "all", "id", "are", "keys", "of", "this", "map" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/DiagramBuilder.java#L388-L403
160,816
kiegroup/jbpm-designer
jbpm-designer-client/src/main/java/org/jbpm/designer/client/util/DataIOEditorNameTextBox.java
DataIOEditorNameTextBox.setInvalidValues
public void setInvalidValues(final Set<String> invalidValues, final boolean isCaseSensitive, final String invalidValueErrorMessage) { if (isCaseSensitive) { this.invalidValues = invalidValues; } else { this.invalidValues = new HashSet<String>(); for (String value : invalidValues) { this.invalidValues.add(value.toLowerCase()); } } this.isCaseSensitive = isCaseSensitive; this.invalidValueErrorMessage = invalidValueErrorMessage; }
java
public void setInvalidValues(final Set<String> invalidValues, final boolean isCaseSensitive, final String invalidValueErrorMessage) { if (isCaseSensitive) { this.invalidValues = invalidValues; } else { this.invalidValues = new HashSet<String>(); for (String value : invalidValues) { this.invalidValues.add(value.toLowerCase()); } } this.isCaseSensitive = isCaseSensitive; this.invalidValueErrorMessage = invalidValueErrorMessage; }
[ "public", "void", "setInvalidValues", "(", "final", "Set", "<", "String", ">", "invalidValues", ",", "final", "boolean", "isCaseSensitive", ",", "final", "String", "invalidValueErrorMessage", ")", "{", "if", "(", "isCaseSensitive", ")", "{", "this", ".", "invalidValues", "=", "invalidValues", ";", "}", "else", "{", "this", ".", "invalidValues", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "String", "value", ":", "invalidValues", ")", "{", "this", ".", "invalidValues", ".", "add", "(", "value", ".", "toLowerCase", "(", ")", ")", ";", "}", "}", "this", ".", "isCaseSensitive", "=", "isCaseSensitive", ";", "this", ".", "invalidValueErrorMessage", "=", "invalidValueErrorMessage", ";", "}" ]
Sets the invalid values for the TextBox @param invalidValues @param isCaseSensitive @param invalidValueErrorMessage
[ "Sets", "the", "invalid", "values", "for", "the", "TextBox" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/util/DataIOEditorNameTextBox.java#L47-L60
160,817
kiegroup/jbpm-designer
jbpm-designer-client/src/main/java/org/jbpm/designer/client/util/DataIOEditorNameTextBox.java
DataIOEditorNameTextBox.setRegExp
public void setRegExp(final String pattern, final String invalidCharactersInNameErrorMessage, final String invalidCharacterTypedMessage) { regExp = RegExp.compile(pattern); this.invalidCharactersInNameErrorMessage = invalidCharactersInNameErrorMessage; this.invalidCharacterTypedMessage = invalidCharacterTypedMessage; }
java
public void setRegExp(final String pattern, final String invalidCharactersInNameErrorMessage, final String invalidCharacterTypedMessage) { regExp = RegExp.compile(pattern); this.invalidCharactersInNameErrorMessage = invalidCharactersInNameErrorMessage; this.invalidCharacterTypedMessage = invalidCharacterTypedMessage; }
[ "public", "void", "setRegExp", "(", "final", "String", "pattern", ",", "final", "String", "invalidCharactersInNameErrorMessage", ",", "final", "String", "invalidCharacterTypedMessage", ")", "{", "regExp", "=", "RegExp", ".", "compile", "(", "pattern", ")", ";", "this", ".", "invalidCharactersInNameErrorMessage", "=", "invalidCharactersInNameErrorMessage", ";", "this", ".", "invalidCharacterTypedMessage", "=", "invalidCharacterTypedMessage", ";", "}" ]
Sets the RegExp pattern for the TextBox @param pattern @param invalidCharactersInNameErrorMessage
[ "Sets", "the", "RegExp", "pattern", "for", "the", "TextBox" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/util/DataIOEditorNameTextBox.java#L67-L73
160,818
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/Shape.java
Shape.getProperties
public HashMap<String, String> getProperties() { if (this.properties == null) { this.properties = new HashMap<String, String>(); } return properties; }
java
public HashMap<String, String> getProperties() { if (this.properties == null) { this.properties = new HashMap<String, String>(); } return properties; }
[ "public", "HashMap", "<", "String", ",", "String", ">", "getProperties", "(", ")", "{", "if", "(", "this", ".", "properties", "==", "null", ")", "{", "this", ".", "properties", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "}", "return", "properties", ";", "}" ]
return a HashMap with all properties, name as key, value as value @return the properties
[ "return", "a", "HashMap", "with", "all", "properties", "name", "as", "key", "value", "as", "value" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/Shape.java#L153-L158
160,819
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/Shape.java
Shape.putProperty
public String putProperty(String key, String value) { return this.getProperties().put(key, value); }
java
public String putProperty(String key, String value) { return this.getProperties().put(key, value); }
[ "public", "String", "putProperty", "(", "String", "key", ",", "String", "value", ")", "{", "return", "this", ".", "getProperties", "(", ")", ".", "put", "(", "key", ",", "value", ")", ";", "}" ]
changes an existing property with the same name, or adds a new one @param key property name with which the specified value is to be associated @param value value to be associated with the specified property name @return the previous value associated with property name, or null if there was no mapping for property name. (A null return can also indicate that the map previously associated null with key.)
[ "changes", "an", "existing", "property", "with", "the", "same", "name", "or", "adds", "a", "new", "one" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/Shape.java#L177-L181
160,820
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/web/server/CalledElementServlet.java
CalledElementServlet.getRuleFlowNames
List<String> getRuleFlowNames(HttpServletRequest req) { final String[] projectAndBranch = getProjectAndBranchNames(req); // Query RuleFlowGroups for asset project and branch List<RefactoringPageRow> results = queryService.query( DesignerFindRuleFlowNamesQuery.NAME, new HashSet<ValueIndexTerm>() {{ add(new ValueSharedPartIndexTerm("*", PartType.RULEFLOW_GROUP, TermSearchType.WILDCARD)); add(new ValueModuleNameIndexTerm(projectAndBranch[0])); if (projectAndBranch[1] != null) { add(new ValueBranchNameIndexTerm(projectAndBranch[1])); } }}); final List<String> ruleFlowGroupNames = new ArrayList<String>(); for (RefactoringPageRow row : results) { ruleFlowGroupNames.add((String) row.getValue()); } Collections.sort(ruleFlowGroupNames); // Query RuleFlowGroups for all projects and branches results = queryService.query( DesignerFindRuleFlowNamesQuery.NAME, new HashSet<ValueIndexTerm>() {{ add(new ValueSharedPartIndexTerm("*", PartType.RULEFLOW_GROUP, TermSearchType.WILDCARD)); }}); final List<String> otherRuleFlowGroupNames = new LinkedList<String>(); for (RefactoringPageRow row : results) { String ruleFlowGroupName = (String) row.getValue(); if (!ruleFlowGroupNames.contains(ruleFlowGroupName)) { // but only add the new ones otherRuleFlowGroupNames.add(ruleFlowGroupName); } } Collections.sort(otherRuleFlowGroupNames); ruleFlowGroupNames.addAll(otherRuleFlowGroupNames); return ruleFlowGroupNames; }
java
List<String> getRuleFlowNames(HttpServletRequest req) { final String[] projectAndBranch = getProjectAndBranchNames(req); // Query RuleFlowGroups for asset project and branch List<RefactoringPageRow> results = queryService.query( DesignerFindRuleFlowNamesQuery.NAME, new HashSet<ValueIndexTerm>() {{ add(new ValueSharedPartIndexTerm("*", PartType.RULEFLOW_GROUP, TermSearchType.WILDCARD)); add(new ValueModuleNameIndexTerm(projectAndBranch[0])); if (projectAndBranch[1] != null) { add(new ValueBranchNameIndexTerm(projectAndBranch[1])); } }}); final List<String> ruleFlowGroupNames = new ArrayList<String>(); for (RefactoringPageRow row : results) { ruleFlowGroupNames.add((String) row.getValue()); } Collections.sort(ruleFlowGroupNames); // Query RuleFlowGroups for all projects and branches results = queryService.query( DesignerFindRuleFlowNamesQuery.NAME, new HashSet<ValueIndexTerm>() {{ add(new ValueSharedPartIndexTerm("*", PartType.RULEFLOW_GROUP, TermSearchType.WILDCARD)); }}); final List<String> otherRuleFlowGroupNames = new LinkedList<String>(); for (RefactoringPageRow row : results) { String ruleFlowGroupName = (String) row.getValue(); if (!ruleFlowGroupNames.contains(ruleFlowGroupName)) { // but only add the new ones otherRuleFlowGroupNames.add(ruleFlowGroupName); } } Collections.sort(otherRuleFlowGroupNames); ruleFlowGroupNames.addAll(otherRuleFlowGroupNames); return ruleFlowGroupNames; }
[ "List", "<", "String", ">", "getRuleFlowNames", "(", "HttpServletRequest", "req", ")", "{", "final", "String", "[", "]", "projectAndBranch", "=", "getProjectAndBranchNames", "(", "req", ")", ";", "// Query RuleFlowGroups for asset project and branch", "List", "<", "RefactoringPageRow", ">", "results", "=", "queryService", ".", "query", "(", "DesignerFindRuleFlowNamesQuery", ".", "NAME", ",", "new", "HashSet", "<", "ValueIndexTerm", ">", "(", ")", "{", "{", "add", "(", "new", "ValueSharedPartIndexTerm", "(", "\"*\"", ",", "PartType", ".", "RULEFLOW_GROUP", ",", "TermSearchType", ".", "WILDCARD", ")", ")", ";", "add", "(", "new", "ValueModuleNameIndexTerm", "(", "projectAndBranch", "[", "0", "]", ")", ")", ";", "if", "(", "projectAndBranch", "[", "1", "]", "!=", "null", ")", "{", "add", "(", "new", "ValueBranchNameIndexTerm", "(", "projectAndBranch", "[", "1", "]", ")", ")", ";", "}", "}", "}", ")", ";", "final", "List", "<", "String", ">", "ruleFlowGroupNames", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "RefactoringPageRow", "row", ":", "results", ")", "{", "ruleFlowGroupNames", ".", "add", "(", "(", "String", ")", "row", ".", "getValue", "(", ")", ")", ";", "}", "Collections", ".", "sort", "(", "ruleFlowGroupNames", ")", ";", "// Query RuleFlowGroups for all projects and branches", "results", "=", "queryService", ".", "query", "(", "DesignerFindRuleFlowNamesQuery", ".", "NAME", ",", "new", "HashSet", "<", "ValueIndexTerm", ">", "(", ")", "{", "{", "add", "(", "new", "ValueSharedPartIndexTerm", "(", "\"*\"", ",", "PartType", ".", "RULEFLOW_GROUP", ",", "TermSearchType", ".", "WILDCARD", ")", ")", ";", "}", "}", ")", ";", "final", "List", "<", "String", ">", "otherRuleFlowGroupNames", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "for", "(", "RefactoringPageRow", "row", ":", "results", ")", "{", "String", "ruleFlowGroupName", "=", "(", "String", ")", "row", ".", "getValue", "(", ")", ";", "if", "(", "!", "ruleFlowGroupNames", ".", "contains", "(", "ruleFlowGroupName", ")", ")", "{", "// but only add the new ones", "otherRuleFlowGroupNames", ".", "add", "(", "ruleFlowGroupName", ")", ";", "}", "}", "Collections", ".", "sort", "(", "otherRuleFlowGroupNames", ")", ";", "ruleFlowGroupNames", ".", "addAll", "(", "otherRuleFlowGroupNames", ")", ";", "return", "ruleFlowGroupNames", ";", "}" ]
package scope in order to test the method
[ "package", "scope", "in", "order", "to", "test", "the", "method" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/web/server/CalledElementServlet.java#L206-L249
160,821
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/web/plugin/impl/PluginServiceImpl.java
PluginServiceImpl.getLocalPluginsRegistry
public static Map<String, IDiagramPlugin> getLocalPluginsRegistry(ServletContext context) { if (LOCAL == null) { LOCAL = initializeLocalPlugins(context); } return LOCAL; }
java
public static Map<String, IDiagramPlugin> getLocalPluginsRegistry(ServletContext context) { if (LOCAL == null) { LOCAL = initializeLocalPlugins(context); } return LOCAL; }
[ "public", "static", "Map", "<", "String", ",", "IDiagramPlugin", ">", "getLocalPluginsRegistry", "(", "ServletContext", "context", ")", "{", "if", "(", "LOCAL", "==", "null", ")", "{", "LOCAL", "=", "initializeLocalPlugins", "(", "context", ")", ";", "}", "return", "LOCAL", ";", "}" ]
Initialize the local plugins registry @param context the servlet context necessary to grab the files inside the servlet. @return the set of local plugins organized by name
[ "Initialize", "the", "local", "plugins", "registry" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/web/plugin/impl/PluginServiceImpl.java#L81-L87
160,822
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/Diagram.java
Diagram.addSsextension
public boolean addSsextension(String ssExt) { if (this.ssextensions == null) { this.ssextensions = new ArrayList<String>(); } return this.ssextensions.add(ssExt); }
java
public boolean addSsextension(String ssExt) { if (this.ssextensions == null) { this.ssextensions = new ArrayList<String>(); } return this.ssextensions.add(ssExt); }
[ "public", "boolean", "addSsextension", "(", "String", "ssExt", ")", "{", "if", "(", "this", ".", "ssextensions", "==", "null", ")", "{", "this", ".", "ssextensions", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "}", "return", "this", ".", "ssextensions", ".", "add", "(", "ssExt", ")", ";", "}" ]
Add an additional SSExtension @param ssExt the ssextension to set
[ "Add", "an", "additional", "SSExtension" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/Diagram.java#L101-L106
160,823
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java
JSONBuilder.parseStencil
private static JSONObject parseStencil(String stencilId) throws JSONException { JSONObject stencilObject = new JSONObject(); stencilObject.put("id", stencilId.toString()); return stencilObject; }
java
private static JSONObject parseStencil(String stencilId) throws JSONException { JSONObject stencilObject = new JSONObject(); stencilObject.put("id", stencilId.toString()); return stencilObject; }
[ "private", "static", "JSONObject", "parseStencil", "(", "String", "stencilId", ")", "throws", "JSONException", "{", "JSONObject", "stencilObject", "=", "new", "JSONObject", "(", ")", ";", "stencilObject", ".", "put", "(", "\"id\"", ",", "stencilId", ".", "toString", "(", ")", ")", ";", "return", "stencilObject", ";", "}" ]
Delivers the correct JSON Object for the stencilId @param stencilId @throws org.json.JSONException
[ "Delivers", "the", "correct", "JSON", "Object", "for", "the", "stencilId" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L66-L73
160,824
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java
JSONBuilder.parseChildShapesRecursive
private static JSONArray parseChildShapesRecursive(ArrayList<Shape> childShapes) throws JSONException { if (childShapes != null) { JSONArray childShapesArray = new JSONArray(); for (Shape childShape : childShapes) { JSONObject childShapeObject = new JSONObject(); childShapeObject.put("resourceId", childShape.getResourceId().toString()); childShapeObject.put("properties", parseProperties(childShape.getProperties())); childShapeObject.put("stencil", parseStencil(childShape.getStencilId())); childShapeObject.put("childShapes", parseChildShapesRecursive(childShape.getChildShapes())); childShapeObject.put("outgoing", parseOutgoings(childShape.getOutgoings())); childShapeObject.put("bounds", parseBounds(childShape.getBounds())); childShapeObject.put("dockers", parseDockers(childShape.getDockers())); if (childShape.getTarget() != null) { childShapeObject.put("target", parseTarget(childShape.getTarget())); } childShapesArray.put(childShapeObject); } return childShapesArray; } return new JSONArray(); }
java
private static JSONArray parseChildShapesRecursive(ArrayList<Shape> childShapes) throws JSONException { if (childShapes != null) { JSONArray childShapesArray = new JSONArray(); for (Shape childShape : childShapes) { JSONObject childShapeObject = new JSONObject(); childShapeObject.put("resourceId", childShape.getResourceId().toString()); childShapeObject.put("properties", parseProperties(childShape.getProperties())); childShapeObject.put("stencil", parseStencil(childShape.getStencilId())); childShapeObject.put("childShapes", parseChildShapesRecursive(childShape.getChildShapes())); childShapeObject.put("outgoing", parseOutgoings(childShape.getOutgoings())); childShapeObject.put("bounds", parseBounds(childShape.getBounds())); childShapeObject.put("dockers", parseDockers(childShape.getDockers())); if (childShape.getTarget() != null) { childShapeObject.put("target", parseTarget(childShape.getTarget())); } childShapesArray.put(childShapeObject); } return childShapesArray; } return new JSONArray(); }
[ "private", "static", "JSONArray", "parseChildShapesRecursive", "(", "ArrayList", "<", "Shape", ">", "childShapes", ")", "throws", "JSONException", "{", "if", "(", "childShapes", "!=", "null", ")", "{", "JSONArray", "childShapesArray", "=", "new", "JSONArray", "(", ")", ";", "for", "(", "Shape", "childShape", ":", "childShapes", ")", "{", "JSONObject", "childShapeObject", "=", "new", "JSONObject", "(", ")", ";", "childShapeObject", ".", "put", "(", "\"resourceId\"", ",", "childShape", ".", "getResourceId", "(", ")", ".", "toString", "(", ")", ")", ";", "childShapeObject", ".", "put", "(", "\"properties\"", ",", "parseProperties", "(", "childShape", ".", "getProperties", "(", ")", ")", ")", ";", "childShapeObject", ".", "put", "(", "\"stencil\"", ",", "parseStencil", "(", "childShape", ".", "getStencilId", "(", ")", ")", ")", ";", "childShapeObject", ".", "put", "(", "\"childShapes\"", ",", "parseChildShapesRecursive", "(", "childShape", ".", "getChildShapes", "(", ")", ")", ")", ";", "childShapeObject", ".", "put", "(", "\"outgoing\"", ",", "parseOutgoings", "(", "childShape", ".", "getOutgoings", "(", ")", ")", ")", ";", "childShapeObject", ".", "put", "(", "\"bounds\"", ",", "parseBounds", "(", "childShape", ".", "getBounds", "(", ")", ")", ")", ";", "childShapeObject", ".", "put", "(", "\"dockers\"", ",", "parseDockers", "(", "childShape", ".", "getDockers", "(", ")", ")", ")", ";", "if", "(", "childShape", ".", "getTarget", "(", ")", "!=", "null", ")", "{", "childShapeObject", ".", "put", "(", "\"target\"", ",", "parseTarget", "(", "childShape", ".", "getTarget", "(", ")", ")", ")", ";", "}", "childShapesArray", ".", "put", "(", "childShapeObject", ")", ";", "}", "return", "childShapesArray", ";", "}", "return", "new", "JSONArray", "(", ")", ";", "}" ]
Parses all child Shapes recursively and adds them to the correct JSON Object @param childShapes @throws org.json.JSONException
[ "Parses", "all", "child", "Shapes", "recursively", "and", "adds", "them", "to", "the", "correct", "JSON", "Object" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L82-L116
160,825
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java
JSONBuilder.parseTarget
private static JSONObject parseTarget(Shape target) throws JSONException { JSONObject targetObject = new JSONObject(); targetObject.put("resourceId", target.getResourceId().toString()); return targetObject; }
java
private static JSONObject parseTarget(Shape target) throws JSONException { JSONObject targetObject = new JSONObject(); targetObject.put("resourceId", target.getResourceId().toString()); return targetObject; }
[ "private", "static", "JSONObject", "parseTarget", "(", "Shape", "target", ")", "throws", "JSONException", "{", "JSONObject", "targetObject", "=", "new", "JSONObject", "(", ")", ";", "targetObject", ".", "put", "(", "\"resourceId\"", ",", "target", ".", "getResourceId", "(", ")", ".", "toString", "(", ")", ")", ";", "return", "targetObject", ";", "}" ]
Delivers the correct JSON Object for the target @param target @throws org.json.JSONException
[ "Delivers", "the", "correct", "JSON", "Object", "for", "the", "target" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L124-L131
160,826
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java
JSONBuilder.parseDockers
private static JSONArray parseDockers(ArrayList<Point> dockers) throws JSONException { if (dockers != null) { JSONArray dockersArray = new JSONArray(); for (Point docker : dockers) { JSONObject dockerObject = new JSONObject(); dockerObject.put("x", docker.getX().doubleValue()); dockerObject.put("y", docker.getY().doubleValue()); dockersArray.put(dockerObject); } return dockersArray; } return new JSONArray(); }
java
private static JSONArray parseDockers(ArrayList<Point> dockers) throws JSONException { if (dockers != null) { JSONArray dockersArray = new JSONArray(); for (Point docker : dockers) { JSONObject dockerObject = new JSONObject(); dockerObject.put("x", docker.getX().doubleValue()); dockerObject.put("y", docker.getY().doubleValue()); dockersArray.put(dockerObject); } return dockersArray; } return new JSONArray(); }
[ "private", "static", "JSONArray", "parseDockers", "(", "ArrayList", "<", "Point", ">", "dockers", ")", "throws", "JSONException", "{", "if", "(", "dockers", "!=", "null", ")", "{", "JSONArray", "dockersArray", "=", "new", "JSONArray", "(", ")", ";", "for", "(", "Point", "docker", ":", "dockers", ")", "{", "JSONObject", "dockerObject", "=", "new", "JSONObject", "(", ")", ";", "dockerObject", ".", "put", "(", "\"x\"", ",", "docker", ".", "getX", "(", ")", ".", "doubleValue", "(", ")", ")", ";", "dockerObject", ".", "put", "(", "\"y\"", ",", "docker", ".", "getY", "(", ")", ".", "doubleValue", "(", ")", ")", ";", "dockersArray", ".", "put", "(", "dockerObject", ")", ";", "}", "return", "dockersArray", ";", "}", "return", "new", "JSONArray", "(", ")", ";", "}" ]
Delivers the correct JSON Object for the dockers @param dockers @throws org.json.JSONException
[ "Delivers", "the", "correct", "JSON", "Object", "for", "the", "dockers" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L139-L158
160,827
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java
JSONBuilder.parseOutgoings
private static JSONArray parseOutgoings(ArrayList<Shape> outgoings) throws JSONException { if (outgoings != null) { JSONArray outgoingsArray = new JSONArray(); for (Shape outgoing : outgoings) { JSONObject outgoingObject = new JSONObject(); outgoingObject.put("resourceId", outgoing.getResourceId().toString()); outgoingsArray.put(outgoingObject); } return outgoingsArray; } return new JSONArray(); }
java
private static JSONArray parseOutgoings(ArrayList<Shape> outgoings) throws JSONException { if (outgoings != null) { JSONArray outgoingsArray = new JSONArray(); for (Shape outgoing : outgoings) { JSONObject outgoingObject = new JSONObject(); outgoingObject.put("resourceId", outgoing.getResourceId().toString()); outgoingsArray.put(outgoingObject); } return outgoingsArray; } return new JSONArray(); }
[ "private", "static", "JSONArray", "parseOutgoings", "(", "ArrayList", "<", "Shape", ">", "outgoings", ")", "throws", "JSONException", "{", "if", "(", "outgoings", "!=", "null", ")", "{", "JSONArray", "outgoingsArray", "=", "new", "JSONArray", "(", ")", ";", "for", "(", "Shape", "outgoing", ":", "outgoings", ")", "{", "JSONObject", "outgoingObject", "=", "new", "JSONObject", "(", ")", ";", "outgoingObject", ".", "put", "(", "\"resourceId\"", ",", "outgoing", ".", "getResourceId", "(", ")", ".", "toString", "(", ")", ")", ";", "outgoingsArray", ".", "put", "(", "outgoingObject", ")", ";", "}", "return", "outgoingsArray", ";", "}", "return", "new", "JSONArray", "(", ")", ";", "}" ]
Delivers the correct JSON Object for outgoings @param outgoings @throws org.json.JSONException
[ "Delivers", "the", "correct", "JSON", "Object", "for", "outgoings" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L166-L182
160,828
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java
JSONBuilder.parseProperties
private static JSONObject parseProperties(HashMap<String, String> properties) throws JSONException { if (properties != null) { JSONObject propertiesObject = new JSONObject(); for (String key : properties.keySet()) { String propertyValue = properties.get(key); /* * if(propertyValue.matches("true|false")) { * * propertiesObject.put(key, propertyValue.equals("true")); * * } else if(propertyValue.matches("[0-9]+")) { * * Integer value = Integer.parseInt(propertyValue); * propertiesObject.put(key, value); * * } else */ if (propertyValue.startsWith("{") && propertyValue.endsWith("}")) { propertiesObject.put(key, new JSONObject(propertyValue)); } else { propertiesObject.put(key, propertyValue.toString()); } } return propertiesObject; } return new JSONObject(); }
java
private static JSONObject parseProperties(HashMap<String, String> properties) throws JSONException { if (properties != null) { JSONObject propertiesObject = new JSONObject(); for (String key : properties.keySet()) { String propertyValue = properties.get(key); /* * if(propertyValue.matches("true|false")) { * * propertiesObject.put(key, propertyValue.equals("true")); * * } else if(propertyValue.matches("[0-9]+")) { * * Integer value = Integer.parseInt(propertyValue); * propertiesObject.put(key, value); * * } else */ if (propertyValue.startsWith("{") && propertyValue.endsWith("}")) { propertiesObject.put(key, new JSONObject(propertyValue)); } else { propertiesObject.put(key, propertyValue.toString()); } } return propertiesObject; } return new JSONObject(); }
[ "private", "static", "JSONObject", "parseProperties", "(", "HashMap", "<", "String", ",", "String", ">", "properties", ")", "throws", "JSONException", "{", "if", "(", "properties", "!=", "null", ")", "{", "JSONObject", "propertiesObject", "=", "new", "JSONObject", "(", ")", ";", "for", "(", "String", "key", ":", "properties", ".", "keySet", "(", ")", ")", "{", "String", "propertyValue", "=", "properties", ".", "get", "(", "key", ")", ";", "/*\n * if(propertyValue.matches(\"true|false\")) {\n * \n * propertiesObject.put(key, propertyValue.equals(\"true\"));\n * \n * } else if(propertyValue.matches(\"[0-9]+\")) {\n * \n * Integer value = Integer.parseInt(propertyValue);\n * propertiesObject.put(key, value);\n * \n * } else\n */", "if", "(", "propertyValue", ".", "startsWith", "(", "\"{\"", ")", "&&", "propertyValue", ".", "endsWith", "(", "\"}\"", ")", ")", "{", "propertiesObject", ".", "put", "(", "key", ",", "new", "JSONObject", "(", "propertyValue", ")", ")", ";", "}", "else", "{", "propertiesObject", ".", "put", "(", "key", ",", "propertyValue", ".", "toString", "(", ")", ")", ";", "}", "}", "return", "propertiesObject", ";", "}", "return", "new", "JSONObject", "(", ")", ";", "}" ]
Delivers the correct JSON Object for properties @param properties @throws org.json.JSONException
[ "Delivers", "the", "correct", "JSON", "Object", "for", "properties" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L190-L222
160,829
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java
JSONBuilder.parseStencilSetExtensions
private static JSONArray parseStencilSetExtensions(ArrayList<String> extensions) { if (extensions != null) { JSONArray extensionsArray = new JSONArray(); for (String extension : extensions) { extensionsArray.put(extension.toString()); } return extensionsArray; } return new JSONArray(); }
java
private static JSONArray parseStencilSetExtensions(ArrayList<String> extensions) { if (extensions != null) { JSONArray extensionsArray = new JSONArray(); for (String extension : extensions) { extensionsArray.put(extension.toString()); } return extensionsArray; } return new JSONArray(); }
[ "private", "static", "JSONArray", "parseStencilSetExtensions", "(", "ArrayList", "<", "String", ">", "extensions", ")", "{", "if", "(", "extensions", "!=", "null", ")", "{", "JSONArray", "extensionsArray", "=", "new", "JSONArray", "(", ")", ";", "for", "(", "String", "extension", ":", "extensions", ")", "{", "extensionsArray", ".", "put", "(", "extension", ".", "toString", "(", ")", ")", ";", "}", "return", "extensionsArray", ";", "}", "return", "new", "JSONArray", "(", ")", ";", "}" ]
Delivers the correct JSON Object for the Stencilset Extensions @param extensions
[ "Delivers", "the", "correct", "JSON", "Object", "for", "the", "Stencilset", "Extensions" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L229-L241
160,830
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java
JSONBuilder.parseStencilSet
private static JSONObject parseStencilSet(StencilSet stencilSet) throws JSONException { if (stencilSet != null) { JSONObject stencilSetObject = new JSONObject(); stencilSetObject.put("url", stencilSet.getUrl().toString()); stencilSetObject.put("namespace", stencilSet.getNamespace().toString()); return stencilSetObject; } return new JSONObject(); }
java
private static JSONObject parseStencilSet(StencilSet stencilSet) throws JSONException { if (stencilSet != null) { JSONObject stencilSetObject = new JSONObject(); stencilSetObject.put("url", stencilSet.getUrl().toString()); stencilSetObject.put("namespace", stencilSet.getNamespace().toString()); return stencilSetObject; } return new JSONObject(); }
[ "private", "static", "JSONObject", "parseStencilSet", "(", "StencilSet", "stencilSet", ")", "throws", "JSONException", "{", "if", "(", "stencilSet", "!=", "null", ")", "{", "JSONObject", "stencilSetObject", "=", "new", "JSONObject", "(", ")", ";", "stencilSetObject", ".", "put", "(", "\"url\"", ",", "stencilSet", ".", "getUrl", "(", ")", ".", "toString", "(", ")", ")", ";", "stencilSetObject", ".", "put", "(", "\"namespace\"", ",", "stencilSet", ".", "getNamespace", "(", ")", ".", "toString", "(", ")", ")", ";", "return", "stencilSetObject", ";", "}", "return", "new", "JSONObject", "(", ")", ";", "}" ]
Delivers the correct JSON Object for the Stencilset @param stencilSet @throws org.json.JSONException
[ "Delivers", "the", "correct", "JSON", "Object", "for", "the", "Stencilset" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L249-L262
160,831
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java
JSONBuilder.parseBounds
private static JSONObject parseBounds(Bounds bounds) throws JSONException { if (bounds != null) { JSONObject boundsObject = new JSONObject(); JSONObject lowerRight = new JSONObject(); JSONObject upperLeft = new JSONObject(); lowerRight.put("x", bounds.getLowerRight().getX().doubleValue()); lowerRight.put("y", bounds.getLowerRight().getY().doubleValue()); upperLeft.put("x", bounds.getUpperLeft().getX().doubleValue()); upperLeft.put("y", bounds.getUpperLeft().getY().doubleValue()); boundsObject.put("lowerRight", lowerRight); boundsObject.put("upperLeft", upperLeft); return boundsObject; } return new JSONObject(); }
java
private static JSONObject parseBounds(Bounds bounds) throws JSONException { if (bounds != null) { JSONObject boundsObject = new JSONObject(); JSONObject lowerRight = new JSONObject(); JSONObject upperLeft = new JSONObject(); lowerRight.put("x", bounds.getLowerRight().getX().doubleValue()); lowerRight.put("y", bounds.getLowerRight().getY().doubleValue()); upperLeft.put("x", bounds.getUpperLeft().getX().doubleValue()); upperLeft.put("y", bounds.getUpperLeft().getY().doubleValue()); boundsObject.put("lowerRight", lowerRight); boundsObject.put("upperLeft", upperLeft); return boundsObject; } return new JSONObject(); }
[ "private", "static", "JSONObject", "parseBounds", "(", "Bounds", "bounds", ")", "throws", "JSONException", "{", "if", "(", "bounds", "!=", "null", ")", "{", "JSONObject", "boundsObject", "=", "new", "JSONObject", "(", ")", ";", "JSONObject", "lowerRight", "=", "new", "JSONObject", "(", ")", ";", "JSONObject", "upperLeft", "=", "new", "JSONObject", "(", ")", ";", "lowerRight", ".", "put", "(", "\"x\"", ",", "bounds", ".", "getLowerRight", "(", ")", ".", "getX", "(", ")", ".", "doubleValue", "(", ")", ")", ";", "lowerRight", ".", "put", "(", "\"y\"", ",", "bounds", ".", "getLowerRight", "(", ")", ".", "getY", "(", ")", ".", "doubleValue", "(", ")", ")", ";", "upperLeft", ".", "put", "(", "\"x\"", ",", "bounds", ".", "getUpperLeft", "(", ")", ".", "getX", "(", ")", ".", "doubleValue", "(", ")", ")", ";", "upperLeft", ".", "put", "(", "\"y\"", ",", "bounds", ".", "getUpperLeft", "(", ")", ".", "getY", "(", ")", ".", "doubleValue", "(", ")", ")", ";", "boundsObject", ".", "put", "(", "\"lowerRight\"", ",", "lowerRight", ")", ";", "boundsObject", ".", "put", "(", "\"upperLeft\"", ",", "upperLeft", ")", ";", "return", "boundsObject", ";", "}", "return", "new", "JSONObject", "(", ")", ";", "}" ]
Delivers the correct JSON Object for the Bounds @param bounds @throws org.json.JSONException
[ "Delivers", "the", "correct", "JSON", "Object", "for", "the", "Bounds" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/diagram/JSONBuilder.java#L270-L295
160,832
kiegroup/jbpm-designer
jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java
StringUtils.createQuotedConstant
public static String createQuotedConstant(String str) { if (str == null || str.isEmpty()) { return str; } try { Double.parseDouble(str); } catch (NumberFormatException nfe) { return "\"" + str + "\""; } return str; }
java
public static String createQuotedConstant(String str) { if (str == null || str.isEmpty()) { return str; } try { Double.parseDouble(str); } catch (NumberFormatException nfe) { return "\"" + str + "\""; } return str; }
[ "public", "static", "String", "createQuotedConstant", "(", "String", "str", ")", "{", "if", "(", "str", "==", "null", "||", "str", ".", "isEmpty", "(", ")", ")", "{", "return", "str", ";", "}", "try", "{", "Double", ".", "parseDouble", "(", "str", ")", ";", "}", "catch", "(", "NumberFormatException", "nfe", ")", "{", "return", "\"\\\"\"", "+", "str", "+", "\"\\\"\"", ";", "}", "return", "str", ";", "}" ]
Puts strings inside quotes and numerics are left as they are. @param str @return
[ "Puts", "strings", "inside", "quotes", "and", "numerics", "are", "left", "as", "they", "are", "." ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java#L31-L41
160,833
kiegroup/jbpm-designer
jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java
StringUtils.createUnquotedConstant
public static String createUnquotedConstant(String str) { if (str == null || str.isEmpty()) { return str; } if (str.startsWith("\"")) { str = str.substring(1); } if (str.endsWith("\"")) { str = str.substring(0, str.length() - 1); } return str; }
java
public static String createUnquotedConstant(String str) { if (str == null || str.isEmpty()) { return str; } if (str.startsWith("\"")) { str = str.substring(1); } if (str.endsWith("\"")) { str = str.substring(0, str.length() - 1); } return str; }
[ "public", "static", "String", "createUnquotedConstant", "(", "String", "str", ")", "{", "if", "(", "str", "==", "null", "||", "str", ".", "isEmpty", "(", ")", ")", "{", "return", "str", ";", "}", "if", "(", "str", ".", "startsWith", "(", "\"\\\"\"", ")", ")", "{", "str", "=", "str", ".", "substring", "(", "1", ")", ";", "}", "if", "(", "str", ".", "endsWith", "(", "\"\\\"\"", ")", ")", "{", "str", "=", "str", ".", "substring", "(", "0", ",", "str", ".", "length", "(", ")", "-", "1", ")", ";", "}", "return", "str", ";", "}" ]
Removes double-quotes from around a string @param str @return
[ "Removes", "double", "-", "quotes", "from", "around", "a", "string" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java#L48-L60
160,834
kiegroup/jbpm-designer
jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java
StringUtils.isQuotedConstant
public static boolean isQuotedConstant(String str) { if (str == null || str.isEmpty()) { return false; } return (str.startsWith("\"") && str.endsWith("\"")); }
java
public static boolean isQuotedConstant(String str) { if (str == null || str.isEmpty()) { return false; } return (str.startsWith("\"") && str.endsWith("\"")); }
[ "public", "static", "boolean", "isQuotedConstant", "(", "String", "str", ")", "{", "if", "(", "str", "==", "null", "||", "str", ".", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "return", "(", "str", ".", "startsWith", "(", "\"\\\"\"", ")", "&&", "str", ".", "endsWith", "(", "\"\\\"\"", ")", ")", ";", "}" ]
Returns true if string starts and ends with double-quote @param str @return
[ "Returns", "true", "if", "string", "starts", "and", "ends", "with", "double", "-", "quote" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java#L67-L72
160,835
kiegroup/jbpm-designer
jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java
StringUtils.urlEncode
public String urlEncode(String s) { if (s == null || s.isEmpty()) { return s; } return URL.encodeQueryString(s); }
java
public String urlEncode(String s) { if (s == null || s.isEmpty()) { return s; } return URL.encodeQueryString(s); }
[ "public", "String", "urlEncode", "(", "String", "s", ")", "{", "if", "(", "s", "==", "null", "||", "s", ".", "isEmpty", "(", ")", ")", "{", "return", "s", ";", "}", "return", "URL", ".", "encodeQueryString", "(", "s", ")", ";", "}" ]
URLEncode a string @param s @return
[ "URLEncode", "a", "string" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java#L79-L85
160,836
kiegroup/jbpm-designer
jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java
StringUtils.urlDecode
public String urlDecode(String s) { if (s == null || s.isEmpty()) { return s; } return URL.decodeQueryString(s); }
java
public String urlDecode(String s) { if (s == null || s.isEmpty()) { return s; } return URL.decodeQueryString(s); }
[ "public", "String", "urlDecode", "(", "String", "s", ")", "{", "if", "(", "s", "==", "null", "||", "s", ".", "isEmpty", "(", ")", ")", "{", "return", "s", ";", "}", "return", "URL", ".", "decodeQueryString", "(", "s", ")", ";", "}" ]
URLDecode a string @param s @return
[ "URLDecode", "a", "string" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/util/StringUtils.java#L92-L97
160,837
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java
Bpmn2JsonUnmarshaller.unmarshall
private Bpmn2Resource unmarshall(JsonParser parser, String preProcessingData) throws IOException { try { parser.nextToken(); // open the object ResourceSet rSet = new ResourceSetImpl(); rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn2", new JBPMBpmn2ResourceFactoryImpl()); Bpmn2Resource bpmn2 = (Bpmn2Resource) rSet.createResource(URI.createURI("virtual.bpmn2")); rSet.getResources().add(bpmn2); _currentResource = bpmn2; if (preProcessingData == null || preProcessingData.length() < 1) { preProcessingData = "ReadOnlyService"; } // do the unmarshalling now: Definitions def = (Definitions) unmarshallItem(parser, preProcessingData); def.setExporter(exporterName); def.setExporterVersion(exporterVersion); revisitUserTasks(def); revisitServiceTasks(def); revisitMessages(def); revisitCatchEvents(def); revisitThrowEvents(def); revisitLanes(def); revisitSubProcessItemDefs(def); revisitArtifacts(def); revisitGroups(def); revisitTaskAssociations(def); revisitTaskIoSpecification(def); revisitSendReceiveTasks(def); reconnectFlows(); revisitGateways(def); revisitCatchEventsConvertToBoundary(def); revisitBoundaryEventsPositions(def); createDiagram(def); updateIDs(def); revisitDataObjects(def); revisitAssociationsIoSpec(def); revisitWsdlImports(def); revisitMultiInstanceTasks(def); addSimulation(def); revisitItemDefinitions(def); revisitProcessDoc(def); revisitDI(def); revisitSignalRef(def); orderDiagramElements(def); // return def; _currentResource.getContents().add(def); return _currentResource; } catch (Exception e) { _logger.error(e.getMessage()); return _currentResource; } finally { parser.close(); _objMap.clear(); _idMap.clear(); _outgoingFlows.clear(); _sequenceFlowTargets.clear(); _bounds.clear(); _currentResource = null; } }
java
private Bpmn2Resource unmarshall(JsonParser parser, String preProcessingData) throws IOException { try { parser.nextToken(); // open the object ResourceSet rSet = new ResourceSetImpl(); rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn2", new JBPMBpmn2ResourceFactoryImpl()); Bpmn2Resource bpmn2 = (Bpmn2Resource) rSet.createResource(URI.createURI("virtual.bpmn2")); rSet.getResources().add(bpmn2); _currentResource = bpmn2; if (preProcessingData == null || preProcessingData.length() < 1) { preProcessingData = "ReadOnlyService"; } // do the unmarshalling now: Definitions def = (Definitions) unmarshallItem(parser, preProcessingData); def.setExporter(exporterName); def.setExporterVersion(exporterVersion); revisitUserTasks(def); revisitServiceTasks(def); revisitMessages(def); revisitCatchEvents(def); revisitThrowEvents(def); revisitLanes(def); revisitSubProcessItemDefs(def); revisitArtifacts(def); revisitGroups(def); revisitTaskAssociations(def); revisitTaskIoSpecification(def); revisitSendReceiveTasks(def); reconnectFlows(); revisitGateways(def); revisitCatchEventsConvertToBoundary(def); revisitBoundaryEventsPositions(def); createDiagram(def); updateIDs(def); revisitDataObjects(def); revisitAssociationsIoSpec(def); revisitWsdlImports(def); revisitMultiInstanceTasks(def); addSimulation(def); revisitItemDefinitions(def); revisitProcessDoc(def); revisitDI(def); revisitSignalRef(def); orderDiagramElements(def); // return def; _currentResource.getContents().add(def); return _currentResource; } catch (Exception e) { _logger.error(e.getMessage()); return _currentResource; } finally { parser.close(); _objMap.clear(); _idMap.clear(); _outgoingFlows.clear(); _sequenceFlowTargets.clear(); _bounds.clear(); _currentResource = null; } }
[ "private", "Bpmn2Resource", "unmarshall", "(", "JsonParser", "parser", ",", "String", "preProcessingData", ")", "throws", "IOException", "{", "try", "{", "parser", ".", "nextToken", "(", ")", ";", "// open the object", "ResourceSet", "rSet", "=", "new", "ResourceSetImpl", "(", ")", ";", "rSet", ".", "getResourceFactoryRegistry", "(", ")", ".", "getExtensionToFactoryMap", "(", ")", ".", "put", "(", "\"bpmn2\"", ",", "new", "JBPMBpmn2ResourceFactoryImpl", "(", ")", ")", ";", "Bpmn2Resource", "bpmn2", "=", "(", "Bpmn2Resource", ")", "rSet", ".", "createResource", "(", "URI", ".", "createURI", "(", "\"virtual.bpmn2\"", ")", ")", ";", "rSet", ".", "getResources", "(", ")", ".", "add", "(", "bpmn2", ")", ";", "_currentResource", "=", "bpmn2", ";", "if", "(", "preProcessingData", "==", "null", "||", "preProcessingData", ".", "length", "(", ")", "<", "1", ")", "{", "preProcessingData", "=", "\"ReadOnlyService\"", ";", "}", "// do the unmarshalling now:", "Definitions", "def", "=", "(", "Definitions", ")", "unmarshallItem", "(", "parser", ",", "preProcessingData", ")", ";", "def", ".", "setExporter", "(", "exporterName", ")", ";", "def", ".", "setExporterVersion", "(", "exporterVersion", ")", ";", "revisitUserTasks", "(", "def", ")", ";", "revisitServiceTasks", "(", "def", ")", ";", "revisitMessages", "(", "def", ")", ";", "revisitCatchEvents", "(", "def", ")", ";", "revisitThrowEvents", "(", "def", ")", ";", "revisitLanes", "(", "def", ")", ";", "revisitSubProcessItemDefs", "(", "def", ")", ";", "revisitArtifacts", "(", "def", ")", ";", "revisitGroups", "(", "def", ")", ";", "revisitTaskAssociations", "(", "def", ")", ";", "revisitTaskIoSpecification", "(", "def", ")", ";", "revisitSendReceiveTasks", "(", "def", ")", ";", "reconnectFlows", "(", ")", ";", "revisitGateways", "(", "def", ")", ";", "revisitCatchEventsConvertToBoundary", "(", "def", ")", ";", "revisitBoundaryEventsPositions", "(", "def", ")", ";", "createDiagram", "(", "def", ")", ";", "updateIDs", "(", "def", ")", ";", "revisitDataObjects", "(", "def", ")", ";", "revisitAssociationsIoSpec", "(", "def", ")", ";", "revisitWsdlImports", "(", "def", ")", ";", "revisitMultiInstanceTasks", "(", "def", ")", ";", "addSimulation", "(", "def", ")", ";", "revisitItemDefinitions", "(", "def", ")", ";", "revisitProcessDoc", "(", "def", ")", ";", "revisitDI", "(", "def", ")", ";", "revisitSignalRef", "(", "def", ")", ";", "orderDiagramElements", "(", "def", ")", ";", "// return def;", "_currentResource", ".", "getContents", "(", ")", ".", "add", "(", "def", ")", ";", "return", "_currentResource", ";", "}", "catch", "(", "Exception", "e", ")", "{", "_logger", ".", "error", "(", "e", ".", "getMessage", "(", ")", ")", ";", "return", "_currentResource", ";", "}", "finally", "{", "parser", ".", "close", "(", ")", ";", "_objMap", ".", "clear", "(", ")", ";", "_idMap", ".", "clear", "(", ")", ";", "_outgoingFlows", ".", "clear", "(", ")", ";", "_sequenceFlowTargets", ".", "clear", "(", ")", ";", "_bounds", ".", "clear", "(", ")", ";", "_currentResource", "=", "null", ";", "}", "}" ]
Start unmarshalling using the parser. @param parser @param preProcessingData @return the root element of a bpmn2 document. @throws java.io.IOException
[ "Start", "unmarshalling", "using", "the", "parser", "." ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java#L274-L338
160,838
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java
Bpmn2JsonUnmarshaller.revisitThrowEvents
public void revisitThrowEvents(Definitions def) { List<RootElement> rootElements = def.getRootElements(); List<Signal> toAddSignals = new ArrayList<Signal>(); Set<Error> toAddErrors = new HashSet<Error>(); Set<Escalation> toAddEscalations = new HashSet<Escalation>(); Set<Message> toAddMessages = new HashSet<Message>(); Set<ItemDefinition> toAddItemDefinitions = new HashSet<ItemDefinition>(); for (RootElement root : rootElements) { if (root instanceof Process) { setThrowEventsInfo((Process) root, def, rootElements, toAddSignals, toAddErrors, toAddEscalations, toAddMessages, toAddItemDefinitions); } } for (Lane lane : _lanes) { setThrowEventsInfoForLanes(lane, def, rootElements, toAddSignals, toAddErrors, toAddEscalations, toAddMessages, toAddItemDefinitions); } for (Signal s : toAddSignals) { def.getRootElements().add(s); } for (Error er : toAddErrors) { def.getRootElements().add(er); } for (Escalation es : toAddEscalations) { def.getRootElements().add(es); } for (ItemDefinition idef : toAddItemDefinitions) { def.getRootElements().add(idef); } for (Message msg : toAddMessages) { def.getRootElements().add(msg); } }
java
public void revisitThrowEvents(Definitions def) { List<RootElement> rootElements = def.getRootElements(); List<Signal> toAddSignals = new ArrayList<Signal>(); Set<Error> toAddErrors = new HashSet<Error>(); Set<Escalation> toAddEscalations = new HashSet<Escalation>(); Set<Message> toAddMessages = new HashSet<Message>(); Set<ItemDefinition> toAddItemDefinitions = new HashSet<ItemDefinition>(); for (RootElement root : rootElements) { if (root instanceof Process) { setThrowEventsInfo((Process) root, def, rootElements, toAddSignals, toAddErrors, toAddEscalations, toAddMessages, toAddItemDefinitions); } } for (Lane lane : _lanes) { setThrowEventsInfoForLanes(lane, def, rootElements, toAddSignals, toAddErrors, toAddEscalations, toAddMessages, toAddItemDefinitions); } for (Signal s : toAddSignals) { def.getRootElements().add(s); } for (Error er : toAddErrors) { def.getRootElements().add(er); } for (Escalation es : toAddEscalations) { def.getRootElements().add(es); } for (ItemDefinition idef : toAddItemDefinitions) { def.getRootElements().add(idef); } for (Message msg : toAddMessages) { def.getRootElements().add(msg); } }
[ "public", "void", "revisitThrowEvents", "(", "Definitions", "def", ")", "{", "List", "<", "RootElement", ">", "rootElements", "=", "def", ".", "getRootElements", "(", ")", ";", "List", "<", "Signal", ">", "toAddSignals", "=", "new", "ArrayList", "<", "Signal", ">", "(", ")", ";", "Set", "<", "Error", ">", "toAddErrors", "=", "new", "HashSet", "<", "Error", ">", "(", ")", ";", "Set", "<", "Escalation", ">", "toAddEscalations", "=", "new", "HashSet", "<", "Escalation", ">", "(", ")", ";", "Set", "<", "Message", ">", "toAddMessages", "=", "new", "HashSet", "<", "Message", ">", "(", ")", ";", "Set", "<", "ItemDefinition", ">", "toAddItemDefinitions", "=", "new", "HashSet", "<", "ItemDefinition", ">", "(", ")", ";", "for", "(", "RootElement", "root", ":", "rootElements", ")", "{", "if", "(", "root", "instanceof", "Process", ")", "{", "setThrowEventsInfo", "(", "(", "Process", ")", "root", ",", "def", ",", "rootElements", ",", "toAddSignals", ",", "toAddErrors", ",", "toAddEscalations", ",", "toAddMessages", ",", "toAddItemDefinitions", ")", ";", "}", "}", "for", "(", "Lane", "lane", ":", "_lanes", ")", "{", "setThrowEventsInfoForLanes", "(", "lane", ",", "def", ",", "rootElements", ",", "toAddSignals", ",", "toAddErrors", ",", "toAddEscalations", ",", "toAddMessages", ",", "toAddItemDefinitions", ")", ";", "}", "for", "(", "Signal", "s", ":", "toAddSignals", ")", "{", "def", ".", "getRootElements", "(", ")", ".", "add", "(", "s", ")", ";", "}", "for", "(", "Error", "er", ":", "toAddErrors", ")", "{", "def", ".", "getRootElements", "(", ")", ".", "add", "(", "er", ")", ";", "}", "for", "(", "Escalation", "es", ":", "toAddEscalations", ")", "{", "def", ".", "getRootElements", "(", ")", ".", "add", "(", "es", ")", ";", "}", "for", "(", "ItemDefinition", "idef", ":", "toAddItemDefinitions", ")", "{", "def", ".", "getRootElements", "(", ")", ".", "add", "(", "idef", ")", ";", "}", "for", "(", "Message", "msg", ":", "toAddMessages", ")", "{", "def", ".", "getRootElements", "(", ")", ".", "add", "(", "msg", ")", ";", "}", "}" ]
Updates event definitions for all throwing events. @param def Definitions
[ "Updates", "event", "definitions", "for", "all", "throwing", "events", "." ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java#L1704-L1748
160,839
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java
Bpmn2JsonUnmarshaller.revisitGateways
private void revisitGateways(Definitions def) { List<RootElement> rootElements = def.getRootElements(); for (RootElement root : rootElements) { if (root instanceof Process) { setGatewayInfo((Process) root); } } }
java
private void revisitGateways(Definitions def) { List<RootElement> rootElements = def.getRootElements(); for (RootElement root : rootElements) { if (root instanceof Process) { setGatewayInfo((Process) root); } } }
[ "private", "void", "revisitGateways", "(", "Definitions", "def", ")", "{", "List", "<", "RootElement", ">", "rootElements", "=", "def", ".", "getRootElements", "(", ")", ";", "for", "(", "RootElement", "root", ":", "rootElements", ")", "{", "if", "(", "root", "instanceof", "Process", ")", "{", "setGatewayInfo", "(", "(", "Process", ")", "root", ")", ";", "}", "}", "}" ]
Updates the gatewayDirection attributes of all gateways. @param def
[ "Updates", "the", "gatewayDirection", "attributes", "of", "all", "gateways", "." ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java#L2613-L2620
160,840
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java
Bpmn2JsonUnmarshaller.revisitMessages
private void revisitMessages(Definitions def) { List<RootElement> rootElements = def.getRootElements(); List<ItemDefinition> toAddDefinitions = new ArrayList<ItemDefinition>(); for (RootElement root : rootElements) { if (root instanceof Message) { if (!existsMessageItemDefinition(rootElements, root.getId())) { ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition(); itemdef.setId(root.getId() + "Type"); toAddDefinitions.add(itemdef); ((Message) root).setItemRef(itemdef); } } } for (ItemDefinition id : toAddDefinitions) { def.getRootElements().add(id); } }
java
private void revisitMessages(Definitions def) { List<RootElement> rootElements = def.getRootElements(); List<ItemDefinition> toAddDefinitions = new ArrayList<ItemDefinition>(); for (RootElement root : rootElements) { if (root instanceof Message) { if (!existsMessageItemDefinition(rootElements, root.getId())) { ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition(); itemdef.setId(root.getId() + "Type"); toAddDefinitions.add(itemdef); ((Message) root).setItemRef(itemdef); } } } for (ItemDefinition id : toAddDefinitions) { def.getRootElements().add(id); } }
[ "private", "void", "revisitMessages", "(", "Definitions", "def", ")", "{", "List", "<", "RootElement", ">", "rootElements", "=", "def", ".", "getRootElements", "(", ")", ";", "List", "<", "ItemDefinition", ">", "toAddDefinitions", "=", "new", "ArrayList", "<", "ItemDefinition", ">", "(", ")", ";", "for", "(", "RootElement", "root", ":", "rootElements", ")", "{", "if", "(", "root", "instanceof", "Message", ")", "{", "if", "(", "!", "existsMessageItemDefinition", "(", "rootElements", ",", "root", ".", "getId", "(", ")", ")", ")", "{", "ItemDefinition", "itemdef", "=", "Bpmn2Factory", ".", "eINSTANCE", ".", "createItemDefinition", "(", ")", ";", "itemdef", ".", "setId", "(", "root", ".", "getId", "(", ")", "+", "\"Type\"", ")", ";", "toAddDefinitions", ".", "add", "(", "itemdef", ")", ";", "(", "(", "Message", ")", "root", ")", ".", "setItemRef", "(", "itemdef", ")", ";", "}", "}", "}", "for", "(", "ItemDefinition", "id", ":", "toAddDefinitions", ")", "{", "def", ".", "getRootElements", "(", ")", ".", "add", "(", "id", ")", ";", "}", "}" ]
Revisit message to set their item ref to a item definition @param def Definitions
[ "Revisit", "message", "to", "set", "their", "item", "ref", "to", "a", "item", "definition" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java#L3032-L3049
160,841
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java
Bpmn2JsonUnmarshaller.reconnectFlows
private void reconnectFlows() { // create the reverse id map: for (Entry<Object, List<String>> entry : _outgoingFlows.entrySet()) { for (String flowId : entry.getValue()) { if (entry.getKey() instanceof SequenceFlow) { // if it is a sequence flow, we can tell its targets if (_idMap.get(flowId) instanceof FlowNode) { ((SequenceFlow) entry.getKey()).setTargetRef((FlowNode) _idMap.get(flowId)); } if (_idMap.get(flowId) instanceof Association) { ((Association) _idMap.get(flowId)).setTargetRef((SequenceFlow) entry.getKey()); } } else if (entry.getKey() instanceof Association) { ((Association) entry.getKey()).setTargetRef((BaseElement) _idMap.get(flowId)); } else { // if it is a node, we can map it to its outgoing sequence flows if (_idMap.get(flowId) instanceof SequenceFlow) { ((FlowNode) entry.getKey()).getOutgoing().add((SequenceFlow) _idMap.get(flowId)); } else if (_idMap.get(flowId) instanceof Association) { ((Association) _idMap.get(flowId)).setSourceRef((BaseElement) entry.getKey()); } } } } }
java
private void reconnectFlows() { // create the reverse id map: for (Entry<Object, List<String>> entry : _outgoingFlows.entrySet()) { for (String flowId : entry.getValue()) { if (entry.getKey() instanceof SequenceFlow) { // if it is a sequence flow, we can tell its targets if (_idMap.get(flowId) instanceof FlowNode) { ((SequenceFlow) entry.getKey()).setTargetRef((FlowNode) _idMap.get(flowId)); } if (_idMap.get(flowId) instanceof Association) { ((Association) _idMap.get(flowId)).setTargetRef((SequenceFlow) entry.getKey()); } } else if (entry.getKey() instanceof Association) { ((Association) entry.getKey()).setTargetRef((BaseElement) _idMap.get(flowId)); } else { // if it is a node, we can map it to its outgoing sequence flows if (_idMap.get(flowId) instanceof SequenceFlow) { ((FlowNode) entry.getKey()).getOutgoing().add((SequenceFlow) _idMap.get(flowId)); } else if (_idMap.get(flowId) instanceof Association) { ((Association) _idMap.get(flowId)).setSourceRef((BaseElement) entry.getKey()); } } } } }
[ "private", "void", "reconnectFlows", "(", ")", "{", "// create the reverse id map:", "for", "(", "Entry", "<", "Object", ",", "List", "<", "String", ">", ">", "entry", ":", "_outgoingFlows", ".", "entrySet", "(", ")", ")", "{", "for", "(", "String", "flowId", ":", "entry", ".", "getValue", "(", ")", ")", "{", "if", "(", "entry", ".", "getKey", "(", ")", "instanceof", "SequenceFlow", ")", "{", "// if it is a sequence flow, we can tell its targets", "if", "(", "_idMap", ".", "get", "(", "flowId", ")", "instanceof", "FlowNode", ")", "{", "(", "(", "SequenceFlow", ")", "entry", ".", "getKey", "(", ")", ")", ".", "setTargetRef", "(", "(", "FlowNode", ")", "_idMap", ".", "get", "(", "flowId", ")", ")", ";", "}", "if", "(", "_idMap", ".", "get", "(", "flowId", ")", "instanceof", "Association", ")", "{", "(", "(", "Association", ")", "_idMap", ".", "get", "(", "flowId", ")", ")", ".", "setTargetRef", "(", "(", "SequenceFlow", ")", "entry", ".", "getKey", "(", ")", ")", ";", "}", "}", "else", "if", "(", "entry", ".", "getKey", "(", ")", "instanceof", "Association", ")", "{", "(", "(", "Association", ")", "entry", ".", "getKey", "(", ")", ")", ".", "setTargetRef", "(", "(", "BaseElement", ")", "_idMap", ".", "get", "(", "flowId", ")", ")", ";", "}", "else", "{", "// if it is a node, we can map it to its outgoing sequence flows", "if", "(", "_idMap", ".", "get", "(", "flowId", ")", "instanceof", "SequenceFlow", ")", "{", "(", "(", "FlowNode", ")", "entry", ".", "getKey", "(", ")", ")", ".", "getOutgoing", "(", ")", ".", "add", "(", "(", "SequenceFlow", ")", "_idMap", ".", "get", "(", "flowId", ")", ")", ";", "}", "else", "if", "(", "_idMap", ".", "get", "(", "flowId", ")", "instanceof", "Association", ")", "{", "(", "(", "Association", ")", "_idMap", ".", "get", "(", "flowId", ")", ")", ".", "setSourceRef", "(", "(", "BaseElement", ")", "entry", ".", "getKey", "(", ")", ")", ";", "}", "}", "}", "}", "}" ]
Reconnect the sequence flows and the flow nodes. Done after the initial pass so that we have all the target information.
[ "Reconnect", "the", "sequence", "flows", "and", "the", "flow", "nodes", ".", "Done", "after", "the", "initial", "pass", "so", "that", "we", "have", "all", "the", "target", "information", "." ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/bpmn2/impl/Bpmn2JsonUnmarshaller.java#L3076-L3098
160,842
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/web/server/menu/connector/AbstractConnectorServlet.java
AbstractConnectorServlet.parseRequest
protected void parseRequest(HttpServletRequest request, HttpServletResponse response) { requestParams = new HashMap<String, Object>(); listFiles = new ArrayList<FileItemStream>(); listFileStreams = new ArrayList<ByteArrayOutputStream>(); // Parse the request if (ServletFileUpload.isMultipartContent(request)) { // multipart request try { ServletFileUpload upload = new ServletFileUpload(); FileItemIterator iter = upload.getItemIterator(request); while (iter.hasNext()) { FileItemStream item = iter.next(); String name = item.getFieldName(); InputStream stream = item.openStream(); if (item.isFormField()) { requestParams.put(name, Streams.asString(stream)); } else { String fileName = item.getName(); if (fileName != null && !"".equals(fileName.trim())) { listFiles.add(item); ByteArrayOutputStream os = new ByteArrayOutputStream(); IOUtils.copy(stream, os); listFileStreams.add(os); } } } } catch (Exception e) { logger.error("Unexpected error parsing multipart content", e); } } else { // not a multipart for (Object mapKey : request.getParameterMap().keySet()) { String mapKeyString = (String) mapKey; if (mapKeyString.endsWith("[]")) { // multiple values String values[] = request.getParameterValues(mapKeyString); List<String> listeValues = new ArrayList<String>(); for (String value : values) { listeValues.add(value); } requestParams.put(mapKeyString, listeValues); } else { // single value String value = request.getParameter(mapKeyString); requestParams.put(mapKeyString, value); } } } }
java
protected void parseRequest(HttpServletRequest request, HttpServletResponse response) { requestParams = new HashMap<String, Object>(); listFiles = new ArrayList<FileItemStream>(); listFileStreams = new ArrayList<ByteArrayOutputStream>(); // Parse the request if (ServletFileUpload.isMultipartContent(request)) { // multipart request try { ServletFileUpload upload = new ServletFileUpload(); FileItemIterator iter = upload.getItemIterator(request); while (iter.hasNext()) { FileItemStream item = iter.next(); String name = item.getFieldName(); InputStream stream = item.openStream(); if (item.isFormField()) { requestParams.put(name, Streams.asString(stream)); } else { String fileName = item.getName(); if (fileName != null && !"".equals(fileName.trim())) { listFiles.add(item); ByteArrayOutputStream os = new ByteArrayOutputStream(); IOUtils.copy(stream, os); listFileStreams.add(os); } } } } catch (Exception e) { logger.error("Unexpected error parsing multipart content", e); } } else { // not a multipart for (Object mapKey : request.getParameterMap().keySet()) { String mapKeyString = (String) mapKey; if (mapKeyString.endsWith("[]")) { // multiple values String values[] = request.getParameterValues(mapKeyString); List<String> listeValues = new ArrayList<String>(); for (String value : values) { listeValues.add(value); } requestParams.put(mapKeyString, listeValues); } else { // single value String value = request.getParameter(mapKeyString); requestParams.put(mapKeyString, value); } } } }
[ "protected", "void", "parseRequest", "(", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ")", "{", "requestParams", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "listFiles", "=", "new", "ArrayList", "<", "FileItemStream", ">", "(", ")", ";", "listFileStreams", "=", "new", "ArrayList", "<", "ByteArrayOutputStream", ">", "(", ")", ";", "// Parse the request", "if", "(", "ServletFileUpload", ".", "isMultipartContent", "(", "request", ")", ")", "{", "// multipart request", "try", "{", "ServletFileUpload", "upload", "=", "new", "ServletFileUpload", "(", ")", ";", "FileItemIterator", "iter", "=", "upload", ".", "getItemIterator", "(", "request", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "FileItemStream", "item", "=", "iter", ".", "next", "(", ")", ";", "String", "name", "=", "item", ".", "getFieldName", "(", ")", ";", "InputStream", "stream", "=", "item", ".", "openStream", "(", ")", ";", "if", "(", "item", ".", "isFormField", "(", ")", ")", "{", "requestParams", ".", "put", "(", "name", ",", "Streams", ".", "asString", "(", "stream", ")", ")", ";", "}", "else", "{", "String", "fileName", "=", "item", ".", "getName", "(", ")", ";", "if", "(", "fileName", "!=", "null", "&&", "!", "\"\"", ".", "equals", "(", "fileName", ".", "trim", "(", ")", ")", ")", "{", "listFiles", ".", "add", "(", "item", ")", ";", "ByteArrayOutputStream", "os", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "IOUtils", ".", "copy", "(", "stream", ",", "os", ")", ";", "listFileStreams", ".", "add", "(", "os", ")", ";", "}", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"Unexpected error parsing multipart content\"", ",", "e", ")", ";", "}", "}", "else", "{", "// not a multipart", "for", "(", "Object", "mapKey", ":", "request", ".", "getParameterMap", "(", ")", ".", "keySet", "(", ")", ")", "{", "String", "mapKeyString", "=", "(", "String", ")", "mapKey", ";", "if", "(", "mapKeyString", ".", "endsWith", "(", "\"[]\"", ")", ")", "{", "// multiple values", "String", "values", "[", "]", "=", "request", ".", "getParameterValues", "(", "mapKeyString", ")", ";", "List", "<", "String", ">", "listeValues", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "value", ":", "values", ")", "{", "listeValues", ".", "add", "(", "value", ")", ";", "}", "requestParams", ".", "put", "(", "mapKeyString", ",", "listeValues", ")", ";", "}", "else", "{", "// single value", "String", "value", "=", "request", ".", "getParameter", "(", "mapKeyString", ")", ";", "requestParams", ".", "put", "(", "mapKeyString", ",", "value", ")", ";", "}", "}", "}", "}" ]
Parse request parameters and files. @param request @param response
[ "Parse", "request", "parameters", "and", "files", "." ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/web/server/menu/connector/AbstractConnectorServlet.java#L295-L352
160,843
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/web/server/menu/connector/AbstractConnectorServlet.java
AbstractConnectorServlet.putResponse
protected void putResponse(JSONObject json, String param, Object value) { try { json.put(param, value); } catch (JSONException e) { logger.error("json write error", e); } }
java
protected void putResponse(JSONObject json, String param, Object value) { try { json.put(param, value); } catch (JSONException e) { logger.error("json write error", e); } }
[ "protected", "void", "putResponse", "(", "JSONObject", "json", ",", "String", "param", ",", "Object", "value", ")", "{", "try", "{", "json", ".", "put", "(", "param", ",", "value", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "logger", ".", "error", "(", "\"json write error\"", ",", "e", ")", ";", "}", "}" ]
Append data to JSON response. @param param @param value
[ "Append", "data", "to", "JSON", "response", "." ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/web/server/menu/connector/AbstractConnectorServlet.java#L359-L369
160,844
kiegroup/jbpm-designer
jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/Variable.java
Variable.deserialize
public static Variable deserialize(String s, VariableType variableType, List<String> dataTypes) { Variable var = new Variable(variableType); String[] varParts = s.split(":"); if (varParts.length > 0) { String name = varParts[0]; if (!name.isEmpty()) { var.setName(name); if (varParts.length == 2) { String dataType = varParts[1]; if (!dataType.isEmpty()) { if (dataTypes != null && dataTypes.contains(dataType)) { var.setDataType(dataType); } else { var.setCustomDataType(dataType); } } } } } return var; }
java
public static Variable deserialize(String s, VariableType variableType, List<String> dataTypes) { Variable var = new Variable(variableType); String[] varParts = s.split(":"); if (varParts.length > 0) { String name = varParts[0]; if (!name.isEmpty()) { var.setName(name); if (varParts.length == 2) { String dataType = varParts[1]; if (!dataType.isEmpty()) { if (dataTypes != null && dataTypes.contains(dataType)) { var.setDataType(dataType); } else { var.setCustomDataType(dataType); } } } } } return var; }
[ "public", "static", "Variable", "deserialize", "(", "String", "s", ",", "VariableType", "variableType", ",", "List", "<", "String", ">", "dataTypes", ")", "{", "Variable", "var", "=", "new", "Variable", "(", "variableType", ")", ";", "String", "[", "]", "varParts", "=", "s", ".", "split", "(", "\":\"", ")", ";", "if", "(", "varParts", ".", "length", ">", "0", ")", "{", "String", "name", "=", "varParts", "[", "0", "]", ";", "if", "(", "!", "name", ".", "isEmpty", "(", ")", ")", "{", "var", ".", "setName", "(", "name", ")", ";", "if", "(", "varParts", ".", "length", "==", "2", ")", "{", "String", "dataType", "=", "varParts", "[", "1", "]", ";", "if", "(", "!", "dataType", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "dataTypes", "!=", "null", "&&", "dataTypes", ".", "contains", "(", "dataType", ")", ")", "{", "var", ".", "setDataType", "(", "dataType", ")", ";", "}", "else", "{", "var", ".", "setCustomDataType", "(", "dataType", ")", ";", "}", "}", "}", "}", "}", "return", "var", ";", "}" ]
Deserializes a variable, checking whether the datatype is custom or not @param s @param variableType @param dataTypes @return
[ "Deserializes", "a", "variable", "checking", "whether", "the", "datatype", "is", "custom", "or", "not" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/Variable.java#L109-L131
160,845
kiegroup/jbpm-designer
jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/Variable.java
Variable.deserialize
public static Variable deserialize(String s, VariableType variableType) { return deserialize(s, variableType, null); }
java
public static Variable deserialize(String s, VariableType variableType) { return deserialize(s, variableType, null); }
[ "public", "static", "Variable", "deserialize", "(", "String", "s", ",", "VariableType", "variableType", ")", "{", "return", "deserialize", "(", "s", ",", "variableType", ",", "null", ")", ";", "}" ]
Deserializes a variable, NOT checking whether the datatype is custom @param s @param variableType @return
[ "Deserializes", "a", "variable", "NOT", "checking", "whether", "the", "datatype", "is", "custom" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/shared/Variable.java#L139-L144
160,846
kiegroup/jbpm-designer
jbpm-designer-utilities/src/main/java/org/jbpm/designer/utilities/svginline/SvgInline.java
SvgInline.processStencilSet
public void processStencilSet() throws IOException { StringBuilder stencilSetFileContents = new StringBuilder(); Scanner scanner = null; try { scanner = new Scanner(new File(ssInFile), "UTF-8"); String currentLine = ""; String prevLine = ""; while (scanner.hasNextLine()) { prevLine = currentLine; currentLine = scanner.nextLine(); String trimmedPrevLine = prevLine.trim(); String trimmedCurrentLine = currentLine.trim(); // First time processing - replace view="<file>.svg" with _view_file="<file>.svg" + view="<svg_xml>" if (trimmedCurrentLine.matches(VIEW_PROPERTY_NAME_PATTERN) && trimmedCurrentLine.endsWith(VIEW_PROPERTY_VALUE_SUFFIX)) { String newLines = processViewPropertySvgReference(currentLine); stencilSetFileContents.append(newLines); } // Second time processing - replace view="<svg_xml>" with refreshed contents of file referenced by previous line else if (trimmedPrevLine.matches(VIEW_FILE_PROPERTY_NAME_PATTERN) && trimmedPrevLine.endsWith(VIEW_PROPERTY_VALUE_SUFFIX) && trimmedCurrentLine.matches(VIEW_PROPERTY_NAME_PATTERN)) { String newLines = processViewFilePropertySvgReference(prevLine, currentLine); stencilSetFileContents.append(newLines); } else { stencilSetFileContents.append(currentLine + LINE_SEPARATOR); } } } finally { if (scanner != null) { scanner.close(); } } Writer out = null; try { out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(ssOutFile), "UTF-8")); out.write(stencilSetFileContents.toString()); } catch (FileNotFoundException e) { } catch (UnsupportedEncodingException e) { } catch (IOException e) { } finally { if (out != null) { try { out.close(); } catch (IOException e) { } } } System.out.println("SVG files referenced more than once:"); for (Map.Entry<String, Integer> stringIntegerEntry : mapSVGCounts.entrySet()) { if (stringIntegerEntry.getValue() > 1) { System.out.println("\t" + stringIntegerEntry.getKey() + "\t = " + stringIntegerEntry.getValue()); } } }
java
public void processStencilSet() throws IOException { StringBuilder stencilSetFileContents = new StringBuilder(); Scanner scanner = null; try { scanner = new Scanner(new File(ssInFile), "UTF-8"); String currentLine = ""; String prevLine = ""; while (scanner.hasNextLine()) { prevLine = currentLine; currentLine = scanner.nextLine(); String trimmedPrevLine = prevLine.trim(); String trimmedCurrentLine = currentLine.trim(); // First time processing - replace view="<file>.svg" with _view_file="<file>.svg" + view="<svg_xml>" if (trimmedCurrentLine.matches(VIEW_PROPERTY_NAME_PATTERN) && trimmedCurrentLine.endsWith(VIEW_PROPERTY_VALUE_SUFFIX)) { String newLines = processViewPropertySvgReference(currentLine); stencilSetFileContents.append(newLines); } // Second time processing - replace view="<svg_xml>" with refreshed contents of file referenced by previous line else if (trimmedPrevLine.matches(VIEW_FILE_PROPERTY_NAME_PATTERN) && trimmedPrevLine.endsWith(VIEW_PROPERTY_VALUE_SUFFIX) && trimmedCurrentLine.matches(VIEW_PROPERTY_NAME_PATTERN)) { String newLines = processViewFilePropertySvgReference(prevLine, currentLine); stencilSetFileContents.append(newLines); } else { stencilSetFileContents.append(currentLine + LINE_SEPARATOR); } } } finally { if (scanner != null) { scanner.close(); } } Writer out = null; try { out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(ssOutFile), "UTF-8")); out.write(stencilSetFileContents.toString()); } catch (FileNotFoundException e) { } catch (UnsupportedEncodingException e) { } catch (IOException e) { } finally { if (out != null) { try { out.close(); } catch (IOException e) { } } } System.out.println("SVG files referenced more than once:"); for (Map.Entry<String, Integer> stringIntegerEntry : mapSVGCounts.entrySet()) { if (stringIntegerEntry.getValue() > 1) { System.out.println("\t" + stringIntegerEntry.getKey() + "\t = " + stringIntegerEntry.getValue()); } } }
[ "public", "void", "processStencilSet", "(", ")", "throws", "IOException", "{", "StringBuilder", "stencilSetFileContents", "=", "new", "StringBuilder", "(", ")", ";", "Scanner", "scanner", "=", "null", ";", "try", "{", "scanner", "=", "new", "Scanner", "(", "new", "File", "(", "ssInFile", ")", ",", "\"UTF-8\"", ")", ";", "String", "currentLine", "=", "\"\"", ";", "String", "prevLine", "=", "\"\"", ";", "while", "(", "scanner", ".", "hasNextLine", "(", ")", ")", "{", "prevLine", "=", "currentLine", ";", "currentLine", "=", "scanner", ".", "nextLine", "(", ")", ";", "String", "trimmedPrevLine", "=", "prevLine", ".", "trim", "(", ")", ";", "String", "trimmedCurrentLine", "=", "currentLine", ".", "trim", "(", ")", ";", "// First time processing - replace view=\"<file>.svg\" with _view_file=\"<file>.svg\" + view=\"<svg_xml>\"", "if", "(", "trimmedCurrentLine", ".", "matches", "(", "VIEW_PROPERTY_NAME_PATTERN", ")", "&&", "trimmedCurrentLine", ".", "endsWith", "(", "VIEW_PROPERTY_VALUE_SUFFIX", ")", ")", "{", "String", "newLines", "=", "processViewPropertySvgReference", "(", "currentLine", ")", ";", "stencilSetFileContents", ".", "append", "(", "newLines", ")", ";", "}", "// Second time processing - replace view=\"<svg_xml>\" with refreshed contents of file referenced by previous line", "else", "if", "(", "trimmedPrevLine", ".", "matches", "(", "VIEW_FILE_PROPERTY_NAME_PATTERN", ")", "&&", "trimmedPrevLine", ".", "endsWith", "(", "VIEW_PROPERTY_VALUE_SUFFIX", ")", "&&", "trimmedCurrentLine", ".", "matches", "(", "VIEW_PROPERTY_NAME_PATTERN", ")", ")", "{", "String", "newLines", "=", "processViewFilePropertySvgReference", "(", "prevLine", ",", "currentLine", ")", ";", "stencilSetFileContents", ".", "append", "(", "newLines", ")", ";", "}", "else", "{", "stencilSetFileContents", ".", "append", "(", "currentLine", "+", "LINE_SEPARATOR", ")", ";", "}", "}", "}", "finally", "{", "if", "(", "scanner", "!=", "null", ")", "{", "scanner", ".", "close", "(", ")", ";", "}", "}", "Writer", "out", "=", "null", ";", "try", "{", "out", "=", "new", "BufferedWriter", "(", "new", "OutputStreamWriter", "(", "new", "FileOutputStream", "(", "ssOutFile", ")", ",", "\"UTF-8\"", ")", ")", ";", "out", ".", "write", "(", "stencilSetFileContents", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "}", "catch", "(", "IOException", "e", ")", "{", "}", "finally", "{", "if", "(", "out", "!=", "null", ")", "{", "try", "{", "out", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "}", "}", "System", ".", "out", ".", "println", "(", "\"SVG files referenced more than once:\"", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Integer", ">", "stringIntegerEntry", ":", "mapSVGCounts", ".", "entrySet", "(", ")", ")", "{", "if", "(", "stringIntegerEntry", ".", "getValue", "(", ")", ">", "1", ")", "{", "System", ".", "out", ".", "println", "(", "\"\\t\"", "+", "stringIntegerEntry", ".", "getKey", "(", ")", "+", "\"\\t = \"", "+", "stringIntegerEntry", ".", "getValue", "(", ")", ")", ";", "}", "}", "}" ]
Processes a stencilset template file @throws IOException
[ "Processes", "a", "stencilset", "template", "file" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-utilities/src/main/java/org/jbpm/designer/utilities/svginline/SvgInline.java#L77-L138
160,847
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/web/profile/impl/ProfileServiceImpl.java
ProfileServiceImpl.init
public void init(ServletContext context) { if (profiles != null) { for (IDiagramProfile profile : profiles) { profile.init(context); _registry.put(profile.getName(), profile); } } }
java
public void init(ServletContext context) { if (profiles != null) { for (IDiagramProfile profile : profiles) { profile.init(context); _registry.put(profile.getName(), profile); } } }
[ "public", "void", "init", "(", "ServletContext", "context", ")", "{", "if", "(", "profiles", "!=", "null", ")", "{", "for", "(", "IDiagramProfile", "profile", ":", "profiles", ")", "{", "profile", ".", "init", "(", "context", ")", ";", "_registry", ".", "put", "(", "profile", ".", "getName", "(", ")", ",", "profile", ")", ";", "}", "}", "}" ]
Initialize the service with a context @param context the servlet context to initialize the profile.
[ "Initialize", "the", "service", "with", "a", "context" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/web/profile/impl/ProfileServiceImpl.java#L66-L74
160,848
voldemort/voldemort
src/java/voldemort/utils/ReflectUtils.java
ReflectUtils.getPropertyName
public static String getPropertyName(String name) { if(name != null && (name.startsWith("get") || name.startsWith("set"))) { StringBuilder b = new StringBuilder(name); b.delete(0, 3); b.setCharAt(0, Character.toLowerCase(b.charAt(0))); return b.toString(); } else { return name; } }
java
public static String getPropertyName(String name) { if(name != null && (name.startsWith("get") || name.startsWith("set"))) { StringBuilder b = new StringBuilder(name); b.delete(0, 3); b.setCharAt(0, Character.toLowerCase(b.charAt(0))); return b.toString(); } else { return name; } }
[ "public", "static", "String", "getPropertyName", "(", "String", "name", ")", "{", "if", "(", "name", "!=", "null", "&&", "(", "name", ".", "startsWith", "(", "\"get\"", ")", "||", "name", ".", "startsWith", "(", "\"set\"", ")", ")", ")", "{", "StringBuilder", "b", "=", "new", "StringBuilder", "(", "name", ")", ";", "b", ".", "delete", "(", "0", ",", "3", ")", ";", "b", ".", "setCharAt", "(", "0", ",", "Character", ".", "toLowerCase", "(", "b", ".", "charAt", "(", "0", ")", ")", ")", ";", "return", "b", ".", "toString", "(", ")", ";", "}", "else", "{", "return", "name", ";", "}", "}" ]
Get the property name of a method name. For example the property name of setSomeValue would be someValue. Names not beginning with set or get are not changed. @param name The name to process @return The property name
[ "Get", "the", "property", "name", "of", "a", "method", "name", ".", "For", "example", "the", "property", "name", "of", "setSomeValue", "would", "be", "someValue", ".", "Names", "not", "beginning", "with", "set", "or", "get", "are", "not", "changed", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/ReflectUtils.java#L38-L47
160,849
voldemort/voldemort
src/java/voldemort/utils/ReflectUtils.java
ReflectUtils.loadClass
public static Class<?> loadClass(String className) { try { return Class.forName(className); } catch(ClassNotFoundException e) { throw new IllegalArgumentException(e); } }
java
public static Class<?> loadClass(String className) { try { return Class.forName(className); } catch(ClassNotFoundException e) { throw new IllegalArgumentException(e); } }
[ "public", "static", "Class", "<", "?", ">", "loadClass", "(", "String", "className", ")", "{", "try", "{", "return", "Class", ".", "forName", "(", "className", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "e", ")", ";", "}", "}" ]
Load the given class using the default constructor @param className The name of the class @return The class object
[ "Load", "the", "given", "class", "using", "the", "default", "constructor" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/ReflectUtils.java#L55-L61
160,850
voldemort/voldemort
src/java/voldemort/utils/ReflectUtils.java
ReflectUtils.loadClass
public static Class<?> loadClass(String className, ClassLoader cl) { try { return Class.forName(className, false, cl); } catch(ClassNotFoundException e) { throw new IllegalArgumentException(e); } }
java
public static Class<?> loadClass(String className, ClassLoader cl) { try { return Class.forName(className, false, cl); } catch(ClassNotFoundException e) { throw new IllegalArgumentException(e); } }
[ "public", "static", "Class", "<", "?", ">", "loadClass", "(", "String", "className", ",", "ClassLoader", "cl", ")", "{", "try", "{", "return", "Class", ".", "forName", "(", "className", ",", "false", ",", "cl", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "e", ")", ";", "}", "}" ]
Load the given class using a specific class loader. @param className The name of the class @param cl The Class Loader to be used for finding the class. @return The class object
[ "Load", "the", "given", "class", "using", "a", "specific", "class", "loader", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/ReflectUtils.java#L70-L76
160,851
voldemort/voldemort
src/java/voldemort/utils/ReflectUtils.java
ReflectUtils.callConstructor
public static <T> T callConstructor(Class<T> klass) { return callConstructor(klass, new Class<?>[0], new Object[0]); }
java
public static <T> T callConstructor(Class<T> klass) { return callConstructor(klass, new Class<?>[0], new Object[0]); }
[ "public", "static", "<", "T", ">", "T", "callConstructor", "(", "Class", "<", "T", ">", "klass", ")", "{", "return", "callConstructor", "(", "klass", ",", "new", "Class", "<", "?", ">", "[", "0", "]", ",", "new", "Object", "[", "0", "]", ")", ";", "}" ]
Call the no-arg constructor for the given class @param <T> The type of the thing to construct @param klass The class @return The constructed thing
[ "Call", "the", "no", "-", "arg", "constructor", "for", "the", "given", "class" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/ReflectUtils.java#L85-L87
160,852
voldemort/voldemort
src/java/voldemort/utils/ReflectUtils.java
ReflectUtils.callConstructor
public static <T> T callConstructor(Class<T> klass, Object[] args) { Class<?>[] klasses = new Class[args.length]; for(int i = 0; i < args.length; i++) klasses[i] = args[i].getClass(); return callConstructor(klass, klasses, args); }
java
public static <T> T callConstructor(Class<T> klass, Object[] args) { Class<?>[] klasses = new Class[args.length]; for(int i = 0; i < args.length; i++) klasses[i] = args[i].getClass(); return callConstructor(klass, klasses, args); }
[ "public", "static", "<", "T", ">", "T", "callConstructor", "(", "Class", "<", "T", ">", "klass", ",", "Object", "[", "]", "args", ")", "{", "Class", "<", "?", ">", "[", "]", "klasses", "=", "new", "Class", "[", "args", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "args", ".", "length", ";", "i", "++", ")", "klasses", "[", "i", "]", "=", "args", "[", "i", "]", ".", "getClass", "(", ")", ";", "return", "callConstructor", "(", "klass", ",", "klasses", ",", "args", ")", ";", "}" ]
Call the constructor for the given class, inferring the correct types for the arguments. This could be confusing if there are multiple constructors with the same number of arguments and the values themselves don't disambiguate. @param klass The class to construct @param args The arguments @return The constructed value
[ "Call", "the", "constructor", "for", "the", "given", "class", "inferring", "the", "correct", "types", "for", "the", "arguments", ".", "This", "could", "be", "confusing", "if", "there", "are", "multiple", "constructors", "with", "the", "same", "number", "of", "arguments", "and", "the", "values", "themselves", "don", "t", "disambiguate", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/ReflectUtils.java#L99-L104
160,853
voldemort/voldemort
src/java/voldemort/utils/ReflectUtils.java
ReflectUtils.callMethod
public static <T> Object callMethod(Object obj, Class<T> c, String name, Class<?>[] classes, Object[] args) { try { Method m = getMethod(c, name, classes); return m.invoke(obj, args); } catch(InvocationTargetException e) { throw getCause(e); } catch(IllegalAccessException e) { throw new IllegalStateException(e); } }
java
public static <T> Object callMethod(Object obj, Class<T> c, String name, Class<?>[] classes, Object[] args) { try { Method m = getMethod(c, name, classes); return m.invoke(obj, args); } catch(InvocationTargetException e) { throw getCause(e); } catch(IllegalAccessException e) { throw new IllegalStateException(e); } }
[ "public", "static", "<", "T", ">", "Object", "callMethod", "(", "Object", "obj", ",", "Class", "<", "T", ">", "c", ",", "String", "name", ",", "Class", "<", "?", ">", "[", "]", "classes", ",", "Object", "[", "]", "args", ")", "{", "try", "{", "Method", "m", "=", "getMethod", "(", "c", ",", "name", ",", "classes", ")", ";", "return", "m", ".", "invoke", "(", "obj", ",", "args", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "throw", "getCause", "(", "e", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}" ]
Call the named method @param obj The object to call the method on @param c The class of the object @param name The name of the method @param args The method arguments @return The result of the method
[ "Call", "the", "named", "method" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/ReflectUtils.java#L137-L150
160,854
voldemort/voldemort
src/java/voldemort/utils/ReflectUtils.java
ReflectUtils.getMethod
public static <T> Method getMethod(Class<T> c, String name, Class<?>... argTypes) { try { return c.getMethod(name, argTypes); } catch(NoSuchMethodException e) { throw new IllegalArgumentException(e); } }
java
public static <T> Method getMethod(Class<T> c, String name, Class<?>... argTypes) { try { return c.getMethod(name, argTypes); } catch(NoSuchMethodException e) { throw new IllegalArgumentException(e); } }
[ "public", "static", "<", "T", ">", "Method", "getMethod", "(", "Class", "<", "T", ">", "c", ",", "String", "name", ",", "Class", "<", "?", ">", "...", "argTypes", ")", "{", "try", "{", "return", "c", ".", "getMethod", "(", "name", ",", "argTypes", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "e", ")", ";", "}", "}" ]
Get the named method from the class @param c The class to get the method from @param name The method name @param argTypes The argument types @return The method
[ "Get", "the", "named", "method", "from", "the", "class" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/ReflectUtils.java#L160-L166
160,855
voldemort/voldemort
src/java/voldemort/server/storage/prunejob/VersionedPutPruneJob.java
VersionedPutPruneJob.pruneNonReplicaEntries
public static List<Versioned<byte[]>> pruneNonReplicaEntries(List<Versioned<byte[]>> vals, List<Integer> keyReplicas, MutableBoolean didPrune) { List<Versioned<byte[]>> prunedVals = new ArrayList<Versioned<byte[]>>(vals.size()); for(Versioned<byte[]> val: vals) { VectorClock clock = (VectorClock) val.getVersion(); List<ClockEntry> clockEntries = new ArrayList<ClockEntry>(); for(ClockEntry clockEntry: clock.getEntries()) { if(keyReplicas.contains((int) clockEntry.getNodeId())) { clockEntries.add(clockEntry); } else { didPrune.setValue(true); } } prunedVals.add(new Versioned<byte[]>(val.getValue(), new VectorClock(clockEntries, clock.getTimestamp()))); } return prunedVals; }
java
public static List<Versioned<byte[]>> pruneNonReplicaEntries(List<Versioned<byte[]>> vals, List<Integer> keyReplicas, MutableBoolean didPrune) { List<Versioned<byte[]>> prunedVals = new ArrayList<Versioned<byte[]>>(vals.size()); for(Versioned<byte[]> val: vals) { VectorClock clock = (VectorClock) val.getVersion(); List<ClockEntry> clockEntries = new ArrayList<ClockEntry>(); for(ClockEntry clockEntry: clock.getEntries()) { if(keyReplicas.contains((int) clockEntry.getNodeId())) { clockEntries.add(clockEntry); } else { didPrune.setValue(true); } } prunedVals.add(new Versioned<byte[]>(val.getValue(), new VectorClock(clockEntries, clock.getTimestamp()))); } return prunedVals; }
[ "public", "static", "List", "<", "Versioned", "<", "byte", "[", "]", ">", ">", "pruneNonReplicaEntries", "(", "List", "<", "Versioned", "<", "byte", "[", "]", ">", ">", "vals", ",", "List", "<", "Integer", ">", "keyReplicas", ",", "MutableBoolean", "didPrune", ")", "{", "List", "<", "Versioned", "<", "byte", "[", "]", ">", ">", "prunedVals", "=", "new", "ArrayList", "<", "Versioned", "<", "byte", "[", "]", ">", ">", "(", "vals", ".", "size", "(", ")", ")", ";", "for", "(", "Versioned", "<", "byte", "[", "]", ">", "val", ":", "vals", ")", "{", "VectorClock", "clock", "=", "(", "VectorClock", ")", "val", ".", "getVersion", "(", ")", ";", "List", "<", "ClockEntry", ">", "clockEntries", "=", "new", "ArrayList", "<", "ClockEntry", ">", "(", ")", ";", "for", "(", "ClockEntry", "clockEntry", ":", "clock", ".", "getEntries", "(", ")", ")", "{", "if", "(", "keyReplicas", ".", "contains", "(", "(", "int", ")", "clockEntry", ".", "getNodeId", "(", ")", ")", ")", "{", "clockEntries", ".", "add", "(", "clockEntry", ")", ";", "}", "else", "{", "didPrune", ".", "setValue", "(", "true", ")", ";", "}", "}", "prunedVals", ".", "add", "(", "new", "Versioned", "<", "byte", "[", "]", ">", "(", "val", ".", "getValue", "(", ")", ",", "new", "VectorClock", "(", "clockEntries", ",", "clock", ".", "getTimestamp", "(", ")", ")", ")", ")", ";", "}", "return", "prunedVals", ";", "}" ]
Remove all non replica clock entries from the list of versioned values provided @param vals list of versioned values to prune replicas from @param keyReplicas list of current replicas for the given key @param didPrune flag to mark if we did actually prune something @return pruned list
[ "Remove", "all", "non", "replica", "clock", "entries", "from", "the", "list", "of", "versioned", "values", "provided" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/storage/prunejob/VersionedPutPruneJob.java#L181-L199
160,856
voldemort/voldemort
src/java/voldemort/serialization/ObjectSerializer.java
ObjectSerializer.toBytes
public byte[] toBytes(T object) { try { ByteArrayOutputStream stream = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(stream); out.writeObject(object); return stream.toByteArray(); } catch(IOException e) { throw new SerializationException(e); } }
java
public byte[] toBytes(T object) { try { ByteArrayOutputStream stream = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(stream); out.writeObject(object); return stream.toByteArray(); } catch(IOException e) { throw new SerializationException(e); } }
[ "public", "byte", "[", "]", "toBytes", "(", "T", "object", ")", "{", "try", "{", "ByteArrayOutputStream", "stream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "ObjectOutputStream", "out", "=", "new", "ObjectOutputStream", "(", "stream", ")", ";", "out", ".", "writeObject", "(", "object", ")", ";", "return", "stream", ".", "toByteArray", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "SerializationException", "(", "e", ")", ";", "}", "}" ]
Transform the given object into an array of bytes @param object The object to be serialized @return The bytes created from serializing the object
[ "Transform", "the", "given", "object", "into", "an", "array", "of", "bytes" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/serialization/ObjectSerializer.java#L40-L49
160,857
voldemort/voldemort
src/java/voldemort/serialization/ObjectSerializer.java
ObjectSerializer.toObject
@SuppressWarnings("unchecked") public T toObject(byte[] bytes) { try { return (T) new ObjectInputStream(new ByteArrayInputStream(bytes)).readObject(); } catch(IOException e) { throw new SerializationException(e); } catch(ClassNotFoundException c) { throw new SerializationException(c); } }
java
@SuppressWarnings("unchecked") public T toObject(byte[] bytes) { try { return (T) new ObjectInputStream(new ByteArrayInputStream(bytes)).readObject(); } catch(IOException e) { throw new SerializationException(e); } catch(ClassNotFoundException c) { throw new SerializationException(c); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "T", "toObject", "(", "byte", "[", "]", "bytes", ")", "{", "try", "{", "return", "(", "T", ")", "new", "ObjectInputStream", "(", "new", "ByteArrayInputStream", "(", "bytes", ")", ")", ".", "readObject", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "SerializationException", "(", "e", ")", ";", "}", "catch", "(", "ClassNotFoundException", "c", ")", "{", "throw", "new", "SerializationException", "(", "c", ")", ";", "}", "}" ]
Transform the given bytes into an object. @param bytes The bytes to construct the object from @return The object constructed
[ "Transform", "the", "given", "bytes", "into", "an", "object", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/serialization/ObjectSerializer.java#L57-L66
160,858
voldemort/voldemort
src/java/voldemort/server/protocol/vold/VoldemortNativeRequestHandler.java
VoldemortNativeRequestHandler.isCompleteRequest
@Override public boolean isCompleteRequest(final ByteBuffer buffer) throws VoldemortException { DataInputStream inputStream = new DataInputStream(new ByteBufferBackedInputStream(buffer)); try { byte opCode = inputStream.readByte(); // Store Name inputStream.readUTF(); // Store routing type getRoutingType(inputStream); switch(opCode) { case VoldemortOpCode.GET_VERSION_OP_CODE: if(!GetVersionRequestHandler.isCompleteRequest(inputStream, buffer)) return false; break; case VoldemortOpCode.GET_OP_CODE: if(!GetRequestHandler.isCompleteRequest(inputStream, buffer, protocolVersion)) return false; break; case VoldemortOpCode.GET_ALL_OP_CODE: if(!GetAllRequestHandler.isCompleteRequest(inputStream, buffer, protocolVersion)) return false; break; case VoldemortOpCode.PUT_OP_CODE: { if(!PutRequestHandler.isCompleteRequest(inputStream, buffer, protocolVersion)) return false; break; } case VoldemortOpCode.DELETE_OP_CODE: { if(!DeleteRequestHandler.isCompleteRequest(inputStream, buffer)) return false; break; } default: throw new VoldemortException(" Unrecognized Voldemort OpCode " + opCode); } // This should not happen, if we reach here and if buffer has more // data, there is something wrong. if(buffer.hasRemaining()) { logger.info("Probably a client bug, Discarding additional bytes in isCompleteRequest. Opcode: " + opCode + ", remaining bytes: " + buffer.remaining()); } return true; } catch(IOException e) { // This could also occur if the various methods we call into // re-throw a corrupted value error as some other type of exception. // For example, updating the position on a buffer past its limit // throws an InvalidArgumentException. if(logger.isDebugEnabled()) logger.debug("Probable partial read occurred causing exception", e); return false; } }
java
@Override public boolean isCompleteRequest(final ByteBuffer buffer) throws VoldemortException { DataInputStream inputStream = new DataInputStream(new ByteBufferBackedInputStream(buffer)); try { byte opCode = inputStream.readByte(); // Store Name inputStream.readUTF(); // Store routing type getRoutingType(inputStream); switch(opCode) { case VoldemortOpCode.GET_VERSION_OP_CODE: if(!GetVersionRequestHandler.isCompleteRequest(inputStream, buffer)) return false; break; case VoldemortOpCode.GET_OP_CODE: if(!GetRequestHandler.isCompleteRequest(inputStream, buffer, protocolVersion)) return false; break; case VoldemortOpCode.GET_ALL_OP_CODE: if(!GetAllRequestHandler.isCompleteRequest(inputStream, buffer, protocolVersion)) return false; break; case VoldemortOpCode.PUT_OP_CODE: { if(!PutRequestHandler.isCompleteRequest(inputStream, buffer, protocolVersion)) return false; break; } case VoldemortOpCode.DELETE_OP_CODE: { if(!DeleteRequestHandler.isCompleteRequest(inputStream, buffer)) return false; break; } default: throw new VoldemortException(" Unrecognized Voldemort OpCode " + opCode); } // This should not happen, if we reach here and if buffer has more // data, there is something wrong. if(buffer.hasRemaining()) { logger.info("Probably a client bug, Discarding additional bytes in isCompleteRequest. Opcode: " + opCode + ", remaining bytes: " + buffer.remaining()); } return true; } catch(IOException e) { // This could also occur if the various methods we call into // re-throw a corrupted value error as some other type of exception. // For example, updating the position on a buffer past its limit // throws an InvalidArgumentException. if(logger.isDebugEnabled()) logger.debug("Probable partial read occurred causing exception", e); return false; } }
[ "@", "Override", "public", "boolean", "isCompleteRequest", "(", "final", "ByteBuffer", "buffer", ")", "throws", "VoldemortException", "{", "DataInputStream", "inputStream", "=", "new", "DataInputStream", "(", "new", "ByteBufferBackedInputStream", "(", "buffer", ")", ")", ";", "try", "{", "byte", "opCode", "=", "inputStream", ".", "readByte", "(", ")", ";", "// Store Name", "inputStream", ".", "readUTF", "(", ")", ";", "// Store routing type", "getRoutingType", "(", "inputStream", ")", ";", "switch", "(", "opCode", ")", "{", "case", "VoldemortOpCode", ".", "GET_VERSION_OP_CODE", ":", "if", "(", "!", "GetVersionRequestHandler", ".", "isCompleteRequest", "(", "inputStream", ",", "buffer", ")", ")", "return", "false", ";", "break", ";", "case", "VoldemortOpCode", ".", "GET_OP_CODE", ":", "if", "(", "!", "GetRequestHandler", ".", "isCompleteRequest", "(", "inputStream", ",", "buffer", ",", "protocolVersion", ")", ")", "return", "false", ";", "break", ";", "case", "VoldemortOpCode", ".", "GET_ALL_OP_CODE", ":", "if", "(", "!", "GetAllRequestHandler", ".", "isCompleteRequest", "(", "inputStream", ",", "buffer", ",", "protocolVersion", ")", ")", "return", "false", ";", "break", ";", "case", "VoldemortOpCode", ".", "PUT_OP_CODE", ":", "{", "if", "(", "!", "PutRequestHandler", ".", "isCompleteRequest", "(", "inputStream", ",", "buffer", ",", "protocolVersion", ")", ")", "return", "false", ";", "break", ";", "}", "case", "VoldemortOpCode", ".", "DELETE_OP_CODE", ":", "{", "if", "(", "!", "DeleteRequestHandler", ".", "isCompleteRequest", "(", "inputStream", ",", "buffer", ")", ")", "return", "false", ";", "break", ";", "}", "default", ":", "throw", "new", "VoldemortException", "(", "\" Unrecognized Voldemort OpCode \"", "+", "opCode", ")", ";", "}", "// This should not happen, if we reach here and if buffer has more", "// data, there is something wrong.", "if", "(", "buffer", ".", "hasRemaining", "(", ")", ")", "{", "logger", ".", "info", "(", "\"Probably a client bug, Discarding additional bytes in isCompleteRequest. Opcode: \"", "+", "opCode", "+", "\", remaining bytes: \"", "+", "buffer", ".", "remaining", "(", ")", ")", ";", "}", "return", "true", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// This could also occur if the various methods we call into", "// re-throw a corrupted value error as some other type of exception.", "// For example, updating the position on a buffer past its limit", "// throws an InvalidArgumentException.", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "logger", ".", "debug", "(", "\"Probable partial read occurred causing exception\"", ",", "e", ")", ";", "return", "false", ";", "}", "}" ]
This is pretty ugly. We end up mimicking the request logic here, so this needs to stay in sync with handleRequest.
[ "This", "is", "pretty", "ugly", ".", "We", "end", "up", "mimicking", "the", "request", "logic", "here", "so", "this", "needs", "to", "stay", "in", "sync", "with", "handleRequest", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/protocol/vold/VoldemortNativeRequestHandler.java#L161-L216
160,859
voldemort/voldemort
src/java/voldemort/utils/WriteThroughCache.java
WriteThroughCache.put
@Override synchronized public V put(K key, V value) { V oldValue = this.get(key); try { super.put(key, value); writeBack(key, value); return oldValue; } catch(Exception e) { super.put(key, oldValue); writeBack(key, oldValue); throw new VoldemortException("Failed to put(" + key + ", " + value + ") in write through cache", e); } }
java
@Override synchronized public V put(K key, V value) { V oldValue = this.get(key); try { super.put(key, value); writeBack(key, value); return oldValue; } catch(Exception e) { super.put(key, oldValue); writeBack(key, oldValue); throw new VoldemortException("Failed to put(" + key + ", " + value + ") in write through cache", e); } }
[ "@", "Override", "synchronized", "public", "V", "put", "(", "K", "key", ",", "V", "value", ")", "{", "V", "oldValue", "=", "this", ".", "get", "(", "key", ")", ";", "try", "{", "super", ".", "put", "(", "key", ",", "value", ")", ";", "writeBack", "(", "key", ",", "value", ")", ";", "return", "oldValue", ";", "}", "catch", "(", "Exception", "e", ")", "{", "super", ".", "put", "(", "key", ",", "oldValue", ")", ";", "writeBack", "(", "key", ",", "oldValue", ")", ";", "throw", "new", "VoldemortException", "(", "\"Failed to put(\"", "+", "key", "+", "\", \"", "+", "value", "+", "\") in write through cache\"", ",", "e", ")", ";", "}", "}" ]
Updates the value in HashMap and writeBack as Atomic step
[ "Updates", "the", "value", "in", "HashMap", "and", "writeBack", "as", "Atomic", "step" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/WriteThroughCache.java#L55-L68
160,860
voldemort/voldemort
src/java/voldemort/store/readonly/checksum/CheckSum.java
CheckSum.update
public void update(int number) { byte[] numberInBytes = new byte[ByteUtils.SIZE_OF_INT]; ByteUtils.writeInt(numberInBytes, number, 0); update(numberInBytes); }
java
public void update(int number) { byte[] numberInBytes = new byte[ByteUtils.SIZE_OF_INT]; ByteUtils.writeInt(numberInBytes, number, 0); update(numberInBytes); }
[ "public", "void", "update", "(", "int", "number", ")", "{", "byte", "[", "]", "numberInBytes", "=", "new", "byte", "[", "ByteUtils", ".", "SIZE_OF_INT", "]", ";", "ByteUtils", ".", "writeInt", "(", "numberInBytes", ",", "number", ",", "0", ")", ";", "update", "(", "numberInBytes", ")", ";", "}" ]
Update the underlying buffer using the integer @param number number to be stored in checksum buffer
[ "Update", "the", "underlying", "buffer", "using", "the", "integer" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/checksum/CheckSum.java#L64-L68
160,861
voldemort/voldemort
src/java/voldemort/store/readonly/checksum/CheckSum.java
CheckSum.update
public void update(short number) { byte[] numberInBytes = new byte[ByteUtils.SIZE_OF_SHORT]; ByteUtils.writeShort(numberInBytes, number, 0); update(numberInBytes); }
java
public void update(short number) { byte[] numberInBytes = new byte[ByteUtils.SIZE_OF_SHORT]; ByteUtils.writeShort(numberInBytes, number, 0); update(numberInBytes); }
[ "public", "void", "update", "(", "short", "number", ")", "{", "byte", "[", "]", "numberInBytes", "=", "new", "byte", "[", "ByteUtils", ".", "SIZE_OF_SHORT", "]", ";", "ByteUtils", ".", "writeShort", "(", "numberInBytes", ",", "number", ",", "0", ")", ";", "update", "(", "numberInBytes", ")", ";", "}" ]
Update the underlying buffer using the short @param number number to be stored in checksum buffer
[ "Update", "the", "underlying", "buffer", "using", "the", "short" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/checksum/CheckSum.java#L75-L79
160,862
voldemort/voldemort
src/java/voldemort/store/routed/action/AsyncPutSynchronizer.java
AsyncPutSynchronizer.tryDelegateSlop
public synchronized boolean tryDelegateSlop(Node node) { if(asyncCallbackShouldSendhint) { return false; } else { slopDestinations.put(node, true); return true; } }
java
public synchronized boolean tryDelegateSlop(Node node) { if(asyncCallbackShouldSendhint) { return false; } else { slopDestinations.put(node, true); return true; } }
[ "public", "synchronized", "boolean", "tryDelegateSlop", "(", "Node", "node", ")", "{", "if", "(", "asyncCallbackShouldSendhint", ")", "{", "return", "false", ";", "}", "else", "{", "slopDestinations", ".", "put", "(", "node", ",", "true", ")", ";", "return", "true", ";", "}", "}" ]
Try to delegate the responsibility of sending slops to master @param node The node that slop should eventually be pushed to @return true if master accept the responsibility; false if master does not accept
[ "Try", "to", "delegate", "the", "responsibility", "of", "sending", "slops", "to", "master" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/routed/action/AsyncPutSynchronizer.java#L64-L71
160,863
voldemort/voldemort
src/java/voldemort/store/routed/action/AsyncPutSynchronizer.java
AsyncPutSynchronizer.tryDelegateResponseHandling
public synchronized boolean tryDelegateResponseHandling(Response<ByteArray, Object> response) { if(responseHandlingCutoff) { return false; } else { responseQueue.offer(response); this.notifyAll(); return true; } }
java
public synchronized boolean tryDelegateResponseHandling(Response<ByteArray, Object> response) { if(responseHandlingCutoff) { return false; } else { responseQueue.offer(response); this.notifyAll(); return true; } }
[ "public", "synchronized", "boolean", "tryDelegateResponseHandling", "(", "Response", "<", "ByteArray", ",", "Object", ">", "response", ")", "{", "if", "(", "responseHandlingCutoff", ")", "{", "return", "false", ";", "}", "else", "{", "responseQueue", ".", "offer", "(", "response", ")", ";", "this", ".", "notifyAll", "(", ")", ";", "return", "true", ";", "}", "}" ]
try to delegate the master to handle the response @param response @return true if the master accepted the response; false if the master didn't accept
[ "try", "to", "delegate", "the", "master", "to", "handle", "the", "response" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/routed/action/AsyncPutSynchronizer.java#L87-L95
160,864
voldemort/voldemort
src/java/voldemort/store/routed/action/AsyncPutSynchronizer.java
AsyncPutSynchronizer.responseQueuePoll
public synchronized Response<ByteArray, Object> responseQueuePoll(long timeout, TimeUnit timeUnit) throws InterruptedException { long timeoutMs = timeUnit.toMillis(timeout); long timeoutWallClockMs = System.currentTimeMillis() + timeoutMs; while(responseQueue.isEmpty() && System.currentTimeMillis() < timeoutWallClockMs) { long remainingMs = Math.max(0, timeoutWallClockMs - System.currentTimeMillis()); if(logger.isDebugEnabled()) { logger.debug("Start waiting for response queue with timeoutMs: " + timeoutMs); } this.wait(remainingMs); if(logger.isDebugEnabled()) { logger.debug("End waiting for response queue with timeoutMs: " + timeoutMs); } } return responseQueue.poll(); }
java
public synchronized Response<ByteArray, Object> responseQueuePoll(long timeout, TimeUnit timeUnit) throws InterruptedException { long timeoutMs = timeUnit.toMillis(timeout); long timeoutWallClockMs = System.currentTimeMillis() + timeoutMs; while(responseQueue.isEmpty() && System.currentTimeMillis() < timeoutWallClockMs) { long remainingMs = Math.max(0, timeoutWallClockMs - System.currentTimeMillis()); if(logger.isDebugEnabled()) { logger.debug("Start waiting for response queue with timeoutMs: " + timeoutMs); } this.wait(remainingMs); if(logger.isDebugEnabled()) { logger.debug("End waiting for response queue with timeoutMs: " + timeoutMs); } } return responseQueue.poll(); }
[ "public", "synchronized", "Response", "<", "ByteArray", ",", "Object", ">", "responseQueuePoll", "(", "long", "timeout", ",", "TimeUnit", "timeUnit", ")", "throws", "InterruptedException", "{", "long", "timeoutMs", "=", "timeUnit", ".", "toMillis", "(", "timeout", ")", ";", "long", "timeoutWallClockMs", "=", "System", ".", "currentTimeMillis", "(", ")", "+", "timeoutMs", ";", "while", "(", "responseQueue", ".", "isEmpty", "(", ")", "&&", "System", ".", "currentTimeMillis", "(", ")", "<", "timeoutWallClockMs", ")", "{", "long", "remainingMs", "=", "Math", ".", "max", "(", "0", ",", "timeoutWallClockMs", "-", "System", ".", "currentTimeMillis", "(", ")", ")", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Start waiting for response queue with timeoutMs: \"", "+", "timeoutMs", ")", ";", "}", "this", ".", "wait", "(", "remainingMs", ")", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"End waiting for response queue with timeoutMs: \"", "+", "timeoutMs", ")", ";", "}", "}", "return", "responseQueue", ".", "poll", "(", ")", ";", "}" ]
poll the response queue for response @param timeout timeout amount @param timeUnit timeUnit of timeout @return same result of BlockQueue.poll(long, TimeUnit) @throws InterruptedException
[ "poll", "the", "response", "queue", "for", "response" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/routed/action/AsyncPutSynchronizer.java#L105-L121
160,865
voldemort/voldemort
contrib/restclient/src/java/voldemort/restclient/RESTClientConfig.java
RESTClientConfig.setProperties
private void setProperties(Properties properties) { Props props = new Props(properties); if(props.containsKey(ClientConfig.ENABLE_JMX_PROPERTY)) { this.setEnableJmx(props.getBoolean(ClientConfig.ENABLE_JMX_PROPERTY)); } if(props.containsKey(ClientConfig.BOOTSTRAP_URLS_PROPERTY)) { List<String> urls = props.getList(ClientConfig.BOOTSTRAP_URLS_PROPERTY); if(urls.size() > 0) { setHttpBootstrapURL(urls.get(0)); } } if(props.containsKey(ClientConfig.MAX_TOTAL_CONNECTIONS_PROPERTY)) { setMaxR2ConnectionPoolSize(props.getInt(ClientConfig.MAX_TOTAL_CONNECTIONS_PROPERTY, maxR2ConnectionPoolSize)); } if(props.containsKey(ClientConfig.ROUTING_TIMEOUT_MS_PROPERTY)) this.setTimeoutMs(props.getLong(ClientConfig.ROUTING_TIMEOUT_MS_PROPERTY, timeoutMs), TimeUnit.MILLISECONDS); // By default, make all the timeouts equal to routing timeout timeoutConfig = new TimeoutConfig(timeoutMs, false); if(props.containsKey(ClientConfig.GETALL_ROUTING_TIMEOUT_MS_PROPERTY)) timeoutConfig.setOperationTimeout(VoldemortOpCode.GET_ALL_OP_CODE, props.getInt(ClientConfig.GETALL_ROUTING_TIMEOUT_MS_PROPERTY)); if(props.containsKey(ClientConfig.GET_ROUTING_TIMEOUT_MS_PROPERTY)) timeoutConfig.setOperationTimeout(VoldemortOpCode.GET_OP_CODE, props.getInt(ClientConfig.GET_ROUTING_TIMEOUT_MS_PROPERTY)); if(props.containsKey(ClientConfig.PUT_ROUTING_TIMEOUT_MS_PROPERTY)) { long putTimeoutMs = props.getInt(ClientConfig.PUT_ROUTING_TIMEOUT_MS_PROPERTY); timeoutConfig.setOperationTimeout(VoldemortOpCode.PUT_OP_CODE, putTimeoutMs); // By default, use the same thing for getVersions() also timeoutConfig.setOperationTimeout(VoldemortOpCode.GET_VERSION_OP_CODE, putTimeoutMs); } // of course, if someone overrides it, we will respect that if(props.containsKey(ClientConfig.GET_VERSIONS_ROUTING_TIMEOUT_MS_PROPERTY)) timeoutConfig.setOperationTimeout(VoldemortOpCode.GET_VERSION_OP_CODE, props.getInt(ClientConfig.GET_VERSIONS_ROUTING_TIMEOUT_MS_PROPERTY)); if(props.containsKey(ClientConfig.DELETE_ROUTING_TIMEOUT_MS_PROPERTY)) timeoutConfig.setOperationTimeout(VoldemortOpCode.DELETE_OP_CODE, props.getInt(ClientConfig.DELETE_ROUTING_TIMEOUT_MS_PROPERTY)); if(props.containsKey(ClientConfig.ALLOW_PARTIAL_GETALLS_PROPERTY)) timeoutConfig.setPartialGetAllAllowed(props.getBoolean(ClientConfig.ALLOW_PARTIAL_GETALLS_PROPERTY)); }
java
private void setProperties(Properties properties) { Props props = new Props(properties); if(props.containsKey(ClientConfig.ENABLE_JMX_PROPERTY)) { this.setEnableJmx(props.getBoolean(ClientConfig.ENABLE_JMX_PROPERTY)); } if(props.containsKey(ClientConfig.BOOTSTRAP_URLS_PROPERTY)) { List<String> urls = props.getList(ClientConfig.BOOTSTRAP_URLS_PROPERTY); if(urls.size() > 0) { setHttpBootstrapURL(urls.get(0)); } } if(props.containsKey(ClientConfig.MAX_TOTAL_CONNECTIONS_PROPERTY)) { setMaxR2ConnectionPoolSize(props.getInt(ClientConfig.MAX_TOTAL_CONNECTIONS_PROPERTY, maxR2ConnectionPoolSize)); } if(props.containsKey(ClientConfig.ROUTING_TIMEOUT_MS_PROPERTY)) this.setTimeoutMs(props.getLong(ClientConfig.ROUTING_TIMEOUT_MS_PROPERTY, timeoutMs), TimeUnit.MILLISECONDS); // By default, make all the timeouts equal to routing timeout timeoutConfig = new TimeoutConfig(timeoutMs, false); if(props.containsKey(ClientConfig.GETALL_ROUTING_TIMEOUT_MS_PROPERTY)) timeoutConfig.setOperationTimeout(VoldemortOpCode.GET_ALL_OP_CODE, props.getInt(ClientConfig.GETALL_ROUTING_TIMEOUT_MS_PROPERTY)); if(props.containsKey(ClientConfig.GET_ROUTING_TIMEOUT_MS_PROPERTY)) timeoutConfig.setOperationTimeout(VoldemortOpCode.GET_OP_CODE, props.getInt(ClientConfig.GET_ROUTING_TIMEOUT_MS_PROPERTY)); if(props.containsKey(ClientConfig.PUT_ROUTING_TIMEOUT_MS_PROPERTY)) { long putTimeoutMs = props.getInt(ClientConfig.PUT_ROUTING_TIMEOUT_MS_PROPERTY); timeoutConfig.setOperationTimeout(VoldemortOpCode.PUT_OP_CODE, putTimeoutMs); // By default, use the same thing for getVersions() also timeoutConfig.setOperationTimeout(VoldemortOpCode.GET_VERSION_OP_CODE, putTimeoutMs); } // of course, if someone overrides it, we will respect that if(props.containsKey(ClientConfig.GET_VERSIONS_ROUTING_TIMEOUT_MS_PROPERTY)) timeoutConfig.setOperationTimeout(VoldemortOpCode.GET_VERSION_OP_CODE, props.getInt(ClientConfig.GET_VERSIONS_ROUTING_TIMEOUT_MS_PROPERTY)); if(props.containsKey(ClientConfig.DELETE_ROUTING_TIMEOUT_MS_PROPERTY)) timeoutConfig.setOperationTimeout(VoldemortOpCode.DELETE_OP_CODE, props.getInt(ClientConfig.DELETE_ROUTING_TIMEOUT_MS_PROPERTY)); if(props.containsKey(ClientConfig.ALLOW_PARTIAL_GETALLS_PROPERTY)) timeoutConfig.setPartialGetAllAllowed(props.getBoolean(ClientConfig.ALLOW_PARTIAL_GETALLS_PROPERTY)); }
[ "private", "void", "setProperties", "(", "Properties", "properties", ")", "{", "Props", "props", "=", "new", "Props", "(", "properties", ")", ";", "if", "(", "props", ".", "containsKey", "(", "ClientConfig", ".", "ENABLE_JMX_PROPERTY", ")", ")", "{", "this", ".", "setEnableJmx", "(", "props", ".", "getBoolean", "(", "ClientConfig", ".", "ENABLE_JMX_PROPERTY", ")", ")", ";", "}", "if", "(", "props", ".", "containsKey", "(", "ClientConfig", ".", "BOOTSTRAP_URLS_PROPERTY", ")", ")", "{", "List", "<", "String", ">", "urls", "=", "props", ".", "getList", "(", "ClientConfig", ".", "BOOTSTRAP_URLS_PROPERTY", ")", ";", "if", "(", "urls", ".", "size", "(", ")", ">", "0", ")", "{", "setHttpBootstrapURL", "(", "urls", ".", "get", "(", "0", ")", ")", ";", "}", "}", "if", "(", "props", ".", "containsKey", "(", "ClientConfig", ".", "MAX_TOTAL_CONNECTIONS_PROPERTY", ")", ")", "{", "setMaxR2ConnectionPoolSize", "(", "props", ".", "getInt", "(", "ClientConfig", ".", "MAX_TOTAL_CONNECTIONS_PROPERTY", ",", "maxR2ConnectionPoolSize", ")", ")", ";", "}", "if", "(", "props", ".", "containsKey", "(", "ClientConfig", ".", "ROUTING_TIMEOUT_MS_PROPERTY", ")", ")", "this", ".", "setTimeoutMs", "(", "props", ".", "getLong", "(", "ClientConfig", ".", "ROUTING_TIMEOUT_MS_PROPERTY", ",", "timeoutMs", ")", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "// By default, make all the timeouts equal to routing timeout", "timeoutConfig", "=", "new", "TimeoutConfig", "(", "timeoutMs", ",", "false", ")", ";", "if", "(", "props", ".", "containsKey", "(", "ClientConfig", ".", "GETALL_ROUTING_TIMEOUT_MS_PROPERTY", ")", ")", "timeoutConfig", ".", "setOperationTimeout", "(", "VoldemortOpCode", ".", "GET_ALL_OP_CODE", ",", "props", ".", "getInt", "(", "ClientConfig", ".", "GETALL_ROUTING_TIMEOUT_MS_PROPERTY", ")", ")", ";", "if", "(", "props", ".", "containsKey", "(", "ClientConfig", ".", "GET_ROUTING_TIMEOUT_MS_PROPERTY", ")", ")", "timeoutConfig", ".", "setOperationTimeout", "(", "VoldemortOpCode", ".", "GET_OP_CODE", ",", "props", ".", "getInt", "(", "ClientConfig", ".", "GET_ROUTING_TIMEOUT_MS_PROPERTY", ")", ")", ";", "if", "(", "props", ".", "containsKey", "(", "ClientConfig", ".", "PUT_ROUTING_TIMEOUT_MS_PROPERTY", ")", ")", "{", "long", "putTimeoutMs", "=", "props", ".", "getInt", "(", "ClientConfig", ".", "PUT_ROUTING_TIMEOUT_MS_PROPERTY", ")", ";", "timeoutConfig", ".", "setOperationTimeout", "(", "VoldemortOpCode", ".", "PUT_OP_CODE", ",", "putTimeoutMs", ")", ";", "// By default, use the same thing for getVersions() also", "timeoutConfig", ".", "setOperationTimeout", "(", "VoldemortOpCode", ".", "GET_VERSION_OP_CODE", ",", "putTimeoutMs", ")", ";", "}", "// of course, if someone overrides it, we will respect that", "if", "(", "props", ".", "containsKey", "(", "ClientConfig", ".", "GET_VERSIONS_ROUTING_TIMEOUT_MS_PROPERTY", ")", ")", "timeoutConfig", ".", "setOperationTimeout", "(", "VoldemortOpCode", ".", "GET_VERSION_OP_CODE", ",", "props", ".", "getInt", "(", "ClientConfig", ".", "GET_VERSIONS_ROUTING_TIMEOUT_MS_PROPERTY", ")", ")", ";", "if", "(", "props", ".", "containsKey", "(", "ClientConfig", ".", "DELETE_ROUTING_TIMEOUT_MS_PROPERTY", ")", ")", "timeoutConfig", ".", "setOperationTimeout", "(", "VoldemortOpCode", ".", "DELETE_OP_CODE", ",", "props", ".", "getInt", "(", "ClientConfig", ".", "DELETE_ROUTING_TIMEOUT_MS_PROPERTY", ")", ")", ";", "if", "(", "props", ".", "containsKey", "(", "ClientConfig", ".", "ALLOW_PARTIAL_GETALLS_PROPERTY", ")", ")", "timeoutConfig", ".", "setPartialGetAllAllowed", "(", "props", ".", "getBoolean", "(", "ClientConfig", ".", "ALLOW_PARTIAL_GETALLS_PROPERTY", ")", ")", ";", "}" ]
Set the values using the specified Properties object. @param properties Properties object containing specific property values for the RESTClient config Note: We're using the same property names as that in ClientConfig for backwards compatibility.
[ "Set", "the", "values", "using", "the", "specified", "Properties", "object", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/contrib/restclient/src/java/voldemort/restclient/RESTClientConfig.java#L76-L128
160,866
voldemort/voldemort
src/java/voldemort/rest/coordinator/config/CoordinatorConfig.java
CoordinatorConfig.setProperties
private void setProperties(Properties properties) { Props props = new Props(properties); if(props.containsKey(BOOTSTRAP_URLS_PROPERTY)) { setBootstrapURLs(props.getList(BOOTSTRAP_URLS_PROPERTY)); } if(props.containsKey(FAT_CLIENTS_CONFIG_SOURCE)) { setFatClientConfigSource(StoreClientConfigSource.get(props.getString(FAT_CLIENTS_CONFIG_SOURCE))); } if(props.containsKey(FAT_CLIENTS_CONFIG_FILE_PATH_PROPERTY)) { setFatClientConfigPath(props.getString(FAT_CLIENTS_CONFIG_FILE_PATH_PROPERTY)); } if(props.containsKey(METADATA_CHECK_INTERVAL_IN_MS)) { setMetadataCheckIntervalInMs(props.getInt(METADATA_CHECK_INTERVAL_IN_MS)); } if(props.containsKey(NETTY_SERVER_PORT)) { setServerPort(props.getInt(NETTY_SERVER_PORT)); } if(props.containsKey(NETTY_SERVER_BACKLOG)) { setNettyServerBacklog(props.getInt(NETTY_SERVER_BACKLOG)); } if(props.containsKey(COORDINATOR_CORE_THREADS)) { setCoordinatorCoreThreads(props.getInt(COORDINATOR_CORE_THREADS)); } if(props.containsKey(COORDINATOR_MAX_THREADS)) { setCoordinatorMaxThreads(props.getInt(COORDINATOR_MAX_THREADS)); } if(props.containsKey(COORDINATOR_QUEUED_REQUESTS)) { setCoordinatorQueuedRequestsSize(props.getInt(COORDINATOR_QUEUED_REQUESTS)); } if(props.containsKey(HTTP_MESSAGE_DECODER_MAX_INITIAL_LINE_LENGTH)) { setHttpMessageDecoderMaxInitialLength(props.getInt(HTTP_MESSAGE_DECODER_MAX_INITIAL_LINE_LENGTH)); } if(props.containsKey(HTTP_MESSAGE_DECODER_MAX_HEADER_SIZE)) { setHttpMessageDecoderMaxHeaderSize(props.getInt(HTTP_MESSAGE_DECODER_MAX_HEADER_SIZE)); } if(props.containsKey(HTTP_MESSAGE_DECODER_MAX_CHUNK_SIZE)) { setHttpMessageDecoderMaxChunkSize(props.getInt(HTTP_MESSAGE_DECODER_MAX_CHUNK_SIZE)); } if(props.containsKey(ADMIN_ENABLE)) { setAdminServiceEnabled(props.getBoolean(ADMIN_ENABLE)); } if(props.containsKey(ADMIN_PORT)) { setAdminPort(props.getInt(ADMIN_PORT)); } }
java
private void setProperties(Properties properties) { Props props = new Props(properties); if(props.containsKey(BOOTSTRAP_URLS_PROPERTY)) { setBootstrapURLs(props.getList(BOOTSTRAP_URLS_PROPERTY)); } if(props.containsKey(FAT_CLIENTS_CONFIG_SOURCE)) { setFatClientConfigSource(StoreClientConfigSource.get(props.getString(FAT_CLIENTS_CONFIG_SOURCE))); } if(props.containsKey(FAT_CLIENTS_CONFIG_FILE_PATH_PROPERTY)) { setFatClientConfigPath(props.getString(FAT_CLIENTS_CONFIG_FILE_PATH_PROPERTY)); } if(props.containsKey(METADATA_CHECK_INTERVAL_IN_MS)) { setMetadataCheckIntervalInMs(props.getInt(METADATA_CHECK_INTERVAL_IN_MS)); } if(props.containsKey(NETTY_SERVER_PORT)) { setServerPort(props.getInt(NETTY_SERVER_PORT)); } if(props.containsKey(NETTY_SERVER_BACKLOG)) { setNettyServerBacklog(props.getInt(NETTY_SERVER_BACKLOG)); } if(props.containsKey(COORDINATOR_CORE_THREADS)) { setCoordinatorCoreThreads(props.getInt(COORDINATOR_CORE_THREADS)); } if(props.containsKey(COORDINATOR_MAX_THREADS)) { setCoordinatorMaxThreads(props.getInt(COORDINATOR_MAX_THREADS)); } if(props.containsKey(COORDINATOR_QUEUED_REQUESTS)) { setCoordinatorQueuedRequestsSize(props.getInt(COORDINATOR_QUEUED_REQUESTS)); } if(props.containsKey(HTTP_MESSAGE_DECODER_MAX_INITIAL_LINE_LENGTH)) { setHttpMessageDecoderMaxInitialLength(props.getInt(HTTP_MESSAGE_DECODER_MAX_INITIAL_LINE_LENGTH)); } if(props.containsKey(HTTP_MESSAGE_DECODER_MAX_HEADER_SIZE)) { setHttpMessageDecoderMaxHeaderSize(props.getInt(HTTP_MESSAGE_DECODER_MAX_HEADER_SIZE)); } if(props.containsKey(HTTP_MESSAGE_DECODER_MAX_CHUNK_SIZE)) { setHttpMessageDecoderMaxChunkSize(props.getInt(HTTP_MESSAGE_DECODER_MAX_CHUNK_SIZE)); } if(props.containsKey(ADMIN_ENABLE)) { setAdminServiceEnabled(props.getBoolean(ADMIN_ENABLE)); } if(props.containsKey(ADMIN_PORT)) { setAdminPort(props.getInt(ADMIN_PORT)); } }
[ "private", "void", "setProperties", "(", "Properties", "properties", ")", "{", "Props", "props", "=", "new", "Props", "(", "properties", ")", ";", "if", "(", "props", ".", "containsKey", "(", "BOOTSTRAP_URLS_PROPERTY", ")", ")", "{", "setBootstrapURLs", "(", "props", ".", "getList", "(", "BOOTSTRAP_URLS_PROPERTY", ")", ")", ";", "}", "if", "(", "props", ".", "containsKey", "(", "FAT_CLIENTS_CONFIG_SOURCE", ")", ")", "{", "setFatClientConfigSource", "(", "StoreClientConfigSource", ".", "get", "(", "props", ".", "getString", "(", "FAT_CLIENTS_CONFIG_SOURCE", ")", ")", ")", ";", "}", "if", "(", "props", ".", "containsKey", "(", "FAT_CLIENTS_CONFIG_FILE_PATH_PROPERTY", ")", ")", "{", "setFatClientConfigPath", "(", "props", ".", "getString", "(", "FAT_CLIENTS_CONFIG_FILE_PATH_PROPERTY", ")", ")", ";", "}", "if", "(", "props", ".", "containsKey", "(", "METADATA_CHECK_INTERVAL_IN_MS", ")", ")", "{", "setMetadataCheckIntervalInMs", "(", "props", ".", "getInt", "(", "METADATA_CHECK_INTERVAL_IN_MS", ")", ")", ";", "}", "if", "(", "props", ".", "containsKey", "(", "NETTY_SERVER_PORT", ")", ")", "{", "setServerPort", "(", "props", ".", "getInt", "(", "NETTY_SERVER_PORT", ")", ")", ";", "}", "if", "(", "props", ".", "containsKey", "(", "NETTY_SERVER_BACKLOG", ")", ")", "{", "setNettyServerBacklog", "(", "props", ".", "getInt", "(", "NETTY_SERVER_BACKLOG", ")", ")", ";", "}", "if", "(", "props", ".", "containsKey", "(", "COORDINATOR_CORE_THREADS", ")", ")", "{", "setCoordinatorCoreThreads", "(", "props", ".", "getInt", "(", "COORDINATOR_CORE_THREADS", ")", ")", ";", "}", "if", "(", "props", ".", "containsKey", "(", "COORDINATOR_MAX_THREADS", ")", ")", "{", "setCoordinatorMaxThreads", "(", "props", ".", "getInt", "(", "COORDINATOR_MAX_THREADS", ")", ")", ";", "}", "if", "(", "props", ".", "containsKey", "(", "COORDINATOR_QUEUED_REQUESTS", ")", ")", "{", "setCoordinatorQueuedRequestsSize", "(", "props", ".", "getInt", "(", "COORDINATOR_QUEUED_REQUESTS", ")", ")", ";", "}", "if", "(", "props", ".", "containsKey", "(", "HTTP_MESSAGE_DECODER_MAX_INITIAL_LINE_LENGTH", ")", ")", "{", "setHttpMessageDecoderMaxInitialLength", "(", "props", ".", "getInt", "(", "HTTP_MESSAGE_DECODER_MAX_INITIAL_LINE_LENGTH", ")", ")", ";", "}", "if", "(", "props", ".", "containsKey", "(", "HTTP_MESSAGE_DECODER_MAX_HEADER_SIZE", ")", ")", "{", "setHttpMessageDecoderMaxHeaderSize", "(", "props", ".", "getInt", "(", "HTTP_MESSAGE_DECODER_MAX_HEADER_SIZE", ")", ")", ";", "}", "if", "(", "props", ".", "containsKey", "(", "HTTP_MESSAGE_DECODER_MAX_CHUNK_SIZE", ")", ")", "{", "setHttpMessageDecoderMaxChunkSize", "(", "props", ".", "getInt", "(", "HTTP_MESSAGE_DECODER_MAX_CHUNK_SIZE", ")", ")", ";", "}", "if", "(", "props", ".", "containsKey", "(", "ADMIN_ENABLE", ")", ")", "{", "setAdminServiceEnabled", "(", "props", ".", "getBoolean", "(", "ADMIN_ENABLE", ")", ")", ";", "}", "if", "(", "props", ".", "containsKey", "(", "ADMIN_PORT", ")", ")", "{", "setAdminPort", "(", "props", ".", "getInt", "(", "ADMIN_PORT", ")", ")", ";", "}", "}" ]
Set the values using the specified Properties object @param properties Properties object containing specific property values for the Coordinator config
[ "Set", "the", "values", "using", "the", "specified", "Properties", "object" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/coordinator/config/CoordinatorConfig.java#L115-L173
160,867
voldemort/voldemort
src/java/voldemort/rest/coordinator/config/CoordinatorConfig.java
CoordinatorConfig.setBootstrapURLs
public CoordinatorConfig setBootstrapURLs(List<String> bootstrapUrls) { this.bootstrapURLs = Utils.notNull(bootstrapUrls); if(this.bootstrapURLs.size() <= 0) throw new IllegalArgumentException("Must provide at least one bootstrap URL."); return this; }
java
public CoordinatorConfig setBootstrapURLs(List<String> bootstrapUrls) { this.bootstrapURLs = Utils.notNull(bootstrapUrls); if(this.bootstrapURLs.size() <= 0) throw new IllegalArgumentException("Must provide at least one bootstrap URL."); return this; }
[ "public", "CoordinatorConfig", "setBootstrapURLs", "(", "List", "<", "String", ">", "bootstrapUrls", ")", "{", "this", ".", "bootstrapURLs", "=", "Utils", ".", "notNull", "(", "bootstrapUrls", ")", ";", "if", "(", "this", ".", "bootstrapURLs", ".", "size", "(", ")", "<=", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"Must provide at least one bootstrap URL.\"", ")", ";", "return", "this", ";", "}" ]
Sets the bootstrap URLs used by the different Fat clients inside the Coordinator @param bootstrapUrls list of bootstrap URLs defining which cluster to connect to @return modified CoordinatorConfig
[ "Sets", "the", "bootstrap", "URLs", "used", "by", "the", "different", "Fat", "clients", "inside", "the", "Coordinator" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/coordinator/config/CoordinatorConfig.java#L189-L194
160,868
voldemort/voldemort
src/java/voldemort/store/slop/HintedHandoff.java
HintedHandoff.sendOneAsyncHint
private void sendOneAsyncHint(final ByteArray slopKey, final Versioned<byte[]> slopVersioned, final List<Node> nodesToTry) { Node nodeToHostHint = null; boolean foundNode = false; while(nodesToTry.size() > 0) { nodeToHostHint = nodesToTry.remove(0); if(!failedNodes.contains(nodeToHostHint) && failureDetector.isAvailable(nodeToHostHint)) { foundNode = true; break; } } if(!foundNode) { Slop slop = slopSerializer.toObject(slopVersioned.getValue()); logger.error("Trying to send an async hint but used up all nodes. key: " + slop.getKey() + " version: " + slopVersioned.getVersion().toString()); return; } final Node node = nodeToHostHint; int nodeId = node.getId(); NonblockingStore nonblockingStore = nonblockingSlopStores.get(nodeId); Utils.notNull(nonblockingStore); final Long startNs = System.nanoTime(); NonblockingStoreCallback callback = new NonblockingStoreCallback() { @Override public void requestComplete(Object result, long requestTime) { Slop slop = null; boolean loggerDebugEnabled = logger.isDebugEnabled(); if(loggerDebugEnabled) { slop = slopSerializer.toObject(slopVersioned.getValue()); } Response<ByteArray, Object> response = new Response<ByteArray, Object>(node, slopKey, result, requestTime); if(response.getValue() instanceof Exception && !(response.getValue() instanceof ObsoleteVersionException)) { if(!failedNodes.contains(node)) failedNodes.add(node); if(response.getValue() instanceof UnreachableStoreException) { UnreachableStoreException use = (UnreachableStoreException) response.getValue(); if(loggerDebugEnabled) { logger.debug("Write of key " + slop.getKey() + " for " + slop.getNodeId() + " to node " + node + " failed due to unreachable: " + use.getMessage()); } failureDetector.recordException(node, (System.nanoTime() - startNs) / Time.NS_PER_MS, use); } sendOneAsyncHint(slopKey, slopVersioned, nodesToTry); } if(loggerDebugEnabled) logger.debug("Slop write of key " + slop.getKey() + " for node " + slop.getNodeId() + " to node " + node + " succeeded in " + (System.nanoTime() - startNs) + " ns"); failureDetector.recordSuccess(node, (System.nanoTime() - startNs) / Time.NS_PER_MS); } }; nonblockingStore.submitPutRequest(slopKey, slopVersioned, null, callback, timeoutMs); }
java
private void sendOneAsyncHint(final ByteArray slopKey, final Versioned<byte[]> slopVersioned, final List<Node> nodesToTry) { Node nodeToHostHint = null; boolean foundNode = false; while(nodesToTry.size() > 0) { nodeToHostHint = nodesToTry.remove(0); if(!failedNodes.contains(nodeToHostHint) && failureDetector.isAvailable(nodeToHostHint)) { foundNode = true; break; } } if(!foundNode) { Slop slop = slopSerializer.toObject(slopVersioned.getValue()); logger.error("Trying to send an async hint but used up all nodes. key: " + slop.getKey() + " version: " + slopVersioned.getVersion().toString()); return; } final Node node = nodeToHostHint; int nodeId = node.getId(); NonblockingStore nonblockingStore = nonblockingSlopStores.get(nodeId); Utils.notNull(nonblockingStore); final Long startNs = System.nanoTime(); NonblockingStoreCallback callback = new NonblockingStoreCallback() { @Override public void requestComplete(Object result, long requestTime) { Slop slop = null; boolean loggerDebugEnabled = logger.isDebugEnabled(); if(loggerDebugEnabled) { slop = slopSerializer.toObject(slopVersioned.getValue()); } Response<ByteArray, Object> response = new Response<ByteArray, Object>(node, slopKey, result, requestTime); if(response.getValue() instanceof Exception && !(response.getValue() instanceof ObsoleteVersionException)) { if(!failedNodes.contains(node)) failedNodes.add(node); if(response.getValue() instanceof UnreachableStoreException) { UnreachableStoreException use = (UnreachableStoreException) response.getValue(); if(loggerDebugEnabled) { logger.debug("Write of key " + slop.getKey() + " for " + slop.getNodeId() + " to node " + node + " failed due to unreachable: " + use.getMessage()); } failureDetector.recordException(node, (System.nanoTime() - startNs) / Time.NS_PER_MS, use); } sendOneAsyncHint(slopKey, slopVersioned, nodesToTry); } if(loggerDebugEnabled) logger.debug("Slop write of key " + slop.getKey() + " for node " + slop.getNodeId() + " to node " + node + " succeeded in " + (System.nanoTime() - startNs) + " ns"); failureDetector.recordSuccess(node, (System.nanoTime() - startNs) / Time.NS_PER_MS); } }; nonblockingStore.submitPutRequest(slopKey, slopVersioned, null, callback, timeoutMs); }
[ "private", "void", "sendOneAsyncHint", "(", "final", "ByteArray", "slopKey", ",", "final", "Versioned", "<", "byte", "[", "]", ">", "slopVersioned", ",", "final", "List", "<", "Node", ">", "nodesToTry", ")", "{", "Node", "nodeToHostHint", "=", "null", ";", "boolean", "foundNode", "=", "false", ";", "while", "(", "nodesToTry", ".", "size", "(", ")", ">", "0", ")", "{", "nodeToHostHint", "=", "nodesToTry", ".", "remove", "(", "0", ")", ";", "if", "(", "!", "failedNodes", ".", "contains", "(", "nodeToHostHint", ")", "&&", "failureDetector", ".", "isAvailable", "(", "nodeToHostHint", ")", ")", "{", "foundNode", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "foundNode", ")", "{", "Slop", "slop", "=", "slopSerializer", ".", "toObject", "(", "slopVersioned", ".", "getValue", "(", ")", ")", ";", "logger", ".", "error", "(", "\"Trying to send an async hint but used up all nodes. key: \"", "+", "slop", ".", "getKey", "(", ")", "+", "\" version: \"", "+", "slopVersioned", ".", "getVersion", "(", ")", ".", "toString", "(", ")", ")", ";", "return", ";", "}", "final", "Node", "node", "=", "nodeToHostHint", ";", "int", "nodeId", "=", "node", ".", "getId", "(", ")", ";", "NonblockingStore", "nonblockingStore", "=", "nonblockingSlopStores", ".", "get", "(", "nodeId", ")", ";", "Utils", ".", "notNull", "(", "nonblockingStore", ")", ";", "final", "Long", "startNs", "=", "System", ".", "nanoTime", "(", ")", ";", "NonblockingStoreCallback", "callback", "=", "new", "NonblockingStoreCallback", "(", ")", "{", "@", "Override", "public", "void", "requestComplete", "(", "Object", "result", ",", "long", "requestTime", ")", "{", "Slop", "slop", "=", "null", ";", "boolean", "loggerDebugEnabled", "=", "logger", ".", "isDebugEnabled", "(", ")", ";", "if", "(", "loggerDebugEnabled", ")", "{", "slop", "=", "slopSerializer", ".", "toObject", "(", "slopVersioned", ".", "getValue", "(", ")", ")", ";", "}", "Response", "<", "ByteArray", ",", "Object", ">", "response", "=", "new", "Response", "<", "ByteArray", ",", "Object", ">", "(", "node", ",", "slopKey", ",", "result", ",", "requestTime", ")", ";", "if", "(", "response", ".", "getValue", "(", ")", "instanceof", "Exception", "&&", "!", "(", "response", ".", "getValue", "(", ")", "instanceof", "ObsoleteVersionException", ")", ")", "{", "if", "(", "!", "failedNodes", ".", "contains", "(", "node", ")", ")", "failedNodes", ".", "add", "(", "node", ")", ";", "if", "(", "response", ".", "getValue", "(", ")", "instanceof", "UnreachableStoreException", ")", "{", "UnreachableStoreException", "use", "=", "(", "UnreachableStoreException", ")", "response", ".", "getValue", "(", ")", ";", "if", "(", "loggerDebugEnabled", ")", "{", "logger", ".", "debug", "(", "\"Write of key \"", "+", "slop", ".", "getKey", "(", ")", "+", "\" for \"", "+", "slop", ".", "getNodeId", "(", ")", "+", "\" to node \"", "+", "node", "+", "\" failed due to unreachable: \"", "+", "use", ".", "getMessage", "(", ")", ")", ";", "}", "failureDetector", ".", "recordException", "(", "node", ",", "(", "System", ".", "nanoTime", "(", ")", "-", "startNs", ")", "/", "Time", ".", "NS_PER_MS", ",", "use", ")", ";", "}", "sendOneAsyncHint", "(", "slopKey", ",", "slopVersioned", ",", "nodesToTry", ")", ";", "}", "if", "(", "loggerDebugEnabled", ")", "logger", ".", "debug", "(", "\"Slop write of key \"", "+", "slop", ".", "getKey", "(", ")", "+", "\" for node \"", "+", "slop", ".", "getNodeId", "(", ")", "+", "\" to node \"", "+", "node", "+", "\" succeeded in \"", "+", "(", "System", ".", "nanoTime", "(", ")", "-", "startNs", ")", "+", "\" ns\"", ")", ";", "failureDetector", ".", "recordSuccess", "(", "node", ",", "(", "System", ".", "nanoTime", "(", ")", "-", "startNs", ")", "/", "Time", ".", "NS_PER_MS", ")", ";", "}", "}", ";", "nonblockingStore", ".", "submitPutRequest", "(", "slopKey", ",", "slopVersioned", ",", "null", ",", "callback", ",", "timeoutMs", ")", ";", "}" ]
A callback that handles requestComplete event from NIO selector manager Will try any possible nodes and pass itself as callback util all nodes are exhausted @param slopKey @param slopVersioned @param nodesToTry List of nodes to try to contact. Will become shorter after each callback
[ "A", "callback", "that", "handles", "requestComplete", "event", "from", "NIO", "selector", "manager", "Will", "try", "any", "possible", "nodes", "and", "pass", "itself", "as", "callback", "util", "all", "nodes", "are", "exhausted" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/slop/HintedHandoff.java#L127-L194
160,869
voldemort/voldemort
src/java/voldemort/store/readonly/ExternalSorter.java
ExternalSorter.sorted
public Iterable<V> sorted(Iterator<V> input) { ExecutorService executor = new ThreadPoolExecutor(this.numThreads, this.numThreads, 1000L, TimeUnit.MILLISECONDS, new SynchronousQueue<Runnable>(), new CallerRunsPolicy()); final AtomicInteger count = new AtomicInteger(0); final List<File> tempFiles = Collections.synchronizedList(new ArrayList<File>()); while(input.hasNext()) { final int segmentId = count.getAndIncrement(); final long segmentStartMs = System.currentTimeMillis(); logger.info("Segment " + segmentId + ": filling sort buffer for segment..."); @SuppressWarnings("unchecked") final V[] buffer = (V[]) new Object[internalSortSize]; int segmentSizeIter = 0; for(; segmentSizeIter < internalSortSize && input.hasNext(); segmentSizeIter++) buffer[segmentSizeIter] = input.next(); final int segmentSize = segmentSizeIter; logger.info("Segment " + segmentId + ": sort buffer filled...adding to sort queue."); // sort and write out asynchronously executor.execute(new Runnable() { public void run() { logger.info("Segment " + segmentId + ": sorting buffer."); long start = System.currentTimeMillis(); Arrays.sort(buffer, 0, segmentSize, comparator); long elapsed = System.currentTimeMillis() - start; logger.info("Segment " + segmentId + ": sort completed in " + elapsed + " ms, writing to temp file."); // write out values to a temp file try { File tempFile = File.createTempFile("segment-", ".dat", tempDir); tempFile.deleteOnExit(); tempFiles.add(tempFile); OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile), bufferSize); if(gzip) os = new GZIPOutputStream(os); DataOutputStream output = new DataOutputStream(os); for(int i = 0; i < segmentSize; i++) writeValue(output, buffer[i]); output.close(); } catch(IOException e) { throw new VoldemortException(e); } long segmentElapsed = System.currentTimeMillis() - segmentStartMs; logger.info("Segment " + segmentId + ": completed processing of segment in " + segmentElapsed + " ms."); } }); } // wait for all sorting to complete executor.shutdown(); try { executor.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS); // create iterator over sorted values return new DefaultIterable<V>(new ExternalSorterIterator(tempFiles, bufferSize / tempFiles.size())); } catch(InterruptedException e) { throw new RuntimeException(e); } }
java
public Iterable<V> sorted(Iterator<V> input) { ExecutorService executor = new ThreadPoolExecutor(this.numThreads, this.numThreads, 1000L, TimeUnit.MILLISECONDS, new SynchronousQueue<Runnable>(), new CallerRunsPolicy()); final AtomicInteger count = new AtomicInteger(0); final List<File> tempFiles = Collections.synchronizedList(new ArrayList<File>()); while(input.hasNext()) { final int segmentId = count.getAndIncrement(); final long segmentStartMs = System.currentTimeMillis(); logger.info("Segment " + segmentId + ": filling sort buffer for segment..."); @SuppressWarnings("unchecked") final V[] buffer = (V[]) new Object[internalSortSize]; int segmentSizeIter = 0; for(; segmentSizeIter < internalSortSize && input.hasNext(); segmentSizeIter++) buffer[segmentSizeIter] = input.next(); final int segmentSize = segmentSizeIter; logger.info("Segment " + segmentId + ": sort buffer filled...adding to sort queue."); // sort and write out asynchronously executor.execute(new Runnable() { public void run() { logger.info("Segment " + segmentId + ": sorting buffer."); long start = System.currentTimeMillis(); Arrays.sort(buffer, 0, segmentSize, comparator); long elapsed = System.currentTimeMillis() - start; logger.info("Segment " + segmentId + ": sort completed in " + elapsed + " ms, writing to temp file."); // write out values to a temp file try { File tempFile = File.createTempFile("segment-", ".dat", tempDir); tempFile.deleteOnExit(); tempFiles.add(tempFile); OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile), bufferSize); if(gzip) os = new GZIPOutputStream(os); DataOutputStream output = new DataOutputStream(os); for(int i = 0; i < segmentSize; i++) writeValue(output, buffer[i]); output.close(); } catch(IOException e) { throw new VoldemortException(e); } long segmentElapsed = System.currentTimeMillis() - segmentStartMs; logger.info("Segment " + segmentId + ": completed processing of segment in " + segmentElapsed + " ms."); } }); } // wait for all sorting to complete executor.shutdown(); try { executor.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS); // create iterator over sorted values return new DefaultIterable<V>(new ExternalSorterIterator(tempFiles, bufferSize / tempFiles.size())); } catch(InterruptedException e) { throw new RuntimeException(e); } }
[ "public", "Iterable", "<", "V", ">", "sorted", "(", "Iterator", "<", "V", ">", "input", ")", "{", "ExecutorService", "executor", "=", "new", "ThreadPoolExecutor", "(", "this", ".", "numThreads", ",", "this", ".", "numThreads", ",", "1000L", ",", "TimeUnit", ".", "MILLISECONDS", ",", "new", "SynchronousQueue", "<", "Runnable", ">", "(", ")", ",", "new", "CallerRunsPolicy", "(", ")", ")", ";", "final", "AtomicInteger", "count", "=", "new", "AtomicInteger", "(", "0", ")", ";", "final", "List", "<", "File", ">", "tempFiles", "=", "Collections", ".", "synchronizedList", "(", "new", "ArrayList", "<", "File", ">", "(", ")", ")", ";", "while", "(", "input", ".", "hasNext", "(", ")", ")", "{", "final", "int", "segmentId", "=", "count", ".", "getAndIncrement", "(", ")", ";", "final", "long", "segmentStartMs", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "logger", ".", "info", "(", "\"Segment \"", "+", "segmentId", "+", "\": filling sort buffer for segment...\"", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "final", "V", "[", "]", "buffer", "=", "(", "V", "[", "]", ")", "new", "Object", "[", "internalSortSize", "]", ";", "int", "segmentSizeIter", "=", "0", ";", "for", "(", ";", "segmentSizeIter", "<", "internalSortSize", "&&", "input", ".", "hasNext", "(", ")", ";", "segmentSizeIter", "++", ")", "buffer", "[", "segmentSizeIter", "]", "=", "input", ".", "next", "(", ")", ";", "final", "int", "segmentSize", "=", "segmentSizeIter", ";", "logger", ".", "info", "(", "\"Segment \"", "+", "segmentId", "+", "\": sort buffer filled...adding to sort queue.\"", ")", ";", "// sort and write out asynchronously", "executor", ".", "execute", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "logger", ".", "info", "(", "\"Segment \"", "+", "segmentId", "+", "\": sorting buffer.\"", ")", ";", "long", "start", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "Arrays", ".", "sort", "(", "buffer", ",", "0", ",", "segmentSize", ",", "comparator", ")", ";", "long", "elapsed", "=", "System", ".", "currentTimeMillis", "(", ")", "-", "start", ";", "logger", ".", "info", "(", "\"Segment \"", "+", "segmentId", "+", "\": sort completed in \"", "+", "elapsed", "+", "\" ms, writing to temp file.\"", ")", ";", "// write out values to a temp file", "try", "{", "File", "tempFile", "=", "File", ".", "createTempFile", "(", "\"segment-\"", ",", "\".dat\"", ",", "tempDir", ")", ";", "tempFile", ".", "deleteOnExit", "(", ")", ";", "tempFiles", ".", "add", "(", "tempFile", ")", ";", "OutputStream", "os", "=", "new", "BufferedOutputStream", "(", "new", "FileOutputStream", "(", "tempFile", ")", ",", "bufferSize", ")", ";", "if", "(", "gzip", ")", "os", "=", "new", "GZIPOutputStream", "(", "os", ")", ";", "DataOutputStream", "output", "=", "new", "DataOutputStream", "(", "os", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "segmentSize", ";", "i", "++", ")", "writeValue", "(", "output", ",", "buffer", "[", "i", "]", ")", ";", "output", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "VoldemortException", "(", "e", ")", ";", "}", "long", "segmentElapsed", "=", "System", ".", "currentTimeMillis", "(", ")", "-", "segmentStartMs", ";", "logger", ".", "info", "(", "\"Segment \"", "+", "segmentId", "+", "\": completed processing of segment in \"", "+", "segmentElapsed", "+", "\" ms.\"", ")", ";", "}", "}", ")", ";", "}", "// wait for all sorting to complete", "executor", ".", "shutdown", "(", ")", ";", "try", "{", "executor", ".", "awaitTermination", "(", "Long", ".", "MAX_VALUE", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "// create iterator over sorted values", "return", "new", "DefaultIterable", "<", "V", ">", "(", "new", "ExternalSorterIterator", "(", "tempFiles", ",", "bufferSize", "/", "tempFiles", ".", "size", "(", ")", ")", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Produce an iterator over the input values in sorted order. Sorting will occur in the fixed space configured in the constructor, data will be dumped to disk as necessary. @param input An iterator over the input values @return An iterator over the values
[ "Produce", "an", "iterator", "over", "the", "input", "values", "in", "sorted", "order", ".", "Sorting", "will", "occur", "in", "the", "fixed", "space", "configured", "in", "the", "constructor", "data", "will", "be", "dumped", "to", "disk", "as", "necessary", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/ExternalSorter.java#L162-L227
160,870
voldemort/voldemort
src/java/voldemort/store/routed/action/PerformParallelPutRequests.java
PerformParallelPutRequests.processResponse
private void processResponse(Response<ByteArray, Object> response, Pipeline pipeline) { if(response == null) { logger.warn("RoutingTimedout on waiting for async ops; parallelResponseToWait: " + numNodesPendingResponse + "; preferred-1: " + (preferred - 1) + "; quorumOK: " + quorumSatisfied + "; zoneOK: " + zonesSatisfied); } else { numNodesPendingResponse = numNodesPendingResponse - 1; numResponsesGot = numResponsesGot + 1; if(response.getValue() instanceof Exception && !(response.getValue() instanceof ObsoleteVersionException)) { if(logger.isDebugEnabled()) { logger.debug("PUT {key:" + key + "} handling async put error"); } if(response.getValue() instanceof QuotaExceededException) { /** * TODO Not sure if we need to count this Exception for * stats or silently ignore and just log a warning. While * QuotaExceededException thrown from other places mean the * operation failed, this one does not fail the operation * but instead stores slops. Introduce a new Exception in * client side to just monitor how mamy Async writes fail on * exceeding Quota? * */ if(logger.isDebugEnabled()) { logger.debug("Received quota exceeded exception after a successful " + pipeline.getOperation().getSimpleName() + " call on node " + response.getNode().getId() + ", store '" + pipelineData.getStoreName() + "', master-node '" + pipelineData.getMaster().getId() + "'"); } } else if(handleResponseError(response, pipeline, failureDetector)) { if(logger.isDebugEnabled()) { logger.debug("PUT {key:" + key + "} severe async put error, exiting parallel put stage"); } return; } if(PipelineRoutedStore.isSlopableFailure(response.getValue()) || response.getValue() instanceof QuotaExceededException) { /** * We want to slop ParallelPuts which fail due to * QuotaExceededException. * * TODO Though this is not the right way of doing things, in * order to avoid inconsistencies and data loss, we chose to * slop the quota failed parallel puts. * * As a long term solution - 1) either Quota management * should be hidden completely in a routing layer like * Coordinator or 2) the Server should be able to * distinguish between serial and parallel puts and should * only quota for serial puts * */ pipelineData.getSynchronizer().tryDelegateSlop(response.getNode()); } if(logger.isDebugEnabled()) { logger.debug("PUT {key:" + key + "} handled async put error"); } } else { pipelineData.incrementSuccesses(); failureDetector.recordSuccess(response.getNode(), response.getRequestTime()); pipelineData.getZoneResponses().add(response.getNode().getZoneId()); } } }
java
private void processResponse(Response<ByteArray, Object> response, Pipeline pipeline) { if(response == null) { logger.warn("RoutingTimedout on waiting for async ops; parallelResponseToWait: " + numNodesPendingResponse + "; preferred-1: " + (preferred - 1) + "; quorumOK: " + quorumSatisfied + "; zoneOK: " + zonesSatisfied); } else { numNodesPendingResponse = numNodesPendingResponse - 1; numResponsesGot = numResponsesGot + 1; if(response.getValue() instanceof Exception && !(response.getValue() instanceof ObsoleteVersionException)) { if(logger.isDebugEnabled()) { logger.debug("PUT {key:" + key + "} handling async put error"); } if(response.getValue() instanceof QuotaExceededException) { /** * TODO Not sure if we need to count this Exception for * stats or silently ignore and just log a warning. While * QuotaExceededException thrown from other places mean the * operation failed, this one does not fail the operation * but instead stores slops. Introduce a new Exception in * client side to just monitor how mamy Async writes fail on * exceeding Quota? * */ if(logger.isDebugEnabled()) { logger.debug("Received quota exceeded exception after a successful " + pipeline.getOperation().getSimpleName() + " call on node " + response.getNode().getId() + ", store '" + pipelineData.getStoreName() + "', master-node '" + pipelineData.getMaster().getId() + "'"); } } else if(handleResponseError(response, pipeline, failureDetector)) { if(logger.isDebugEnabled()) { logger.debug("PUT {key:" + key + "} severe async put error, exiting parallel put stage"); } return; } if(PipelineRoutedStore.isSlopableFailure(response.getValue()) || response.getValue() instanceof QuotaExceededException) { /** * We want to slop ParallelPuts which fail due to * QuotaExceededException. * * TODO Though this is not the right way of doing things, in * order to avoid inconsistencies and data loss, we chose to * slop the quota failed parallel puts. * * As a long term solution - 1) either Quota management * should be hidden completely in a routing layer like * Coordinator or 2) the Server should be able to * distinguish between serial and parallel puts and should * only quota for serial puts * */ pipelineData.getSynchronizer().tryDelegateSlop(response.getNode()); } if(logger.isDebugEnabled()) { logger.debug("PUT {key:" + key + "} handled async put error"); } } else { pipelineData.incrementSuccesses(); failureDetector.recordSuccess(response.getNode(), response.getRequestTime()); pipelineData.getZoneResponses().add(response.getNode().getZoneId()); } } }
[ "private", "void", "processResponse", "(", "Response", "<", "ByteArray", ",", "Object", ">", "response", ",", "Pipeline", "pipeline", ")", "{", "if", "(", "response", "==", "null", ")", "{", "logger", ".", "warn", "(", "\"RoutingTimedout on waiting for async ops; parallelResponseToWait: \"", "+", "numNodesPendingResponse", "+", "\"; preferred-1: \"", "+", "(", "preferred", "-", "1", ")", "+", "\"; quorumOK: \"", "+", "quorumSatisfied", "+", "\"; zoneOK: \"", "+", "zonesSatisfied", ")", ";", "}", "else", "{", "numNodesPendingResponse", "=", "numNodesPendingResponse", "-", "1", ";", "numResponsesGot", "=", "numResponsesGot", "+", "1", ";", "if", "(", "response", ".", "getValue", "(", ")", "instanceof", "Exception", "&&", "!", "(", "response", ".", "getValue", "(", ")", "instanceof", "ObsoleteVersionException", ")", ")", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"PUT {key:\"", "+", "key", "+", "\"} handling async put error\"", ")", ";", "}", "if", "(", "response", ".", "getValue", "(", ")", "instanceof", "QuotaExceededException", ")", "{", "/**\n * TODO Not sure if we need to count this Exception for\n * stats or silently ignore and just log a warning. While\n * QuotaExceededException thrown from other places mean the\n * operation failed, this one does not fail the operation\n * but instead stores slops. Introduce a new Exception in\n * client side to just monitor how mamy Async writes fail on\n * exceeding Quota?\n * \n */", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Received quota exceeded exception after a successful \"", "+", "pipeline", ".", "getOperation", "(", ")", ".", "getSimpleName", "(", ")", "+", "\" call on node \"", "+", "response", ".", "getNode", "(", ")", ".", "getId", "(", ")", "+", "\", store '\"", "+", "pipelineData", ".", "getStoreName", "(", ")", "+", "\"', master-node '\"", "+", "pipelineData", ".", "getMaster", "(", ")", ".", "getId", "(", ")", "+", "\"'\"", ")", ";", "}", "}", "else", "if", "(", "handleResponseError", "(", "response", ",", "pipeline", ",", "failureDetector", ")", ")", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"PUT {key:\"", "+", "key", "+", "\"} severe async put error, exiting parallel put stage\"", ")", ";", "}", "return", ";", "}", "if", "(", "PipelineRoutedStore", ".", "isSlopableFailure", "(", "response", ".", "getValue", "(", ")", ")", "||", "response", ".", "getValue", "(", ")", "instanceof", "QuotaExceededException", ")", "{", "/**\n * We want to slop ParallelPuts which fail due to\n * QuotaExceededException.\n * \n * TODO Though this is not the right way of doing things, in\n * order to avoid inconsistencies and data loss, we chose to\n * slop the quota failed parallel puts.\n * \n * As a long term solution - 1) either Quota management\n * should be hidden completely in a routing layer like\n * Coordinator or 2) the Server should be able to\n * distinguish between serial and parallel puts and should\n * only quota for serial puts\n * \n */", "pipelineData", ".", "getSynchronizer", "(", ")", ".", "tryDelegateSlop", "(", "response", ".", "getNode", "(", ")", ")", ";", "}", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"PUT {key:\"", "+", "key", "+", "\"} handled async put error\"", ")", ";", "}", "}", "else", "{", "pipelineData", ".", "incrementSuccesses", "(", ")", ";", "failureDetector", ".", "recordSuccess", "(", "response", ".", "getNode", "(", ")", ",", "response", ".", "getRequestTime", "(", ")", ")", ";", "pipelineData", ".", "getZoneResponses", "(", ")", ".", "add", "(", "response", ".", "getNode", "(", ")", ".", "getZoneId", "(", ")", ")", ";", "}", "}", "}" ]
Process the response by reporting proper log and feeding failure detectors @param response @param pipeline
[ "Process", "the", "response", "by", "reporting", "proper", "log", "and", "feeding", "failure", "detectors" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/routed/action/PerformParallelPutRequests.java#L381-L450
160,871
voldemort/voldemort
src/java/voldemort/store/routed/action/PerformParallelPutRequests.java
PerformParallelPutRequests.isZonesSatisfied
private boolean isZonesSatisfied() { boolean zonesSatisfied = false; if(pipelineData.getZonesRequired() == null) { zonesSatisfied = true; } else { int numZonesSatisfied = pipelineData.getZoneResponses().size(); if(numZonesSatisfied >= (pipelineData.getZonesRequired() + 1)) { zonesSatisfied = true; } } return zonesSatisfied; }
java
private boolean isZonesSatisfied() { boolean zonesSatisfied = false; if(pipelineData.getZonesRequired() == null) { zonesSatisfied = true; } else { int numZonesSatisfied = pipelineData.getZoneResponses().size(); if(numZonesSatisfied >= (pipelineData.getZonesRequired() + 1)) { zonesSatisfied = true; } } return zonesSatisfied; }
[ "private", "boolean", "isZonesSatisfied", "(", ")", "{", "boolean", "zonesSatisfied", "=", "false", ";", "if", "(", "pipelineData", ".", "getZonesRequired", "(", ")", "==", "null", ")", "{", "zonesSatisfied", "=", "true", ";", "}", "else", "{", "int", "numZonesSatisfied", "=", "pipelineData", ".", "getZoneResponses", "(", ")", ".", "size", "(", ")", ";", "if", "(", "numZonesSatisfied", ">=", "(", "pipelineData", ".", "getZonesRequired", "(", ")", "+", "1", ")", ")", "{", "zonesSatisfied", "=", "true", ";", "}", "}", "return", "zonesSatisfied", ";", "}" ]
Check if zone count policy is satisfied @return whether zone is satisfied
[ "Check", "if", "zone", "count", "policy", "is", "satisfied" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/routed/action/PerformParallelPutRequests.java#L466-L477
160,872
voldemort/voldemort
src/java/voldemort/client/ClientConfig.java
ClientConfig.setIdleConnectionTimeout
public ClientConfig setIdleConnectionTimeout(long idleConnectionTimeout, TimeUnit unit) { if (idleConnectionTimeout <= 0) { this.idleConnectionTimeoutMs = -1; } else { if(unit.toMinutes(idleConnectionTimeout) < 10) { throw new IllegalArgumentException("idleConnectionTimeout should be minimum of 10 minutes"); } this.idleConnectionTimeoutMs = unit.toMillis(idleConnectionTimeout); } return this; }
java
public ClientConfig setIdleConnectionTimeout(long idleConnectionTimeout, TimeUnit unit) { if (idleConnectionTimeout <= 0) { this.idleConnectionTimeoutMs = -1; } else { if(unit.toMinutes(idleConnectionTimeout) < 10) { throw new IllegalArgumentException("idleConnectionTimeout should be minimum of 10 minutes"); } this.idleConnectionTimeoutMs = unit.toMillis(idleConnectionTimeout); } return this; }
[ "public", "ClientConfig", "setIdleConnectionTimeout", "(", "long", "idleConnectionTimeout", ",", "TimeUnit", "unit", ")", "{", "if", "(", "idleConnectionTimeout", "<=", "0", ")", "{", "this", ".", "idleConnectionTimeoutMs", "=", "-", "1", ";", "}", "else", "{", "if", "(", "unit", ".", "toMinutes", "(", "idleConnectionTimeout", ")", "<", "10", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"idleConnectionTimeout should be minimum of 10 minutes\"", ")", ";", "}", "this", ".", "idleConnectionTimeoutMs", "=", "unit", ".", "toMillis", "(", "idleConnectionTimeout", ")", ";", "}", "return", "this", ";", "}" ]
Set the timeout for idle connections. Voldemort client caches all connections to the Voldemort server. This setting allows the a connection to be dropped, if it is idle for more than this time. This could be useful in the following cases 1) Voldemort client is not directly connected to the server and is connected via a proxy or firewall. The Proxy or firewall could drop the connection silently. If the connection is dropped, then client will see operations fail with a timeout. Setting this property enables the Voldemort client to tear down the connection before a firewall could drop it. 2) Voldemort server caches the connection and each connection has an associated memory cost. Setting this property on all clients, enable the clients to prune the connections and there by freeing up the server connections. throws IllegalArgumentException if the timeout is less than 10 minutes. Currently it can't be set below 10 minutes to avoid the racing risk of contention between connection checkout and selector trying to close it. This is intended for low throughput scenarios. @param idleConnectionTimeout zero or negative number to disable the feature ( default -1) timeout @param unit {@link TimeUnit} @return ClientConfig object for chained set throws {@link IllegalArgumentException} if the timeout is greater than 0, but less than 10 minutes.
[ "Set", "the", "timeout", "for", "idle", "connections", ".", "Voldemort", "client", "caches", "all", "connections", "to", "the", "Voldemort", "server", ".", "This", "setting", "allows", "the", "a", "connection", "to", "be", "dropped", "if", "it", "is", "idle", "for", "more", "than", "this", "time", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/client/ClientConfig.java#L617-L627
160,873
voldemort/voldemort
src/java/voldemort/client/ClientConfig.java
ClientConfig.setNodeBannagePeriod
@Deprecated public ClientConfig setNodeBannagePeriod(int nodeBannagePeriod, TimeUnit unit) { this.failureDetectorBannagePeriod = unit.toMillis(nodeBannagePeriod); return this; }
java
@Deprecated public ClientConfig setNodeBannagePeriod(int nodeBannagePeriod, TimeUnit unit) { this.failureDetectorBannagePeriod = unit.toMillis(nodeBannagePeriod); return this; }
[ "@", "Deprecated", "public", "ClientConfig", "setNodeBannagePeriod", "(", "int", "nodeBannagePeriod", ",", "TimeUnit", "unit", ")", "{", "this", ".", "failureDetectorBannagePeriod", "=", "unit", ".", "toMillis", "(", "nodeBannagePeriod", ")", ";", "return", "this", ";", "}" ]
The period of time to ban a node that gives an error on an operation. @param nodeBannagePeriod The period of time to ban the node @param unit The time unit of the given value @deprecated Use {@link #setFailureDetectorBannagePeriod(long)} instead
[ "The", "period", "of", "time", "to", "ban", "a", "node", "that", "gives", "an", "error", "on", "an", "operation", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/client/ClientConfig.java#L721-L725
160,874
voldemort/voldemort
src/java/voldemort/client/ClientConfig.java
ClientConfig.setThreadIdleTime
@Deprecated public ClientConfig setThreadIdleTime(long threadIdleTime, TimeUnit unit) { this.threadIdleMs = unit.toMillis(threadIdleTime); return this; }
java
@Deprecated public ClientConfig setThreadIdleTime(long threadIdleTime, TimeUnit unit) { this.threadIdleMs = unit.toMillis(threadIdleTime); return this; }
[ "@", "Deprecated", "public", "ClientConfig", "setThreadIdleTime", "(", "long", "threadIdleTime", ",", "TimeUnit", "unit", ")", "{", "this", ".", "threadIdleMs", "=", "unit", ".", "toMillis", "(", "threadIdleTime", ")", ";", "return", "this", ";", "}" ]
The amount of time to keep an idle client thread alive @param threadIdleTime
[ "The", "amount", "of", "time", "to", "keep", "an", "idle", "client", "thread", "alive" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/client/ClientConfig.java#L862-L866
160,875
voldemort/voldemort
src/java/voldemort/store/socket/clientrequest/ClientRequestExecutorPool.java
ClientRequestExecutorPool.close
@Override public void close(SocketDestination destination) { factory.setLastClosedTimestamp(destination); queuedPool.reset(destination); }
java
@Override public void close(SocketDestination destination) { factory.setLastClosedTimestamp(destination); queuedPool.reset(destination); }
[ "@", "Override", "public", "void", "close", "(", "SocketDestination", "destination", ")", "{", "factory", ".", "setLastClosedTimestamp", "(", "destination", ")", ";", "queuedPool", ".", "reset", "(", "destination", ")", ";", "}" ]
Reset the pool of resources for a specific destination. Idle resources will be destroyed. Checked out resources that are subsequently checked in will be destroyed. Newly created resources can be checked in to reestablish resources for the specific destination.
[ "Reset", "the", "pool", "of", "resources", "for", "a", "specific", "destination", ".", "Idle", "resources", "will", "be", "destroyed", ".", "Checked", "out", "resources", "that", "are", "subsequently", "checked", "in", "will", "be", "destroyed", ".", "Newly", "created", "resources", "can", "be", "checked", "in", "to", "reestablish", "resources", "for", "the", "specific", "destination", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/socket/clientrequest/ClientRequestExecutorPool.java#L269-L273
160,876
voldemort/voldemort
src/java/voldemort/store/socket/clientrequest/ClientRequestExecutorPool.java
ClientRequestExecutorPool.close
@Override public void close() { // unregister MBeans if(stats != null) { try { if(this.jmxEnabled) JmxUtils.unregisterMbean(getAggregateMetricName()); } catch(Exception e) {} stats.close(); } factory.close(); queuedPool.close(); }
java
@Override public void close() { // unregister MBeans if(stats != null) { try { if(this.jmxEnabled) JmxUtils.unregisterMbean(getAggregateMetricName()); } catch(Exception e) {} stats.close(); } factory.close(); queuedPool.close(); }
[ "@", "Override", "public", "void", "close", "(", ")", "{", "// unregister MBeans", "if", "(", "stats", "!=", "null", ")", "{", "try", "{", "if", "(", "this", ".", "jmxEnabled", ")", "JmxUtils", ".", "unregisterMbean", "(", "getAggregateMetricName", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "stats", ".", "close", "(", ")", ";", "}", "factory", ".", "close", "(", ")", ";", "queuedPool", ".", "close", "(", ")", ";", "}" ]
Permanently close the ClientRequestExecutor pool. Resources subsequently checked in will be destroyed.
[ "Permanently", "close", "the", "ClientRequestExecutor", "pool", ".", "Resources", "subsequently", "checked", "in", "will", "be", "destroyed", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/socket/clientrequest/ClientRequestExecutorPool.java#L279-L291
160,877
voldemort/voldemort
contrib/hadoop-store-builder/src/java/voldemort/store/readonly/mr/HadoopStoreBuilderUtils.java
HadoopStoreBuilderUtils.readFileContents
public static String readFileContents(FileSystem fs, Path path, int bufferSize) throws IOException { if(bufferSize <= 0) return new String(); FSDataInputStream input = fs.open(path); byte[] buffer = new byte[bufferSize]; ByteArrayOutputStream stream = new ByteArrayOutputStream(); while(true) { int read = input.read(buffer); if(read < 0) { break; } else { buffer = ByteUtils.copy(buffer, 0, read); } stream.write(buffer); } return new String(stream.toByteArray()); }
java
public static String readFileContents(FileSystem fs, Path path, int bufferSize) throws IOException { if(bufferSize <= 0) return new String(); FSDataInputStream input = fs.open(path); byte[] buffer = new byte[bufferSize]; ByteArrayOutputStream stream = new ByteArrayOutputStream(); while(true) { int read = input.read(buffer); if(read < 0) { break; } else { buffer = ByteUtils.copy(buffer, 0, read); } stream.write(buffer); } return new String(stream.toByteArray()); }
[ "public", "static", "String", "readFileContents", "(", "FileSystem", "fs", ",", "Path", "path", ",", "int", "bufferSize", ")", "throws", "IOException", "{", "if", "(", "bufferSize", "<=", "0", ")", "return", "new", "String", "(", ")", ";", "FSDataInputStream", "input", "=", "fs", ".", "open", "(", "path", ")", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "bufferSize", "]", ";", "ByteArrayOutputStream", "stream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "while", "(", "true", ")", "{", "int", "read", "=", "input", ".", "read", "(", "buffer", ")", ";", "if", "(", "read", "<", "0", ")", "{", "break", ";", "}", "else", "{", "buffer", "=", "ByteUtils", ".", "copy", "(", "buffer", ",", "0", ",", "read", ")", ";", "}", "stream", ".", "write", "(", "buffer", ")", ";", "}", "return", "new", "String", "(", "stream", ".", "toByteArray", "(", ")", ")", ";", "}" ]
Given a filesystem, path and buffer-size, read the file contents and presents it as a string @param fs Underlying filesystem @param path The file to read @param bufferSize The buffer size to use for reading @return The contents of the file as a string @throws IOException
[ "Given", "a", "filesystem", "path", "and", "buffer", "-", "size", "read", "the", "file", "contents", "and", "presents", "it", "as", "a", "string" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/contrib/hadoop-store-builder/src/java/voldemort/store/readonly/mr/HadoopStoreBuilderUtils.java#L52-L73
160,878
voldemort/voldemort
contrib/hadoop-store-builder/src/java/voldemort/store/readonly/mr/HadoopStoreBuilderUtils.java
HadoopStoreBuilderUtils.getDataChunkFiles
public static FileStatus[] getDataChunkFiles(FileSystem fs, Path path, final int partitionId, final int replicaType) throws IOException { return fs.listStatus(path, new PathFilter() { public boolean accept(Path input) { if(input.getName().matches("^" + Integer.toString(partitionId) + "_" + Integer.toString(replicaType) + "_[\\d]+\\.data")) { return true; } else { return false; } } }); }
java
public static FileStatus[] getDataChunkFiles(FileSystem fs, Path path, final int partitionId, final int replicaType) throws IOException { return fs.listStatus(path, new PathFilter() { public boolean accept(Path input) { if(input.getName().matches("^" + Integer.toString(partitionId) + "_" + Integer.toString(replicaType) + "_[\\d]+\\.data")) { return true; } else { return false; } } }); }
[ "public", "static", "FileStatus", "[", "]", "getDataChunkFiles", "(", "FileSystem", "fs", ",", "Path", "path", ",", "final", "int", "partitionId", ",", "final", "int", "replicaType", ")", "throws", "IOException", "{", "return", "fs", ".", "listStatus", "(", "path", ",", "new", "PathFilter", "(", ")", "{", "public", "boolean", "accept", "(", "Path", "input", ")", "{", "if", "(", "input", ".", "getName", "(", ")", ".", "matches", "(", "\"^\"", "+", "Integer", ".", "toString", "(", "partitionId", ")", "+", "\"_\"", "+", "Integer", ".", "toString", "(", "replicaType", ")", "+", "\"_[\\\\d]+\\\\.data\"", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "}", ")", ";", "}" ]
Given a filesystem and path to a node, gets all the files which belong to a partition and replica type Works only for {@link ReadOnlyStorageFormat.READONLY_V2} @param fs Underlying filesystem @param path The node directory path @param partitionId The partition id for which we get the files @param replicaType The replica type @return Returns list of files of this partition, replicaType @throws IOException
[ "Given", "a", "filesystem", "and", "path", "to", "a", "node", "gets", "all", "the", "files", "which", "belong", "to", "a", "partition", "and", "replica", "type" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/contrib/hadoop-store-builder/src/java/voldemort/store/readonly/mr/HadoopStoreBuilderUtils.java#L88-L103
160,879
voldemort/voldemort
src/java/voldemort/store/routed/action/PerformSerialRequests.java
PerformSerialRequests.isSatisfied
private boolean isSatisfied() { if(pipelineData.getZonesRequired() != null) { return ((pipelineData.getSuccesses() >= required) && (pipelineData.getZoneResponses() .size() >= (pipelineData.getZonesRequired() + 1))); } else { return pipelineData.getSuccesses() >= required; } }
java
private boolean isSatisfied() { if(pipelineData.getZonesRequired() != null) { return ((pipelineData.getSuccesses() >= required) && (pipelineData.getZoneResponses() .size() >= (pipelineData.getZonesRequired() + 1))); } else { return pipelineData.getSuccesses() >= required; } }
[ "private", "boolean", "isSatisfied", "(", ")", "{", "if", "(", "pipelineData", ".", "getZonesRequired", "(", ")", "!=", "null", ")", "{", "return", "(", "(", "pipelineData", ".", "getSuccesses", "(", ")", ">=", "required", ")", "&&", "(", "pipelineData", ".", "getZoneResponses", "(", ")", ".", "size", "(", ")", ">=", "(", "pipelineData", ".", "getZonesRequired", "(", ")", "+", "1", ")", ")", ")", ";", "}", "else", "{", "return", "pipelineData", ".", "getSuccesses", "(", ")", ">=", "required", ";", "}", "}" ]
Checks whether every property except 'preferred' is satisfied @return
[ "Checks", "whether", "every", "property", "except", "preferred", "is", "satisfied" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/routed/action/PerformSerialRequests.java#L74-L81
160,880
voldemort/voldemort
src/java/voldemort/client/rebalance/RebalanceBatchPlan.java
RebalanceBatchPlan.getCrossZonePartitionStoreMoves
public int getCrossZonePartitionStoreMoves() { int xzonePartitionStoreMoves = 0; for (RebalanceTaskInfo info : batchPlan) { Node donorNode = finalCluster.getNodeById(info.getDonorId()); Node stealerNode = finalCluster.getNodeById(info.getStealerId()); if(donorNode.getZoneId() != stealerNode.getZoneId()) { xzonePartitionStoreMoves += info.getPartitionStoreMoves(); } } return xzonePartitionStoreMoves; }
java
public int getCrossZonePartitionStoreMoves() { int xzonePartitionStoreMoves = 0; for (RebalanceTaskInfo info : batchPlan) { Node donorNode = finalCluster.getNodeById(info.getDonorId()); Node stealerNode = finalCluster.getNodeById(info.getStealerId()); if(donorNode.getZoneId() != stealerNode.getZoneId()) { xzonePartitionStoreMoves += info.getPartitionStoreMoves(); } } return xzonePartitionStoreMoves; }
[ "public", "int", "getCrossZonePartitionStoreMoves", "(", ")", "{", "int", "xzonePartitionStoreMoves", "=", "0", ";", "for", "(", "RebalanceTaskInfo", "info", ":", "batchPlan", ")", "{", "Node", "donorNode", "=", "finalCluster", ".", "getNodeById", "(", "info", ".", "getDonorId", "(", ")", ")", ";", "Node", "stealerNode", "=", "finalCluster", ".", "getNodeById", "(", "info", ".", "getStealerId", "(", ")", ")", ";", "if", "(", "donorNode", ".", "getZoneId", "(", ")", "!=", "stealerNode", ".", "getZoneId", "(", ")", ")", "{", "xzonePartitionStoreMoves", "+=", "info", ".", "getPartitionStoreMoves", "(", ")", ";", "}", "}", "return", "xzonePartitionStoreMoves", ";", "}" ]
Determines total number of partition-stores moved across zones. @return number of cross zone partition-store moves
[ "Determines", "total", "number", "of", "partition", "-", "stores", "moved", "across", "zones", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/client/rebalance/RebalanceBatchPlan.java#L150-L162
160,881
voldemort/voldemort
src/java/voldemort/client/rebalance/RebalanceBatchPlan.java
RebalanceBatchPlan.getDonorId
protected int getDonorId(StoreRoutingPlan currentSRP, StoreRoutingPlan finalSRP, int stealerZoneId, int stealerNodeId, int stealerPartitionId) { int stealerZoneNAry = finalSRP.getZoneNaryForNodesPartition(stealerZoneId, stealerNodeId, stealerPartitionId); int donorZoneId; if(currentSRP.zoneNAryExists(stealerZoneId, stealerZoneNAry, stealerPartitionId)) { // Steal from local n-ary (since one exists). donorZoneId = stealerZoneId; } else { // Steal from zone that hosts primary partition Id. int currentMasterNodeId = currentSRP.getNodeIdForPartitionId(stealerPartitionId); donorZoneId = currentCluster.getNodeById(currentMasterNodeId).getZoneId(); } return currentSRP.getNodeIdForZoneNary(donorZoneId, stealerZoneNAry, stealerPartitionId); }
java
protected int getDonorId(StoreRoutingPlan currentSRP, StoreRoutingPlan finalSRP, int stealerZoneId, int stealerNodeId, int stealerPartitionId) { int stealerZoneNAry = finalSRP.getZoneNaryForNodesPartition(stealerZoneId, stealerNodeId, stealerPartitionId); int donorZoneId; if(currentSRP.zoneNAryExists(stealerZoneId, stealerZoneNAry, stealerPartitionId)) { // Steal from local n-ary (since one exists). donorZoneId = stealerZoneId; } else { // Steal from zone that hosts primary partition Id. int currentMasterNodeId = currentSRP.getNodeIdForPartitionId(stealerPartitionId); donorZoneId = currentCluster.getNodeById(currentMasterNodeId).getZoneId(); } return currentSRP.getNodeIdForZoneNary(donorZoneId, stealerZoneNAry, stealerPartitionId); }
[ "protected", "int", "getDonorId", "(", "StoreRoutingPlan", "currentSRP", ",", "StoreRoutingPlan", "finalSRP", ",", "int", "stealerZoneId", ",", "int", "stealerNodeId", ",", "int", "stealerPartitionId", ")", "{", "int", "stealerZoneNAry", "=", "finalSRP", ".", "getZoneNaryForNodesPartition", "(", "stealerZoneId", ",", "stealerNodeId", ",", "stealerPartitionId", ")", ";", "int", "donorZoneId", ";", "if", "(", "currentSRP", ".", "zoneNAryExists", "(", "stealerZoneId", ",", "stealerZoneNAry", ",", "stealerPartitionId", ")", ")", "{", "// Steal from local n-ary (since one exists).", "donorZoneId", "=", "stealerZoneId", ";", "}", "else", "{", "// Steal from zone that hosts primary partition Id.", "int", "currentMasterNodeId", "=", "currentSRP", ".", "getNodeIdForPartitionId", "(", "stealerPartitionId", ")", ";", "donorZoneId", "=", "currentCluster", ".", "getNodeById", "(", "currentMasterNodeId", ")", ".", "getZoneId", "(", ")", ";", "}", "return", "currentSRP", ".", "getNodeIdForZoneNary", "(", "donorZoneId", ",", "stealerZoneNAry", ",", "stealerPartitionId", ")", ";", "}" ]
Decide which donor node to steal from. This is a policy implementation. I.e., in the future, additional policies could be considered. At that time, this method should be overridden in a sub-class, or a policy object ought to implement this algorithm. Current policy: 1) If possible, a stealer node that is the zone n-ary in the finalCluster steals from the zone n-ary in the currentCluster in the same zone. 2) If there are no partition-stores to steal in the same zone (i.e., this is the "zone expansion" use case), then a differnt policy must be used. The stealer node that is the zone n-ary in the finalCluster determines which pre-existing zone in the currentCluster hosts the primary partition id for the partition-store. The stealer then steals the zone n-ary from that pre-existing zone. This policy avoids unnecessary cross-zone moves and distributes the load of cross-zone moves approximately-uniformly across pre-existing zones. Other policies to consider: - For zone expansion, steal all partition-stores from one specific pre-existing zone. - Replace heuristic to approximately uniformly distribute load among existing zones to something more concrete (i.e. track steals from each pre-existing zone and forcibly balance them). - Select a single donor for all replicas in a new zone. This will require donor-based rebalancing to be run (at least for this specific part of the plan). This would reduce the number of donor-side scans of data. (But still send replication factor copies over the WAN.) This would require apparatus in the RebalanceController to work. - Set up some sort of chain-replication in which a single stealer in the new zone steals some replica from a pre-exising zone, and then other n-aries in the new zone steal from the single cross-zone stealer in the zone. This would require apparatus in the RebalanceController to work. @param currentSRP @param finalSRP @param stealerZoneId @param stealerNodeId @param stealerPartitionId @return the node id of the donor for this partition Id.
[ "Decide", "which", "donor", "node", "to", "steal", "from", ".", "This", "is", "a", "policy", "implementation", ".", "I", ".", "e", ".", "in", "the", "future", "additional", "policies", "could", "be", "considered", ".", "At", "that", "time", "this", "method", "should", "be", "overridden", "in", "a", "sub", "-", "class", "or", "a", "policy", "object", "ought", "to", "implement", "this", "algorithm", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/client/rebalance/RebalanceBatchPlan.java#L351-L372
160,882
voldemort/voldemort
src/java/voldemort/rest/RestErrorHandler.java
RestErrorHandler.handleExceptions
protected void handleExceptions(MessageEvent messageEvent, Exception exception) { logger.error("Unknown exception. Internal Server Error.", exception); writeErrorResponse(messageEvent, HttpResponseStatus.INTERNAL_SERVER_ERROR, "Internal Server Error"); }
java
protected void handleExceptions(MessageEvent messageEvent, Exception exception) { logger.error("Unknown exception. Internal Server Error.", exception); writeErrorResponse(messageEvent, HttpResponseStatus.INTERNAL_SERVER_ERROR, "Internal Server Error"); }
[ "protected", "void", "handleExceptions", "(", "MessageEvent", "messageEvent", ",", "Exception", "exception", ")", "{", "logger", ".", "error", "(", "\"Unknown exception. Internal Server Error.\"", ",", "exception", ")", ";", "writeErrorResponse", "(", "messageEvent", ",", "HttpResponseStatus", ".", "INTERNAL_SERVER_ERROR", ",", "\"Internal Server Error\"", ")", ";", "}" ]
Exceptions specific to each operation is handled in the corresponding subclass. At this point we don't know the reason behind this exception. @param exception
[ "Exceptions", "specific", "to", "each", "operation", "is", "handled", "in", "the", "corresponding", "subclass", ".", "At", "this", "point", "we", "don", "t", "know", "the", "reason", "behind", "this", "exception", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/RestErrorHandler.java#L25-L30
160,883
voldemort/voldemort
src/java/voldemort/rest/RestErrorHandler.java
RestErrorHandler.writeErrorResponse
public static void writeErrorResponse(MessageEvent messageEvent, HttpResponseStatus status, String message) { // Create the Response object HttpResponse response = new DefaultHttpResponse(HTTP_1_1, status); response.setHeader(CONTENT_TYPE, "text/plain; charset=UTF-8"); response.setContent(ChannelBuffers.copiedBuffer("Failure: " + status.toString() + ". " + message + "\r\n", CharsetUtil.UTF_8)); response.setHeader(CONTENT_LENGTH, response.getContent().readableBytes()); // Write the response to the Netty Channel messageEvent.getChannel().write(response); }
java
public static void writeErrorResponse(MessageEvent messageEvent, HttpResponseStatus status, String message) { // Create the Response object HttpResponse response = new DefaultHttpResponse(HTTP_1_1, status); response.setHeader(CONTENT_TYPE, "text/plain; charset=UTF-8"); response.setContent(ChannelBuffers.copiedBuffer("Failure: " + status.toString() + ". " + message + "\r\n", CharsetUtil.UTF_8)); response.setHeader(CONTENT_LENGTH, response.getContent().readableBytes()); // Write the response to the Netty Channel messageEvent.getChannel().write(response); }
[ "public", "static", "void", "writeErrorResponse", "(", "MessageEvent", "messageEvent", ",", "HttpResponseStatus", "status", ",", "String", "message", ")", "{", "// Create the Response object", "HttpResponse", "response", "=", "new", "DefaultHttpResponse", "(", "HTTP_1_1", ",", "status", ")", ";", "response", ".", "setHeader", "(", "CONTENT_TYPE", ",", "\"text/plain; charset=UTF-8\"", ")", ";", "response", ".", "setContent", "(", "ChannelBuffers", ".", "copiedBuffer", "(", "\"Failure: \"", "+", "status", ".", "toString", "(", ")", "+", "\". \"", "+", "message", "+", "\"\\r\\n\"", ",", "CharsetUtil", ".", "UTF_8", ")", ")", ";", "response", ".", "setHeader", "(", "CONTENT_LENGTH", ",", "response", ".", "getContent", "(", ")", ".", "readableBytes", "(", ")", ")", ";", "// Write the response to the Netty Channel", "messageEvent", ".", "getChannel", "(", ")", ".", "write", "(", "response", ")", ";", "}" ]
Writes all error responses to the client. TODO REST-Server 1. collect error stats @param messageEvent - for retrieving the channel details @param status - error code @param message - error message
[ "Writes", "all", "error", "responses", "to", "the", "client", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/RestErrorHandler.java#L41-L54
160,884
voldemort/voldemort
src/java/voldemort/rest/RestPutRequestValidator.java
RestPutRequestValidator.parseAndValidateRequest
@Override public boolean parseAndValidateRequest() { boolean result = false; if(!super.parseAndValidateRequest() || !hasVectorClock(this.isVectorClockOptional) || !hasContentLength() || !hasContentType()) { result = false; } else { result = true; } return result; }
java
@Override public boolean parseAndValidateRequest() { boolean result = false; if(!super.parseAndValidateRequest() || !hasVectorClock(this.isVectorClockOptional) || !hasContentLength() || !hasContentType()) { result = false; } else { result = true; } return result; }
[ "@", "Override", "public", "boolean", "parseAndValidateRequest", "(", ")", "{", "boolean", "result", "=", "false", ";", "if", "(", "!", "super", ".", "parseAndValidateRequest", "(", ")", "||", "!", "hasVectorClock", "(", "this", ".", "isVectorClockOptional", ")", "||", "!", "hasContentLength", "(", ")", "||", "!", "hasContentType", "(", ")", ")", "{", "result", "=", "false", ";", "}", "else", "{", "result", "=", "true", ";", "}", "return", "result", ";", "}" ]
Validations specific to PUT
[ "Validations", "specific", "to", "PUT" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/RestPutRequestValidator.java#L78-L89
160,885
voldemort/voldemort
src/java/voldemort/rest/RestPutRequestValidator.java
RestPutRequestValidator.hasContentLength
protected boolean hasContentLength() { boolean result = false; String contentLength = this.request.getHeader(RestMessageHeaders.CONTENT_LENGTH); if(contentLength != null) { try { Long.parseLong(contentLength); result = true; } catch(NumberFormatException nfe) { logger.error("Exception when validating put request. Incorrect content length parameter. Cannot parse this to long: " + contentLength + ". Details: " + nfe.getMessage(), nfe); RestErrorHandler.writeErrorResponse(this.messageEvent, HttpResponseStatus.BAD_REQUEST, "Incorrect content length parameter. Cannot parse this to long: " + contentLength + ". Details: " + nfe.getMessage()); } } else { logger.error("Error when validating put request. Missing Content-Length header."); RestErrorHandler.writeErrorResponse(this.messageEvent, HttpResponseStatus.BAD_REQUEST, "Missing Content-Length header"); } return result; }
java
protected boolean hasContentLength() { boolean result = false; String contentLength = this.request.getHeader(RestMessageHeaders.CONTENT_LENGTH); if(contentLength != null) { try { Long.parseLong(contentLength); result = true; } catch(NumberFormatException nfe) { logger.error("Exception when validating put request. Incorrect content length parameter. Cannot parse this to long: " + contentLength + ". Details: " + nfe.getMessage(), nfe); RestErrorHandler.writeErrorResponse(this.messageEvent, HttpResponseStatus.BAD_REQUEST, "Incorrect content length parameter. Cannot parse this to long: " + contentLength + ". Details: " + nfe.getMessage()); } } else { logger.error("Error when validating put request. Missing Content-Length header."); RestErrorHandler.writeErrorResponse(this.messageEvent, HttpResponseStatus.BAD_REQUEST, "Missing Content-Length header"); } return result; }
[ "protected", "boolean", "hasContentLength", "(", ")", "{", "boolean", "result", "=", "false", ";", "String", "contentLength", "=", "this", ".", "request", ".", "getHeader", "(", "RestMessageHeaders", ".", "CONTENT_LENGTH", ")", ";", "if", "(", "contentLength", "!=", "null", ")", "{", "try", "{", "Long", ".", "parseLong", "(", "contentLength", ")", ";", "result", "=", "true", ";", "}", "catch", "(", "NumberFormatException", "nfe", ")", "{", "logger", ".", "error", "(", "\"Exception when validating put request. Incorrect content length parameter. Cannot parse this to long: \"", "+", "contentLength", "+", "\". Details: \"", "+", "nfe", ".", "getMessage", "(", ")", ",", "nfe", ")", ";", "RestErrorHandler", ".", "writeErrorResponse", "(", "this", ".", "messageEvent", ",", "HttpResponseStatus", ".", "BAD_REQUEST", ",", "\"Incorrect content length parameter. Cannot parse this to long: \"", "+", "contentLength", "+", "\". Details: \"", "+", "nfe", ".", "getMessage", "(", ")", ")", ";", "}", "}", "else", "{", "logger", ".", "error", "(", "\"Error when validating put request. Missing Content-Length header.\"", ")", ";", "RestErrorHandler", ".", "writeErrorResponse", "(", "this", ".", "messageEvent", ",", "HttpResponseStatus", ".", "BAD_REQUEST", ",", "\"Missing Content-Length header\"", ")", ";", "}", "return", "result", ";", "}" ]
Retrieves and validates the content length from the REST request. @return true if has content length
[ "Retrieves", "and", "validates", "the", "content", "length", "from", "the", "REST", "request", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/RestPutRequestValidator.java#L96-L121
160,886
voldemort/voldemort
src/java/voldemort/rest/RestPutRequestValidator.java
RestPutRequestValidator.hasContentType
protected boolean hasContentType() { boolean result = false; if(this.request.getHeader(RestMessageHeaders.CONTENT_TYPE) != null) { result = true; } else { logger.error("Error when validating put request. Missing Content-Type header."); RestErrorHandler.writeErrorResponse(this.messageEvent, HttpResponseStatus.BAD_REQUEST, "Missing Content-Type header"); } return result; }
java
protected boolean hasContentType() { boolean result = false; if(this.request.getHeader(RestMessageHeaders.CONTENT_TYPE) != null) { result = true; } else { logger.error("Error when validating put request. Missing Content-Type header."); RestErrorHandler.writeErrorResponse(this.messageEvent, HttpResponseStatus.BAD_REQUEST, "Missing Content-Type header"); } return result; }
[ "protected", "boolean", "hasContentType", "(", ")", "{", "boolean", "result", "=", "false", ";", "if", "(", "this", ".", "request", ".", "getHeader", "(", "RestMessageHeaders", ".", "CONTENT_TYPE", ")", "!=", "null", ")", "{", "result", "=", "true", ";", "}", "else", "{", "logger", ".", "error", "(", "\"Error when validating put request. Missing Content-Type header.\"", ")", ";", "RestErrorHandler", ".", "writeErrorResponse", "(", "this", ".", "messageEvent", ",", "HttpResponseStatus", ".", "BAD_REQUEST", ",", "\"Missing Content-Type header\"", ")", ";", "}", "return", "result", ";", "}" ]
Retrieves and validates the content type from the REST requests @return true if has content type.
[ "Retrieves", "and", "validates", "the", "content", "type", "from", "the", "REST", "requests" ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/RestPutRequestValidator.java#L128-L140
160,887
voldemort/voldemort
src/java/voldemort/rest/RestPutRequestValidator.java
RestPutRequestValidator.parseValue
private void parseValue() { ChannelBuffer content = this.request.getContent(); this.parsedValue = new byte[content.capacity()]; content.readBytes(parsedValue); }
java
private void parseValue() { ChannelBuffer content = this.request.getContent(); this.parsedValue = new byte[content.capacity()]; content.readBytes(parsedValue); }
[ "private", "void", "parseValue", "(", ")", "{", "ChannelBuffer", "content", "=", "this", ".", "request", ".", "getContent", "(", ")", ";", "this", ".", "parsedValue", "=", "new", "byte", "[", "content", ".", "capacity", "(", ")", "]", ";", "content", ".", "readBytes", "(", "parsedValue", ")", ";", "}" ]
Retrieve the value from the REST request body. TODO: REST-Server value cannot be null ( null/empty string ?)
[ "Retrieve", "the", "value", "from", "the", "REST", "request", "body", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/RestPutRequestValidator.java#L147-L151
160,888
voldemort/voldemort
contrib/hadoop-store-builder/src/java/voldemort/store/readonly/swapper/HdfsFailedFetchLock.java
HdfsFailedFetchLock.handleIOException
private void handleIOException(IOException e, String action, int attempt) throws VoldemortException, InterruptedException { if ( // any of the following happens, we need to bubble up // FileSystem instance got closed, somehow e.getMessage().contains("Filesystem closed") || // HDFS permission issues ExceptionUtils.recursiveClassEquals(e, AccessControlException.class)) { throw new VoldemortException("Got an IOException we cannot recover from while trying to " + action + ". Attempt # " + attempt + "/" + maxAttempts + ". Will not try again.", e); } else { logFailureAndWait(action, IO_EXCEPTION, attempt, e); } }
java
private void handleIOException(IOException e, String action, int attempt) throws VoldemortException, InterruptedException { if ( // any of the following happens, we need to bubble up // FileSystem instance got closed, somehow e.getMessage().contains("Filesystem closed") || // HDFS permission issues ExceptionUtils.recursiveClassEquals(e, AccessControlException.class)) { throw new VoldemortException("Got an IOException we cannot recover from while trying to " + action + ". Attempt # " + attempt + "/" + maxAttempts + ". Will not try again.", e); } else { logFailureAndWait(action, IO_EXCEPTION, attempt, e); } }
[ "private", "void", "handleIOException", "(", "IOException", "e", ",", "String", "action", ",", "int", "attempt", ")", "throws", "VoldemortException", ",", "InterruptedException", "{", "if", "(", "// any of the following happens, we need to bubble up", "// FileSystem instance got closed, somehow", "e", ".", "getMessage", "(", ")", ".", "contains", "(", "\"Filesystem closed\"", ")", "||", "// HDFS permission issues", "ExceptionUtils", ".", "recursiveClassEquals", "(", "e", ",", "AccessControlException", ".", "class", ")", ")", "{", "throw", "new", "VoldemortException", "(", "\"Got an IOException we cannot recover from while trying to \"", "+", "action", "+", "\". Attempt # \"", "+", "attempt", "+", "\"/\"", "+", "maxAttempts", "+", "\". Will not try again.\"", ",", "e", ")", ";", "}", "else", "{", "logFailureAndWait", "(", "action", ",", "IO_EXCEPTION", ",", "attempt", ",", "e", ")", ";", "}", "}" ]
This function is intended to detect the subset of IOException which are not considered recoverable, in which case we want to bubble up the exception, instead of retrying. @throws VoldemortException
[ "This", "function", "is", "intended", "to", "detect", "the", "subset", "of", "IOException", "which", "are", "not", "considered", "recoverable", "in", "which", "case", "we", "want", "to", "bubble", "up", "the", "exception", "instead", "of", "retrying", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/contrib/hadoop-store-builder/src/java/voldemort/store/readonly/swapper/HdfsFailedFetchLock.java#L186-L198
160,889
voldemort/voldemort
src/java/voldemort/cluster/failuredetector/AbstractFailureDetector.java
AbstractFailureDetector.setAvailable
private boolean setAvailable(NodeStatus nodeStatus, boolean isAvailable) { synchronized(nodeStatus) { boolean previous = nodeStatus.isAvailable(); nodeStatus.setAvailable(isAvailable); nodeStatus.setLastChecked(getConfig().getTime().getMilliseconds()); return previous; } }
java
private boolean setAvailable(NodeStatus nodeStatus, boolean isAvailable) { synchronized(nodeStatus) { boolean previous = nodeStatus.isAvailable(); nodeStatus.setAvailable(isAvailable); nodeStatus.setLastChecked(getConfig().getTime().getMilliseconds()); return previous; } }
[ "private", "boolean", "setAvailable", "(", "NodeStatus", "nodeStatus", ",", "boolean", "isAvailable", ")", "{", "synchronized", "(", "nodeStatus", ")", "{", "boolean", "previous", "=", "nodeStatus", ".", "isAvailable", "(", ")", ";", "nodeStatus", ".", "setAvailable", "(", "isAvailable", ")", ";", "nodeStatus", ".", "setLastChecked", "(", "getConfig", "(", ")", ".", "getTime", "(", ")", ".", "getMilliseconds", "(", ")", ")", ";", "return", "previous", ";", "}", "}" ]
We need to distinguish the case where we're newly available and the case where we're already available. So we check the node status before we update it and return it to the caller. @param isAvailable True to set to available, false to make unavailable @return Previous value of isAvailable
[ "We", "need", "to", "distinguish", "the", "case", "where", "we", "re", "newly", "available", "and", "the", "case", "where", "we", "re", "already", "available", ".", "So", "we", "check", "the", "node", "status", "before", "we", "update", "it", "and", "return", "it", "to", "the", "caller", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/cluster/failuredetector/AbstractFailureDetector.java#L273-L282
160,890
voldemort/voldemort
src/java/voldemort/tools/admin/AdminParserUtils.java
AdminParserUtils.acceptsDir
public static void acceptsDir(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_D, OPT_DIR), "directory path for input/output") .withRequiredArg() .describedAs("dir-path") .ofType(String.class); }
java
public static void acceptsDir(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_D, OPT_DIR), "directory path for input/output") .withRequiredArg() .describedAs("dir-path") .ofType(String.class); }
[ "public", "static", "void", "acceptsDir", "(", "OptionParser", "parser", ")", "{", "parser", ".", "acceptsAll", "(", "Arrays", ".", "asList", "(", "OPT_D", ",", "OPT_DIR", ")", ",", "\"directory path for input/output\"", ")", ".", "withRequiredArg", "(", ")", ".", "describedAs", "(", "\"dir-path\"", ")", ".", "ofType", "(", "String", ".", "class", ")", ";", "}" ]
Adds OPT_D | OPT_DIR option to OptionParser, with one argument. @param parser OptionParser to be modified @param required Tells if this option is required or optional
[ "Adds", "OPT_D", "|", "OPT_DIR", "option", "to", "OptionParser", "with", "one", "argument", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/admin/AdminParserUtils.java#L148-L153
160,891
voldemort/voldemort
src/java/voldemort/tools/admin/AdminParserUtils.java
AdminParserUtils.acceptsFile
public static void acceptsFile(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_F, OPT_FILE), "file path for input/output") .withRequiredArg() .describedAs("file-path") .ofType(String.class); }
java
public static void acceptsFile(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_F, OPT_FILE), "file path for input/output") .withRequiredArg() .describedAs("file-path") .ofType(String.class); }
[ "public", "static", "void", "acceptsFile", "(", "OptionParser", "parser", ")", "{", "parser", ".", "acceptsAll", "(", "Arrays", ".", "asList", "(", "OPT_F", ",", "OPT_FILE", ")", ",", "\"file path for input/output\"", ")", ".", "withRequiredArg", "(", ")", ".", "describedAs", "(", "\"file-path\"", ")", ".", "ofType", "(", "String", ".", "class", ")", ";", "}" ]
Adds OPT_F | OPT_FILE option to OptionParser, with one argument. @param parser OptionParser to be modified @param required Tells if this option is required or optional
[ "Adds", "OPT_F", "|", "OPT_FILE", "option", "to", "OptionParser", "with", "one", "argument", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/admin/AdminParserUtils.java#L161-L166
160,892
voldemort/voldemort
src/java/voldemort/tools/admin/AdminParserUtils.java
AdminParserUtils.acceptsFormat
public static void acceptsFormat(OptionParser parser) { parser.accepts(OPT_FORMAT, "format of key or entry, could be hex, json or binary") .withRequiredArg() .describedAs("hex | json | binary") .ofType(String.class); }
java
public static void acceptsFormat(OptionParser parser) { parser.accepts(OPT_FORMAT, "format of key or entry, could be hex, json or binary") .withRequiredArg() .describedAs("hex | json | binary") .ofType(String.class); }
[ "public", "static", "void", "acceptsFormat", "(", "OptionParser", "parser", ")", "{", "parser", ".", "accepts", "(", "OPT_FORMAT", ",", "\"format of key or entry, could be hex, json or binary\"", ")", ".", "withRequiredArg", "(", ")", ".", "describedAs", "(", "\"hex | json | binary\"", ")", ".", "ofType", "(", "String", ".", "class", ")", ";", "}" ]
Adds OPT_FORMAT option to OptionParser, with one argument. @param parser OptionParser to be modified @param required Tells if this option is required or optional
[ "Adds", "OPT_FORMAT", "option", "to", "OptionParser", "with", "one", "argument", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/admin/AdminParserUtils.java#L174-L179
160,893
voldemort/voldemort
src/java/voldemort/tools/admin/AdminParserUtils.java
AdminParserUtils.acceptsNodeSingle
public static void acceptsNodeSingle(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_N, OPT_NODE), "node id") .withRequiredArg() .describedAs("node-id") .ofType(Integer.class); }
java
public static void acceptsNodeSingle(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_N, OPT_NODE), "node id") .withRequiredArg() .describedAs("node-id") .ofType(Integer.class); }
[ "public", "static", "void", "acceptsNodeSingle", "(", "OptionParser", "parser", ")", "{", "parser", ".", "acceptsAll", "(", "Arrays", ".", "asList", "(", "OPT_N", ",", "OPT_NODE", ")", ",", "\"node id\"", ")", ".", "withRequiredArg", "(", ")", ".", "describedAs", "(", "\"node-id\"", ")", ".", "ofType", "(", "Integer", ".", "class", ")", ";", "}" ]
Adds OPT_N | OPT_NODE option to OptionParser, with one argument. @param parser OptionParser to be modified @param required Tells if this option is required or optional
[ "Adds", "OPT_N", "|", "OPT_NODE", "option", "to", "OptionParser", "with", "one", "argument", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/admin/AdminParserUtils.java#L187-L192
160,894
voldemort/voldemort
src/java/voldemort/tools/admin/AdminParserUtils.java
AdminParserUtils.acceptsUrl
public static void acceptsUrl(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_U, OPT_URL), "bootstrap url") .withRequiredArg() .describedAs("url") .ofType(String.class); }
java
public static void acceptsUrl(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_U, OPT_URL), "bootstrap url") .withRequiredArg() .describedAs("url") .ofType(String.class); }
[ "public", "static", "void", "acceptsUrl", "(", "OptionParser", "parser", ")", "{", "parser", ".", "acceptsAll", "(", "Arrays", ".", "asList", "(", "OPT_U", ",", "OPT_URL", ")", ",", "\"bootstrap url\"", ")", ".", "withRequiredArg", "(", ")", ".", "describedAs", "(", "\"url\"", ")", ".", "ofType", "(", "String", ".", "class", ")", ";", "}" ]
Adds OPT_U | OPT_URL option to OptionParser, with one argument. @param parser OptionParser to be modified @param required Tells if this option is required or optional
[ "Adds", "OPT_U", "|", "OPT_URL", "option", "to", "OptionParser", "with", "one", "argument", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/admin/AdminParserUtils.java#L213-L218
160,895
voldemort/voldemort
src/java/voldemort/tools/admin/AdminParserUtils.java
AdminParserUtils.acceptsZone
public static void acceptsZone(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_Z, OPT_ZONE), "zone id") .withRequiredArg() .describedAs("zone-id") .ofType(Integer.class); }
java
public static void acceptsZone(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_Z, OPT_ZONE), "zone id") .withRequiredArg() .describedAs("zone-id") .ofType(Integer.class); }
[ "public", "static", "void", "acceptsZone", "(", "OptionParser", "parser", ")", "{", "parser", ".", "acceptsAll", "(", "Arrays", ".", "asList", "(", "OPT_Z", ",", "OPT_ZONE", ")", ",", "\"zone id\"", ")", ".", "withRequiredArg", "(", ")", ".", "describedAs", "(", "\"zone-id\"", ")", ".", "ofType", "(", "Integer", ".", "class", ")", ";", "}" ]
Adds OPT_Z | OPT_ZONE option to OptionParser, with one argument. @param parser OptionParser to be modified @param required Tells if this option is required or optional
[ "Adds", "OPT_Z", "|", "OPT_ZONE", "option", "to", "OptionParser", "with", "one", "argument", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/admin/AdminParserUtils.java#L226-L231
160,896
voldemort/voldemort
src/java/voldemort/tools/admin/AdminParserUtils.java
AdminParserUtils.acceptsHex
public static void acceptsHex(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_X, OPT_HEX), "fetch key/entry by key value of hex type") .withRequiredArg() .describedAs("key-list") .withValuesSeparatedBy(',') .ofType(String.class); }
java
public static void acceptsHex(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_X, OPT_HEX), "fetch key/entry by key value of hex type") .withRequiredArg() .describedAs("key-list") .withValuesSeparatedBy(',') .ofType(String.class); }
[ "public", "static", "void", "acceptsHex", "(", "OptionParser", "parser", ")", "{", "parser", ".", "acceptsAll", "(", "Arrays", ".", "asList", "(", "OPT_X", ",", "OPT_HEX", ")", ",", "\"fetch key/entry by key value of hex type\"", ")", ".", "withRequiredArg", "(", ")", ".", "describedAs", "(", "\"key-list\"", ")", ".", "withValuesSeparatedBy", "(", "'", "'", ")", ".", "ofType", "(", "String", ".", "class", ")", ";", "}" ]
Adds OPT_X | OPT_HEX option to OptionParser, with multiple arguments. @param parser OptionParser to be modified @param required Tells if this option is required or optional
[ "Adds", "OPT_X", "|", "OPT_HEX", "option", "to", "OptionParser", "with", "multiple", "arguments", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/admin/AdminParserUtils.java#L239-L245
160,897
voldemort/voldemort
src/java/voldemort/tools/admin/AdminParserUtils.java
AdminParserUtils.acceptsJson
public static void acceptsJson(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_J, OPT_JSON), "fetch key/entry by key value of json type") .withRequiredArg() .describedAs("key-list") .withValuesSeparatedBy(',') .ofType(String.class); }
java
public static void acceptsJson(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_J, OPT_JSON), "fetch key/entry by key value of json type") .withRequiredArg() .describedAs("key-list") .withValuesSeparatedBy(',') .ofType(String.class); }
[ "public", "static", "void", "acceptsJson", "(", "OptionParser", "parser", ")", "{", "parser", ".", "acceptsAll", "(", "Arrays", ".", "asList", "(", "OPT_J", ",", "OPT_JSON", ")", ",", "\"fetch key/entry by key value of json type\"", ")", ".", "withRequiredArg", "(", ")", ".", "describedAs", "(", "\"key-list\"", ")", ".", "withValuesSeparatedBy", "(", "'", "'", ")", ".", "ofType", "(", "String", ".", "class", ")", ";", "}" ]
Adds OPT_J | OPT_JSON option to OptionParser, with multiple arguments. @param parser OptionParser to be modified @param required Tells if this option is required or optional
[ "Adds", "OPT_J", "|", "OPT_JSON", "option", "to", "OptionParser", "with", "multiple", "arguments", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/admin/AdminParserUtils.java#L253-L260
160,898
voldemort/voldemort
src/java/voldemort/tools/admin/AdminParserUtils.java
AdminParserUtils.acceptsNodeMultiple
public static void acceptsNodeMultiple(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_N, OPT_NODE), "node id list") .withRequiredArg() .describedAs("node-id-list") .withValuesSeparatedBy(',') .ofType(Integer.class); }
java
public static void acceptsNodeMultiple(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_N, OPT_NODE), "node id list") .withRequiredArg() .describedAs("node-id-list") .withValuesSeparatedBy(',') .ofType(Integer.class); }
[ "public", "static", "void", "acceptsNodeMultiple", "(", "OptionParser", "parser", ")", "{", "parser", ".", "acceptsAll", "(", "Arrays", ".", "asList", "(", "OPT_N", ",", "OPT_NODE", ")", ",", "\"node id list\"", ")", ".", "withRequiredArg", "(", ")", ".", "describedAs", "(", "\"node-id-list\"", ")", ".", "withValuesSeparatedBy", "(", "'", "'", ")", ".", "ofType", "(", "Integer", ".", "class", ")", ";", "}" ]
Adds OPT_N | OPT_NODE option to OptionParser, with multiple arguments. @param parser OptionParser to be modified @param required Tells if this option is required or optional
[ "Adds", "OPT_N", "|", "OPT_NODE", "option", "to", "OptionParser", "with", "multiple", "arguments", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/admin/AdminParserUtils.java#L268-L274
160,899
voldemort/voldemort
src/java/voldemort/tools/admin/AdminParserUtils.java
AdminParserUtils.acceptsPartition
public static void acceptsPartition(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_P, OPT_PARTITION), "partition id list") .withRequiredArg() .describedAs("partition-id-list") .withValuesSeparatedBy(',') .ofType(Integer.class); }
java
public static void acceptsPartition(OptionParser parser) { parser.acceptsAll(Arrays.asList(OPT_P, OPT_PARTITION), "partition id list") .withRequiredArg() .describedAs("partition-id-list") .withValuesSeparatedBy(',') .ofType(Integer.class); }
[ "public", "static", "void", "acceptsPartition", "(", "OptionParser", "parser", ")", "{", "parser", ".", "acceptsAll", "(", "Arrays", ".", "asList", "(", "OPT_P", ",", "OPT_PARTITION", ")", ",", "\"partition id list\"", ")", ".", "withRequiredArg", "(", ")", ".", "describedAs", "(", "\"partition-id-list\"", ")", ".", "withValuesSeparatedBy", "(", "'", "'", ")", ".", "ofType", "(", "Integer", ".", "class", ")", ";", "}" ]
Adds OPT_P | OPT_PARTITION option to OptionParser, with multiple arguments. @param parser OptionParser to be modified @param required Tells if this option is required or optional
[ "Adds", "OPT_P", "|", "OPT_PARTITION", "option", "to", "OptionParser", "with", "multiple", "arguments", "." ]
a7dbdea58032021361680faacf2782cf981c5332
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/admin/AdminParserUtils.java#L283-L289