id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
138,400
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java
TaskManagerService.checkTenantTasks
private void checkTenantTasks(Tenant tenant) { m_logger.debug("Checking tenant '{}' for needy tasks", tenant); try { for (ApplicationDefinition appDef : SchemaService.instance().getAllApplications(tenant)) { for (Task task : getAppTasks(appDef)) { checkTaskForExecution(appDef, task); } } } catch (Throwable e) { m_logger.warn("Could not check tasks for tenant '{}': {}", tenant.getName(), e); } }
java
private void checkTenantTasks(Tenant tenant) { m_logger.debug("Checking tenant '{}' for needy tasks", tenant); try { for (ApplicationDefinition appDef : SchemaService.instance().getAllApplications(tenant)) { for (Task task : getAppTasks(appDef)) { checkTaskForExecution(appDef, task); } } } catch (Throwable e) { m_logger.warn("Could not check tasks for tenant '{}': {}", tenant.getName(), e); } }
[ "private", "void", "checkTenantTasks", "(", "Tenant", "tenant", ")", "{", "m_logger", ".", "debug", "(", "\"Checking tenant '{}' for needy tasks\"", ",", "tenant", ")", ";", "try", "{", "for", "(", "ApplicationDefinition", "appDef", ":", "SchemaService", ".", "instance", "(", ")", ".", "getAllApplications", "(", "tenant", ")", ")", "{", "for", "(", "Task", "task", ":", "getAppTasks", "(", "appDef", ")", ")", "{", "checkTaskForExecution", "(", "appDef", ",", "task", ")", ";", "}", "}", "}", "catch", "(", "Throwable", "e", ")", "{", "m_logger", ".", "warn", "(", "\"Could not check tasks for tenant '{}': {}\"", ",", "tenant", ".", "getName", "(", ")", ",", "e", ")", ";", "}", "}" ]
Check the given tenant for tasks that need execution.
[ "Check", "the", "given", "tenant", "for", "tasks", "that", "need", "execution", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java#L329-L340
138,401
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java
TaskManagerService.checkTaskForExecution
private void checkTaskForExecution(ApplicationDefinition appDef, Task task) { Tenant tenant = Tenant.getTenant(appDef); m_logger.debug("Checking task '{}' in tenant '{}'", task.getTaskID(), tenant); synchronized (m_executeLock) { Iterator<DColumn> colIter = DBService.instance(tenant).getAllColumns(TaskManagerService.TASKS_STORE_NAME, task.getTaskID()).iterator(); TaskRecord taskRecord = null; if (!colIter.hasNext()) { taskRecord = storeTaskRecord(tenant, task); } else { taskRecord = buildTaskRecord(task.getTaskID(), colIter); } if (taskShouldExecute(task, taskRecord) && canHandleMoreTasks()) { attemptToExecuteTask(appDef, task, taskRecord); } } }
java
private void checkTaskForExecution(ApplicationDefinition appDef, Task task) { Tenant tenant = Tenant.getTenant(appDef); m_logger.debug("Checking task '{}' in tenant '{}'", task.getTaskID(), tenant); synchronized (m_executeLock) { Iterator<DColumn> colIter = DBService.instance(tenant).getAllColumns(TaskManagerService.TASKS_STORE_NAME, task.getTaskID()).iterator(); TaskRecord taskRecord = null; if (!colIter.hasNext()) { taskRecord = storeTaskRecord(tenant, task); } else { taskRecord = buildTaskRecord(task.getTaskID(), colIter); } if (taskShouldExecute(task, taskRecord) && canHandleMoreTasks()) { attemptToExecuteTask(appDef, task, taskRecord); } } }
[ "private", "void", "checkTaskForExecution", "(", "ApplicationDefinition", "appDef", ",", "Task", "task", ")", "{", "Tenant", "tenant", "=", "Tenant", ".", "getTenant", "(", "appDef", ")", ";", "m_logger", ".", "debug", "(", "\"Checking task '{}' in tenant '{}'\"", ",", "task", ".", "getTaskID", "(", ")", ",", "tenant", ")", ";", "synchronized", "(", "m_executeLock", ")", "{", "Iterator", "<", "DColumn", ">", "colIter", "=", "DBService", ".", "instance", "(", "tenant", ")", ".", "getAllColumns", "(", "TaskManagerService", ".", "TASKS_STORE_NAME", ",", "task", ".", "getTaskID", "(", ")", ")", ".", "iterator", "(", ")", ";", "TaskRecord", "taskRecord", "=", "null", ";", "if", "(", "!", "colIter", ".", "hasNext", "(", ")", ")", "{", "taskRecord", "=", "storeTaskRecord", "(", "tenant", ",", "task", ")", ";", "}", "else", "{", "taskRecord", "=", "buildTaskRecord", "(", "task", ".", "getTaskID", "(", ")", ",", "colIter", ")", ";", "}", "if", "(", "taskShouldExecute", "(", "task", ",", "taskRecord", ")", "&&", "canHandleMoreTasks", "(", ")", ")", "{", "attemptToExecuteTask", "(", "appDef", ",", "task", ",", "taskRecord", ")", ";", "}", "}", "}" ]
Check the given task to see if we should and can execute it.
[ "Check", "the", "given", "task", "to", "see", "if", "we", "should", "and", "can", "execute", "it", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java#L343-L359
138,402
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java
TaskManagerService.attemptToExecuteTask
private void attemptToExecuteTask(ApplicationDefinition appDef, Task task, TaskRecord taskRecord) { Tenant tenant = Tenant.getTenant(appDef); String taskID = taskRecord.getTaskID(); String claimID = "_claim/" + taskID; long claimStamp = System.currentTimeMillis(); writeTaskClaim(tenant, claimID, claimStamp); if (taskClaimedByUs(tenant, claimID)) { startTask(appDef, task, taskRecord); } else { m_logger.info("Will not start task: it was claimed by another service"); } }
java
private void attemptToExecuteTask(ApplicationDefinition appDef, Task task, TaskRecord taskRecord) { Tenant tenant = Tenant.getTenant(appDef); String taskID = taskRecord.getTaskID(); String claimID = "_claim/" + taskID; long claimStamp = System.currentTimeMillis(); writeTaskClaim(tenant, claimID, claimStamp); if (taskClaimedByUs(tenant, claimID)) { startTask(appDef, task, taskRecord); } else { m_logger.info("Will not start task: it was claimed by another service"); } }
[ "private", "void", "attemptToExecuteTask", "(", "ApplicationDefinition", "appDef", ",", "Task", "task", ",", "TaskRecord", "taskRecord", ")", "{", "Tenant", "tenant", "=", "Tenant", ".", "getTenant", "(", "appDef", ")", ";", "String", "taskID", "=", "taskRecord", ".", "getTaskID", "(", ")", ";", "String", "claimID", "=", "\"_claim/\"", "+", "taskID", ";", "long", "claimStamp", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "writeTaskClaim", "(", "tenant", ",", "claimID", ",", "claimStamp", ")", ";", "if", "(", "taskClaimedByUs", "(", "tenant", ",", "claimID", ")", ")", "{", "startTask", "(", "appDef", ",", "task", ",", "taskRecord", ")", ";", "}", "else", "{", "m_logger", ".", "info", "(", "\"Will not start task: it was claimed by another service\"", ")", ";", "}", "}" ]
Attempt to start the given task by creating claim and see if we win it.
[ "Attempt", "to", "start", "the", "given", "task", "by", "creating", "claim", "and", "see", "if", "we", "win", "it", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java#L398-L409
138,403
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java
TaskManagerService.startTask
private void startTask(ApplicationDefinition appDef, Task task, TaskRecord taskRecord) { try { task.setParams(m_localHost, taskRecord); m_executor.execute(task); } catch (Exception e) { m_logger.error("Failed to start task '" + task.getTaskID() + "'", e); } }
java
private void startTask(ApplicationDefinition appDef, Task task, TaskRecord taskRecord) { try { task.setParams(m_localHost, taskRecord); m_executor.execute(task); } catch (Exception e) { m_logger.error("Failed to start task '" + task.getTaskID() + "'", e); } }
[ "private", "void", "startTask", "(", "ApplicationDefinition", "appDef", ",", "Task", "task", ",", "TaskRecord", "taskRecord", ")", "{", "try", "{", "task", ".", "setParams", "(", "m_localHost", ",", "taskRecord", ")", ";", "m_executor", ".", "execute", "(", "task", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "m_logger", ".", "error", "(", "\"Failed to start task '\"", "+", "task", ".", "getTaskID", "(", ")", "+", "\"'\"", ",", "e", ")", ";", "}", "}" ]
Execute the given task by handing it to the ExecutorService.
[ "Execute", "the", "given", "task", "by", "handing", "it", "to", "the", "ExecutorService", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java#L412-L419
138,404
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java
TaskManagerService.taskClaimedByUs
private boolean taskClaimedByUs(Tenant tenant, String claimID) { waitForClaim(); Iterator<DColumn> colIter = DBService.instance(tenant).getAllColumns(TaskManagerService.TASKS_STORE_NAME, claimID).iterator(); if (colIter == null) { m_logger.warn("Claim record disappeared: {}", claimID); return false; } String claimingHost = m_hostClaimID; long earliestClaim = Long.MAX_VALUE; while (colIter.hasNext()) { DColumn col = colIter.next(); try { long claimStamp = Long.parseLong(col.getValue()); // otarakanov: sometimes, the task writes a claim but does not start. The claim remains the lowest // and makes future tries to write new claims but not start. // we disregard claims older that ten minutes. long secondsSinceClaim = (System.currentTimeMillis() - claimStamp) / 1000; if(secondsSinceClaim > 600) continue; String claimHost = col.getName(); if (claimStamp < earliestClaim) { claimingHost = claimHost; earliestClaim = claimStamp; } else if (claimStamp == earliestClaim) { // Two nodes chose the same claim stamp. Lower node name wins. if (claimHost.compareTo(claimingHost) < 0) { claimingHost = claimHost; } } } catch (NumberFormatException e) { // Ignore this column } } return claimingHost.equals(m_hostClaimID) && !m_bShutdown; }
java
private boolean taskClaimedByUs(Tenant tenant, String claimID) { waitForClaim(); Iterator<DColumn> colIter = DBService.instance(tenant).getAllColumns(TaskManagerService.TASKS_STORE_NAME, claimID).iterator(); if (colIter == null) { m_logger.warn("Claim record disappeared: {}", claimID); return false; } String claimingHost = m_hostClaimID; long earliestClaim = Long.MAX_VALUE; while (colIter.hasNext()) { DColumn col = colIter.next(); try { long claimStamp = Long.parseLong(col.getValue()); // otarakanov: sometimes, the task writes a claim but does not start. The claim remains the lowest // and makes future tries to write new claims but not start. // we disregard claims older that ten minutes. long secondsSinceClaim = (System.currentTimeMillis() - claimStamp) / 1000; if(secondsSinceClaim > 600) continue; String claimHost = col.getName(); if (claimStamp < earliestClaim) { claimingHost = claimHost; earliestClaim = claimStamp; } else if (claimStamp == earliestClaim) { // Two nodes chose the same claim stamp. Lower node name wins. if (claimHost.compareTo(claimingHost) < 0) { claimingHost = claimHost; } } } catch (NumberFormatException e) { // Ignore this column } } return claimingHost.equals(m_hostClaimID) && !m_bShutdown; }
[ "private", "boolean", "taskClaimedByUs", "(", "Tenant", "tenant", ",", "String", "claimID", ")", "{", "waitForClaim", "(", ")", ";", "Iterator", "<", "DColumn", ">", "colIter", "=", "DBService", ".", "instance", "(", "tenant", ")", ".", "getAllColumns", "(", "TaskManagerService", ".", "TASKS_STORE_NAME", ",", "claimID", ")", ".", "iterator", "(", ")", ";", "if", "(", "colIter", "==", "null", ")", "{", "m_logger", ".", "warn", "(", "\"Claim record disappeared: {}\"", ",", "claimID", ")", ";", "return", "false", ";", "}", "String", "claimingHost", "=", "m_hostClaimID", ";", "long", "earliestClaim", "=", "Long", ".", "MAX_VALUE", ";", "while", "(", "colIter", ".", "hasNext", "(", ")", ")", "{", "DColumn", "col", "=", "colIter", ".", "next", "(", ")", ";", "try", "{", "long", "claimStamp", "=", "Long", ".", "parseLong", "(", "col", ".", "getValue", "(", ")", ")", ";", "// otarakanov: sometimes, the task writes a claim but does not start. The claim remains the lowest", "// and makes future tries to write new claims but not start. ", "// we disregard claims older that ten minutes.", "long", "secondsSinceClaim", "=", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "claimStamp", ")", "/", "1000", ";", "if", "(", "secondsSinceClaim", ">", "600", ")", "continue", ";", "String", "claimHost", "=", "col", ".", "getName", "(", ")", ";", "if", "(", "claimStamp", "<", "earliestClaim", ")", "{", "claimingHost", "=", "claimHost", ";", "earliestClaim", "=", "claimStamp", ";", "}", "else", "if", "(", "claimStamp", "==", "earliestClaim", ")", "{", "// Two nodes chose the same claim stamp. Lower node name wins.", "if", "(", "claimHost", ".", "compareTo", "(", "claimingHost", ")", "<", "0", ")", "{", "claimingHost", "=", "claimHost", ";", "}", "}", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "// Ignore this column", "}", "}", "return", "claimingHost", ".", "equals", "(", "m_hostClaimID", ")", "&&", "!", "m_bShutdown", ";", "}" ]
Indicate if we won the claim to run the given task.
[ "Indicate", "if", "we", "won", "the", "claim", "to", "run", "the", "given", "task", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java#L422-L456
138,405
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java
TaskManagerService.writeTaskClaim
private void writeTaskClaim(Tenant tenant, String claimID, long claimStamp) { DBTransaction dbTran = DBService.instance(tenant).startTransaction(); dbTran.addColumn(TaskManagerService.TASKS_STORE_NAME, claimID, m_hostClaimID, claimStamp); DBService.instance(tenant).commit(dbTran); }
java
private void writeTaskClaim(Tenant tenant, String claimID, long claimStamp) { DBTransaction dbTran = DBService.instance(tenant).startTransaction(); dbTran.addColumn(TaskManagerService.TASKS_STORE_NAME, claimID, m_hostClaimID, claimStamp); DBService.instance(tenant).commit(dbTran); }
[ "private", "void", "writeTaskClaim", "(", "Tenant", "tenant", ",", "String", "claimID", ",", "long", "claimStamp", ")", "{", "DBTransaction", "dbTran", "=", "DBService", ".", "instance", "(", "tenant", ")", ".", "startTransaction", "(", ")", ";", "dbTran", ".", "addColumn", "(", "TaskManagerService", ".", "TASKS_STORE_NAME", ",", "claimID", ",", "m_hostClaimID", ",", "claimStamp", ")", ";", "DBService", ".", "instance", "(", "tenant", ")", ".", "commit", "(", "dbTran", ")", ";", "}" ]
Write a claim record to the Tasks table.
[ "Write", "a", "claim", "record", "to", "the", "Tasks", "table", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java#L467-L471
138,406
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java
TaskManagerService.buildTaskRecord
private TaskRecord buildTaskRecord(String taskID, Iterator<DColumn> colIter) { TaskRecord taskRecord = new TaskRecord(taskID); while (colIter.hasNext()) { DColumn col = colIter.next(); taskRecord.setProperty(col.getName(), col.getValue()); } return taskRecord; }
java
private TaskRecord buildTaskRecord(String taskID, Iterator<DColumn> colIter) { TaskRecord taskRecord = new TaskRecord(taskID); while (colIter.hasNext()) { DColumn col = colIter.next(); taskRecord.setProperty(col.getName(), col.getValue()); } return taskRecord; }
[ "private", "TaskRecord", "buildTaskRecord", "(", "String", "taskID", ",", "Iterator", "<", "DColumn", ">", "colIter", ")", "{", "TaskRecord", "taskRecord", "=", "new", "TaskRecord", "(", "taskID", ")", ";", "while", "(", "colIter", ".", "hasNext", "(", ")", ")", "{", "DColumn", "col", "=", "colIter", ".", "next", "(", ")", ";", "taskRecord", ".", "setProperty", "(", "col", ".", "getName", "(", ")", ",", "col", ".", "getValue", "(", ")", ")", ";", "}", "return", "taskRecord", ";", "}" ]
Create a TaskRecord from a task status row read from the Tasks table.
[ "Create", "a", "TaskRecord", "from", "a", "task", "status", "row", "read", "from", "the", "Tasks", "table", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java#L474-L481
138,407
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java
TaskManagerService.storeTaskRecord
private TaskRecord storeTaskRecord(Tenant tenant, Task task) { DBTransaction dbTran = DBService.instance(tenant).startTransaction(); TaskRecord taskRecord = new TaskRecord(task.getTaskID()); Map<String, String> propMap = taskRecord.getProperties(); assert propMap.size() > 0 : "Need at least one property to store a row!"; for (String propName : propMap.keySet()) { dbTran.addColumn(TaskManagerService.TASKS_STORE_NAME, task.getTaskID(), propName, propMap.get(propName)); } DBService.instance(tenant).commit(dbTran); return taskRecord; }
java
private TaskRecord storeTaskRecord(Tenant tenant, Task task) { DBTransaction dbTran = DBService.instance(tenant).startTransaction(); TaskRecord taskRecord = new TaskRecord(task.getTaskID()); Map<String, String> propMap = taskRecord.getProperties(); assert propMap.size() > 0 : "Need at least one property to store a row!"; for (String propName : propMap.keySet()) { dbTran.addColumn(TaskManagerService.TASKS_STORE_NAME, task.getTaskID(), propName, propMap.get(propName)); } DBService.instance(tenant).commit(dbTran); return taskRecord; }
[ "private", "TaskRecord", "storeTaskRecord", "(", "Tenant", "tenant", ",", "Task", "task", ")", "{", "DBTransaction", "dbTran", "=", "DBService", ".", "instance", "(", "tenant", ")", ".", "startTransaction", "(", ")", ";", "TaskRecord", "taskRecord", "=", "new", "TaskRecord", "(", "task", ".", "getTaskID", "(", ")", ")", ";", "Map", "<", "String", ",", "String", ">", "propMap", "=", "taskRecord", ".", "getProperties", "(", ")", ";", "assert", "propMap", ".", "size", "(", ")", ">", "0", ":", "\"Need at least one property to store a row!\"", ";", "for", "(", "String", "propName", ":", "propMap", ".", "keySet", "(", ")", ")", "{", "dbTran", ".", "addColumn", "(", "TaskManagerService", ".", "TASKS_STORE_NAME", ",", "task", ".", "getTaskID", "(", ")", ",", "propName", ",", "propMap", ".", "get", "(", "propName", ")", ")", ";", "}", "DBService", ".", "instance", "(", "tenant", ")", ".", "commit", "(", "dbTran", ")", ";", "return", "taskRecord", ";", "}" ]
Create a TaskRecord for the given task and write it to the Tasks table.
[ "Create", "a", "TaskRecord", "for", "the", "given", "task", "and", "write", "it", "to", "the", "Tasks", "table", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java#L484-L494
138,408
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java
TaskManagerService.getAppTasks
private List<Task> getAppTasks(ApplicationDefinition appDef) { List<Task> appTasks = new ArrayList<>(); try { StorageService service = SchemaService.instance().getStorageService(appDef); Collection<Task> appTaskColl = service.getAppTasks(appDef); if (appTaskColl != null) { appTasks.addAll(service.getAppTasks(appDef)); } } catch (IllegalArgumentException e) { // StorageService has not been initialized; no tasks for this application. } return appTasks; }
java
private List<Task> getAppTasks(ApplicationDefinition appDef) { List<Task> appTasks = new ArrayList<>(); try { StorageService service = SchemaService.instance().getStorageService(appDef); Collection<Task> appTaskColl = service.getAppTasks(appDef); if (appTaskColl != null) { appTasks.addAll(service.getAppTasks(appDef)); } } catch (IllegalArgumentException e) { // StorageService has not been initialized; no tasks for this application. } return appTasks; }
[ "private", "List", "<", "Task", ">", "getAppTasks", "(", "ApplicationDefinition", "appDef", ")", "{", "List", "<", "Task", ">", "appTasks", "=", "new", "ArrayList", "<>", "(", ")", ";", "try", "{", "StorageService", "service", "=", "SchemaService", ".", "instance", "(", ")", ".", "getStorageService", "(", "appDef", ")", ";", "Collection", "<", "Task", ">", "appTaskColl", "=", "service", ".", "getAppTasks", "(", "appDef", ")", ";", "if", "(", "appTaskColl", "!=", "null", ")", "{", "appTasks", ".", "addAll", "(", "service", ".", "getAppTasks", "(", "appDef", ")", ")", ";", "}", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "// StorageService has not been initialized; no tasks for this application.", "}", "return", "appTasks", ";", "}" ]
Ask the storage manager for the given application for its required tasks.
[ "Ask", "the", "storage", "manager", "for", "the", "given", "application", "for", "its", "required", "tasks", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java#L497-L509
138,409
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java
TaskManagerService.checkForDeadTask
private void checkForDeadTask(Tenant tenant, TaskRecord taskRecord) { Calendar lastReport = taskRecord.getTime(TaskRecord.PROP_PROGRESS_TIME); if (lastReport == null) { lastReport = taskRecord.getTime(TaskRecord.PROP_START_TIME); if (lastReport == null) { return; // corrupt/incomplete task record } } long minsSinceLastActivity = (System.currentTimeMillis() - lastReport.getTimeInMillis()) / (1000 * 60); if (isOurActiveTask(tenant, taskRecord.getTaskID())) { checkForHungTask(tenant, taskRecord, minsSinceLastActivity); } else { checkForAbandonedTask(tenant, taskRecord, minsSinceLastActivity); } }
java
private void checkForDeadTask(Tenant tenant, TaskRecord taskRecord) { Calendar lastReport = taskRecord.getTime(TaskRecord.PROP_PROGRESS_TIME); if (lastReport == null) { lastReport = taskRecord.getTime(TaskRecord.PROP_START_TIME); if (lastReport == null) { return; // corrupt/incomplete task record } } long minsSinceLastActivity = (System.currentTimeMillis() - lastReport.getTimeInMillis()) / (1000 * 60); if (isOurActiveTask(tenant, taskRecord.getTaskID())) { checkForHungTask(tenant, taskRecord, minsSinceLastActivity); } else { checkForAbandonedTask(tenant, taskRecord, minsSinceLastActivity); } }
[ "private", "void", "checkForDeadTask", "(", "Tenant", "tenant", ",", "TaskRecord", "taskRecord", ")", "{", "Calendar", "lastReport", "=", "taskRecord", ".", "getTime", "(", "TaskRecord", ".", "PROP_PROGRESS_TIME", ")", ";", "if", "(", "lastReport", "==", "null", ")", "{", "lastReport", "=", "taskRecord", ".", "getTime", "(", "TaskRecord", ".", "PROP_START_TIME", ")", ";", "if", "(", "lastReport", "==", "null", ")", "{", "return", ";", "// corrupt/incomplete task record", "}", "}", "long", "minsSinceLastActivity", "=", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "lastReport", ".", "getTimeInMillis", "(", ")", ")", "/", "(", "1000", "*", "60", ")", ";", "if", "(", "isOurActiveTask", "(", "tenant", ",", "taskRecord", ".", "getTaskID", "(", ")", ")", ")", "{", "checkForHungTask", "(", "tenant", ",", "taskRecord", ",", "minsSinceLastActivity", ")", ";", "}", "else", "{", "checkForAbandonedTask", "(", "tenant", ",", "taskRecord", ",", "minsSinceLastActivity", ")", ";", "}", "}" ]
See if the given in-progress task may be hung or abandoned.
[ "See", "if", "the", "given", "in", "-", "progress", "task", "may", "be", "hung", "or", "abandoned", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java#L537-L551
138,410
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java
TaskManagerService.checkForHungTask
private void checkForHungTask(Tenant tenant, TaskRecord taskRecord, long minsSinceLastActivity) { if (minsSinceLastActivity > HUNG_TASK_THRESHOLD_MINS) { String taskIdentity = createMapKey(tenant, taskRecord.getTaskID()); String reason = "No progress reported in " + minsSinceLastActivity + " minutes"; m_logger.warn("Local task {} has not reported progress in {} minutes; " + "restart the server if this continues for too long", taskIdentity, minsSinceLastActivity); taskRecord.setProperty(TaskRecord.PROP_PROGRESS_TIME, Long.toString(System.currentTimeMillis())); taskRecord.setProperty(TaskRecord.PROP_PROGRESS, reason); updateTaskStatus(tenant, taskRecord, false); } }
java
private void checkForHungTask(Tenant tenant, TaskRecord taskRecord, long minsSinceLastActivity) { if (minsSinceLastActivity > HUNG_TASK_THRESHOLD_MINS) { String taskIdentity = createMapKey(tenant, taskRecord.getTaskID()); String reason = "No progress reported in " + minsSinceLastActivity + " minutes"; m_logger.warn("Local task {} has not reported progress in {} minutes; " + "restart the server if this continues for too long", taskIdentity, minsSinceLastActivity); taskRecord.setProperty(TaskRecord.PROP_PROGRESS_TIME, Long.toString(System.currentTimeMillis())); taskRecord.setProperty(TaskRecord.PROP_PROGRESS, reason); updateTaskStatus(tenant, taskRecord, false); } }
[ "private", "void", "checkForHungTask", "(", "Tenant", "tenant", ",", "TaskRecord", "taskRecord", ",", "long", "minsSinceLastActivity", ")", "{", "if", "(", "minsSinceLastActivity", ">", "HUNG_TASK_THRESHOLD_MINS", ")", "{", "String", "taskIdentity", "=", "createMapKey", "(", "tenant", ",", "taskRecord", ".", "getTaskID", "(", ")", ")", ";", "String", "reason", "=", "\"No progress reported in \"", "+", "minsSinceLastActivity", "+", "\" minutes\"", ";", "m_logger", ".", "warn", "(", "\"Local task {} has not reported progress in {} minutes; \"", "+", "\"restart the server if this continues for too long\"", ",", "taskIdentity", ",", "minsSinceLastActivity", ")", ";", "taskRecord", ".", "setProperty", "(", "TaskRecord", ".", "PROP_PROGRESS_TIME", ",", "Long", ".", "toString", "(", "System", ".", "currentTimeMillis", "(", ")", ")", ")", ";", "taskRecord", ".", "setProperty", "(", "TaskRecord", ".", "PROP_PROGRESS", ",", "reason", ")", ";", "updateTaskStatus", "(", "tenant", ",", "taskRecord", ",", "false", ")", ";", "}", "}" ]
potentially harmful second task execution.
[ "potentially", "harmful", "second", "task", "execution", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java#L557-L568
138,411
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java
TaskManagerService.checkForAbandonedTask
private void checkForAbandonedTask(Tenant tenant, TaskRecord taskRecord, long minsSinceLastActivity) { if (minsSinceLastActivity > DEAD_TASK_THRESHOLD_MINS) { String taskIdentity = createMapKey(tenant, taskRecord.getTaskID()); String reason = "No progress reported in " + minsSinceLastActivity + " minutes"; m_logger.error("Remote task {} has not reported progress in {} minutes; marking as failed", taskIdentity, minsSinceLastActivity); taskRecord.setProperty(TaskRecord.PROP_FINISH_TIME, Long.toString(System.currentTimeMillis())); taskRecord.setProperty(TaskRecord.PROP_FAIL_REASON, reason); taskRecord.setStatus(TaskStatus.FAILED); updateTaskStatus(tenant, taskRecord, true); } }
java
private void checkForAbandonedTask(Tenant tenant, TaskRecord taskRecord, long minsSinceLastActivity) { if (minsSinceLastActivity > DEAD_TASK_THRESHOLD_MINS) { String taskIdentity = createMapKey(tenant, taskRecord.getTaskID()); String reason = "No progress reported in " + minsSinceLastActivity + " minutes"; m_logger.error("Remote task {} has not reported progress in {} minutes; marking as failed", taskIdentity, minsSinceLastActivity); taskRecord.setProperty(TaskRecord.PROP_FINISH_TIME, Long.toString(System.currentTimeMillis())); taskRecord.setProperty(TaskRecord.PROP_FAIL_REASON, reason); taskRecord.setStatus(TaskStatus.FAILED); updateTaskStatus(tenant, taskRecord, true); } }
[ "private", "void", "checkForAbandonedTask", "(", "Tenant", "tenant", ",", "TaskRecord", "taskRecord", ",", "long", "minsSinceLastActivity", ")", "{", "if", "(", "minsSinceLastActivity", ">", "DEAD_TASK_THRESHOLD_MINS", ")", "{", "String", "taskIdentity", "=", "createMapKey", "(", "tenant", ",", "taskRecord", ".", "getTaskID", "(", ")", ")", ";", "String", "reason", "=", "\"No progress reported in \"", "+", "minsSinceLastActivity", "+", "\" minutes\"", ";", "m_logger", ".", "error", "(", "\"Remote task {} has not reported progress in {} minutes; marking as failed\"", ",", "taskIdentity", ",", "minsSinceLastActivity", ")", ";", "taskRecord", ".", "setProperty", "(", "TaskRecord", ".", "PROP_FINISH_TIME", ",", "Long", ".", "toString", "(", "System", ".", "currentTimeMillis", "(", ")", ")", ")", ";", "taskRecord", ".", "setProperty", "(", "TaskRecord", ".", "PROP_FAIL_REASON", ",", "reason", ")", ";", "taskRecord", ".", "setStatus", "(", "TaskStatus", ".", "FAILED", ")", ";", "updateTaskStatus", "(", "tenant", ",", "taskRecord", ",", "true", ")", ";", "}", "}" ]
to restart upon the next check-tasks cycle.
[ "to", "restart", "upon", "the", "next", "check", "-", "tasks", "cycle", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java#L573-L584
138,412
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java
TaskManagerService.isOurActiveTask
private boolean isOurActiveTask(Tenant tenant, String taskID) { synchronized (m_activeTasks) { return m_activeTasks.containsKey(createMapKey(tenant, taskID)); } }
java
private boolean isOurActiveTask(Tenant tenant, String taskID) { synchronized (m_activeTasks) { return m_activeTasks.containsKey(createMapKey(tenant, taskID)); } }
[ "private", "boolean", "isOurActiveTask", "(", "Tenant", "tenant", ",", "String", "taskID", ")", "{", "synchronized", "(", "m_activeTasks", ")", "{", "return", "m_activeTasks", ".", "containsKey", "(", "createMapKey", "(", "tenant", ",", "taskID", ")", ")", ";", "}", "}" ]
Return true if we are currently executing the given task.
[ "Return", "true", "if", "we", "are", "currently", "executing", "the", "given", "task", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskManagerService.java#L592-L596
138,413
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java
BatchObjectUpdater.commitTransaction
private void commitTransaction() { Tenant tenant = Tenant.getTenant(m_tableDef); DBTransaction dbTran = DBService.instance(tenant).startTransaction(); m_parentTran.applyUpdates(dbTran); DBService.instance(tenant).commit(dbTran); m_parentTran.clear(); }
java
private void commitTransaction() { Tenant tenant = Tenant.getTenant(m_tableDef); DBTransaction dbTran = DBService.instance(tenant).startTransaction(); m_parentTran.applyUpdates(dbTran); DBService.instance(tenant).commit(dbTran); m_parentTran.clear(); }
[ "private", "void", "commitTransaction", "(", ")", "{", "Tenant", "tenant", "=", "Tenant", ".", "getTenant", "(", "m_tableDef", ")", ";", "DBTransaction", "dbTran", "=", "DBService", ".", "instance", "(", "tenant", ")", ".", "startTransaction", "(", ")", ";", "m_parentTran", ".", "applyUpdates", "(", "dbTran", ")", ";", "DBService", ".", "instance", "(", "tenant", ")", ".", "commit", "(", "dbTran", ")", ";", "m_parentTran", ".", "clear", "(", ")", ";", "}" ]
Post all updates in the parent transaction to the database.
[ "Post", "all", "updates", "in", "the", "parent", "transaction", "to", "the", "database", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java#L150-L156
138,414
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java
BatchObjectUpdater.updateBatch
private boolean updateBatch(DBObjectBatch dbObjBatch, BatchResult batchResult) throws IOException { Map<String, Map<String, String>> objCurrScalarMap = getCurrentScalars(dbObjBatch); Map<String, Map<String, Integer>> targObjShardNos = getLinkTargetShardNumbers(dbObjBatch); for (DBObject dbObj : dbObjBatch.getObjects()) { checkCommit(); Map<String, String> currScalarMap = objCurrScalarMap.get(dbObj.getObjectID()); ObjectResult objResult = updateObject(dbObj, currScalarMap, targObjShardNos); batchResult.addObjectResult(objResult); } commitTransaction(); return batchResult.hasUpdates(); }
java
private boolean updateBatch(DBObjectBatch dbObjBatch, BatchResult batchResult) throws IOException { Map<String, Map<String, String>> objCurrScalarMap = getCurrentScalars(dbObjBatch); Map<String, Map<String, Integer>> targObjShardNos = getLinkTargetShardNumbers(dbObjBatch); for (DBObject dbObj : dbObjBatch.getObjects()) { checkCommit(); Map<String, String> currScalarMap = objCurrScalarMap.get(dbObj.getObjectID()); ObjectResult objResult = updateObject(dbObj, currScalarMap, targObjShardNos); batchResult.addObjectResult(objResult); } commitTransaction(); return batchResult.hasUpdates(); }
[ "private", "boolean", "updateBatch", "(", "DBObjectBatch", "dbObjBatch", ",", "BatchResult", "batchResult", ")", "throws", "IOException", "{", "Map", "<", "String", ",", "Map", "<", "String", ",", "String", ">", ">", "objCurrScalarMap", "=", "getCurrentScalars", "(", "dbObjBatch", ")", ";", "Map", "<", "String", ",", "Map", "<", "String", ",", "Integer", ">", ">", "targObjShardNos", "=", "getLinkTargetShardNumbers", "(", "dbObjBatch", ")", ";", "for", "(", "DBObject", "dbObj", ":", "dbObjBatch", ".", "getObjects", "(", ")", ")", "{", "checkCommit", "(", ")", ";", "Map", "<", "String", ",", "String", ">", "currScalarMap", "=", "objCurrScalarMap", ".", "get", "(", "dbObj", ".", "getObjectID", "(", ")", ")", ";", "ObjectResult", "objResult", "=", "updateObject", "(", "dbObj", ",", "currScalarMap", ",", "targObjShardNos", ")", ";", "batchResult", ".", "addObjectResult", "(", "objResult", ")", ";", "}", "commitTransaction", "(", ")", ";", "return", "batchResult", ".", "hasUpdates", "(", ")", ";", "}" ]
Update each object in the given batch, updating BatchResult accordingly.
[ "Update", "each", "object", "in", "the", "given", "batch", "updating", "BatchResult", "accordingly", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java#L174-L185
138,415
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java
BatchObjectUpdater.updateObject
private ObjectResult updateObject(DBObject dbObj, Map<String, String> currScalarMap, Map<String, Map<String, Integer>> targObjShardNos) { ObjectResult objResult = null; if (Utils.isEmpty(dbObj.getObjectID())) { objResult = ObjectResult.newErrorResult("Object ID is required", null); } else if (currScalarMap == null) { objResult = ObjectResult.newErrorResult("No object found", dbObj.getObjectID()); } else { ObjectUpdater objUpdater = new ObjectUpdater(m_tableDef); if (targObjShardNos.size() > 0) { objUpdater.setTargetObjectShardNumbers(targObjShardNos); } objResult = objUpdater.updateObject(m_parentTran, dbObj, currScalarMap); } return objResult; }
java
private ObjectResult updateObject(DBObject dbObj, Map<String, String> currScalarMap, Map<String, Map<String, Integer>> targObjShardNos) { ObjectResult objResult = null; if (Utils.isEmpty(dbObj.getObjectID())) { objResult = ObjectResult.newErrorResult("Object ID is required", null); } else if (currScalarMap == null) { objResult = ObjectResult.newErrorResult("No object found", dbObj.getObjectID()); } else { ObjectUpdater objUpdater = new ObjectUpdater(m_tableDef); if (targObjShardNos.size() > 0) { objUpdater.setTargetObjectShardNumbers(targObjShardNos); } objResult = objUpdater.updateObject(m_parentTran, dbObj, currScalarMap); } return objResult; }
[ "private", "ObjectResult", "updateObject", "(", "DBObject", "dbObj", ",", "Map", "<", "String", ",", "String", ">", "currScalarMap", ",", "Map", "<", "String", ",", "Map", "<", "String", ",", "Integer", ">", ">", "targObjShardNos", ")", "{", "ObjectResult", "objResult", "=", "null", ";", "if", "(", "Utils", ".", "isEmpty", "(", "dbObj", ".", "getObjectID", "(", ")", ")", ")", "{", "objResult", "=", "ObjectResult", ".", "newErrorResult", "(", "\"Object ID is required\"", ",", "null", ")", ";", "}", "else", "if", "(", "currScalarMap", "==", "null", ")", "{", "objResult", "=", "ObjectResult", ".", "newErrorResult", "(", "\"No object found\"", ",", "dbObj", ".", "getObjectID", "(", ")", ")", ";", "}", "else", "{", "ObjectUpdater", "objUpdater", "=", "new", "ObjectUpdater", "(", "m_tableDef", ")", ";", "if", "(", "targObjShardNos", ".", "size", "(", ")", ">", "0", ")", "{", "objUpdater", ".", "setTargetObjectShardNumbers", "(", "targObjShardNos", ")", ";", "}", "objResult", "=", "objUpdater", ".", "updateObject", "(", "m_parentTran", ",", "dbObj", ",", "currScalarMap", ")", ";", "}", "return", "objResult", ";", "}" ]
Update the given object, which must exist, using the given set of current scalar values.
[ "Update", "the", "given", "object", "which", "must", "exist", "using", "the", "given", "set", "of", "current", "scalar", "values", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java#L188-L204
138,416
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java
BatchObjectUpdater.addOrUpdateObject
private ObjectResult addOrUpdateObject(DBObject dbObj, Map<String, String> currScalarMap, Map<String, Map<String, Integer>> targObjShardNos) throws IOException { ObjectUpdater objUpdater = new ObjectUpdater(m_tableDef); if (targObjShardNos.size() > 0) { objUpdater.setTargetObjectShardNumbers(targObjShardNos); } if (currScalarMap == null || currScalarMap.size() == 0) { return objUpdater.addNewObject(m_parentTran, dbObj); } else { return objUpdater.updateObject(m_parentTran, dbObj, currScalarMap); } }
java
private ObjectResult addOrUpdateObject(DBObject dbObj, Map<String, String> currScalarMap, Map<String, Map<String, Integer>> targObjShardNos) throws IOException { ObjectUpdater objUpdater = new ObjectUpdater(m_tableDef); if (targObjShardNos.size() > 0) { objUpdater.setTargetObjectShardNumbers(targObjShardNos); } if (currScalarMap == null || currScalarMap.size() == 0) { return objUpdater.addNewObject(m_parentTran, dbObj); } else { return objUpdater.updateObject(m_parentTran, dbObj, currScalarMap); } }
[ "private", "ObjectResult", "addOrUpdateObject", "(", "DBObject", "dbObj", ",", "Map", "<", "String", ",", "String", ">", "currScalarMap", ",", "Map", "<", "String", ",", "Map", "<", "String", ",", "Integer", ">", ">", "targObjShardNos", ")", "throws", "IOException", "{", "ObjectUpdater", "objUpdater", "=", "new", "ObjectUpdater", "(", "m_tableDef", ")", ";", "if", "(", "targObjShardNos", ".", "size", "(", ")", ">", "0", ")", "{", "objUpdater", ".", "setTargetObjectShardNumbers", "(", "targObjShardNos", ")", ";", "}", "if", "(", "currScalarMap", "==", "null", "||", "currScalarMap", ".", "size", "(", ")", "==", "0", ")", "{", "return", "objUpdater", ".", "addNewObject", "(", "m_parentTran", ",", "dbObj", ")", ";", "}", "else", "{", "return", "objUpdater", ".", "updateObject", "(", "m_parentTran", ",", "dbObj", ",", "currScalarMap", ")", ";", "}", "}" ]
Add the given object if its current-value map is null, otherwise update the object.
[ "Add", "the", "given", "object", "if", "its", "current", "-", "value", "map", "is", "null", "otherwise", "update", "the", "object", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java#L207-L220
138,417
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java
BatchObjectUpdater.buildErrorStatus
private void buildErrorStatus(BatchResult result, Throwable ex) { result.setStatus(BatchResult.Status.ERROR); result.setErrorMessage(ex.getLocalizedMessage()); if (ex instanceof IllegalArgumentException) { m_logger.debug("Batch update error: {}", ex.toString()); } else { result.setStackTrace(Utils.getStackTrace(ex)); m_logger.debug("Batch update error: {} stacktrace: {}", ex.toString(), Utils.getStackTrace(ex)); } }
java
private void buildErrorStatus(BatchResult result, Throwable ex) { result.setStatus(BatchResult.Status.ERROR); result.setErrorMessage(ex.getLocalizedMessage()); if (ex instanceof IllegalArgumentException) { m_logger.debug("Batch update error: {}", ex.toString()); } else { result.setStackTrace(Utils.getStackTrace(ex)); m_logger.debug("Batch update error: {} stacktrace: {}", ex.toString(), Utils.getStackTrace(ex)); } }
[ "private", "void", "buildErrorStatus", "(", "BatchResult", "result", ",", "Throwable", "ex", ")", "{", "result", ".", "setStatus", "(", "BatchResult", ".", "Status", ".", "ERROR", ")", ";", "result", ".", "setErrorMessage", "(", "ex", ".", "getLocalizedMessage", "(", ")", ")", ";", "if", "(", "ex", "instanceof", "IllegalArgumentException", ")", "{", "m_logger", ".", "debug", "(", "\"Batch update error: {}\"", ",", "ex", ".", "toString", "(", ")", ")", ";", "}", "else", "{", "result", ".", "setStackTrace", "(", "Utils", ".", "getStackTrace", "(", "ex", ")", ")", ";", "m_logger", ".", "debug", "(", "\"Batch update error: {} stacktrace: {}\"", ",", "ex", ".", "toString", "(", ")", ",", "Utils", ".", "getStackTrace", "(", "ex", ")", ")", ";", "}", "}" ]
Add error fields to the given BatchResult due to the given exception.
[ "Add", "error", "fields", "to", "the", "given", "BatchResult", "due", "to", "the", "given", "exception", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java#L223-L233
138,418
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java
BatchObjectUpdater.getCurrentScalars
private Map<String, Map<String, String>> getCurrentScalars(DBObjectBatch dbObjBatch) throws IOException { Set<String> objIDSet = new HashSet<>(); Set<String> fieldNameSet = new HashSet<String>(); for (DBObject dbObj : dbObjBatch.getObjects()) { if (!Utils.isEmpty(dbObj.getObjectID())) { Utils.require(objIDSet.add(dbObj.getObjectID()), "Cannot update the same object ID twice: " + dbObj.getObjectID()); fieldNameSet.addAll(dbObj.getUpdatedScalarFieldNames(m_tableDef)); } } if (m_tableDef.isSharded()) { fieldNameSet.add(m_tableDef.getShardingField().getName()); } return SpiderService.instance().getObjectScalars(m_tableDef, objIDSet, fieldNameSet); }
java
private Map<String, Map<String, String>> getCurrentScalars(DBObjectBatch dbObjBatch) throws IOException { Set<String> objIDSet = new HashSet<>(); Set<String> fieldNameSet = new HashSet<String>(); for (DBObject dbObj : dbObjBatch.getObjects()) { if (!Utils.isEmpty(dbObj.getObjectID())) { Utils.require(objIDSet.add(dbObj.getObjectID()), "Cannot update the same object ID twice: " + dbObj.getObjectID()); fieldNameSet.addAll(dbObj.getUpdatedScalarFieldNames(m_tableDef)); } } if (m_tableDef.isSharded()) { fieldNameSet.add(m_tableDef.getShardingField().getName()); } return SpiderService.instance().getObjectScalars(m_tableDef, objIDSet, fieldNameSet); }
[ "private", "Map", "<", "String", ",", "Map", "<", "String", ",", "String", ">", ">", "getCurrentScalars", "(", "DBObjectBatch", "dbObjBatch", ")", "throws", "IOException", "{", "Set", "<", "String", ">", "objIDSet", "=", "new", "HashSet", "<>", "(", ")", ";", "Set", "<", "String", ">", "fieldNameSet", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "DBObject", "dbObj", ":", "dbObjBatch", ".", "getObjects", "(", ")", ")", "{", "if", "(", "!", "Utils", ".", "isEmpty", "(", "dbObj", ".", "getObjectID", "(", ")", ")", ")", "{", "Utils", ".", "require", "(", "objIDSet", ".", "add", "(", "dbObj", ".", "getObjectID", "(", ")", ")", ",", "\"Cannot update the same object ID twice: \"", "+", "dbObj", ".", "getObjectID", "(", ")", ")", ";", "fieldNameSet", ".", "addAll", "(", "dbObj", ".", "getUpdatedScalarFieldNames", "(", "m_tableDef", ")", ")", ";", "}", "}", "if", "(", "m_tableDef", ".", "isSharded", "(", ")", ")", "{", "fieldNameSet", ".", "add", "(", "m_tableDef", ".", "getShardingField", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "return", "SpiderService", ".", "instance", "(", ")", ".", "getObjectScalars", "(", "m_tableDef", ",", "objIDSet", ",", "fieldNameSet", ")", ";", "}" ]
Watch and complain about updates to the same ID.
[ "Watch", "and", "complain", "about", "updates", "to", "the", "same", "ID", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java#L244-L258
138,419
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java
BatchObjectUpdater.getLinkTargetShardNumbers
private Map<String, Map<String, Integer>> getLinkTargetShardNumbers(DBObjectBatch dbObjBatch) { Map<String, Map<String, Integer>> result = new HashMap<>(); Map<String, Set<String>> tableTargetObjIDMap = getAllLinkTargetObjIDs(dbObjBatch); for (String targetTableName : tableTargetObjIDMap.keySet()) { Map<String, Integer> shardNoMap = getShardNumbers(targetTableName, tableTargetObjIDMap.get(targetTableName)); if (shardNoMap.size() > 0) { Map<String, Integer> tableShardNoMap = result.get(targetTableName); if (tableShardNoMap == null) { tableShardNoMap = new HashMap<>(); result.put(targetTableName, tableShardNoMap); } tableShardNoMap.putAll(shardNoMap); } } return result; }
java
private Map<String, Map<String, Integer>> getLinkTargetShardNumbers(DBObjectBatch dbObjBatch) { Map<String, Map<String, Integer>> result = new HashMap<>(); Map<String, Set<String>> tableTargetObjIDMap = getAllLinkTargetObjIDs(dbObjBatch); for (String targetTableName : tableTargetObjIDMap.keySet()) { Map<String, Integer> shardNoMap = getShardNumbers(targetTableName, tableTargetObjIDMap.get(targetTableName)); if (shardNoMap.size() > 0) { Map<String, Integer> tableShardNoMap = result.get(targetTableName); if (tableShardNoMap == null) { tableShardNoMap = new HashMap<>(); result.put(targetTableName, tableShardNoMap); } tableShardNoMap.putAll(shardNoMap); } } return result; }
[ "private", "Map", "<", "String", ",", "Map", "<", "String", ",", "Integer", ">", ">", "getLinkTargetShardNumbers", "(", "DBObjectBatch", "dbObjBatch", ")", "{", "Map", "<", "String", ",", "Map", "<", "String", ",", "Integer", ">", ">", "result", "=", "new", "HashMap", "<>", "(", ")", ";", "Map", "<", "String", ",", "Set", "<", "String", ">", ">", "tableTargetObjIDMap", "=", "getAllLinkTargetObjIDs", "(", "dbObjBatch", ")", ";", "for", "(", "String", "targetTableName", ":", "tableTargetObjIDMap", ".", "keySet", "(", ")", ")", "{", "Map", "<", "String", ",", "Integer", ">", "shardNoMap", "=", "getShardNumbers", "(", "targetTableName", ",", "tableTargetObjIDMap", ".", "get", "(", "targetTableName", ")", ")", ";", "if", "(", "shardNoMap", ".", "size", "(", ")", ">", "0", ")", "{", "Map", "<", "String", ",", "Integer", ">", "tableShardNoMap", "=", "result", ".", "get", "(", "targetTableName", ")", ";", "if", "(", "tableShardNoMap", "==", "null", ")", "{", "tableShardNoMap", "=", "new", "HashMap", "<>", "(", ")", ";", "result", ".", "put", "(", "targetTableName", ",", "tableShardNoMap", ")", ";", "}", "tableShardNoMap", ".", "putAll", "(", "shardNoMap", ")", ";", "}", "}", "return", "result", ";", "}" ]
objects that have no sharding-field value.
[ "objects", "that", "have", "no", "sharding", "-", "field", "value", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java#L263-L279
138,420
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java
BatchObjectUpdater.getAllLinkTargetObjIDs
private Map<String, Set<String>> getAllLinkTargetObjIDs(DBObjectBatch dbObjBatch) { Map<String, Set<String>> resultMap = new HashMap<>(); for (FieldDefinition fieldDef : m_tableDef.getFieldDefinitions()) { if (!fieldDef.isLinkField() || !fieldDef.getInverseTableDef().isSharded()) { continue; } Set<String> targObjIDs = getLinkTargetObjIDs(fieldDef, dbObjBatch); if (targObjIDs.size() == 0) { continue; // no assignments to this sharded link in the batch } String targetTableName = fieldDef.getInverseTableDef().getTableName(); Set<String> tableObjIDs = resultMap.get(targetTableName); if (tableObjIDs == null) { tableObjIDs = new HashSet<>(); resultMap.put(targetTableName, tableObjIDs); } tableObjIDs.addAll(targObjIDs); } return resultMap; }
java
private Map<String, Set<String>> getAllLinkTargetObjIDs(DBObjectBatch dbObjBatch) { Map<String, Set<String>> resultMap = new HashMap<>(); for (FieldDefinition fieldDef : m_tableDef.getFieldDefinitions()) { if (!fieldDef.isLinkField() || !fieldDef.getInverseTableDef().isSharded()) { continue; } Set<String> targObjIDs = getLinkTargetObjIDs(fieldDef, dbObjBatch); if (targObjIDs.size() == 0) { continue; // no assignments to this sharded link in the batch } String targetTableName = fieldDef.getInverseTableDef().getTableName(); Set<String> tableObjIDs = resultMap.get(targetTableName); if (tableObjIDs == null) { tableObjIDs = new HashSet<>(); resultMap.put(targetTableName, tableObjIDs); } tableObjIDs.addAll(targObjIDs); } return resultMap; }
[ "private", "Map", "<", "String", ",", "Set", "<", "String", ">", ">", "getAllLinkTargetObjIDs", "(", "DBObjectBatch", "dbObjBatch", ")", "{", "Map", "<", "String", ",", "Set", "<", "String", ">", ">", "resultMap", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "FieldDefinition", "fieldDef", ":", "m_tableDef", ".", "getFieldDefinitions", "(", ")", ")", "{", "if", "(", "!", "fieldDef", ".", "isLinkField", "(", ")", "||", "!", "fieldDef", ".", "getInverseTableDef", "(", ")", ".", "isSharded", "(", ")", ")", "{", "continue", ";", "}", "Set", "<", "String", ">", "targObjIDs", "=", "getLinkTargetObjIDs", "(", "fieldDef", ",", "dbObjBatch", ")", ";", "if", "(", "targObjIDs", ".", "size", "(", ")", "==", "0", ")", "{", "continue", ";", "// no assignments to this sharded link in the batch\r", "}", "String", "targetTableName", "=", "fieldDef", ".", "getInverseTableDef", "(", ")", ".", "getTableName", "(", ")", ";", "Set", "<", "String", ">", "tableObjIDs", "=", "resultMap", ".", "get", "(", "targetTableName", ")", ";", "if", "(", "tableObjIDs", "==", "null", ")", "{", "tableObjIDs", "=", "new", "HashSet", "<>", "(", ")", ";", "resultMap", ".", "put", "(", "targetTableName", ",", "tableObjIDs", ")", ";", "}", "tableObjIDs", ".", "addAll", "(", "targObjIDs", ")", ";", "}", "return", "resultMap", ";", "}" ]
table in the given batch.
[ "table", "in", "the", "given", "batch", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java#L283-L303
138,421
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java
BatchObjectUpdater.getLinkTargetObjIDs
private Set<String> getLinkTargetObjIDs(FieldDefinition linkDef, DBObjectBatch dbObjBatch) { Set<String> targObjIDs = new HashSet<>(); for (DBObject dbObj : dbObjBatch.getObjects()) { List<String> objIDs = dbObj.getFieldValues(linkDef.getName()); if (objIDs != null) { targObjIDs.addAll(objIDs); } Set<String> removeIDs = dbObj.getRemoveValues(linkDef.getName()); if (removeIDs != null) { targObjIDs.addAll(removeIDs); } } return targObjIDs; }
java
private Set<String> getLinkTargetObjIDs(FieldDefinition linkDef, DBObjectBatch dbObjBatch) { Set<String> targObjIDs = new HashSet<>(); for (DBObject dbObj : dbObjBatch.getObjects()) { List<String> objIDs = dbObj.getFieldValues(linkDef.getName()); if (objIDs != null) { targObjIDs.addAll(objIDs); } Set<String> removeIDs = dbObj.getRemoveValues(linkDef.getName()); if (removeIDs != null) { targObjIDs.addAll(removeIDs); } } return targObjIDs; }
[ "private", "Set", "<", "String", ">", "getLinkTargetObjIDs", "(", "FieldDefinition", "linkDef", ",", "DBObjectBatch", "dbObjBatch", ")", "{", "Set", "<", "String", ">", "targObjIDs", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "DBObject", "dbObj", ":", "dbObjBatch", ".", "getObjects", "(", ")", ")", "{", "List", "<", "String", ">", "objIDs", "=", "dbObj", ".", "getFieldValues", "(", "linkDef", ".", "getName", "(", ")", ")", ";", "if", "(", "objIDs", "!=", "null", ")", "{", "targObjIDs", ".", "addAll", "(", "objIDs", ")", ";", "}", "Set", "<", "String", ">", "removeIDs", "=", "dbObj", ".", "getRemoveValues", "(", "linkDef", ".", "getName", "(", ")", ")", ";", "if", "(", "removeIDs", "!=", "null", ")", "{", "targObjIDs", ".", "addAll", "(", "removeIDs", ")", ";", "}", "}", "return", "targObjIDs", ";", "}" ]
Target object IDs can be in the add or remove set.
[ "Target", "object", "IDs", "can", "be", "in", "the", "add", "or", "remove", "set", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java#L307-L320
138,422
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java
BatchObjectUpdater.getShardNumbers
private Map<String, Integer> getShardNumbers(String tableName, Set<String> targObjIDs) { TableDefinition tableDef = m_tableDef.getAppDef().getTableDef(tableName); FieldDefinition shardField = tableDef.getShardingField(); Map<String, String> shardFieldMap = SpiderService.instance().getObjectScalar(tableDef, targObjIDs, shardField.getName()); Map<String, Integer> shardNoMap = new HashMap<>(); for (String objID : shardFieldMap.keySet()) { Date shardingFieldDate = Utils.dateFromString(shardFieldMap.get(objID)); int shardNo = tableDef.computeShardNumber(shardingFieldDate); shardNoMap.put(objID, shardNo); } return shardNoMap; }
java
private Map<String, Integer> getShardNumbers(String tableName, Set<String> targObjIDs) { TableDefinition tableDef = m_tableDef.getAppDef().getTableDef(tableName); FieldDefinition shardField = tableDef.getShardingField(); Map<String, String> shardFieldMap = SpiderService.instance().getObjectScalar(tableDef, targObjIDs, shardField.getName()); Map<String, Integer> shardNoMap = new HashMap<>(); for (String objID : shardFieldMap.keySet()) { Date shardingFieldDate = Utils.dateFromString(shardFieldMap.get(objID)); int shardNo = tableDef.computeShardNumber(shardingFieldDate); shardNoMap.put(objID, shardNo); } return shardNoMap; }
[ "private", "Map", "<", "String", ",", "Integer", ">", "getShardNumbers", "(", "String", "tableName", ",", "Set", "<", "String", ">", "targObjIDs", ")", "{", "TableDefinition", "tableDef", "=", "m_tableDef", ".", "getAppDef", "(", ")", ".", "getTableDef", "(", "tableName", ")", ";", "FieldDefinition", "shardField", "=", "tableDef", ".", "getShardingField", "(", ")", ";", "Map", "<", "String", ",", "String", ">", "shardFieldMap", "=", "SpiderService", ".", "instance", "(", ")", ".", "getObjectScalar", "(", "tableDef", ",", "targObjIDs", ",", "shardField", ".", "getName", "(", ")", ")", ";", "Map", "<", "String", ",", "Integer", ">", "shardNoMap", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "String", "objID", ":", "shardFieldMap", ".", "keySet", "(", ")", ")", "{", "Date", "shardingFieldDate", "=", "Utils", ".", "dateFromString", "(", "shardFieldMap", ".", "get", "(", "objID", ")", ")", ";", "int", "shardNo", "=", "tableDef", ".", "computeShardNumber", "(", "shardingFieldDate", ")", ";", "shardNoMap", ".", "put", "(", "objID", ",", "shardNo", ")", ";", "}", "return", "shardNoMap", ";", "}" ]
has no value for its sharding-field, leave the map empty for that object ID.
[ "has", "no", "value", "for", "its", "sharding", "-", "field", "leave", "the", "map", "empty", "for", "that", "object", "ID", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/BatchObjectUpdater.java#L324-L336
138,423
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/UserDefinition.java
UserDefinition.parse
public void parse(UNode userNode) { m_userID = userNode.getName(); m_password = null; m_permissions.clear(); for (String childName : userNode.getMemberNames()) { UNode childNode = userNode.getMember(childName); switch (childNode.getName()) { case "password": Utils.require(childNode.isValue(), "'password' must be a simple value: " + childNode); m_password = childNode.getValue(); break; case "hash": Utils.require(childNode.isValue(), "Invalid 'hash' value"); m_hash = childNode.getValue(); break; case "permissions": Utils.require(childNode.isValue(), "'permissions' must be a list of values: " + childNode); String[] permissions = childNode.getValue().split(","); for (String permission : permissions) { String permToken = permission.toUpperCase().trim(); try { m_permissions.add(Permission.valueOf(permToken)); } catch (IllegalArgumentException e) { Utils.require(false, "Unrecognized permission: %s; allowed values are: %s", permToken, Arrays.asList(Permission.values()).toString()); } } break; default: Utils.require(false, "Unknown 'user' property: " + childNode); } } }
java
public void parse(UNode userNode) { m_userID = userNode.getName(); m_password = null; m_permissions.clear(); for (String childName : userNode.getMemberNames()) { UNode childNode = userNode.getMember(childName); switch (childNode.getName()) { case "password": Utils.require(childNode.isValue(), "'password' must be a simple value: " + childNode); m_password = childNode.getValue(); break; case "hash": Utils.require(childNode.isValue(), "Invalid 'hash' value"); m_hash = childNode.getValue(); break; case "permissions": Utils.require(childNode.isValue(), "'permissions' must be a list of values: " + childNode); String[] permissions = childNode.getValue().split(","); for (String permission : permissions) { String permToken = permission.toUpperCase().trim(); try { m_permissions.add(Permission.valueOf(permToken)); } catch (IllegalArgumentException e) { Utils.require(false, "Unrecognized permission: %s; allowed values are: %s", permToken, Arrays.asList(Permission.values()).toString()); } } break; default: Utils.require(false, "Unknown 'user' property: " + childNode); } } }
[ "public", "void", "parse", "(", "UNode", "userNode", ")", "{", "m_userID", "=", "userNode", ".", "getName", "(", ")", ";", "m_password", "=", "null", ";", "m_permissions", ".", "clear", "(", ")", ";", "for", "(", "String", "childName", ":", "userNode", ".", "getMemberNames", "(", ")", ")", "{", "UNode", "childNode", "=", "userNode", ".", "getMember", "(", "childName", ")", ";", "switch", "(", "childNode", ".", "getName", "(", ")", ")", "{", "case", "\"password\"", ":", "Utils", ".", "require", "(", "childNode", ".", "isValue", "(", ")", ",", "\"'password' must be a simple value: \"", "+", "childNode", ")", ";", "m_password", "=", "childNode", ".", "getValue", "(", ")", ";", "break", ";", "case", "\"hash\"", ":", "Utils", ".", "require", "(", "childNode", ".", "isValue", "(", ")", ",", "\"Invalid 'hash' value\"", ")", ";", "m_hash", "=", "childNode", ".", "getValue", "(", ")", ";", "break", ";", "case", "\"permissions\"", ":", "Utils", ".", "require", "(", "childNode", ".", "isValue", "(", ")", ",", "\"'permissions' must be a list of values: \"", "+", "childNode", ")", ";", "String", "[", "]", "permissions", "=", "childNode", ".", "getValue", "(", ")", ".", "split", "(", "\",\"", ")", ";", "for", "(", "String", "permission", ":", "permissions", ")", "{", "String", "permToken", "=", "permission", ".", "toUpperCase", "(", ")", ".", "trim", "(", ")", ";", "try", "{", "m_permissions", ".", "add", "(", "Permission", ".", "valueOf", "(", "permToken", ")", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "Utils", ".", "require", "(", "false", ",", "\"Unrecognized permission: %s; allowed values are: %s\"", ",", "permToken", ",", "Arrays", ".", "asList", "(", "Permission", ".", "values", "(", ")", ")", ".", "toString", "(", ")", ")", ";", "}", "}", "break", ";", "default", ":", "Utils", ".", "require", "(", "false", ",", "\"Unknown 'user' property: \"", "+", "childNode", ")", ";", "}", "}", "}" ]
Parse a user definition expressed as a UNode tree. @param userNode Root {@link UNode}, which must be a "user" node.
[ "Parse", "a", "user", "definition", "expressed", "as", "a", "UNode", "tree", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UserDefinition.java#L171-L207
138,424
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/UserDefinition.java
UserDefinition.toDoc
public UNode toDoc() { UNode userNode = UNode.createMapNode(m_userID, "user"); if (!Utils.isEmpty(m_password)) { userNode.addValueNode("password", m_password, true); } if (!Utils.isEmpty(m_hash)) { userNode.addValueNode("hash", m_hash, true); } String permissions = "ALL"; if (m_permissions.size() > 0) { permissions = Utils.concatenate(m_permissions, ","); } userNode.addValueNode("permissions", permissions); return userNode; }
java
public UNode toDoc() { UNode userNode = UNode.createMapNode(m_userID, "user"); if (!Utils.isEmpty(m_password)) { userNode.addValueNode("password", m_password, true); } if (!Utils.isEmpty(m_hash)) { userNode.addValueNode("hash", m_hash, true); } String permissions = "ALL"; if (m_permissions.size() > 0) { permissions = Utils.concatenate(m_permissions, ","); } userNode.addValueNode("permissions", permissions); return userNode; }
[ "public", "UNode", "toDoc", "(", ")", "{", "UNode", "userNode", "=", "UNode", ".", "createMapNode", "(", "m_userID", ",", "\"user\"", ")", ";", "if", "(", "!", "Utils", ".", "isEmpty", "(", "m_password", ")", ")", "{", "userNode", ".", "addValueNode", "(", "\"password\"", ",", "m_password", ",", "true", ")", ";", "}", "if", "(", "!", "Utils", ".", "isEmpty", "(", "m_hash", ")", ")", "{", "userNode", ".", "addValueNode", "(", "\"hash\"", ",", "m_hash", ",", "true", ")", ";", "}", "String", "permissions", "=", "\"ALL\"", ";", "if", "(", "m_permissions", ".", "size", "(", ")", ">", "0", ")", "{", "permissions", "=", "Utils", ".", "concatenate", "(", "m_permissions", ",", "\",\"", ")", ";", "}", "userNode", ".", "addValueNode", "(", "\"permissions\"", ",", "permissions", ")", ";", "return", "userNode", ";", "}" ]
Serialize this user definition into a UNode tree. @return Root {@link UNode} of the serialized tree.
[ "Serialize", "this", "user", "definition", "into", "a", "UNode", "tree", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/UserDefinition.java#L214-L228
138,425
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/QueryResult.java
QueryResult.parseObject
private DBObject parseObject(TableDefinition tableDef, UNode docNode) { assert tableDef != null; assert docNode != null; assert docNode.getName().equals("doc"); // Create the DBObject that we will return and parse the child nodes into it. DBObject dbObj = new DBObject(); for (UNode childNode: docNode.getMemberList()) { // Extract field name and characterize what we expect. String fieldName = childNode.getName(); FieldDefinition fieldDef = tableDef.getFieldDef(fieldName); boolean isLinkField = fieldDef == null ? false : fieldDef.isLinkField(); boolean isGroupField = fieldDef == null ? false : fieldDef.isGroupField(); boolean isCollection = fieldDef == null ? false : fieldDef.isCollection(); Utils.require(!isGroupField, // we currently don't expect group fields in query results "Unexpected group field in query results: " + fieldName); // Parse value based on what we expect. if (isLinkField) { parseLinkValue(dbObj, childNode, fieldDef); } else if (isCollection) { parseMVScalarValue(dbObj, childNode, fieldDef); } else { // Simple SV scalar value. Utils.require(childNode.isValue(), "Value of an SV scalar must be a value: " + childNode); dbObj.addFieldValue(fieldName, childNode.getValue()); } } // Our object is complete return dbObj; }
java
private DBObject parseObject(TableDefinition tableDef, UNode docNode) { assert tableDef != null; assert docNode != null; assert docNode.getName().equals("doc"); // Create the DBObject that we will return and parse the child nodes into it. DBObject dbObj = new DBObject(); for (UNode childNode: docNode.getMemberList()) { // Extract field name and characterize what we expect. String fieldName = childNode.getName(); FieldDefinition fieldDef = tableDef.getFieldDef(fieldName); boolean isLinkField = fieldDef == null ? false : fieldDef.isLinkField(); boolean isGroupField = fieldDef == null ? false : fieldDef.isGroupField(); boolean isCollection = fieldDef == null ? false : fieldDef.isCollection(); Utils.require(!isGroupField, // we currently don't expect group fields in query results "Unexpected group field in query results: " + fieldName); // Parse value based on what we expect. if (isLinkField) { parseLinkValue(dbObj, childNode, fieldDef); } else if (isCollection) { parseMVScalarValue(dbObj, childNode, fieldDef); } else { // Simple SV scalar value. Utils.require(childNode.isValue(), "Value of an SV scalar must be a value: " + childNode); dbObj.addFieldValue(fieldName, childNode.getValue()); } } // Our object is complete return dbObj; }
[ "private", "DBObject", "parseObject", "(", "TableDefinition", "tableDef", ",", "UNode", "docNode", ")", "{", "assert", "tableDef", "!=", "null", ";", "assert", "docNode", "!=", "null", ";", "assert", "docNode", ".", "getName", "(", ")", ".", "equals", "(", "\"doc\"", ")", ";", "// Create the DBObject that we will return and parse the child nodes into it.\r", "DBObject", "dbObj", "=", "new", "DBObject", "(", ")", ";", "for", "(", "UNode", "childNode", ":", "docNode", ".", "getMemberList", "(", ")", ")", "{", "// Extract field name and characterize what we expect.\r", "String", "fieldName", "=", "childNode", ".", "getName", "(", ")", ";", "FieldDefinition", "fieldDef", "=", "tableDef", ".", "getFieldDef", "(", "fieldName", ")", ";", "boolean", "isLinkField", "=", "fieldDef", "==", "null", "?", "false", ":", "fieldDef", ".", "isLinkField", "(", ")", ";", "boolean", "isGroupField", "=", "fieldDef", "==", "null", "?", "false", ":", "fieldDef", ".", "isGroupField", "(", ")", ";", "boolean", "isCollection", "=", "fieldDef", "==", "null", "?", "false", ":", "fieldDef", ".", "isCollection", "(", ")", ";", "Utils", ".", "require", "(", "!", "isGroupField", ",", "// we currently don't expect group fields in query results\r", "\"Unexpected group field in query results: \"", "+", "fieldName", ")", ";", "// Parse value based on what we expect.\r", "if", "(", "isLinkField", ")", "{", "parseLinkValue", "(", "dbObj", ",", "childNode", ",", "fieldDef", ")", ";", "}", "else", "if", "(", "isCollection", ")", "{", "parseMVScalarValue", "(", "dbObj", ",", "childNode", ",", "fieldDef", ")", ";", "}", "else", "{", "// Simple SV scalar value.\r", "Utils", ".", "require", "(", "childNode", ".", "isValue", "(", ")", ",", "\"Value of an SV scalar must be a value: \"", "+", "childNode", ")", ";", "dbObj", ".", "addFieldValue", "(", "fieldName", ",", "childNode", ".", "getValue", "(", ")", ")", ";", "}", "}", "// Our object is complete\r", "return", "dbObj", ";", "}" ]
than the perspective table of the query.
[ "than", "the", "perspective", "table", "of", "the", "query", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/QueryResult.java#L221-L253
138,426
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/QueryResult.java
QueryResult.parseLinkValue
private void parseLinkValue(DBObject owningObj, UNode linkNode, FieldDefinition linkFieldDef) { // Prerequisites: assert owningObj != null; assert linkNode != null; assert linkFieldDef != null; assert linkFieldDef.isLinkField(); TableDefinition tableDef = linkFieldDef.getTableDef(); // Value should be an array, though it could be a map with one child. Utils.require(linkNode.isCollection(), "Value of link field should be a collection: " + linkNode); // Iterate through child nodes. TableDefinition extentTableDef = tableDef.getAppDef().getTableDef(linkFieldDef.getLinkExtent()); for (UNode childNode : linkNode.getMemberList()) { // Ensure this element is "doc" node. Utils.require(childNode.getName().equals("doc"), "link field array values should be 'doc' objects: " + childNode); // Recurse and build a DBObject from the doc node. DBObject linkedObject = parseObject(extentTableDef, childNode); // Add the linked object to the cache and add its object ID to the set. String objID = linkedObject.getObjectID(); cacheLinkedObject(owningObj.getObjectID(), linkFieldDef.getName(), linkedObject); owningObj.addFieldValues(linkFieldDef.getName(), Arrays.asList(objID)); } }
java
private void parseLinkValue(DBObject owningObj, UNode linkNode, FieldDefinition linkFieldDef) { // Prerequisites: assert owningObj != null; assert linkNode != null; assert linkFieldDef != null; assert linkFieldDef.isLinkField(); TableDefinition tableDef = linkFieldDef.getTableDef(); // Value should be an array, though it could be a map with one child. Utils.require(linkNode.isCollection(), "Value of link field should be a collection: " + linkNode); // Iterate through child nodes. TableDefinition extentTableDef = tableDef.getAppDef().getTableDef(linkFieldDef.getLinkExtent()); for (UNode childNode : linkNode.getMemberList()) { // Ensure this element is "doc" node. Utils.require(childNode.getName().equals("doc"), "link field array values should be 'doc' objects: " + childNode); // Recurse and build a DBObject from the doc node. DBObject linkedObject = parseObject(extentTableDef, childNode); // Add the linked object to the cache and add its object ID to the set. String objID = linkedObject.getObjectID(); cacheLinkedObject(owningObj.getObjectID(), linkFieldDef.getName(), linkedObject); owningObj.addFieldValues(linkFieldDef.getName(), Arrays.asList(objID)); } }
[ "private", "void", "parseLinkValue", "(", "DBObject", "owningObj", ",", "UNode", "linkNode", ",", "FieldDefinition", "linkFieldDef", ")", "{", "// Prerequisites:\r", "assert", "owningObj", "!=", "null", ";", "assert", "linkNode", "!=", "null", ";", "assert", "linkFieldDef", "!=", "null", ";", "assert", "linkFieldDef", ".", "isLinkField", "(", ")", ";", "TableDefinition", "tableDef", "=", "linkFieldDef", ".", "getTableDef", "(", ")", ";", "// Value should be an array, though it could be a map with one child.\r", "Utils", ".", "require", "(", "linkNode", ".", "isCollection", "(", ")", ",", "\"Value of link field should be a collection: \"", "+", "linkNode", ")", ";", "// Iterate through child nodes.\r", "TableDefinition", "extentTableDef", "=", "tableDef", ".", "getAppDef", "(", ")", ".", "getTableDef", "(", "linkFieldDef", ".", "getLinkExtent", "(", ")", ")", ";", "for", "(", "UNode", "childNode", ":", "linkNode", ".", "getMemberList", "(", ")", ")", "{", "// Ensure this element is \"doc\" node.\r", "Utils", ".", "require", "(", "childNode", ".", "getName", "(", ")", ".", "equals", "(", "\"doc\"", ")", ",", "\"link field array values should be 'doc' objects: \"", "+", "childNode", ")", ";", "// Recurse and build a DBObject from the doc node.\r", "DBObject", "linkedObject", "=", "parseObject", "(", "extentTableDef", ",", "childNode", ")", ";", "// Add the linked object to the cache and add its object ID to the set.\r", "String", "objID", "=", "linkedObject", ".", "getObjectID", "(", ")", ";", "cacheLinkedObject", "(", "owningObj", ".", "getObjectID", "(", ")", ",", "linkFieldDef", ".", "getName", "(", ")", ",", "linkedObject", ")", ";", "owningObj", ".", "addFieldValues", "(", "linkFieldDef", ".", "getName", "(", ")", ",", "Arrays", ".", "asList", "(", "objID", ")", ")", ";", "}", "}" ]
object and add it to the linked object cache for the owning object and link.
[ "object", "and", "add", "it", "to", "the", "linked", "object", "cache", "for", "the", "owning", "object", "and", "link", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/QueryResult.java#L273-L302
138,427
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/QueryResult.java
QueryResult.cacheLinkedObject
private void cacheLinkedObject(String owningObjID, String linkFieldName, DBObject linkedObject) { // Find or create map for the owning object. Map<String, Map<String, DBObject>> objMap = m_linkedObjectMap.get(owningObjID); if (objMap == null) { objMap = new HashMap<String, Map<String, DBObject>>(); m_linkedObjectMap.put(owningObjID, objMap); } // Find or create map for the link field. Map<String, DBObject> linkMap = objMap.get(linkFieldName); if (linkMap == null) { linkMap = new HashMap<String, DBObject>(); objMap.put(linkFieldName, linkMap); } // Add the object to the link map. linkMap.put(linkedObject.getObjectID(), linkedObject); }
java
private void cacheLinkedObject(String owningObjID, String linkFieldName, DBObject linkedObject) { // Find or create map for the owning object. Map<String, Map<String, DBObject>> objMap = m_linkedObjectMap.get(owningObjID); if (objMap == null) { objMap = new HashMap<String, Map<String, DBObject>>(); m_linkedObjectMap.put(owningObjID, objMap); } // Find or create map for the link field. Map<String, DBObject> linkMap = objMap.get(linkFieldName); if (linkMap == null) { linkMap = new HashMap<String, DBObject>(); objMap.put(linkFieldName, linkMap); } // Add the object to the link map. linkMap.put(linkedObject.getObjectID(), linkedObject); }
[ "private", "void", "cacheLinkedObject", "(", "String", "owningObjID", ",", "String", "linkFieldName", ",", "DBObject", "linkedObject", ")", "{", "// Find or create map for the owning object.\r", "Map", "<", "String", ",", "Map", "<", "String", ",", "DBObject", ">", ">", "objMap", "=", "m_linkedObjectMap", ".", "get", "(", "owningObjID", ")", ";", "if", "(", "objMap", "==", "null", ")", "{", "objMap", "=", "new", "HashMap", "<", "String", ",", "Map", "<", "String", ",", "DBObject", ">", ">", "(", ")", ";", "m_linkedObjectMap", ".", "put", "(", "owningObjID", ",", "objMap", ")", ";", "}", "// Find or create map for the link field.\r", "Map", "<", "String", ",", "DBObject", ">", "linkMap", "=", "objMap", ".", "get", "(", "linkFieldName", ")", ";", "if", "(", "linkMap", "==", "null", ")", "{", "linkMap", "=", "new", "HashMap", "<", "String", ",", "DBObject", ">", "(", ")", ";", "objMap", ".", "put", "(", "linkFieldName", ",", "linkMap", ")", ";", "}", "// Add the object to the link map.\r", "linkMap", ".", "put", "(", "linkedObject", ".", "getObjectID", "(", ")", ",", "linkedObject", ")", ";", "}" ]
link field name.
[ "link", "field", "name", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/QueryResult.java#L334-L353
138,428
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/rest/RESTParameter.java
RESTParameter.fromUNode
public static RESTParameter fromUNode(UNode paramNode) { RESTParameter param = new RESTParameter(); String name = paramNode.getName(); Utils.require(!Utils.isEmpty(name), "Missing parameter name: " + paramNode); param.setName(name); for (UNode childNode : paramNode.getMemberList()) { switch (childNode.getName()) { case "_required": param.setRequired(Boolean.parseBoolean(childNode.getValue())); break; case "_type": param.setType(childNode.getValue()); break; default: // Ignore system properties we don't recognize. if (childNode.getName().charAt(0) != '_') { param.add(RESTParameter.fromUNode(childNode)); } break; } } return param; }
java
public static RESTParameter fromUNode(UNode paramNode) { RESTParameter param = new RESTParameter(); String name = paramNode.getName(); Utils.require(!Utils.isEmpty(name), "Missing parameter name: " + paramNode); param.setName(name); for (UNode childNode : paramNode.getMemberList()) { switch (childNode.getName()) { case "_required": param.setRequired(Boolean.parseBoolean(childNode.getValue())); break; case "_type": param.setType(childNode.getValue()); break; default: // Ignore system properties we don't recognize. if (childNode.getName().charAt(0) != '_') { param.add(RESTParameter.fromUNode(childNode)); } break; } } return param; }
[ "public", "static", "RESTParameter", "fromUNode", "(", "UNode", "paramNode", ")", "{", "RESTParameter", "param", "=", "new", "RESTParameter", "(", ")", ";", "String", "name", "=", "paramNode", ".", "getName", "(", ")", ";", "Utils", ".", "require", "(", "!", "Utils", ".", "isEmpty", "(", "name", ")", ",", "\"Missing parameter name: \"", "+", "paramNode", ")", ";", "param", ".", "setName", "(", "name", ")", ";", "for", "(", "UNode", "childNode", ":", "paramNode", ".", "getMemberList", "(", ")", ")", "{", "switch", "(", "childNode", ".", "getName", "(", ")", ")", "{", "case", "\"_required\"", ":", "param", ".", "setRequired", "(", "Boolean", ".", "parseBoolean", "(", "childNode", ".", "getValue", "(", ")", ")", ")", ";", "break", ";", "case", "\"_type\"", ":", "param", ".", "setType", "(", "childNode", ".", "getValue", "(", ")", ")", ";", "break", ";", "default", ":", "// Ignore system properties we don't recognize.", "if", "(", "childNode", ".", "getName", "(", ")", ".", "charAt", "(", "0", ")", "!=", "'", "'", ")", "{", "param", ".", "add", "(", "RESTParameter", ".", "fromUNode", "(", "childNode", ")", ")", ";", "}", "break", ";", "}", "}", "return", "param", ";", "}" ]
Create a new RESTParameter object from the given UNode tree. @param paramNode Root {@link UNode} of a parameter description. @return New RESTParameter created from UNode tree.
[ "Create", "a", "new", "RESTParameter", "object", "from", "the", "given", "UNode", "tree", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/rest/RESTParameter.java#L121-L144
138,429
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/rest/RESTParameter.java
RESTParameter.toDoc
public UNode toDoc() { UNode paramNode = UNode.createMapNode(m_name); if (!Utils.isEmpty(m_type)) { paramNode.addValueNode("_type", m_type); } if (m_isRequired) { paramNode.addValueNode("_required", Boolean.toString(m_isRequired)); } if (m_parameters.size() > 0) { for (RESTParameter param : m_parameters) { paramNode.addChildNode(param.toDoc()); } } return paramNode; }
java
public UNode toDoc() { UNode paramNode = UNode.createMapNode(m_name); if (!Utils.isEmpty(m_type)) { paramNode.addValueNode("_type", m_type); } if (m_isRequired) { paramNode.addValueNode("_required", Boolean.toString(m_isRequired)); } if (m_parameters.size() > 0) { for (RESTParameter param : m_parameters) { paramNode.addChildNode(param.toDoc()); } } return paramNode; }
[ "public", "UNode", "toDoc", "(", ")", "{", "UNode", "paramNode", "=", "UNode", ".", "createMapNode", "(", "m_name", ")", ";", "if", "(", "!", "Utils", ".", "isEmpty", "(", "m_type", ")", ")", "{", "paramNode", ".", "addValueNode", "(", "\"_type\"", ",", "m_type", ")", ";", "}", "if", "(", "m_isRequired", ")", "{", "paramNode", ".", "addValueNode", "(", "\"_required\"", ",", "Boolean", ".", "toString", "(", "m_isRequired", ")", ")", ";", "}", "if", "(", "m_parameters", ".", "size", "(", ")", ">", "0", ")", "{", "for", "(", "RESTParameter", "param", ":", "m_parameters", ")", "{", "paramNode", ".", "addChildNode", "(", "param", ".", "toDoc", "(", ")", ")", ";", "}", "}", "return", "paramNode", ";", "}" ]
Serialize this RESTParameter into a UNode tree and return the root node. @return Root {@link UNode} of the serialized tree.
[ "Serialize", "this", "RESTParameter", "into", "a", "UNode", "tree", "and", "return", "the", "root", "node", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/rest/RESTParameter.java#L151-L165
138,430
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/rest/RESTParameter.java
RESTParameter.add
public RESTParameter add(RESTParameter childParam) { Utils.require(!Utils.isEmpty(childParam.getName()), "Child parameter name cannot be empty"); m_parameters.add(childParam); return this; }
java
public RESTParameter add(RESTParameter childParam) { Utils.require(!Utils.isEmpty(childParam.getName()), "Child parameter name cannot be empty"); m_parameters.add(childParam); return this; }
[ "public", "RESTParameter", "add", "(", "RESTParameter", "childParam", ")", "{", "Utils", ".", "require", "(", "!", "Utils", ".", "isEmpty", "(", "childParam", ".", "getName", "(", ")", ")", ",", "\"Child parameter name cannot be empty\"", ")", ";", "m_parameters", ".", "add", "(", "childParam", ")", ";", "return", "this", ";", "}" ]
Add the given RESTParameter as a child of this parameter. This parameter is returned to support builder syntax. @param childParam New child RESTParameter of this parameter. The child parameter name must be unique. @return This parameter object.
[ "Add", "the", "given", "RESTParameter", "as", "a", "child", "of", "this", "parameter", ".", "This", "parameter", "is", "returned", "to", "support", "builder", "syntax", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/rest/RESTParameter.java#L187-L191
138,431
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/rest/RESTParameter.java
RESTParameter.add
public RESTParameter add(String childParamName, String childParamType) { return add(new RESTParameter(childParamName, childParamType)); }
java
public RESTParameter add(String childParamName, String childParamType) { return add(new RESTParameter(childParamName, childParamType)); }
[ "public", "RESTParameter", "add", "(", "String", "childParamName", ",", "String", "childParamType", ")", "{", "return", "add", "(", "new", "RESTParameter", "(", "childParamName", ",", "childParamType", ")", ")", ";", "}" ]
Add a new child parameter with the given name and type to this parameter. The child parameter will not be marked as required. This parameter is returned to support builder syntax. @param childParamName Name of new child parameter. @param childParamType Type of new child parameter. @return This parameter object.
[ "Add", "a", "new", "child", "parameter", "with", "the", "given", "name", "and", "type", "to", "this", "parameter", ".", "The", "child", "parameter", "will", "not", "be", "marked", "as", "required", ".", "This", "parameter", "is", "returned", "to", "support", "builder", "syntax", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/rest/RESTParameter.java#L202-L204
138,432
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/ThriftService.java
ThriftService.getDBConnection
DBConn getDBConnection() { DBConn dbConn = null; synchronized (m_dbConns) { if (m_dbConns.size() > 0) { dbConn = m_dbConns.poll(); } else { dbConn = createAndConnectConn(m_keyspace); } } return dbConn; }
java
DBConn getDBConnection() { DBConn dbConn = null; synchronized (m_dbConns) { if (m_dbConns.size() > 0) { dbConn = m_dbConns.poll(); } else { dbConn = createAndConnectConn(m_keyspace); } } return dbConn; }
[ "DBConn", "getDBConnection", "(", ")", "{", "DBConn", "dbConn", "=", "null", ";", "synchronized", "(", "m_dbConns", ")", "{", "if", "(", "m_dbConns", ".", "size", "(", ")", ">", "0", ")", "{", "dbConn", "=", "m_dbConns", ".", "poll", "(", ")", ";", "}", "else", "{", "dbConn", "=", "createAndConnectConn", "(", "m_keyspace", ")", ";", "}", "}", "return", "dbConn", ";", "}" ]
Get an available database connection from the pool, creating a new one if needed.
[ "Get", "an", "available", "database", "connection", "from", "the", "pool", "creating", "a", "new", "one", "if", "needed", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/ThriftService.java#L224-L234
138,433
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/ThriftService.java
ThriftService.connectDBConn
void connectDBConn(DBConn dbConn) throws DBNotAvailableException, RuntimeException { // If we're using failover hosts, see if it's time to try primary hosts again. if (m_bUseSecondaryHosts && (System.currentTimeMillis() - m_lastPrimaryHostCheckTimeMillis) > getParamInt("primary_host_recheck_millis", 60000)) { m_bUseSecondaryHosts = false; } // Try all primary hosts first if possible. DBNotAvailableException lastException = null; if (!m_bUseSecondaryHosts) { String[] dbHosts = getParamString("dbhost").split(","); for (int attempt = 1; !dbConn.isOpen() && attempt <= dbHosts.length; attempt++) { try { dbConn.connect(chooseHost(dbHosts)); } catch (DBNotAvailableException ex) { lastException = ex; } catch (RuntimeException ex) { throw ex; // bad keyspace; abort connection attempts } } m_lastPrimaryHostCheckTimeMillis = System.currentTimeMillis(); } // Try secondary hosts if needed and if configured. if (!dbConn.isOpen() && !Utils.isEmpty(getParamString("secondary_dbhost"))) { if (!m_bUseSecondaryHosts) { m_logger.info("All connections to 'dbhost' failed; trying 'secondary_dbhost'"); } String[] dbHosts = getParamString("secondary_dbhost").split(","); for (int attempt = 1; !dbConn.isOpen() && attempt <= dbHosts.length; attempt++) { try { dbConn.connect(chooseHost(dbHosts)); } catch (DBNotAvailableException e) { lastException = e; } catch (RuntimeException ex) { throw ex; // bad keyspace; abort connection attempts } } if (dbConn.isOpen()) { m_bUseSecondaryHosts = true; // stick with secondary hosts for now. } } if (!dbConn.isOpen()) { m_logger.error("All Thrift connection attempts failed.", lastException); throw lastException; } }
java
void connectDBConn(DBConn dbConn) throws DBNotAvailableException, RuntimeException { // If we're using failover hosts, see if it's time to try primary hosts again. if (m_bUseSecondaryHosts && (System.currentTimeMillis() - m_lastPrimaryHostCheckTimeMillis) > getParamInt("primary_host_recheck_millis", 60000)) { m_bUseSecondaryHosts = false; } // Try all primary hosts first if possible. DBNotAvailableException lastException = null; if (!m_bUseSecondaryHosts) { String[] dbHosts = getParamString("dbhost").split(","); for (int attempt = 1; !dbConn.isOpen() && attempt <= dbHosts.length; attempt++) { try { dbConn.connect(chooseHost(dbHosts)); } catch (DBNotAvailableException ex) { lastException = ex; } catch (RuntimeException ex) { throw ex; // bad keyspace; abort connection attempts } } m_lastPrimaryHostCheckTimeMillis = System.currentTimeMillis(); } // Try secondary hosts if needed and if configured. if (!dbConn.isOpen() && !Utils.isEmpty(getParamString("secondary_dbhost"))) { if (!m_bUseSecondaryHosts) { m_logger.info("All connections to 'dbhost' failed; trying 'secondary_dbhost'"); } String[] dbHosts = getParamString("secondary_dbhost").split(","); for (int attempt = 1; !dbConn.isOpen() && attempt <= dbHosts.length; attempt++) { try { dbConn.connect(chooseHost(dbHosts)); } catch (DBNotAvailableException e) { lastException = e; } catch (RuntimeException ex) { throw ex; // bad keyspace; abort connection attempts } } if (dbConn.isOpen()) { m_bUseSecondaryHosts = true; // stick with secondary hosts for now. } } if (!dbConn.isOpen()) { m_logger.error("All Thrift connection attempts failed.", lastException); throw lastException; } }
[ "void", "connectDBConn", "(", "DBConn", "dbConn", ")", "throws", "DBNotAvailableException", ",", "RuntimeException", "{", "// If we're using failover hosts, see if it's time to try primary hosts again.", "if", "(", "m_bUseSecondaryHosts", "&&", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "m_lastPrimaryHostCheckTimeMillis", ")", ">", "getParamInt", "(", "\"primary_host_recheck_millis\"", ",", "60000", ")", ")", "{", "m_bUseSecondaryHosts", "=", "false", ";", "}", "// Try all primary hosts first if possible.", "DBNotAvailableException", "lastException", "=", "null", ";", "if", "(", "!", "m_bUseSecondaryHosts", ")", "{", "String", "[", "]", "dbHosts", "=", "getParamString", "(", "\"dbhost\"", ")", ".", "split", "(", "\",\"", ")", ";", "for", "(", "int", "attempt", "=", "1", ";", "!", "dbConn", ".", "isOpen", "(", ")", "&&", "attempt", "<=", "dbHosts", ".", "length", ";", "attempt", "++", ")", "{", "try", "{", "dbConn", ".", "connect", "(", "chooseHost", "(", "dbHosts", ")", ")", ";", "}", "catch", "(", "DBNotAvailableException", "ex", ")", "{", "lastException", "=", "ex", ";", "}", "catch", "(", "RuntimeException", "ex", ")", "{", "throw", "ex", ";", "// bad keyspace; abort connection attempts", "}", "}", "m_lastPrimaryHostCheckTimeMillis", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "}", "// Try secondary hosts if needed and if configured.", "if", "(", "!", "dbConn", ".", "isOpen", "(", ")", "&&", "!", "Utils", ".", "isEmpty", "(", "getParamString", "(", "\"secondary_dbhost\"", ")", ")", ")", "{", "if", "(", "!", "m_bUseSecondaryHosts", ")", "{", "m_logger", ".", "info", "(", "\"All connections to 'dbhost' failed; trying 'secondary_dbhost'\"", ")", ";", "}", "String", "[", "]", "dbHosts", "=", "getParamString", "(", "\"secondary_dbhost\"", ")", ".", "split", "(", "\",\"", ")", ";", "for", "(", "int", "attempt", "=", "1", ";", "!", "dbConn", ".", "isOpen", "(", ")", "&&", "attempt", "<=", "dbHosts", ".", "length", ";", "attempt", "++", ")", "{", "try", "{", "dbConn", ".", "connect", "(", "chooseHost", "(", "dbHosts", ")", ")", ";", "}", "catch", "(", "DBNotAvailableException", "e", ")", "{", "lastException", "=", "e", ";", "}", "catch", "(", "RuntimeException", "ex", ")", "{", "throw", "ex", ";", "// bad keyspace; abort connection attempts", "}", "}", "if", "(", "dbConn", ".", "isOpen", "(", ")", ")", "{", "m_bUseSecondaryHosts", "=", "true", ";", "// stick with secondary hosts for now.", "}", "}", "if", "(", "!", "dbConn", ".", "isOpen", "(", ")", ")", "{", "m_logger", ".", "error", "(", "\"All Thrift connection attempts failed.\"", ",", "lastException", ")", ";", "throw", "lastException", ";", "}", "}" ]
configured keyspace is not available, a RuntimeException is thrown.
[ "configured", "keyspace", "is", "not", "available", "a", "RuntimeException", "is", "thrown", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/ThriftService.java#L264-L311
138,434
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/ThriftService.java
ThriftService.createAndConnectConn
private DBConn createAndConnectConn(String keyspace) throws DBNotAvailableException, RuntimeException { DBConn dbConn = new DBConn(this, keyspace); connectDBConn(dbConn); return dbConn; }
java
private DBConn createAndConnectConn(String keyspace) throws DBNotAvailableException, RuntimeException { DBConn dbConn = new DBConn(this, keyspace); connectDBConn(dbConn); return dbConn; }
[ "private", "DBConn", "createAndConnectConn", "(", "String", "keyspace", ")", "throws", "DBNotAvailableException", ",", "RuntimeException", "{", "DBConn", "dbConn", "=", "new", "DBConn", "(", "this", ",", "keyspace", ")", ";", "connectDBConn", "(", "dbConn", ")", ";", "return", "dbConn", ";", "}" ]
the given keyspace does not exist.
[ "the", "given", "keyspace", "does", "not", "exist", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/ThriftService.java#L319-L323
138,435
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/ThriftService.java
ThriftService.chooseHost
private String chooseHost(String[] dbHosts) { String host = null; synchronized (m_lastHostLock) { if (dbHosts.length == 1) { host = dbHosts[0]; } else if (!Utils.isEmpty(m_lastHost)) { for (int index = 0; host == null && index < dbHosts.length; index++) { if (dbHosts[index].equals(m_lastHost)) { host = dbHosts[(++index) % dbHosts.length]; } } } if (host == null) { host = dbHosts[new Random().nextInt(dbHosts.length)]; } m_lastHost = host; } return host; }
java
private String chooseHost(String[] dbHosts) { String host = null; synchronized (m_lastHostLock) { if (dbHosts.length == 1) { host = dbHosts[0]; } else if (!Utils.isEmpty(m_lastHost)) { for (int index = 0; host == null && index < dbHosts.length; index++) { if (dbHosts[index].equals(m_lastHost)) { host = dbHosts[(++index) % dbHosts.length]; } } } if (host == null) { host = dbHosts[new Random().nextInt(dbHosts.length)]; } m_lastHost = host; } return host; }
[ "private", "String", "chooseHost", "(", "String", "[", "]", "dbHosts", ")", "{", "String", "host", "=", "null", ";", "synchronized", "(", "m_lastHostLock", ")", "{", "if", "(", "dbHosts", ".", "length", "==", "1", ")", "{", "host", "=", "dbHosts", "[", "0", "]", ";", "}", "else", "if", "(", "!", "Utils", ".", "isEmpty", "(", "m_lastHost", ")", ")", "{", "for", "(", "int", "index", "=", "0", ";", "host", "==", "null", "&&", "index", "<", "dbHosts", ".", "length", ";", "index", "++", ")", "{", "if", "(", "dbHosts", "[", "index", "]", ".", "equals", "(", "m_lastHost", ")", ")", "{", "host", "=", "dbHosts", "[", "(", "++", "index", ")", "%", "dbHosts", ".", "length", "]", ";", "}", "}", "}", "if", "(", "host", "==", "null", ")", "{", "host", "=", "dbHosts", "[", "new", "Random", "(", ")", ".", "nextInt", "(", "dbHosts", ".", "length", ")", "]", ";", "}", "m_lastHost", "=", "host", ";", "}", "return", "host", ";", "}" ]
Choose the next Cassandra host name in the list or a random one.
[ "Choose", "the", "next", "Cassandra", "host", "name", "in", "the", "list", "or", "a", "random", "one", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/ThriftService.java#L326-L344
138,436
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java
LinkFieldUpdater.deleteValuesForField
@Override public void deleteValuesForField() { for (String targetObjID : m_dbObj.getFieldValues(m_fieldName)) { deleteLinkInverseValue(targetObjID); } if (m_linkDef.isSharded()) { deleteShardedLinkTermRows(); } }
java
@Override public void deleteValuesForField() { for (String targetObjID : m_dbObj.getFieldValues(m_fieldName)) { deleteLinkInverseValue(targetObjID); } if (m_linkDef.isSharded()) { deleteShardedLinkTermRows(); } }
[ "@", "Override", "public", "void", "deleteValuesForField", "(", ")", "{", "for", "(", "String", "targetObjID", ":", "m_dbObj", ".", "getFieldValues", "(", "m_fieldName", ")", ")", "{", "deleteLinkInverseValue", "(", "targetObjID", ")", ";", "}", "if", "(", "m_linkDef", ".", "isSharded", "(", ")", ")", "{", "deleteShardedLinkTermRows", "(", ")", ";", "}", "}" ]
Clean-up inverses and sharded term rows.
[ "Clean", "-", "up", "inverses", "and", "sharded", "term", "rows", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java#L72-L80
138,437
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java
LinkFieldUpdater.addInverseLinkValue
private void addInverseLinkValue(String targetObjID) { int shardNo = m_tableDef.getShardNumber(m_dbObj); if (shardNo > 0 && m_invLinkDef.isSharded()) { m_dbTran.addShardedLinkValue(targetObjID, m_invLinkDef, m_dbObj.getObjectID(), shardNo); } else { m_dbTran.addLinkValue(targetObjID, m_invLinkDef, m_dbObj.getObjectID()); } // Add the "_ID" field to the inverse object's primary record. m_dbTran.addIDValueColumn(m_invTableDef, targetObjID); // Add the target object's ID to its all-objects row. int targetShardNo = getTargetObjectShardNumber(targetObjID); m_dbTran.addAllObjectsColumn(m_invTableDef, targetObjID, targetShardNo); }
java
private void addInverseLinkValue(String targetObjID) { int shardNo = m_tableDef.getShardNumber(m_dbObj); if (shardNo > 0 && m_invLinkDef.isSharded()) { m_dbTran.addShardedLinkValue(targetObjID, m_invLinkDef, m_dbObj.getObjectID(), shardNo); } else { m_dbTran.addLinkValue(targetObjID, m_invLinkDef, m_dbObj.getObjectID()); } // Add the "_ID" field to the inverse object's primary record. m_dbTran.addIDValueColumn(m_invTableDef, targetObjID); // Add the target object's ID to its all-objects row. int targetShardNo = getTargetObjectShardNumber(targetObjID); m_dbTran.addAllObjectsColumn(m_invTableDef, targetObjID, targetShardNo); }
[ "private", "void", "addInverseLinkValue", "(", "String", "targetObjID", ")", "{", "int", "shardNo", "=", "m_tableDef", ".", "getShardNumber", "(", "m_dbObj", ")", ";", "if", "(", "shardNo", ">", "0", "&&", "m_invLinkDef", ".", "isSharded", "(", ")", ")", "{", "m_dbTran", ".", "addShardedLinkValue", "(", "targetObjID", ",", "m_invLinkDef", ",", "m_dbObj", ".", "getObjectID", "(", ")", ",", "shardNo", ")", ";", "}", "else", "{", "m_dbTran", ".", "addLinkValue", "(", "targetObjID", ",", "m_invLinkDef", ",", "m_dbObj", ".", "getObjectID", "(", ")", ")", ";", "}", "// Add the \"_ID\" field to the inverse object's primary record.\r", "m_dbTran", ".", "addIDValueColumn", "(", "m_invTableDef", ",", "targetObjID", ")", ";", "// Add the target object's ID to its all-objects row.\r", "int", "targetShardNo", "=", "getTargetObjectShardNumber", "(", "targetObjID", ")", ";", "m_dbTran", ".", "addAllObjectsColumn", "(", "m_invTableDef", ",", "targetObjID", ",", "targetShardNo", ")", ";", "}" ]
for the inverse reference.
[ "for", "the", "inverse", "reference", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java#L86-L100
138,438
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java
LinkFieldUpdater.addLinkValue
private void addLinkValue(String targetObjID) { int targetShardNo = getTargetObjectShardNumber(targetObjID); if (targetShardNo > 0 && m_linkDef.isSharded()) { m_dbTran.addShardedLinkValue(m_dbObj.getObjectID(), m_linkDef, targetObjID, targetShardNo); } else { m_dbTran.addLinkValue(m_dbObj.getObjectID(), m_linkDef, targetObjID); } addInverseLinkValue(targetObjID); }
java
private void addLinkValue(String targetObjID) { int targetShardNo = getTargetObjectShardNumber(targetObjID); if (targetShardNo > 0 && m_linkDef.isSharded()) { m_dbTran.addShardedLinkValue(m_dbObj.getObjectID(), m_linkDef, targetObjID, targetShardNo); } else { m_dbTran.addLinkValue(m_dbObj.getObjectID(), m_linkDef, targetObjID); } addInverseLinkValue(targetObjID); }
[ "private", "void", "addLinkValue", "(", "String", "targetObjID", ")", "{", "int", "targetShardNo", "=", "getTargetObjectShardNumber", "(", "targetObjID", ")", ";", "if", "(", "targetShardNo", ">", "0", "&&", "m_linkDef", ".", "isSharded", "(", ")", ")", "{", "m_dbTran", ".", "addShardedLinkValue", "(", "m_dbObj", ".", "getObjectID", "(", ")", ",", "m_linkDef", ",", "targetObjID", ",", "targetShardNo", ")", ";", "}", "else", "{", "m_dbTran", ".", "addLinkValue", "(", "m_dbObj", ".", "getObjectID", "(", ")", ",", "m_linkDef", ",", "targetObjID", ")", ";", "}", "addInverseLinkValue", "(", "targetObjID", ")", ";", "}" ]
Add mutations to add a reference via our link to the given target object ID.
[ "Add", "mutations", "to", "add", "a", "reference", "via", "our", "link", "to", "the", "given", "target", "object", "ID", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java#L103-L111
138,439
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java
LinkFieldUpdater.getTargetObjectShardNumber
private int getTargetObjectShardNumber(String targetObjID) { int targetShardNo = 0; if (m_invTableDef.isSharded() && m_targetObjShardNos != null && m_targetObjShardNos.containsKey(targetObjID)) { targetShardNo = m_targetObjShardNos.get(targetObjID); } return targetShardNo; }
java
private int getTargetObjectShardNumber(String targetObjID) { int targetShardNo = 0; if (m_invTableDef.isSharded() && m_targetObjShardNos != null && m_targetObjShardNos.containsKey(targetObjID)) { targetShardNo = m_targetObjShardNos.get(targetObjID); } return targetShardNo; }
[ "private", "int", "getTargetObjectShardNumber", "(", "String", "targetObjID", ")", "{", "int", "targetShardNo", "=", "0", ";", "if", "(", "m_invTableDef", ".", "isSharded", "(", ")", "&&", "m_targetObjShardNos", "!=", "null", "&&", "m_targetObjShardNos", ".", "containsKey", "(", "targetObjID", ")", ")", "{", "targetShardNo", "=", "m_targetObjShardNos", ".", "get", "(", "targetObjID", ")", ";", "}", "return", "targetShardNo", ";", "}" ]
Get the shard number of the target object ID, if cached.
[ "Get", "the", "shard", "number", "of", "the", "target", "object", "ID", "if", "cached", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java#L114-L122
138,440
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java
LinkFieldUpdater.deleteLinkInverseValue
private void deleteLinkInverseValue(String targetObjID) { int shardNo = m_tableDef.getShardNumber(m_dbObj); if (shardNo > 0 && m_invLinkDef.isSharded()) { m_dbTran.deleteShardedLinkValue(targetObjID, m_invLinkDef, m_dbObj.getObjectID(), shardNo); } else { m_dbTran.deleteLinkValue(targetObjID, m_invLinkDef, m_dbObj.getObjectID()); } }
java
private void deleteLinkInverseValue(String targetObjID) { int shardNo = m_tableDef.getShardNumber(m_dbObj); if (shardNo > 0 && m_invLinkDef.isSharded()) { m_dbTran.deleteShardedLinkValue(targetObjID, m_invLinkDef, m_dbObj.getObjectID(), shardNo); } else { m_dbTran.deleteLinkValue(targetObjID, m_invLinkDef, m_dbObj.getObjectID()); } }
[ "private", "void", "deleteLinkInverseValue", "(", "String", "targetObjID", ")", "{", "int", "shardNo", "=", "m_tableDef", ".", "getShardNumber", "(", "m_dbObj", ")", ";", "if", "(", "shardNo", ">", "0", "&&", "m_invLinkDef", ".", "isSharded", "(", ")", ")", "{", "m_dbTran", ".", "deleteShardedLinkValue", "(", "targetObjID", ",", "m_invLinkDef", ",", "m_dbObj", ".", "getObjectID", "(", ")", ",", "shardNo", ")", ";", "}", "else", "{", "m_dbTran", ".", "deleteLinkValue", "(", "targetObjID", ",", "m_invLinkDef", ",", "m_dbObj", ".", "getObjectID", "(", ")", ")", ";", "}", "}" ]
Delete the inverse reference to the given target object ID.
[ "Delete", "the", "inverse", "reference", "to", "the", "given", "target", "object", "ID", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java#L125-L132
138,441
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java
LinkFieldUpdater.deleteLinkValue
private void deleteLinkValue(String targetObjID) { int targetShardNo = getTargetObjectShardNumber(targetObjID); if (targetShardNo > 0 && m_linkDef.isSharded()) { m_dbTran.deleteShardedLinkValue(targetObjID, m_linkDef, m_dbObj.getObjectID(), targetShardNo); } else { m_dbTran.deleteLinkValue(m_dbObj.getObjectID(), m_linkDef, targetObjID); } deleteLinkInverseValue(targetObjID); }
java
private void deleteLinkValue(String targetObjID) { int targetShardNo = getTargetObjectShardNumber(targetObjID); if (targetShardNo > 0 && m_linkDef.isSharded()) { m_dbTran.deleteShardedLinkValue(targetObjID, m_linkDef, m_dbObj.getObjectID(), targetShardNo); } else { m_dbTran.deleteLinkValue(m_dbObj.getObjectID(), m_linkDef, targetObjID); } deleteLinkInverseValue(targetObjID); }
[ "private", "void", "deleteLinkValue", "(", "String", "targetObjID", ")", "{", "int", "targetShardNo", "=", "getTargetObjectShardNumber", "(", "targetObjID", ")", ";", "if", "(", "targetShardNo", ">", "0", "&&", "m_linkDef", ".", "isSharded", "(", ")", ")", "{", "m_dbTran", ".", "deleteShardedLinkValue", "(", "targetObjID", ",", "m_linkDef", ",", "m_dbObj", ".", "getObjectID", "(", ")", ",", "targetShardNo", ")", ";", "}", "else", "{", "m_dbTran", ".", "deleteLinkValue", "(", "m_dbObj", ".", "getObjectID", "(", ")", ",", "m_linkDef", ",", "targetObjID", ")", ";", "}", "deleteLinkInverseValue", "(", "targetObjID", ")", ";", "}" ]
Delete the reference via our link to the given target object ID and its inverse.
[ "Delete", "the", "reference", "via", "our", "link", "to", "the", "given", "target", "object", "ID", "and", "its", "inverse", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java#L135-L143
138,442
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java
LinkFieldUpdater.deleteShardedLinkTermRows
private void deleteShardedLinkTermRows() { // When link is shard, its sharded extent table is also sharded. Set<Integer> shardNums = SpiderService.instance().getShards(m_invTableDef).keySet(); for (Integer shardNumber : shardNums) { m_dbTran.deleteShardedLinkRow(m_linkDef, m_dbObj.getObjectID(), shardNumber); } }
java
private void deleteShardedLinkTermRows() { // When link is shard, its sharded extent table is also sharded. Set<Integer> shardNums = SpiderService.instance().getShards(m_invTableDef).keySet(); for (Integer shardNumber : shardNums) { m_dbTran.deleteShardedLinkRow(m_linkDef, m_dbObj.getObjectID(), shardNumber); } }
[ "private", "void", "deleteShardedLinkTermRows", "(", ")", "{", "// When link is shard, its sharded extent table is also sharded.\r", "Set", "<", "Integer", ">", "shardNums", "=", "SpiderService", ".", "instance", "(", ")", ".", "getShards", "(", "m_invTableDef", ")", ".", "keySet", "(", ")", ";", "for", "(", "Integer", "shardNumber", ":", "shardNums", ")", "{", "m_dbTran", ".", "deleteShardedLinkRow", "(", "m_linkDef", ",", "m_dbObj", ".", "getObjectID", "(", ")", ",", "shardNumber", ")", ";", "}", "}" ]
Delete all possible term rows that might exist for our sharded link.
[ "Delete", "all", "possible", "term", "rows", "that", "might", "exist", "for", "our", "sharded", "link", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java#L146-L152
138,443
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java
LinkFieldUpdater.updateLinkAddValues
private boolean updateLinkAddValues() { List<String> linkValues = m_dbObj.getFieldValues(m_linkDef.getName()); if (linkValues == null || linkValues.size() == 0) { return false; } Set<String> linkValueSet = new HashSet<>(linkValues); // remove duplicates for (String targetObjID : linkValueSet) { addLinkValue(targetObjID); } return true; }
java
private boolean updateLinkAddValues() { List<String> linkValues = m_dbObj.getFieldValues(m_linkDef.getName()); if (linkValues == null || linkValues.size() == 0) { return false; } Set<String> linkValueSet = new HashSet<>(linkValues); // remove duplicates for (String targetObjID : linkValueSet) { addLinkValue(targetObjID); } return true; }
[ "private", "boolean", "updateLinkAddValues", "(", ")", "{", "List", "<", "String", ">", "linkValues", "=", "m_dbObj", ".", "getFieldValues", "(", "m_linkDef", ".", "getName", "(", ")", ")", ";", "if", "(", "linkValues", "==", "null", "||", "linkValues", ".", "size", "(", ")", "==", "0", ")", "{", "return", "false", ";", "}", "Set", "<", "String", ">", "linkValueSet", "=", "new", "HashSet", "<>", "(", "linkValues", ")", ";", "// remove duplicates\r", "for", "(", "String", "targetObjID", ":", "linkValueSet", ")", "{", "addLinkValue", "(", "targetObjID", ")", ";", "}", "return", "true", ";", "}" ]
Add new values for our link. Return true if at least one update made.
[ "Add", "new", "values", "for", "our", "link", ".", "Return", "true", "if", "at", "least", "one", "update", "made", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java#L155-L165
138,444
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java
LinkFieldUpdater.updateLinkRemoveValues
private boolean updateLinkRemoveValues() { Set<String> removeSet = m_dbObj.getRemoveValues(m_fieldName); List<String> addSet = m_dbObj.getFieldValues(m_fieldName); if (removeSet != null && addSet != null) { removeSet.removeAll(addSet); // add+remove of same ID negates the remove } if (removeSet == null || removeSet.size() == 0) { return false; } for (String removeObjID : removeSet) { deleteLinkValue(removeObjID); } return true; }
java
private boolean updateLinkRemoveValues() { Set<String> removeSet = m_dbObj.getRemoveValues(m_fieldName); List<String> addSet = m_dbObj.getFieldValues(m_fieldName); if (removeSet != null && addSet != null) { removeSet.removeAll(addSet); // add+remove of same ID negates the remove } if (removeSet == null || removeSet.size() == 0) { return false; } for (String removeObjID : removeSet) { deleteLinkValue(removeObjID); } return true; }
[ "private", "boolean", "updateLinkRemoveValues", "(", ")", "{", "Set", "<", "String", ">", "removeSet", "=", "m_dbObj", ".", "getRemoveValues", "(", "m_fieldName", ")", ";", "List", "<", "String", ">", "addSet", "=", "m_dbObj", ".", "getFieldValues", "(", "m_fieldName", ")", ";", "if", "(", "removeSet", "!=", "null", "&&", "addSet", "!=", "null", ")", "{", "removeSet", ".", "removeAll", "(", "addSet", ")", ";", "// add+remove of same ID negates the remove\r", "}", "if", "(", "removeSet", "==", "null", "||", "removeSet", ".", "size", "(", ")", "==", "0", ")", "{", "return", "false", ";", "}", "for", "(", "String", "removeObjID", ":", "removeSet", ")", "{", "deleteLinkValue", "(", "removeObjID", ")", ";", "}", "return", "true", ";", "}" ]
Process removes for our link. Return true if at least one update made.
[ "Process", "removes", "for", "our", "link", ".", "Return", "true", "if", "at", "least", "one", "update", "made", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/LinkFieldUpdater.java#L168-L182
138,445
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ShardCache.java
ShardCache.clear
public synchronized void clear(ApplicationDefinition appDef) { String appName = appDef.getAppName(); for (TableDefinition tableDef : appDef.getTableDefinitions().values()) { m_cacheMap.remove(appName + "/" + tableDef.getTableName()); // might have no entry } m_appShardMap.remove(appName); }
java
public synchronized void clear(ApplicationDefinition appDef) { String appName = appDef.getAppName(); for (TableDefinition tableDef : appDef.getTableDefinitions().values()) { m_cacheMap.remove(appName + "/" + tableDef.getTableName()); // might have no entry } m_appShardMap.remove(appName); }
[ "public", "synchronized", "void", "clear", "(", "ApplicationDefinition", "appDef", ")", "{", "String", "appName", "=", "appDef", ".", "getAppName", "(", ")", ";", "for", "(", "TableDefinition", "tableDef", ":", "appDef", ".", "getTableDefinitions", "(", ")", ".", "values", "(", ")", ")", "{", "m_cacheMap", ".", "remove", "(", "appName", "+", "\"/\"", "+", "tableDef", ".", "getTableName", "(", ")", ")", ";", "// might have no entry\r", "}", "m_appShardMap", ".", "remove", "(", "appName", ")", ";", "}" ]
Clear all cached shard information for the given application. @param appDef {@link ApplicationDefinition} of an application.
[ "Clear", "all", "cached", "shard", "information", "for", "the", "given", "application", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ShardCache.java#L70-L76
138,446
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ShardCache.java
ShardCache.verifyShard
public synchronized void verifyShard(TableDefinition tableDef, int shardNumber) { assert tableDef != null; assert tableDef.isSharded(); assert shardNumber > 0; Map<String, Map<Integer, Date>> tableMap = m_appShardMap.get(tableDef.getAppDef().getAppName()); if (tableMap != null) { Map<Integer, Date> shardMap = tableMap.get(tableDef.getTableName()); if (shardMap != null) { if (shardMap.containsKey(shardNumber)) { return; } } } // Unknown app/table/shard number, so start it. Date shardDate = tableDef.computeShardStart(shardNumber); addShardStart(tableDef, shardNumber, shardDate); }
java
public synchronized void verifyShard(TableDefinition tableDef, int shardNumber) { assert tableDef != null; assert tableDef.isSharded(); assert shardNumber > 0; Map<String, Map<Integer, Date>> tableMap = m_appShardMap.get(tableDef.getAppDef().getAppName()); if (tableMap != null) { Map<Integer, Date> shardMap = tableMap.get(tableDef.getTableName()); if (shardMap != null) { if (shardMap.containsKey(shardNumber)) { return; } } } // Unknown app/table/shard number, so start it. Date shardDate = tableDef.computeShardStart(shardNumber); addShardStart(tableDef, shardNumber, shardDate); }
[ "public", "synchronized", "void", "verifyShard", "(", "TableDefinition", "tableDef", ",", "int", "shardNumber", ")", "{", "assert", "tableDef", "!=", "null", ";", "assert", "tableDef", ".", "isSharded", "(", ")", ";", "assert", "shardNumber", ">", "0", ";", "Map", "<", "String", ",", "Map", "<", "Integer", ",", "Date", ">", ">", "tableMap", "=", "m_appShardMap", ".", "get", "(", "tableDef", ".", "getAppDef", "(", ")", ".", "getAppName", "(", ")", ")", ";", "if", "(", "tableMap", "!=", "null", ")", "{", "Map", "<", "Integer", ",", "Date", ">", "shardMap", "=", "tableMap", ".", "get", "(", "tableDef", ".", "getTableName", "(", ")", ")", ";", "if", "(", "shardMap", "!=", "null", ")", "{", "if", "(", "shardMap", ".", "containsKey", "(", "shardNumber", ")", ")", "{", "return", ";", "}", "}", "}", "// Unknown app/table/shard number, so start it.\r", "Date", "shardDate", "=", "tableDef", ".", "computeShardStart", "(", "shardNumber", ")", ";", "addShardStart", "(", "tableDef", ",", "shardNumber", ",", "shardDate", ")", ";", "}" ]
Verify that the shard with the given number has been registered for the given table. If it hasn't, the shard's starting date is computed, the shard is registered in the _shards row, and the start date is cached. @param tableDef TableDefinition of a sharded table. @param shardNumber Shard number (must be > 0).
[ "Verify", "that", "the", "shard", "with", "the", "given", "number", "has", "been", "registered", "for", "the", "given", "table", ".", "If", "it", "hasn", "t", "the", "shard", "s", "starting", "date", "is", "computed", "the", "shard", "is", "registered", "in", "the", "_shards", "row", "and", "the", "start", "date", "is", "cached", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ShardCache.java#L119-L137
138,447
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ShardCache.java
ShardCache.addShardStart
private void addShardStart(TableDefinition tableDef, int shardNumber, Date shardDate) { SpiderTransaction spiderTran = new SpiderTransaction(); spiderTran.addShardStart(tableDef, shardNumber, shardDate); Tenant tenant = Tenant.getTenant(tableDef); DBTransaction dbTran = DBService.instance(tenant).startTransaction(); spiderTran.applyUpdates(dbTran); DBService.instance(tenant).commit(dbTran); synchronized (this) { cacheShardValue(tableDef, shardNumber, shardDate); } }
java
private void addShardStart(TableDefinition tableDef, int shardNumber, Date shardDate) { SpiderTransaction spiderTran = new SpiderTransaction(); spiderTran.addShardStart(tableDef, shardNumber, shardDate); Tenant tenant = Tenant.getTenant(tableDef); DBTransaction dbTran = DBService.instance(tenant).startTransaction(); spiderTran.applyUpdates(dbTran); DBService.instance(tenant).commit(dbTran); synchronized (this) { cacheShardValue(tableDef, shardNumber, shardDate); } }
[ "private", "void", "addShardStart", "(", "TableDefinition", "tableDef", ",", "int", "shardNumber", ",", "Date", "shardDate", ")", "{", "SpiderTransaction", "spiderTran", "=", "new", "SpiderTransaction", "(", ")", ";", "spiderTran", ".", "addShardStart", "(", "tableDef", ",", "shardNumber", ",", "shardDate", ")", ";", "Tenant", "tenant", "=", "Tenant", ".", "getTenant", "(", "tableDef", ")", ";", "DBTransaction", "dbTran", "=", "DBService", ".", "instance", "(", "tenant", ")", ".", "startTransaction", "(", ")", ";", "spiderTran", ".", "applyUpdates", "(", "dbTran", ")", ";", "DBService", ".", "instance", "(", "tenant", ")", ".", "commit", "(", "dbTran", ")", ";", "synchronized", "(", "this", ")", "{", "cacheShardValue", "(", "tableDef", ",", "shardNumber", ",", "shardDate", ")", ";", "}", "}" ]
Create a local transaction to add the register the given shard, then cache it.
[ "Create", "a", "local", "transaction", "to", "add", "the", "register", "the", "given", "shard", "then", "cache", "it", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ShardCache.java#L142-L152
138,448
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ShardCache.java
ShardCache.cacheShardValue
private void cacheShardValue(TableDefinition tableDef, Integer shardNumber, Date shardStart) { // Get or create the app name -> table map String appName = tableDef.getAppDef().getAppName(); Map<String, Map<Integer, Date>> tableShardNumberMap = m_appShardMap.get(appName); if (tableShardNumberMap == null) { tableShardNumberMap = new HashMap<String, Map<Integer,Date>>(); m_appShardMap.put(appName, tableShardNumberMap); } // Get or create the table name -> shard number map String tableName = tableDef.getTableName(); Map<Integer, Date> shardNumberMap = tableShardNumberMap.get(tableName); if (shardNumberMap == null) { shardNumberMap = new HashMap<Integer, Date>(); tableShardNumberMap.put(tableName, shardNumberMap); } // Add the shard number -> start date shardNumberMap.put(shardNumber, shardStart); m_logger.debug("Sharding date for {}.{} shard #{} set to: {} ({})", new Object[]{appName, tableName, shardNumber, shardStart.getTime(), Utils.formatDateUTC(shardStart)}); }
java
private void cacheShardValue(TableDefinition tableDef, Integer shardNumber, Date shardStart) { // Get or create the app name -> table map String appName = tableDef.getAppDef().getAppName(); Map<String, Map<Integer, Date>> tableShardNumberMap = m_appShardMap.get(appName); if (tableShardNumberMap == null) { tableShardNumberMap = new HashMap<String, Map<Integer,Date>>(); m_appShardMap.put(appName, tableShardNumberMap); } // Get or create the table name -> shard number map String tableName = tableDef.getTableName(); Map<Integer, Date> shardNumberMap = tableShardNumberMap.get(tableName); if (shardNumberMap == null) { shardNumberMap = new HashMap<Integer, Date>(); tableShardNumberMap.put(tableName, shardNumberMap); } // Add the shard number -> start date shardNumberMap.put(shardNumber, shardStart); m_logger.debug("Sharding date for {}.{} shard #{} set to: {} ({})", new Object[]{appName, tableName, shardNumber, shardStart.getTime(), Utils.formatDateUTC(shardStart)}); }
[ "private", "void", "cacheShardValue", "(", "TableDefinition", "tableDef", ",", "Integer", "shardNumber", ",", "Date", "shardStart", ")", "{", "// Get or create the app name -> table map\r", "String", "appName", "=", "tableDef", ".", "getAppDef", "(", ")", ".", "getAppName", "(", ")", ";", "Map", "<", "String", ",", "Map", "<", "Integer", ",", "Date", ">", ">", "tableShardNumberMap", "=", "m_appShardMap", ".", "get", "(", "appName", ")", ";", "if", "(", "tableShardNumberMap", "==", "null", ")", "{", "tableShardNumberMap", "=", "new", "HashMap", "<", "String", ",", "Map", "<", "Integer", ",", "Date", ">", ">", "(", ")", ";", "m_appShardMap", ".", "put", "(", "appName", ",", "tableShardNumberMap", ")", ";", "}", "// Get or create the table name -> shard number map\r", "String", "tableName", "=", "tableDef", ".", "getTableName", "(", ")", ";", "Map", "<", "Integer", ",", "Date", ">", "shardNumberMap", "=", "tableShardNumberMap", ".", "get", "(", "tableName", ")", ";", "if", "(", "shardNumberMap", "==", "null", ")", "{", "shardNumberMap", "=", "new", "HashMap", "<", "Integer", ",", "Date", ">", "(", ")", ";", "tableShardNumberMap", ".", "put", "(", "tableName", ",", "shardNumberMap", ")", ";", "}", "// Add the shard number -> start date\r", "shardNumberMap", ".", "put", "(", "shardNumber", ",", "shardStart", ")", ";", "m_logger", ".", "debug", "(", "\"Sharding date for {}.{} shard #{} set to: {} ({})\"", ",", "new", "Object", "[", "]", "{", "appName", ",", "tableName", ",", "shardNumber", ",", "shardStart", ".", "getTime", "(", ")", ",", "Utils", ".", "formatDateUTC", "(", "shardStart", ")", "}", ")", ";", "}" ]
Cache the given shard.
[ "Cache", "the", "given", "shard", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ShardCache.java#L155-L178
138,449
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ShardCache.java
ShardCache.loadShardCache
private void loadShardCache(TableDefinition tableDef) { String appName = tableDef.getAppDef().getAppName(); String tableName = tableDef.getTableName(); m_logger.debug("Loading shard cache for {}.{}", appName, tableName); Date cacheDate = new Date(); String cacheKey = appName + "/" + tableName; m_cacheMap.put(cacheKey, cacheDate); Map<String, Map<Integer, Date>> tableMap = m_appShardMap.get(appName); if (tableMap == null) { tableMap = new HashMap<>(); m_appShardMap.put(appName, tableMap); } Map<Integer, Date> shardMap = tableMap.get(tableName); if (shardMap == null) { shardMap = new HashMap<>(); tableMap.put(tableName, shardMap); } Tenant tenant = Tenant.getTenant(tableDef); String storeName = SpiderService.termsStoreName(tableDef); for(DColumn col: DBService.instance(tenant).getAllColumns(storeName, SpiderTransaction.SHARDS_ROW_KEY)) { Integer shardNum = Integer.parseInt(col.getName()); Date shardDate = new Date(Long.parseLong(col.getValue())); shardMap.put(shardNum, shardDate); } }
java
private void loadShardCache(TableDefinition tableDef) { String appName = tableDef.getAppDef().getAppName(); String tableName = tableDef.getTableName(); m_logger.debug("Loading shard cache for {}.{}", appName, tableName); Date cacheDate = new Date(); String cacheKey = appName + "/" + tableName; m_cacheMap.put(cacheKey, cacheDate); Map<String, Map<Integer, Date>> tableMap = m_appShardMap.get(appName); if (tableMap == null) { tableMap = new HashMap<>(); m_appShardMap.put(appName, tableMap); } Map<Integer, Date> shardMap = tableMap.get(tableName); if (shardMap == null) { shardMap = new HashMap<>(); tableMap.put(tableName, shardMap); } Tenant tenant = Tenant.getTenant(tableDef); String storeName = SpiderService.termsStoreName(tableDef); for(DColumn col: DBService.instance(tenant).getAllColumns(storeName, SpiderTransaction.SHARDS_ROW_KEY)) { Integer shardNum = Integer.parseInt(col.getName()); Date shardDate = new Date(Long.parseLong(col.getValue())); shardMap.put(shardNum, shardDate); } }
[ "private", "void", "loadShardCache", "(", "TableDefinition", "tableDef", ")", "{", "String", "appName", "=", "tableDef", ".", "getAppDef", "(", ")", ".", "getAppName", "(", ")", ";", "String", "tableName", "=", "tableDef", ".", "getTableName", "(", ")", ";", "m_logger", ".", "debug", "(", "\"Loading shard cache for {}.{}\"", ",", "appName", ",", "tableName", ")", ";", "Date", "cacheDate", "=", "new", "Date", "(", ")", ";", "String", "cacheKey", "=", "appName", "+", "\"/\"", "+", "tableName", ";", "m_cacheMap", ".", "put", "(", "cacheKey", ",", "cacheDate", ")", ";", "Map", "<", "String", ",", "Map", "<", "Integer", ",", "Date", ">", ">", "tableMap", "=", "m_appShardMap", ".", "get", "(", "appName", ")", ";", "if", "(", "tableMap", "==", "null", ")", "{", "tableMap", "=", "new", "HashMap", "<>", "(", ")", ";", "m_appShardMap", ".", "put", "(", "appName", ",", "tableMap", ")", ";", "}", "Map", "<", "Integer", ",", "Date", ">", "shardMap", "=", "tableMap", ".", "get", "(", "tableName", ")", ";", "if", "(", "shardMap", "==", "null", ")", "{", "shardMap", "=", "new", "HashMap", "<>", "(", ")", ";", "tableMap", ".", "put", "(", "tableName", ",", "shardMap", ")", ";", "}", "Tenant", "tenant", "=", "Tenant", ".", "getTenant", "(", "tableDef", ")", ";", "String", "storeName", "=", "SpiderService", ".", "termsStoreName", "(", "tableDef", ")", ";", "for", "(", "DColumn", "col", ":", "DBService", ".", "instance", "(", "tenant", ")", ".", "getAllColumns", "(", "storeName", ",", "SpiderTransaction", ".", "SHARDS_ROW_KEY", ")", ")", "{", "Integer", "shardNum", "=", "Integer", ".", "parseInt", "(", "col", ".", "getName", "(", ")", ")", ";", "Date", "shardDate", "=", "new", "Date", "(", "Long", ".", "parseLong", "(", "col", ".", "getValue", "(", ")", ")", ")", ";", "shardMap", ".", "put", "(", "shardNum", ",", "shardDate", ")", ";", "}", "}" ]
worry about concurrency.
[ "worry", "about", "concurrency", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ShardCache.java#L182-L210
138,450
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ShardCache.java
ShardCache.isTooOld
private boolean isTooOld(Date cacheDate) { Date now = new Date(); return now.getTime() - cacheDate.getTime() > MAX_CACHE_TIME_MILLIS; }
java
private boolean isTooOld(Date cacheDate) { Date now = new Date(); return now.getTime() - cacheDate.getTime() > MAX_CACHE_TIME_MILLIS; }
[ "private", "boolean", "isTooOld", "(", "Date", "cacheDate", ")", "{", "Date", "now", "=", "new", "Date", "(", ")", ";", "return", "now", ".", "getTime", "(", ")", "-", "cacheDate", ".", "getTime", "(", ")", ">", "MAX_CACHE_TIME_MILLIS", ";", "}" ]
Return true if given date has exceeded MAX_CACHE_TIME_MILLIS time.
[ "Return", "true", "if", "given", "date", "has", "exceeded", "MAX_CACHE_TIME_MILLIS", "time", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ShardCache.java#L213-L216
138,451
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java
ObjectUpdater.addNewObject
public ObjectResult addNewObject(SpiderTransaction parentTran, DBObject dbObj) { ObjectResult result = new ObjectResult(); try { addBrandNewObject(dbObj); result.setObjectID(dbObj.getObjectID()); result.setUpdated(true); parentTran.mergeSubTransaction(m_dbTran); m_logger.trace("addNewObject(): Object added/updated for ID={}", dbObj.getObjectID()); } catch (Throwable ex) { buildErrorStatus(result, dbObj.getObjectID(), ex); } return result; }
java
public ObjectResult addNewObject(SpiderTransaction parentTran, DBObject dbObj) { ObjectResult result = new ObjectResult(); try { addBrandNewObject(dbObj); result.setObjectID(dbObj.getObjectID()); result.setUpdated(true); parentTran.mergeSubTransaction(m_dbTran); m_logger.trace("addNewObject(): Object added/updated for ID={}", dbObj.getObjectID()); } catch (Throwable ex) { buildErrorStatus(result, dbObj.getObjectID(), ex); } return result; }
[ "public", "ObjectResult", "addNewObject", "(", "SpiderTransaction", "parentTran", ",", "DBObject", "dbObj", ")", "{", "ObjectResult", "result", "=", "new", "ObjectResult", "(", ")", ";", "try", "{", "addBrandNewObject", "(", "dbObj", ")", ";", "result", ".", "setObjectID", "(", "dbObj", ".", "getObjectID", "(", ")", ")", ";", "result", ".", "setUpdated", "(", "true", ")", ";", "parentTran", ".", "mergeSubTransaction", "(", "m_dbTran", ")", ";", "m_logger", ".", "trace", "(", "\"addNewObject(): Object added/updated for ID={}\"", ",", "dbObj", ".", "getObjectID", "(", ")", ")", ";", "}", "catch", "(", "Throwable", "ex", ")", "{", "buildErrorStatus", "(", "result", ",", "dbObj", ".", "getObjectID", "(", ")", ",", "ex", ")", ";", "}", "return", "result", ";", "}" ]
Add the given DBObject to the database as a new object. No check is made to see if an object with the same ID already exists. If the update is successful, updates are merged to the given parent SpiderTransaction. @param parentTran Parent {@link SpiderTransaction} to which updates are applied if the add is successful. @param dbObj DBObject to be added to the database. @return {@link ObjectResult} representing the results of the update.
[ "Add", "the", "given", "DBObject", "to", "the", "database", "as", "a", "new", "object", ".", "No", "check", "is", "made", "to", "see", "if", "an", "object", "with", "the", "same", "ID", "already", "exists", ".", "If", "the", "update", "is", "successful", "updates", "are", "merged", "to", "the", "given", "parent", "SpiderTransaction", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java#L112-L124
138,452
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java
ObjectUpdater.deleteObject
public ObjectResult deleteObject(SpiderTransaction parentTran, String objID) { ObjectResult result = new ObjectResult(objID); try { result.setObjectID(objID); DBObject dbObj = SpiderService.instance().getObject(m_tableDef, objID); if (dbObj != null) { deleteObject(dbObj); result.setUpdated(true); parentTran.mergeSubTransaction(m_dbTran); m_logger.trace("deleteObject(): object deleted with ID={}", objID); } else { result.setComment("Object not found"); m_logger.trace("deleteObject(): no object with ID={}", objID); } } catch (Throwable ex) { buildErrorStatus(result, objID, ex); } return result; }
java
public ObjectResult deleteObject(SpiderTransaction parentTran, String objID) { ObjectResult result = new ObjectResult(objID); try { result.setObjectID(objID); DBObject dbObj = SpiderService.instance().getObject(m_tableDef, objID); if (dbObj != null) { deleteObject(dbObj); result.setUpdated(true); parentTran.mergeSubTransaction(m_dbTran); m_logger.trace("deleteObject(): object deleted with ID={}", objID); } else { result.setComment("Object not found"); m_logger.trace("deleteObject(): no object with ID={}", objID); } } catch (Throwable ex) { buildErrorStatus(result, objID, ex); } return result; }
[ "public", "ObjectResult", "deleteObject", "(", "SpiderTransaction", "parentTran", ",", "String", "objID", ")", "{", "ObjectResult", "result", "=", "new", "ObjectResult", "(", "objID", ")", ";", "try", "{", "result", ".", "setObjectID", "(", "objID", ")", ";", "DBObject", "dbObj", "=", "SpiderService", ".", "instance", "(", ")", ".", "getObject", "(", "m_tableDef", ",", "objID", ")", ";", "if", "(", "dbObj", "!=", "null", ")", "{", "deleteObject", "(", "dbObj", ")", ";", "result", ".", "setUpdated", "(", "true", ")", ";", "parentTran", ".", "mergeSubTransaction", "(", "m_dbTran", ")", ";", "m_logger", ".", "trace", "(", "\"deleteObject(): object deleted with ID={}\"", ",", "objID", ")", ";", "}", "else", "{", "result", ".", "setComment", "(", "\"Object not found\"", ")", ";", "m_logger", ".", "trace", "(", "\"deleteObject(): no object with ID={}\"", ",", "objID", ")", ";", "}", "}", "catch", "(", "Throwable", "ex", ")", "{", "buildErrorStatus", "(", "result", ",", "objID", ",", "ex", ")", ";", "}", "return", "result", ";", "}" ]
Delete the object with the given object ID. Because of idempotent update semantics, it is not an error if the object does not exist. If an object is actually deleted, updates are merged to the given parent SpiderTransaction. @param parentTran Parent {@link SpiderTransaction} to which updates are applied if the delete is successful. @param objID ID of object to be deleted. @return {@link ObjectResult} representing the results of the delete. Includes a comment if the object was not found.
[ "Delete", "the", "object", "with", "the", "given", "object", "ID", ".", "Because", "of", "idempotent", "update", "semantics", "it", "is", "not", "an", "error", "if", "the", "object", "does", "not", "exist", ".", "If", "an", "object", "is", "actually", "deleted", "updates", "are", "merged", "to", "the", "given", "parent", "SpiderTransaction", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java#L137-L155
138,453
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java
ObjectUpdater.updateObject
public ObjectResult updateObject(SpiderTransaction parentTran, DBObject dbObj, Map<String, String> currScalarMap) { ObjectResult result = new ObjectResult(); try { result.setObjectID(dbObj.getObjectID()); boolean bUpdated = updateExistingObject(dbObj, currScalarMap); result.setUpdated(bUpdated); if (bUpdated) { m_logger.trace("updateObject(): object updated for ID={}", dbObj.getObjectID()); parentTran.mergeSubTransaction(m_dbTran); } else { result.setComment("No updates made"); m_logger.trace("updateObject(): no updates made for ID={}", dbObj.getObjectID()); } } catch (Throwable ex) { buildErrorStatus(result, dbObj.getObjectID(), ex); } return result; }
java
public ObjectResult updateObject(SpiderTransaction parentTran, DBObject dbObj, Map<String, String> currScalarMap) { ObjectResult result = new ObjectResult(); try { result.setObjectID(dbObj.getObjectID()); boolean bUpdated = updateExistingObject(dbObj, currScalarMap); result.setUpdated(bUpdated); if (bUpdated) { m_logger.trace("updateObject(): object updated for ID={}", dbObj.getObjectID()); parentTran.mergeSubTransaction(m_dbTran); } else { result.setComment("No updates made"); m_logger.trace("updateObject(): no updates made for ID={}", dbObj.getObjectID()); } } catch (Throwable ex) { buildErrorStatus(result, dbObj.getObjectID(), ex); } return result; }
[ "public", "ObjectResult", "updateObject", "(", "SpiderTransaction", "parentTran", ",", "DBObject", "dbObj", ",", "Map", "<", "String", ",", "String", ">", "currScalarMap", ")", "{", "ObjectResult", "result", "=", "new", "ObjectResult", "(", ")", ";", "try", "{", "result", ".", "setObjectID", "(", "dbObj", ".", "getObjectID", "(", ")", ")", ";", "boolean", "bUpdated", "=", "updateExistingObject", "(", "dbObj", ",", "currScalarMap", ")", ";", "result", ".", "setUpdated", "(", "bUpdated", ")", ";", "if", "(", "bUpdated", ")", "{", "m_logger", ".", "trace", "(", "\"updateObject(): object updated for ID={}\"", ",", "dbObj", ".", "getObjectID", "(", ")", ")", ";", "parentTran", ".", "mergeSubTransaction", "(", "m_dbTran", ")", ";", "}", "else", "{", "result", ".", "setComment", "(", "\"No updates made\"", ")", ";", "m_logger", ".", "trace", "(", "\"updateObject(): no updates made for ID={}\"", ",", "dbObj", ".", "getObjectID", "(", ")", ")", ";", "}", "}", "catch", "(", "Throwable", "ex", ")", "{", "buildErrorStatus", "(", "result", ",", "dbObj", ".", "getObjectID", "(", ")", ",", "ex", ")", ";", "}", "return", "result", ";", "}" ]
Update the given object, whose current values have been pre-fetched. The object must exist, and the values in the given DBObject are compared to the given current values to determine which ones are being added or updated. If an update is actually made, updates are merged to the given parent SpiderTransaction. @param parentTran Parent {@link SpiderTransaction} to which updates are applied if the delete is successful. @param dbObj DBObject to be updated. @param currScalarMap Map of the existing objects current scalar values for fields being updated. @return {@link ObjectResult} representing the results of the update. Includes a comment if no updates were made.
[ "Update", "the", "given", "object", "whose", "current", "values", "have", "been", "pre", "-", "fetched", ".", "The", "object", "must", "exist", "and", "the", "values", "in", "the", "given", "DBObject", "are", "compared", "to", "the", "given", "current", "values", "to", "determine", "which", "ones", "are", "being", "added", "or", "updated", ".", "If", "an", "update", "is", "actually", "made", "updates", "are", "merged", "to", "the", "given", "parent", "SpiderTransaction", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java#L171-L190
138,454
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java
ObjectUpdater.addBrandNewObject
private boolean addBrandNewObject(DBObject dbObj) { if (Utils.isEmpty(dbObj.getObjectID())) { dbObj.setObjectID(Utils.base64FromBinary(IDGenerator.nextID())); } checkForNewShard(dbObj); for (String fieldName : dbObj.getUpdatedFieldNames()) { FieldUpdater fieldUpdater = FieldUpdater.createFieldUpdater(this, dbObj, fieldName); fieldUpdater.addValuesForField(); } return true; }
java
private boolean addBrandNewObject(DBObject dbObj) { if (Utils.isEmpty(dbObj.getObjectID())) { dbObj.setObjectID(Utils.base64FromBinary(IDGenerator.nextID())); } checkForNewShard(dbObj); for (String fieldName : dbObj.getUpdatedFieldNames()) { FieldUpdater fieldUpdater = FieldUpdater.createFieldUpdater(this, dbObj, fieldName); fieldUpdater.addValuesForField(); } return true; }
[ "private", "boolean", "addBrandNewObject", "(", "DBObject", "dbObj", ")", "{", "if", "(", "Utils", ".", "isEmpty", "(", "dbObj", ".", "getObjectID", "(", ")", ")", ")", "{", "dbObj", ".", "setObjectID", "(", "Utils", ".", "base64FromBinary", "(", "IDGenerator", ".", "nextID", "(", ")", ")", ")", ";", "}", "checkForNewShard", "(", "dbObj", ")", ";", "for", "(", "String", "fieldName", ":", "dbObj", ".", "getUpdatedFieldNames", "(", ")", ")", "{", "FieldUpdater", "fieldUpdater", "=", "FieldUpdater", ".", "createFieldUpdater", "(", "this", ",", "dbObj", ",", "fieldName", ")", ";", "fieldUpdater", ".", "addValuesForField", "(", ")", ";", "}", "return", "true", ";", "}" ]
Add new object to the database.
[ "Add", "new", "object", "to", "the", "database", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java#L195-L205
138,455
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java
ObjectUpdater.buildErrorStatus
private void buildErrorStatus(ObjectResult result, String objID, Throwable ex) { result.setStatus(ObjectResult.Status.ERROR); result.setErrorMessage(ex.getLocalizedMessage()); if (!Utils.isEmpty(objID)) { result.setObjectID(objID); } if (ex instanceof IllegalArgumentException) { m_logger.debug("Object update error: {}", ex.toString()); } else { result.setStackTrace(Utils.getStackTrace(ex)); m_logger.debug("Object update error: {} stacktrace: {}", ex.toString(), Utils.getStackTrace(ex)); } }
java
private void buildErrorStatus(ObjectResult result, String objID, Throwable ex) { result.setStatus(ObjectResult.Status.ERROR); result.setErrorMessage(ex.getLocalizedMessage()); if (!Utils.isEmpty(objID)) { result.setObjectID(objID); } if (ex instanceof IllegalArgumentException) { m_logger.debug("Object update error: {}", ex.toString()); } else { result.setStackTrace(Utils.getStackTrace(ex)); m_logger.debug("Object update error: {} stacktrace: {}", ex.toString(), Utils.getStackTrace(ex)); } }
[ "private", "void", "buildErrorStatus", "(", "ObjectResult", "result", ",", "String", "objID", ",", "Throwable", "ex", ")", "{", "result", ".", "setStatus", "(", "ObjectResult", ".", "Status", ".", "ERROR", ")", ";", "result", ".", "setErrorMessage", "(", "ex", ".", "getLocalizedMessage", "(", ")", ")", ";", "if", "(", "!", "Utils", ".", "isEmpty", "(", "objID", ")", ")", "{", "result", ".", "setObjectID", "(", "objID", ")", ";", "}", "if", "(", "ex", "instanceof", "IllegalArgumentException", ")", "{", "m_logger", ".", "debug", "(", "\"Object update error: {}\"", ",", "ex", ".", "toString", "(", ")", ")", ";", "}", "else", "{", "result", ".", "setStackTrace", "(", "Utils", ".", "getStackTrace", "(", "ex", ")", ")", ";", "m_logger", ".", "debug", "(", "\"Object update error: {} stacktrace: {}\"", ",", "ex", ".", "toString", "(", ")", ",", "Utils", ".", "getStackTrace", "(", "ex", ")", ")", ";", "}", "}" ]
Add error fields to the given ObjectResult due to the given exception.
[ "Add", "error", "fields", "to", "the", "given", "ObjectResult", "due", "to", "the", "given", "exception", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java#L208-L221
138,456
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java
ObjectUpdater.checkForNewShard
private void checkForNewShard(DBObject dbObj) { int shardNumber = m_tableDef.getShardNumber(dbObj); if (shardNumber > 0) { SpiderService.instance().verifyShard(m_tableDef, shardNumber); } }
java
private void checkForNewShard(DBObject dbObj) { int shardNumber = m_tableDef.getShardNumber(dbObj); if (shardNumber > 0) { SpiderService.instance().verifyShard(m_tableDef, shardNumber); } }
[ "private", "void", "checkForNewShard", "(", "DBObject", "dbObj", ")", "{", "int", "shardNumber", "=", "m_tableDef", ".", "getShardNumber", "(", "dbObj", ")", ";", "if", "(", "shardNumber", ">", "0", ")", "{", "SpiderService", ".", "instance", "(", ")", ".", "verifyShard", "(", "m_tableDef", ",", "shardNumber", ")", ";", "}", "}" ]
If object is sharded, see if we need to add a new column to the "current shards" row.
[ "If", "object", "is", "sharded", "see", "if", "we", "need", "to", "add", "a", "new", "column", "to", "the", "current", "shards", "row", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java#L224-L229
138,457
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java
ObjectUpdater.checkNewlySharded
private void checkNewlySharded(DBObject dbObj, Map<String, String> currScalarMap) { if (!m_tableDef.isSharded()) { return; } String shardingFieldName = m_tableDef.getShardingField().getName(); if (!currScalarMap.containsKey(shardingFieldName)) { m_dbTran.addAllObjectsColumn(m_tableDef, dbObj.getObjectID(), m_tableDef.getShardNumber(dbObj)); } }
java
private void checkNewlySharded(DBObject dbObj, Map<String, String> currScalarMap) { if (!m_tableDef.isSharded()) { return; } String shardingFieldName = m_tableDef.getShardingField().getName(); if (!currScalarMap.containsKey(shardingFieldName)) { m_dbTran.addAllObjectsColumn(m_tableDef, dbObj.getObjectID(), m_tableDef.getShardNumber(dbObj)); } }
[ "private", "void", "checkNewlySharded", "(", "DBObject", "dbObj", ",", "Map", "<", "String", ",", "String", ">", "currScalarMap", ")", "{", "if", "(", "!", "m_tableDef", ".", "isSharded", "(", ")", ")", "{", "return", ";", "}", "String", "shardingFieldName", "=", "m_tableDef", ".", "getShardingField", "(", ")", ".", "getName", "(", ")", ";", "if", "(", "!", "currScalarMap", ".", "containsKey", "(", "shardingFieldName", ")", ")", "{", "m_dbTran", ".", "addAllObjectsColumn", "(", "m_tableDef", ",", "dbObj", ".", "getObjectID", "(", ")", ",", "m_tableDef", ".", "getShardNumber", "(", "dbObj", ")", ")", ";", "}", "}" ]
previously undetermined but is not being assigned to a shard.
[ "previously", "undetermined", "but", "is", "not", "being", "assigned", "to", "a", "shard", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java#L233-L241
138,458
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java
ObjectUpdater.deleteObject
private void deleteObject(DBObject dbObj) { for (String fieldName : dbObj.getUpdatedFieldNames()) { FieldUpdater fieldUpdater = FieldUpdater.createFieldUpdater(this, dbObj, fieldName); fieldUpdater.deleteValuesForField(); } m_dbTran.deleteObjectRow(m_tableDef, dbObj.getObjectID()); }
java
private void deleteObject(DBObject dbObj) { for (String fieldName : dbObj.getUpdatedFieldNames()) { FieldUpdater fieldUpdater = FieldUpdater.createFieldUpdater(this, dbObj, fieldName); fieldUpdater.deleteValuesForField(); } m_dbTran.deleteObjectRow(m_tableDef, dbObj.getObjectID()); }
[ "private", "void", "deleteObject", "(", "DBObject", "dbObj", ")", "{", "for", "(", "String", "fieldName", ":", "dbObj", ".", "getUpdatedFieldNames", "(", ")", ")", "{", "FieldUpdater", "fieldUpdater", "=", "FieldUpdater", ".", "createFieldUpdater", "(", "this", ",", "dbObj", ",", "fieldName", ")", ";", "fieldUpdater", ".", "deleteValuesForField", "(", ")", ";", "}", "m_dbTran", ".", "deleteObjectRow", "(", "m_tableDef", ",", "dbObj", ".", "getObjectID", "(", ")", ")", ";", "}" ]
Delete term columns and inverses for field values and the object's primary row.
[ "Delete", "term", "columns", "and", "inverses", "for", "field", "values", "and", "the", "object", "s", "primary", "row", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java#L244-L250
138,459
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java
ObjectUpdater.updateExistingObject
private boolean updateExistingObject(DBObject dbObj, Map<String, String> currScalarMap) { if (objectIsChangingShards(dbObj, currScalarMap)) { return updateShardedObjectMove(dbObj); } else { return updateObjectSameShard(dbObj, currScalarMap); } }
java
private boolean updateExistingObject(DBObject dbObj, Map<String, String> currScalarMap) { if (objectIsChangingShards(dbObj, currScalarMap)) { return updateShardedObjectMove(dbObj); } else { return updateObjectSameShard(dbObj, currScalarMap); } }
[ "private", "boolean", "updateExistingObject", "(", "DBObject", "dbObj", ",", "Map", "<", "String", ",", "String", ">", "currScalarMap", ")", "{", "if", "(", "objectIsChangingShards", "(", "dbObj", ",", "currScalarMap", ")", ")", "{", "return", "updateShardedObjectMove", "(", "dbObj", ")", ";", "}", "else", "{", "return", "updateObjectSameShard", "(", "dbObj", ",", "currScalarMap", ")", ";", "}", "}" ]
Update the given object using the appropriate strategy.
[ "Update", "the", "given", "object", "using", "the", "appropriate", "strategy", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java#L253-L259
138,460
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java
ObjectUpdater.updateObjectSameShard
private boolean updateObjectSameShard(DBObject dbObj, Map<String, String> currScalarMap) { boolean bUpdated = false; checkForNewShard(dbObj); checkNewlySharded(dbObj, currScalarMap); for (String fieldName : dbObj.getUpdatedFieldNames()) { FieldUpdater fieldUpdater = FieldUpdater.createFieldUpdater(this, dbObj, fieldName); bUpdated |= fieldUpdater.updateValuesForField(currScalarMap.get(fieldName)); } return bUpdated; }
java
private boolean updateObjectSameShard(DBObject dbObj, Map<String, String> currScalarMap) { boolean bUpdated = false; checkForNewShard(dbObj); checkNewlySharded(dbObj, currScalarMap); for (String fieldName : dbObj.getUpdatedFieldNames()) { FieldUpdater fieldUpdater = FieldUpdater.createFieldUpdater(this, dbObj, fieldName); bUpdated |= fieldUpdater.updateValuesForField(currScalarMap.get(fieldName)); } return bUpdated; }
[ "private", "boolean", "updateObjectSameShard", "(", "DBObject", "dbObj", ",", "Map", "<", "String", ",", "String", ">", "currScalarMap", ")", "{", "boolean", "bUpdated", "=", "false", ";", "checkForNewShard", "(", "dbObj", ")", ";", "checkNewlySharded", "(", "dbObj", ",", "currScalarMap", ")", ";", "for", "(", "String", "fieldName", ":", "dbObj", ".", "getUpdatedFieldNames", "(", ")", ")", "{", "FieldUpdater", "fieldUpdater", "=", "FieldUpdater", ".", "createFieldUpdater", "(", "this", ",", "dbObj", ",", "fieldName", ")", ";", "bUpdated", "|=", "fieldUpdater", ".", "updateValuesForField", "(", "currScalarMap", ".", "get", "(", "fieldName", ")", ")", ";", "}", "return", "bUpdated", ";", "}" ]
through here.
[ "through", "here", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java#L263-L272
138,461
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java
ObjectUpdater.updateShardedObjectMove
private boolean updateShardedObjectMove(DBObject dbObj) { DBObject currDBObj = SpiderService.instance().getObject(m_tableDef, dbObj.getObjectID()); m_logger.debug("Update forcing move of object {} from shard {} to shard {}", new Object[]{dbObj.getObjectID(), m_tableDef.getShardNumber(currDBObj), m_tableDef.getShardNumber(dbObj)}); deleteObject(currDBObj); mergeAllFieldValues(dbObj, currDBObj); addBrandNewObject(currDBObj); return true; }
java
private boolean updateShardedObjectMove(DBObject dbObj) { DBObject currDBObj = SpiderService.instance().getObject(m_tableDef, dbObj.getObjectID()); m_logger.debug("Update forcing move of object {} from shard {} to shard {}", new Object[]{dbObj.getObjectID(), m_tableDef.getShardNumber(currDBObj), m_tableDef.getShardNumber(dbObj)}); deleteObject(currDBObj); mergeAllFieldValues(dbObj, currDBObj); addBrandNewObject(currDBObj); return true; }
[ "private", "boolean", "updateShardedObjectMove", "(", "DBObject", "dbObj", ")", "{", "DBObject", "currDBObj", "=", "SpiderService", ".", "instance", "(", ")", ".", "getObject", "(", "m_tableDef", ",", "dbObj", ".", "getObjectID", "(", ")", ")", ";", "m_logger", ".", "debug", "(", "\"Update forcing move of object {} from shard {} to shard {}\"", ",", "new", "Object", "[", "]", "{", "dbObj", ".", "getObjectID", "(", ")", ",", "m_tableDef", ".", "getShardNumber", "(", "currDBObj", ")", ",", "m_tableDef", ".", "getShardNumber", "(", "dbObj", ")", "}", ")", ";", "deleteObject", "(", "currDBObj", ")", ";", "mergeAllFieldValues", "(", "dbObj", ",", "currDBObj", ")", ";", "addBrandNewObject", "(", "currDBObj", ")", ";", "return", "true", ";", "}" ]
delete the current object, merge the new fields into it, and re-add it.
[ "delete", "the", "current", "object", "merge", "the", "new", "fields", "into", "it", "and", "re", "-", "add", "it", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java#L276-L287
138,462
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java
ObjectUpdater.objectIsChangingShards
private boolean objectIsChangingShards(DBObject dbObj, Map<String, String> currScalarMap) { if (!m_tableDef.isSharded()) { return false; } // If object had no prior sharding-field value, it is considered in shard 0. int oldShardNumber = 0; String shardingFieldName = m_tableDef.getShardingField().getName(); String currShardFieldValue = currScalarMap.get(shardingFieldName); if (currShardFieldValue != null) { oldShardNumber = m_tableDef.computeShardNumber(Utils.dateFromString(currShardFieldValue)); } // Propagate old sharding-field value if not being updated now. int newShardNumber = m_tableDef.getShardNumber(dbObj); String newShardFieldValue = dbObj.getFieldValue(shardingFieldName); if (newShardFieldValue == null && currShardFieldValue != null) { dbObj.addFieldValue(shardingFieldName, currShardFieldValue); return false; } // May or may not be moving to a new shard. return oldShardNumber != newShardNumber; }
java
private boolean objectIsChangingShards(DBObject dbObj, Map<String, String> currScalarMap) { if (!m_tableDef.isSharded()) { return false; } // If object had no prior sharding-field value, it is considered in shard 0. int oldShardNumber = 0; String shardingFieldName = m_tableDef.getShardingField().getName(); String currShardFieldValue = currScalarMap.get(shardingFieldName); if (currShardFieldValue != null) { oldShardNumber = m_tableDef.computeShardNumber(Utils.dateFromString(currShardFieldValue)); } // Propagate old sharding-field value if not being updated now. int newShardNumber = m_tableDef.getShardNumber(dbObj); String newShardFieldValue = dbObj.getFieldValue(shardingFieldName); if (newShardFieldValue == null && currShardFieldValue != null) { dbObj.addFieldValue(shardingFieldName, currShardFieldValue); return false; } // May or may not be moving to a new shard. return oldShardNumber != newShardNumber; }
[ "private", "boolean", "objectIsChangingShards", "(", "DBObject", "dbObj", ",", "Map", "<", "String", ",", "String", ">", "currScalarMap", ")", "{", "if", "(", "!", "m_tableDef", ".", "isSharded", "(", ")", ")", "{", "return", "false", ";", "}", "// If object had no prior sharding-field value, it is considered in shard 0.\r", "int", "oldShardNumber", "=", "0", ";", "String", "shardingFieldName", "=", "m_tableDef", ".", "getShardingField", "(", ")", ".", "getName", "(", ")", ";", "String", "currShardFieldValue", "=", "currScalarMap", ".", "get", "(", "shardingFieldName", ")", ";", "if", "(", "currShardFieldValue", "!=", "null", ")", "{", "oldShardNumber", "=", "m_tableDef", ".", "computeShardNumber", "(", "Utils", ".", "dateFromString", "(", "currShardFieldValue", ")", ")", ";", "}", "// Propagate old sharding-field value if not being updated now.\r", "int", "newShardNumber", "=", "m_tableDef", ".", "getShardNumber", "(", "dbObj", ")", ";", "String", "newShardFieldValue", "=", "dbObj", ".", "getFieldValue", "(", "shardingFieldName", ")", ";", "if", "(", "newShardFieldValue", "==", "null", "&&", "currShardFieldValue", "!=", "null", ")", "{", "dbObj", ".", "addFieldValue", "(", "shardingFieldName", ",", "currShardFieldValue", ")", ";", "return", "false", ";", "}", "// May or may not be moving to a new shard.\r", "return", "oldShardNumber", "!=", "newShardNumber", ";", "}" ]
moved to a new shard.
[ "moved", "to", "a", "new", "shard", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java#L311-L334
138,463
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/RESTConnector.java
RESTConnector.getClient
public RESTClient getClient(SSLTransportParameters sslParams) { if (m_cellRing == null) { throw new IllegalStateException("Empty pool"); } Cell currentCell = m_cellRing; StringBuilder errorMessage = new StringBuilder(); do { try { RESTClient client = new RESTClient(sslParams, m_cellRing.m_hostName, m_port); client.setCredentials(m_credentials); m_cellRing.m_hostStatus = new HostStatus(); client.setAcceptType(m_defaultContentType); client.setCompression(m_defaultCompression); return client; } catch (RuntimeException e) { m_cellRing.m_hostStatus = new HostStatus(false, e); errorMessage.append("Couldn\'t connect to " + m_cellRing.m_hostName) .append("; reason: " + e.getMessage() + "\n"); } finally { m_cellRing = m_cellRing.next; } } while (currentCell != m_cellRing); throw new IllegalStateException("No active connections found\n" + errorMessage); }
java
public RESTClient getClient(SSLTransportParameters sslParams) { if (m_cellRing == null) { throw new IllegalStateException("Empty pool"); } Cell currentCell = m_cellRing; StringBuilder errorMessage = new StringBuilder(); do { try { RESTClient client = new RESTClient(sslParams, m_cellRing.m_hostName, m_port); client.setCredentials(m_credentials); m_cellRing.m_hostStatus = new HostStatus(); client.setAcceptType(m_defaultContentType); client.setCompression(m_defaultCompression); return client; } catch (RuntimeException e) { m_cellRing.m_hostStatus = new HostStatus(false, e); errorMessage.append("Couldn\'t connect to " + m_cellRing.m_hostName) .append("; reason: " + e.getMessage() + "\n"); } finally { m_cellRing = m_cellRing.next; } } while (currentCell != m_cellRing); throw new IllegalStateException("No active connections found\n" + errorMessage); }
[ "public", "RESTClient", "getClient", "(", "SSLTransportParameters", "sslParams", ")", "{", "if", "(", "m_cellRing", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Empty pool\"", ")", ";", "}", "Cell", "currentCell", "=", "m_cellRing", ";", "StringBuilder", "errorMessage", "=", "new", "StringBuilder", "(", ")", ";", "do", "{", "try", "{", "RESTClient", "client", "=", "new", "RESTClient", "(", "sslParams", ",", "m_cellRing", ".", "m_hostName", ",", "m_port", ")", ";", "client", ".", "setCredentials", "(", "m_credentials", ")", ";", "m_cellRing", ".", "m_hostStatus", "=", "new", "HostStatus", "(", ")", ";", "client", ".", "setAcceptType", "(", "m_defaultContentType", ")", ";", "client", ".", "setCompression", "(", "m_defaultCompression", ")", ";", "return", "client", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "m_cellRing", ".", "m_hostStatus", "=", "new", "HostStatus", "(", "false", ",", "e", ")", ";", "errorMessage", ".", "append", "(", "\"Couldn\\'t connect to \"", "+", "m_cellRing", ".", "m_hostName", ")", ".", "append", "(", "\"; reason: \"", "+", "e", ".", "getMessage", "(", ")", "+", "\"\\n\"", ")", ";", "}", "finally", "{", "m_cellRing", "=", "m_cellRing", ".", "next", ";", "}", "}", "while", "(", "currentCell", "!=", "m_cellRing", ")", ";", "throw", "new", "IllegalStateException", "(", "\"No active connections found\\n\"", "+", "errorMessage", ")", ";", "}" ]
Tries to connect to the "next" host. If no host is available, IllegalStateException will be raised. @param sslParams parameters needed to establish SSL connection @return Client for the connection established
[ "Tries", "to", "connect", "to", "the", "next", "host", ".", "If", "no", "host", "is", "available", "IllegalStateException", "will", "be", "raised", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/RESTConnector.java#L143-L166
138,464
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/RESTConnector.java
RESTConnector.getState
public Map<String, HostStatus> getState() { Map<String, HostStatus> map = new HashMap<>(); if (m_cellRing != null) { Cell currentCell = m_cellRing; do { map.put(currentCell.m_hostName, currentCell.m_hostStatus); currentCell = currentCell.next; } while (currentCell != m_cellRing); } return map; }
java
public Map<String, HostStatus> getState() { Map<String, HostStatus> map = new HashMap<>(); if (m_cellRing != null) { Cell currentCell = m_cellRing; do { map.put(currentCell.m_hostName, currentCell.m_hostStatus); currentCell = currentCell.next; } while (currentCell != m_cellRing); } return map; }
[ "public", "Map", "<", "String", ",", "HostStatus", ">", "getState", "(", ")", "{", "Map", "<", "String", ",", "HostStatus", ">", "map", "=", "new", "HashMap", "<>", "(", ")", ";", "if", "(", "m_cellRing", "!=", "null", ")", "{", "Cell", "currentCell", "=", "m_cellRing", ";", "do", "{", "map", ".", "put", "(", "currentCell", ".", "m_hostName", ",", "currentCell", ".", "m_hostStatus", ")", ";", "currentCell", "=", "currentCell", ".", "next", ";", "}", "while", "(", "currentCell", "!=", "m_cellRing", ")", ";", "}", "return", "map", ";", "}" ]
Generates a map of the last state of the attempts of the connections. Useful in a situation when a getClient method ended in exception, then this method can show the reasons of refusals. @return Map of current connection states.
[ "Generates", "a", "map", "of", "the", "last", "state", "of", "the", "attempts", "of", "the", "connections", ".", "Useful", "in", "a", "situation", "when", "a", "getClient", "method", "ended", "in", "exception", "then", "this", "method", "can", "show", "the", "reasons", "of", "refusals", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/RESTConnector.java#L175-L185
138,465
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/RESTConnector.java
RESTConnector.addToRing
private void addToRing(String host) { Cell newCell = new Cell(); newCell.m_hostName = host; if (m_cellRing == null) { newCell.next = newCell; } else { newCell.next = m_cellRing.next; m_cellRing.next = newCell; } m_cellRing = newCell; }
java
private void addToRing(String host) { Cell newCell = new Cell(); newCell.m_hostName = host; if (m_cellRing == null) { newCell.next = newCell; } else { newCell.next = m_cellRing.next; m_cellRing.next = newCell; } m_cellRing = newCell; }
[ "private", "void", "addToRing", "(", "String", "host", ")", "{", "Cell", "newCell", "=", "new", "Cell", "(", ")", ";", "newCell", ".", "m_hostName", "=", "host", ";", "if", "(", "m_cellRing", "==", "null", ")", "{", "newCell", ".", "next", "=", "newCell", ";", "}", "else", "{", "newCell", ".", "next", "=", "m_cellRing", ".", "next", ";", "m_cellRing", ".", "next", "=", "newCell", ";", "}", "m_cellRing", "=", "newCell", ";", "}" ]
Adds a new host to a cells ring. @param host Host name to add
[ "Adds", "a", "new", "host", "to", "a", "cells", "ring", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/RESTConnector.java#L191-L201
138,466
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/CassandraTransaction.java
CassandraTransaction.createMutation
private static Mutation createMutation(byte[] colName, byte[] colValue, long timestamp) { if (colValue == null) { colValue = EMPTY_BYTES; } Column col = new Column(); col.setName(colName); col.setValue(colValue); col.setTimestamp(timestamp); ColumnOrSuperColumn cosc = new ColumnOrSuperColumn(); cosc.setColumn(col); Mutation mutation = new Mutation(); mutation.setColumn_or_supercolumn(cosc); return mutation; }
java
private static Mutation createMutation(byte[] colName, byte[] colValue, long timestamp) { if (colValue == null) { colValue = EMPTY_BYTES; } Column col = new Column(); col.setName(colName); col.setValue(colValue); col.setTimestamp(timestamp); ColumnOrSuperColumn cosc = new ColumnOrSuperColumn(); cosc.setColumn(col); Mutation mutation = new Mutation(); mutation.setColumn_or_supercolumn(cosc); return mutation; }
[ "private", "static", "Mutation", "createMutation", "(", "byte", "[", "]", "colName", ",", "byte", "[", "]", "colValue", ",", "long", "timestamp", ")", "{", "if", "(", "colValue", "==", "null", ")", "{", "colValue", "=", "EMPTY_BYTES", ";", "}", "Column", "col", "=", "new", "Column", "(", ")", ";", "col", ".", "setName", "(", "colName", ")", ";", "col", ".", "setValue", "(", "colValue", ")", ";", "col", ".", "setTimestamp", "(", "timestamp", ")", ";", "ColumnOrSuperColumn", "cosc", "=", "new", "ColumnOrSuperColumn", "(", ")", ";", "cosc", ".", "setColumn", "(", "col", ")", ";", "Mutation", "mutation", "=", "new", "Mutation", "(", ")", ";", "mutation", ".", "setColumn_or_supercolumn", "(", "cosc", ")", ";", "return", "mutation", ";", "}" ]
Create a Mutation with the given column name and column value
[ "Create", "a", "Mutation", "with", "the", "given", "column", "name", "and", "column", "value" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/CassandraTransaction.java#L119-L134
138,467
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/CassandraTransaction.java
CassandraTransaction.createDeleteColumnMutation
private static Mutation createDeleteColumnMutation(byte[] colName, long timestamp) { SlicePredicate slicePred = new SlicePredicate(); slicePred.addToColumn_names(ByteBuffer.wrap(colName)); Deletion deletion = new Deletion(); deletion.setPredicate(slicePred); deletion.setTimestamp(timestamp); Mutation mutation = new Mutation(); mutation.setDeletion(deletion); return mutation; }
java
private static Mutation createDeleteColumnMutation(byte[] colName, long timestamp) { SlicePredicate slicePred = new SlicePredicate(); slicePred.addToColumn_names(ByteBuffer.wrap(colName)); Deletion deletion = new Deletion(); deletion.setPredicate(slicePred); deletion.setTimestamp(timestamp); Mutation mutation = new Mutation(); mutation.setDeletion(deletion); return mutation; }
[ "private", "static", "Mutation", "createDeleteColumnMutation", "(", "byte", "[", "]", "colName", ",", "long", "timestamp", ")", "{", "SlicePredicate", "slicePred", "=", "new", "SlicePredicate", "(", ")", ";", "slicePred", ".", "addToColumn_names", "(", "ByteBuffer", ".", "wrap", "(", "colName", ")", ")", ";", "Deletion", "deletion", "=", "new", "Deletion", "(", ")", ";", "deletion", ".", "setPredicate", "(", "slicePred", ")", ";", "deletion", ".", "setTimestamp", "(", "timestamp", ")", ";", "Mutation", "mutation", "=", "new", "Mutation", "(", ")", ";", "mutation", ".", "setDeletion", "(", "deletion", ")", ";", "return", "mutation", ";", "}" ]
Create a column mutation that deletes the given column name.
[ "Create", "a", "column", "mutation", "that", "deletes", "the", "given", "column", "name", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/CassandraTransaction.java#L137-L148
138,468
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/olap/collections/NumericUtils.java
NumericUtils.gcd
public static long gcd(long x, long y) { if(x < 0) x = -x; if(y < 0) y = -y; if(x < y) { long temp = x; x = y; y = temp; } long gcd = 1; while(y > 1) { if((x & 1) == 0) { if((y & 1) == 0) { gcd <<= 1; x >>= 1; y >>= 1; } else { x >>= 1; } } else { if((y & 1) == 0) { y >>= 1; } else { x = (x - y) >> 1; } } if(x < y) { long temp = x; x = y; y = temp; } } return y == 1 ? gcd : gcd * x; }
java
public static long gcd(long x, long y) { if(x < 0) x = -x; if(y < 0) y = -y; if(x < y) { long temp = x; x = y; y = temp; } long gcd = 1; while(y > 1) { if((x & 1) == 0) { if((y & 1) == 0) { gcd <<= 1; x >>= 1; y >>= 1; } else { x >>= 1; } } else { if((y & 1) == 0) { y >>= 1; } else { x = (x - y) >> 1; } } if(x < y) { long temp = x; x = y; y = temp; } } return y == 1 ? gcd : gcd * x; }
[ "public", "static", "long", "gcd", "(", "long", "x", ",", "long", "y", ")", "{", "if", "(", "x", "<", "0", ")", "x", "=", "-", "x", ";", "if", "(", "y", "<", "0", ")", "y", "=", "-", "y", ";", "if", "(", "x", "<", "y", ")", "{", "long", "temp", "=", "x", ";", "x", "=", "y", ";", "y", "=", "temp", ";", "}", "long", "gcd", "=", "1", ";", "while", "(", "y", ">", "1", ")", "{", "if", "(", "(", "x", "&", "1", ")", "==", "0", ")", "{", "if", "(", "(", "y", "&", "1", ")", "==", "0", ")", "{", "gcd", "<<=", "1", ";", "x", ">>=", "1", ";", "y", ">>=", "1", ";", "}", "else", "{", "x", ">>=", "1", ";", "}", "}", "else", "{", "if", "(", "(", "y", "&", "1", ")", "==", "0", ")", "{", "y", ">>=", "1", ";", "}", "else", "{", "x", "=", "(", "x", "-", "y", ")", ">>", "1", ";", "}", "}", "if", "(", "x", "<", "y", ")", "{", "long", "temp", "=", "x", ";", "x", "=", "y", ";", "y", "=", "temp", ";", "}", "}", "return", "y", "==", "1", "?", "gcd", ":", "gcd", "*", "x", ";", "}" ]
greatest common divisor
[ "greatest", "common", "divisor" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/olap/collections/NumericUtils.java#L43-L75
138,469
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/DBConn.java
DBConn.getColumn
ColumnOrSuperColumn getColumn(ByteBuffer key, ColumnPath colPath) { m_logger.debug("Fetching {}.{}", new Object[]{Utils.toString(key), toString(colPath)}); ColumnOrSuperColumn column = null; boolean bSuccess = false; for (int attempts = 1; !bSuccess; attempts++) { try { // Attempt to retrieve a slice list. Date startDate = new Date(); column = m_client.get(key, colPath, ConsistencyLevel.ONE); timing("get", startDate); if (attempts > 1) { m_logger.info("get() succeeded on attempt #{}", attempts); } bSuccess = true; } catch (NotFoundException ex) { return null; } catch (InvalidRequestException ex) { // No point in retrying this one. String errMsg = "get() failed for table: " + colPath.getColumn_family(); m_bFailed = true; m_logger.error(errMsg, ex); throw new RuntimeException(errMsg, ex); } catch (Exception ex) { // Abort if all retries exceeded. if (attempts >= m_max_read_attempts) { String errMsg = "All retries exceeded; abandoning get() for table: " + colPath.getColumn_family(); m_bFailed = true; m_logger.error(errMsg, ex); throw new RuntimeException(errMsg, ex); } // Report retry as a warning. m_logger.warn("get() attempt #{} failed: {}", attempts, ex); try { Thread.sleep(attempts * m_retry_wait_millis); } catch (InterruptedException e1) { // ignore } reconnect(ex); } } return column; }
java
ColumnOrSuperColumn getColumn(ByteBuffer key, ColumnPath colPath) { m_logger.debug("Fetching {}.{}", new Object[]{Utils.toString(key), toString(colPath)}); ColumnOrSuperColumn column = null; boolean bSuccess = false; for (int attempts = 1; !bSuccess; attempts++) { try { // Attempt to retrieve a slice list. Date startDate = new Date(); column = m_client.get(key, colPath, ConsistencyLevel.ONE); timing("get", startDate); if (attempts > 1) { m_logger.info("get() succeeded on attempt #{}", attempts); } bSuccess = true; } catch (NotFoundException ex) { return null; } catch (InvalidRequestException ex) { // No point in retrying this one. String errMsg = "get() failed for table: " + colPath.getColumn_family(); m_bFailed = true; m_logger.error(errMsg, ex); throw new RuntimeException(errMsg, ex); } catch (Exception ex) { // Abort if all retries exceeded. if (attempts >= m_max_read_attempts) { String errMsg = "All retries exceeded; abandoning get() for table: " + colPath.getColumn_family(); m_bFailed = true; m_logger.error(errMsg, ex); throw new RuntimeException(errMsg, ex); } // Report retry as a warning. m_logger.warn("get() attempt #{} failed: {}", attempts, ex); try { Thread.sleep(attempts * m_retry_wait_millis); } catch (InterruptedException e1) { // ignore } reconnect(ex); } } return column; }
[ "ColumnOrSuperColumn", "getColumn", "(", "ByteBuffer", "key", ",", "ColumnPath", "colPath", ")", "{", "m_logger", ".", "debug", "(", "\"Fetching {}.{}\"", ",", "new", "Object", "[", "]", "{", "Utils", ".", "toString", "(", "key", ")", ",", "toString", "(", "colPath", ")", "}", ")", ";", "ColumnOrSuperColumn", "column", "=", "null", ";", "boolean", "bSuccess", "=", "false", ";", "for", "(", "int", "attempts", "=", "1", ";", "!", "bSuccess", ";", "attempts", "++", ")", "{", "try", "{", "// Attempt to retrieve a slice list.\r", "Date", "startDate", "=", "new", "Date", "(", ")", ";", "column", "=", "m_client", ".", "get", "(", "key", ",", "colPath", ",", "ConsistencyLevel", ".", "ONE", ")", ";", "timing", "(", "\"get\"", ",", "startDate", ")", ";", "if", "(", "attempts", ">", "1", ")", "{", "m_logger", ".", "info", "(", "\"get() succeeded on attempt #{}\"", ",", "attempts", ")", ";", "}", "bSuccess", "=", "true", ";", "}", "catch", "(", "NotFoundException", "ex", ")", "{", "return", "null", ";", "}", "catch", "(", "InvalidRequestException", "ex", ")", "{", "// No point in retrying this one.\r", "String", "errMsg", "=", "\"get() failed for table: \"", "+", "colPath", ".", "getColumn_family", "(", ")", ";", "m_bFailed", "=", "true", ";", "m_logger", ".", "error", "(", "errMsg", ",", "ex", ")", ";", "throw", "new", "RuntimeException", "(", "errMsg", ",", "ex", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "// Abort if all retries exceeded.\r", "if", "(", "attempts", ">=", "m_max_read_attempts", ")", "{", "String", "errMsg", "=", "\"All retries exceeded; abandoning get() for table: \"", "+", "colPath", ".", "getColumn_family", "(", ")", ";", "m_bFailed", "=", "true", ";", "m_logger", ".", "error", "(", "errMsg", ",", "ex", ")", ";", "throw", "new", "RuntimeException", "(", "errMsg", ",", "ex", ")", ";", "}", "// Report retry as a warning.\r", "m_logger", ".", "warn", "(", "\"get() attempt #{} failed: {}\"", ",", "attempts", ",", "ex", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "attempts", "*", "m_retry_wait_millis", ")", ";", "}", "catch", "(", "InterruptedException", "e1", ")", "{", "// ignore\r", "}", "reconnect", "(", "ex", ")", ";", "}", "}", "return", "column", ";", "}" ]
Fetch a single column.
[ "Fetch", "a", "single", "column", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/DBConn.java#L387-L430
138,470
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/DBConn.java
DBConn.commitDeletes
private void commitDeletes(DBTransaction dbTran, long timestamp) { Map<String, Set<ByteBuffer>> rowDeleteMap = CassandraTransaction.getRowDeletionMap(dbTran); if (rowDeleteMap.size() == 0) { return; } // Iterate through all ColumnFamilies for (String colFamName : rowDeleteMap.keySet()) { // Delete each row in this key set. Set<ByteBuffer> rowKeySet = rowDeleteMap.get(colFamName); for (ByteBuffer rowKey : rowKeySet) { removeRow(timestamp, rowKey, new ColumnPath(colFamName)); } } }
java
private void commitDeletes(DBTransaction dbTran, long timestamp) { Map<String, Set<ByteBuffer>> rowDeleteMap = CassandraTransaction.getRowDeletionMap(dbTran); if (rowDeleteMap.size() == 0) { return; } // Iterate through all ColumnFamilies for (String colFamName : rowDeleteMap.keySet()) { // Delete each row in this key set. Set<ByteBuffer> rowKeySet = rowDeleteMap.get(colFamName); for (ByteBuffer rowKey : rowKeySet) { removeRow(timestamp, rowKey, new ColumnPath(colFamName)); } } }
[ "private", "void", "commitDeletes", "(", "DBTransaction", "dbTran", ",", "long", "timestamp", ")", "{", "Map", "<", "String", ",", "Set", "<", "ByteBuffer", ">", ">", "rowDeleteMap", "=", "CassandraTransaction", ".", "getRowDeletionMap", "(", "dbTran", ")", ";", "if", "(", "rowDeleteMap", ".", "size", "(", ")", "==", "0", ")", "{", "return", ";", "}", "// Iterate through all ColumnFamilies\r", "for", "(", "String", "colFamName", ":", "rowDeleteMap", ".", "keySet", "(", ")", ")", "{", "// Delete each row in this key set.\r", "Set", "<", "ByteBuffer", ">", "rowKeySet", "=", "rowDeleteMap", ".", "get", "(", "colFamName", ")", ";", "for", "(", "ByteBuffer", "rowKey", ":", "rowKeySet", ")", "{", "removeRow", "(", "timestamp", ",", "rowKey", ",", "new", "ColumnPath", "(", "colFamName", ")", ")", ";", "}", "}", "}" ]
Commit all row-deletions in the given MutationMap, if any, using the given timestamp.
[ "Commit", "all", "row", "-", "deletions", "in", "the", "given", "MutationMap", "if", "any", "using", "the", "given", "timestamp", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/DBConn.java#L434-L448
138,471
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/DBConn.java
DBConn.commitMutations
private void commitMutations(DBTransaction dbTran, long timestamp) { Map<ByteBuffer, Map<String, List<Mutation>>> colMutMap = CassandraTransaction.getUpdateMap(dbTran, timestamp); if (colMutMap.size() == 0) { return; } m_logger.debug("Committing {} mutations", CassandraTransaction.totalColumnMutations(dbTran)); // The batch_mutate will be retried up to MAX_COMMIT_RETRIES times. boolean bSuccess = false; for (int attempts = 1; !bSuccess; attempts++) { try { // Attempt to commit all updates in the the current mutation map. Date startDate = new Date(); m_client.batch_mutate(colMutMap, ConsistencyLevel.ONE); timing("commitMutations", startDate); if (attempts > 1) { // Since we had a failure and warned about it, confirm which attempt succeeded. m_logger.info("batch_mutate() succeeded on attempt #{}", attempts); } bSuccess = true; } catch (InvalidRequestException ex) { // No point in retrying this one. m_bFailed = true; m_logger.error("batch_mutate() failed", ex); throw new RuntimeException("batch_mutate() failed", ex); } catch (Exception ex) { // If we've reached the retry limit, we fail this commit. if (attempts >= m_max_commit_attempts) { m_bFailed = true; m_logger.error("All retries exceeded; abandoning batch_mutate()", ex); throw new RuntimeException("All retries exceeded; abandoning batch_mutate()", ex); } // Report retry as a warning. m_logger.warn("batch_mutate() attempt #{} failed: {}", attempts, ex); try { // We wait more with each failure. Thread.sleep(attempts * m_retry_wait_millis); } catch (InterruptedException e1) { // ignore } // Experience suggests that even for timeout exceptions, the connection // may be bad, so we attempt to reconnect. If this fails, it will throw // an DBNotAvailableException, which we pass to the caller. reconnect(ex); } } }
java
private void commitMutations(DBTransaction dbTran, long timestamp) { Map<ByteBuffer, Map<String, List<Mutation>>> colMutMap = CassandraTransaction.getUpdateMap(dbTran, timestamp); if (colMutMap.size() == 0) { return; } m_logger.debug("Committing {} mutations", CassandraTransaction.totalColumnMutations(dbTran)); // The batch_mutate will be retried up to MAX_COMMIT_RETRIES times. boolean bSuccess = false; for (int attempts = 1; !bSuccess; attempts++) { try { // Attempt to commit all updates in the the current mutation map. Date startDate = new Date(); m_client.batch_mutate(colMutMap, ConsistencyLevel.ONE); timing("commitMutations", startDate); if (attempts > 1) { // Since we had a failure and warned about it, confirm which attempt succeeded. m_logger.info("batch_mutate() succeeded on attempt #{}", attempts); } bSuccess = true; } catch (InvalidRequestException ex) { // No point in retrying this one. m_bFailed = true; m_logger.error("batch_mutate() failed", ex); throw new RuntimeException("batch_mutate() failed", ex); } catch (Exception ex) { // If we've reached the retry limit, we fail this commit. if (attempts >= m_max_commit_attempts) { m_bFailed = true; m_logger.error("All retries exceeded; abandoning batch_mutate()", ex); throw new RuntimeException("All retries exceeded; abandoning batch_mutate()", ex); } // Report retry as a warning. m_logger.warn("batch_mutate() attempt #{} failed: {}", attempts, ex); try { // We wait more with each failure. Thread.sleep(attempts * m_retry_wait_millis); } catch (InterruptedException e1) { // ignore } // Experience suggests that even for timeout exceptions, the connection // may be bad, so we attempt to reconnect. If this fails, it will throw // an DBNotAvailableException, which we pass to the caller. reconnect(ex); } } }
[ "private", "void", "commitMutations", "(", "DBTransaction", "dbTran", ",", "long", "timestamp", ")", "{", "Map", "<", "ByteBuffer", ",", "Map", "<", "String", ",", "List", "<", "Mutation", ">", ">", ">", "colMutMap", "=", "CassandraTransaction", ".", "getUpdateMap", "(", "dbTran", ",", "timestamp", ")", ";", "if", "(", "colMutMap", ".", "size", "(", ")", "==", "0", ")", "{", "return", ";", "}", "m_logger", ".", "debug", "(", "\"Committing {} mutations\"", ",", "CassandraTransaction", ".", "totalColumnMutations", "(", "dbTran", ")", ")", ";", "// The batch_mutate will be retried up to MAX_COMMIT_RETRIES times.\r", "boolean", "bSuccess", "=", "false", ";", "for", "(", "int", "attempts", "=", "1", ";", "!", "bSuccess", ";", "attempts", "++", ")", "{", "try", "{", "// Attempt to commit all updates in the the current mutation map.\r", "Date", "startDate", "=", "new", "Date", "(", ")", ";", "m_client", ".", "batch_mutate", "(", "colMutMap", ",", "ConsistencyLevel", ".", "ONE", ")", ";", "timing", "(", "\"commitMutations\"", ",", "startDate", ")", ";", "if", "(", "attempts", ">", "1", ")", "{", "// Since we had a failure and warned about it, confirm which attempt succeeded.\r", "m_logger", ".", "info", "(", "\"batch_mutate() succeeded on attempt #{}\"", ",", "attempts", ")", ";", "}", "bSuccess", "=", "true", ";", "}", "catch", "(", "InvalidRequestException", "ex", ")", "{", "// No point in retrying this one.\r", "m_bFailed", "=", "true", ";", "m_logger", ".", "error", "(", "\"batch_mutate() failed\"", ",", "ex", ")", ";", "throw", "new", "RuntimeException", "(", "\"batch_mutate() failed\"", ",", "ex", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "// If we've reached the retry limit, we fail this commit.\r", "if", "(", "attempts", ">=", "m_max_commit_attempts", ")", "{", "m_bFailed", "=", "true", ";", "m_logger", ".", "error", "(", "\"All retries exceeded; abandoning batch_mutate()\"", ",", "ex", ")", ";", "throw", "new", "RuntimeException", "(", "\"All retries exceeded; abandoning batch_mutate()\"", ",", "ex", ")", ";", "}", "// Report retry as a warning.\r", "m_logger", ".", "warn", "(", "\"batch_mutate() attempt #{} failed: {}\"", ",", "attempts", ",", "ex", ")", ";", "try", "{", "// We wait more with each failure.\r", "Thread", ".", "sleep", "(", "attempts", "*", "m_retry_wait_millis", ")", ";", "}", "catch", "(", "InterruptedException", "e1", ")", "{", "// ignore\r", "}", "// Experience suggests that even for timeout exceptions, the connection\r", "// may be bad, so we attempt to reconnect. If this fails, it will throw\r", "// an DBNotAvailableException, which we pass to the caller.\r", "reconnect", "(", "ex", ")", ";", "}", "}", "}" ]
configured maximum number of retries.
[ "configured", "maximum", "number", "of", "retries", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/DBConn.java#L452-L500
138,472
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/DBConn.java
DBConn.reconnect
private void reconnect(Exception reconnectEx) { // Log the exception as a warning. m_logger.warn("Reconnecting to Cassandra due to error", reconnectEx); // Reconnect up to the configured number of times, waiting a little between each attempt. boolean bSuccess = false; for (int attempt = 1; !bSuccess; attempt++) { try { close(); m_dbService.connectDBConn(this); m_logger.debug("Reconnect successful"); bSuccess = true; } catch (Exception ex) { // Abort if all retries failed. if (attempt >= m_max_reconnect_attempts) { m_logger.error("All reconnect attempts failed; abandoning reconnect", ex); throw new DBNotAvailableException("All reconnect attempts failed", ex); } m_logger.warn("Reconnect attempt #" + attempt + " failed", ex); try { Thread.sleep(m_retry_wait_millis * attempt); } catch (InterruptedException e) { // Ignore } } } }
java
private void reconnect(Exception reconnectEx) { // Log the exception as a warning. m_logger.warn("Reconnecting to Cassandra due to error", reconnectEx); // Reconnect up to the configured number of times, waiting a little between each attempt. boolean bSuccess = false; for (int attempt = 1; !bSuccess; attempt++) { try { close(); m_dbService.connectDBConn(this); m_logger.debug("Reconnect successful"); bSuccess = true; } catch (Exception ex) { // Abort if all retries failed. if (attempt >= m_max_reconnect_attempts) { m_logger.error("All reconnect attempts failed; abandoning reconnect", ex); throw new DBNotAvailableException("All reconnect attempts failed", ex); } m_logger.warn("Reconnect attempt #" + attempt + " failed", ex); try { Thread.sleep(m_retry_wait_millis * attempt); } catch (InterruptedException e) { // Ignore } } } }
[ "private", "void", "reconnect", "(", "Exception", "reconnectEx", ")", "{", "// Log the exception as a warning.\r", "m_logger", ".", "warn", "(", "\"Reconnecting to Cassandra due to error\"", ",", "reconnectEx", ")", ";", "// Reconnect up to the configured number of times, waiting a little between each attempt.\r", "boolean", "bSuccess", "=", "false", ";", "for", "(", "int", "attempt", "=", "1", ";", "!", "bSuccess", ";", "attempt", "++", ")", "{", "try", "{", "close", "(", ")", ";", "m_dbService", ".", "connectDBConn", "(", "this", ")", ";", "m_logger", ".", "debug", "(", "\"Reconnect successful\"", ")", ";", "bSuccess", "=", "true", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "// Abort if all retries failed.\r", "if", "(", "attempt", ">=", "m_max_reconnect_attempts", ")", "{", "m_logger", ".", "error", "(", "\"All reconnect attempts failed; abandoning reconnect\"", ",", "ex", ")", ";", "throw", "new", "DBNotAvailableException", "(", "\"All reconnect attempts failed\"", ",", "ex", ")", ";", "}", "m_logger", ".", "warn", "(", "\"Reconnect attempt #\"", "+", "attempt", "+", "\" failed\"", ",", "ex", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "m_retry_wait_millis", "*", "attempt", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "// Ignore\r", "}", "}", "}", "}" ]
an DBNotAvailableException and leave the Thrift connection null.
[ "an", "DBNotAvailableException", "and", "leave", "the", "Thrift", "connection", "null", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/DBConn.java#L518-L544
138,473
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/DBConn.java
DBConn.timing
private void timing(String metric, Date startDate) { m_logger.trace("Time for '{}': {}", metric, ((new Date()).getTime() - startDate.getTime()) + " millis"); }
java
private void timing(String metric, Date startDate) { m_logger.trace("Time for '{}': {}", metric, ((new Date()).getTime() - startDate.getTime()) + " millis"); }
[ "private", "void", "timing", "(", "String", "metric", ",", "Date", "startDate", ")", "{", "m_logger", ".", "trace", "(", "\"Time for '{}': {}\"", ",", "metric", ",", "(", "(", "new", "Date", "(", ")", ")", ".", "getTime", "(", ")", "-", "startDate", ".", "getTime", "(", ")", ")", "+", "\" millis\"", ")", ";", "}" ]
milliseconds using the given prefix as a label.
[ "milliseconds", "using", "the", "given", "prefix", "as", "a", "label", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/DBConn.java#L602-L605
138,474
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/XMLBuilder.java
XMLBuilder.startElement
public void startElement(String elemName, String attrName, String attrValue) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", attrName, "", "CDATA", attrValue); writeStartElement(elemName, attrs); m_tagStack.push(elemName); }
java
public void startElement(String elemName, String attrName, String attrValue) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", attrName, "", "CDATA", attrValue); writeStartElement(elemName, attrs); m_tagStack.push(elemName); }
[ "public", "void", "startElement", "(", "String", "elemName", ",", "String", "attrName", ",", "String", "attrValue", ")", "{", "AttributesImpl", "attrs", "=", "new", "AttributesImpl", "(", ")", ";", "attrs", ".", "addAttribute", "(", "\"\"", ",", "attrName", ",", "\"\"", ",", "\"CDATA\"", ",", "attrValue", ")", ";", "writeStartElement", "(", "elemName", ",", "attrs", ")", ";", "m_tagStack", ".", "push", "(", "elemName", ")", ";", "}" ]
Start a new XML element using the given start tag and single attribute.
[ "Start", "a", "new", "XML", "element", "using", "the", "given", "start", "tag", "and", "single", "attribute", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/XMLBuilder.java#L73-L78
138,475
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/XMLBuilder.java
XMLBuilder.startElement
public void startElement(String elemName, Attributes attrs) { writeStartElement(elemName, attrs); m_tagStack.push(elemName); }
java
public void startElement(String elemName, Attributes attrs) { writeStartElement(elemName, attrs); m_tagStack.push(elemName); }
[ "public", "void", "startElement", "(", "String", "elemName", ",", "Attributes", "attrs", ")", "{", "writeStartElement", "(", "elemName", ",", "attrs", ")", ";", "m_tagStack", ".", "push", "(", "elemName", ")", ";", "}" ]
Start a new XML element using the given name and attribute set.
[ "Start", "a", "new", "XML", "element", "using", "the", "given", "name", "and", "attribute", "set", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/XMLBuilder.java#L81-L84
138,476
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/XMLBuilder.java
XMLBuilder.addDataElement
public void addDataElement(String elemName, String content, Attributes attrs) { writeDataElement(elemName, attrs, content); }
java
public void addDataElement(String elemName, String content, Attributes attrs) { writeDataElement(elemName, attrs, content); }
[ "public", "void", "addDataElement", "(", "String", "elemName", ",", "String", "content", ",", "Attributes", "attrs", ")", "{", "writeDataElement", "(", "elemName", ",", "attrs", ",", "content", ")", ";", "}" ]
Same as above but using an attribute set.
[ "Same", "as", "above", "but", "using", "an", "attribute", "set", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/XMLBuilder.java#L112-L114
138,477
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/XMLBuilder.java
XMLBuilder.toAttributes
private Attributes toAttributes(Map<String,String> attrs){ AttributesImpl impl = new AttributesImpl(); for (Map.Entry<String,String> attr : attrs.entrySet()){ impl.addAttribute("", attr.getKey(), "", "CDATA", attr.getValue()); } return impl; }
java
private Attributes toAttributes(Map<String,String> attrs){ AttributesImpl impl = new AttributesImpl(); for (Map.Entry<String,String> attr : attrs.entrySet()){ impl.addAttribute("", attr.getKey(), "", "CDATA", attr.getValue()); } return impl; }
[ "private", "Attributes", "toAttributes", "(", "Map", "<", "String", ",", "String", ">", "attrs", ")", "{", "AttributesImpl", "impl", "=", "new", "AttributesImpl", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "attr", ":", "attrs", ".", "entrySet", "(", ")", ")", "{", "impl", ".", "addAttribute", "(", "\"\"", ",", "attr", ".", "getKey", "(", ")", ",", "\"\"", ",", "\"CDATA\"", ",", "attr", ".", "getValue", "(", ")", ")", ";", "}", "return", "impl", ";", "}" ]
Converts attribute map to Attributes class instance.
[ "Converts", "attribute", "map", "to", "Attributes", "class", "instance", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/XMLBuilder.java#L130-L136
138,478
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java
ApplicationDefinition.isValidName
public static boolean isValidName(String appName) { return appName != null && appName.length() > 0 && Utils.isLetter(appName.charAt(0)) && Utils.allAlphaNumUnderscore(appName); }
java
public static boolean isValidName(String appName) { return appName != null && appName.length() > 0 && Utils.isLetter(appName.charAt(0)) && Utils.allAlphaNumUnderscore(appName); }
[ "public", "static", "boolean", "isValidName", "(", "String", "appName", ")", "{", "return", "appName", "!=", "null", "&&", "appName", ".", "length", "(", ")", ">", "0", "&&", "Utils", ".", "isLetter", "(", "appName", ".", "charAt", "(", "0", ")", ")", "&&", "Utils", ".", "allAlphaNumUnderscore", "(", "appName", ")", ";", "}" ]
Test the given string for validity as an application name. A valid application name must begin with a letter and contain only letters, digits, and underscores. @param appName Candidate application name. @return True if name is syntactically valid.
[ "Test", "the", "given", "string", "for", "validity", "as", "an", "application", "name", ".", "A", "valid", "application", "name", "must", "begin", "with", "a", "letter", "and", "contain", "only", "letters", "digits", "and", "underscores", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java#L58-L63
138,479
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java
ApplicationDefinition.parse
public void parse(UNode appNode) { assert appNode != null; // Verify application name and save it. setAppName(appNode.getName()); // Iterate through the application object's members. for (String childName : appNode.getMemberNames()) { // See if we recognize this member. UNode childNode = appNode.getMember(childName); // "key" if (childName.equals("key")) { // Must be a value. Utils.require(childNode.isValue(), "'key' value must be a string: " + childNode); Utils.require(m_key == null, "'key' can be specified only once"); m_key = childNode.getValue(); // "options" } else if (childName.equals("options")) { // Each name in the map is an option name. for (String optName : childNode.getMemberNames()) { // Option must be a value. UNode optNode = childNode.getMember(optName); Utils.require(optNode.isValue(), "'option' must be a value: " + optNode); setOption(optNode.getName(), optNode.getValue()); } // "tables" } else if (childName.equals("tables")) { // Should be specified only once. Utils.require(m_tableMap.size() == 0, "'tables' can be specified only once"); // Parse the table definitions, adding them to this app def and building // the external link map as we go. for (UNode tableNode : childNode.getMemberList()) { // This will throw if the table definition has an error. TableDefinition tableDef = new TableDefinition(); tableDef.parse(tableNode); addTable(tableDef); } // Unrecognized } else { Utils.require(false, "Unrecognized 'application' element: " + childName); } } verify(); }
java
public void parse(UNode appNode) { assert appNode != null; // Verify application name and save it. setAppName(appNode.getName()); // Iterate through the application object's members. for (String childName : appNode.getMemberNames()) { // See if we recognize this member. UNode childNode = appNode.getMember(childName); // "key" if (childName.equals("key")) { // Must be a value. Utils.require(childNode.isValue(), "'key' value must be a string: " + childNode); Utils.require(m_key == null, "'key' can be specified only once"); m_key = childNode.getValue(); // "options" } else if (childName.equals("options")) { // Each name in the map is an option name. for (String optName : childNode.getMemberNames()) { // Option must be a value. UNode optNode = childNode.getMember(optName); Utils.require(optNode.isValue(), "'option' must be a value: " + optNode); setOption(optNode.getName(), optNode.getValue()); } // "tables" } else if (childName.equals("tables")) { // Should be specified only once. Utils.require(m_tableMap.size() == 0, "'tables' can be specified only once"); // Parse the table definitions, adding them to this app def and building // the external link map as we go. for (UNode tableNode : childNode.getMemberList()) { // This will throw if the table definition has an error. TableDefinition tableDef = new TableDefinition(); tableDef.parse(tableNode); addTable(tableDef); } // Unrecognized } else { Utils.require(false, "Unrecognized 'application' element: " + childName); } } verify(); }
[ "public", "void", "parse", "(", "UNode", "appNode", ")", "{", "assert", "appNode", "!=", "null", ";", "// Verify application name and save it.\r", "setAppName", "(", "appNode", ".", "getName", "(", ")", ")", ";", "// Iterate through the application object's members.\r", "for", "(", "String", "childName", ":", "appNode", ".", "getMemberNames", "(", ")", ")", "{", "// See if we recognize this member.\r", "UNode", "childNode", "=", "appNode", ".", "getMember", "(", "childName", ")", ";", "// \"key\"\r", "if", "(", "childName", ".", "equals", "(", "\"key\"", ")", ")", "{", "// Must be a value.\r", "Utils", ".", "require", "(", "childNode", ".", "isValue", "(", ")", ",", "\"'key' value must be a string: \"", "+", "childNode", ")", ";", "Utils", ".", "require", "(", "m_key", "==", "null", ",", "\"'key' can be specified only once\"", ")", ";", "m_key", "=", "childNode", ".", "getValue", "(", ")", ";", "// \"options\"\r", "}", "else", "if", "(", "childName", ".", "equals", "(", "\"options\"", ")", ")", "{", "// Each name in the map is an option name.\r", "for", "(", "String", "optName", ":", "childNode", ".", "getMemberNames", "(", ")", ")", "{", "// Option must be a value.\r", "UNode", "optNode", "=", "childNode", ".", "getMember", "(", "optName", ")", ";", "Utils", ".", "require", "(", "optNode", ".", "isValue", "(", ")", ",", "\"'option' must be a value: \"", "+", "optNode", ")", ";", "setOption", "(", "optNode", ".", "getName", "(", ")", ",", "optNode", ".", "getValue", "(", ")", ")", ";", "}", "// \"tables\"\r", "}", "else", "if", "(", "childName", ".", "equals", "(", "\"tables\"", ")", ")", "{", "// Should be specified only once.\r", "Utils", ".", "require", "(", "m_tableMap", ".", "size", "(", ")", "==", "0", ",", "\"'tables' can be specified only once\"", ")", ";", "// Parse the table definitions, adding them to this app def and building\r", "// the external link map as we go.\r", "for", "(", "UNode", "tableNode", ":", "childNode", ".", "getMemberList", "(", ")", ")", "{", "// This will throw if the table definition has an error.\r", "TableDefinition", "tableDef", "=", "new", "TableDefinition", "(", ")", ";", "tableDef", ".", "parse", "(", "tableNode", ")", ";", "addTable", "(", "tableDef", ")", ";", "}", "// Unrecognized\r", "}", "else", "{", "Utils", ".", "require", "(", "false", ",", "\"Unrecognized 'application' element: \"", "+", "childName", ")", ";", "}", "}", "verify", "(", ")", ";", "}" ]
Parse the application definition rooted at given UNode tree and copy its contents into this object. The root node is the "application" object, so its name is the application name and its child nodes are definitions such as "key", "options", "fields", etc. An exception is thrown if the definition contains an error. @param appNode Root of a UNode tree that defines an application.
[ "Parse", "the", "application", "definition", "rooted", "at", "given", "UNode", "tree", "and", "copy", "its", "contents", "into", "this", "object", ".", "The", "root", "node", "is", "the", "application", "object", "so", "its", "name", "is", "the", "application", "name", "and", "its", "child", "nodes", "are", "definitions", "such", "as", "key", "options", "fields", "etc", ".", "An", "exception", "is", "thrown", "if", "the", "definition", "contains", "an", "error", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java#L79-L132
138,480
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java
ApplicationDefinition.allowsAutoTables
public boolean allowsAutoTables() { String optValue = getOption(CommonDefs.AUTO_TABLES); return optValue != null && optValue.equalsIgnoreCase("true"); }
java
public boolean allowsAutoTables() { String optValue = getOption(CommonDefs.AUTO_TABLES); return optValue != null && optValue.equalsIgnoreCase("true"); }
[ "public", "boolean", "allowsAutoTables", "(", ")", "{", "String", "optValue", "=", "getOption", "(", "CommonDefs", ".", "AUTO_TABLES", ")", ";", "return", "optValue", "!=", "null", "&&", "optValue", ".", "equalsIgnoreCase", "(", "\"true\"", ")", ";", "}" ]
Indicate whether or not this application tables to be implicitly created. @return True if this application tables to be implicitly created.
[ "Indicate", "whether", "or", "not", "this", "application", "tables", "to", "be", "implicitly", "created", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java#L164-L167
138,481
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java
ApplicationDefinition.setOption
public void setOption(String optName, String optValue) { if (optValue == null) { m_optionMap.remove(optName); } else { m_optionMap.put(optName, optValue.trim()); } }
java
public void setOption(String optName, String optValue) { if (optValue == null) { m_optionMap.remove(optName); } else { m_optionMap.put(optName, optValue.trim()); } }
[ "public", "void", "setOption", "(", "String", "optName", ",", "String", "optValue", ")", "{", "if", "(", "optValue", "==", "null", ")", "{", "m_optionMap", ".", "remove", "(", "optName", ")", ";", "}", "else", "{", "m_optionMap", ".", "put", "(", "optName", ",", "optValue", ".", "trim", "(", ")", ")", ";", "}", "}" ]
Set the option with the given name to the given value. If the option value is null, the option is "unset". If the option has an existing value, it is replaced. @param optName Name of option to set (case-sensitive). @param optValue New value of option or null to "unset".
[ "Set", "the", "option", "with", "the", "given", "name", "to", "the", "given", "value", ".", "If", "the", "option", "value", "is", "null", "the", "option", "is", "unset", ".", "If", "the", "option", "has", "an", "existing", "value", "it", "is", "replaced", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java#L302-L308
138,482
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java
ApplicationDefinition.removeTableDef
public void removeTableDef(TableDefinition tableDef) { assert tableDef != null; assert tableDef.getAppDef() == this; m_tableMap.remove(tableDef.getTableName()); }
java
public void removeTableDef(TableDefinition tableDef) { assert tableDef != null; assert tableDef.getAppDef() == this; m_tableMap.remove(tableDef.getTableName()); }
[ "public", "void", "removeTableDef", "(", "TableDefinition", "tableDef", ")", "{", "assert", "tableDef", "!=", "null", ";", "assert", "tableDef", ".", "getAppDef", "(", ")", "==", "this", ";", "m_tableMap", ".", "remove", "(", "tableDef", ".", "getTableName", "(", ")", ")", ";", "}" ]
Remove the given table from this application, presumably because it has been deleted. @param tableDef {@link TableDefinition} to be deleted.
[ "Remove", "the", "given", "table", "from", "this", "application", "presumably", "because", "it", "has", "been", "deleted", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java#L339-L344
138,483
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java
ApplicationDefinition.verify
private void verify() { // Copy table defs to avoid ConcurrentModificationException if we add a table. List<TableDefinition> definedTables = new ArrayList<>(m_tableMap.values()); for (TableDefinition tableDef : definedTables) { // Copy field defs for same reason List<FieldDefinition> definedFields = new ArrayList<>(tableDef.getFieldDefinitions()); for (FieldDefinition fieldDef : definedFields) { if (fieldDef.isLinkType()) { verifyLink(tableDef, fieldDef); } } } }
java
private void verify() { // Copy table defs to avoid ConcurrentModificationException if we add a table. List<TableDefinition> definedTables = new ArrayList<>(m_tableMap.values()); for (TableDefinition tableDef : definedTables) { // Copy field defs for same reason List<FieldDefinition> definedFields = new ArrayList<>(tableDef.getFieldDefinitions()); for (FieldDefinition fieldDef : definedFields) { if (fieldDef.isLinkType()) { verifyLink(tableDef, fieldDef); } } } }
[ "private", "void", "verify", "(", ")", "{", "// Copy table defs to avoid ConcurrentModificationException if we add a table.\r", "List", "<", "TableDefinition", ">", "definedTables", "=", "new", "ArrayList", "<>", "(", "m_tableMap", ".", "values", "(", ")", ")", ";", "for", "(", "TableDefinition", "tableDef", ":", "definedTables", ")", "{", "// Copy field defs for same reason\r", "List", "<", "FieldDefinition", ">", "definedFields", "=", "new", "ArrayList", "<>", "(", "tableDef", ".", "getFieldDefinitions", "(", ")", ")", ";", "for", "(", "FieldDefinition", "fieldDef", ":", "definedFields", ")", "{", "if", "(", "fieldDef", ".", "isLinkType", "(", ")", ")", "{", "verifyLink", "(", "tableDef", ",", "fieldDef", ")", ";", "}", "}", "}", "}" ]
complete and in agreement.
[ "complete", "and", "in", "agreement", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java#L435-L447
138,484
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java
ApplicationDefinition.verifyLink
private void verifyLink(TableDefinition tableDef, FieldDefinition linkDef) { String extent = linkDef.getLinkExtent(); TableDefinition extentTableDef = getTableDef(extent); if (extentTableDef == null) { extentTableDef = new TableDefinition(); extentTableDef.setTableName(extent); tableDef.getAppDef().addTable(extentTableDef); } String inverse = linkDef.getLinkInverse(); FieldDefinition inverseLinkDef = extentTableDef.getFieldDef(inverse); if (inverseLinkDef == null) { inverseLinkDef = new FieldDefinition(inverse); inverseLinkDef.setType(linkDef.getType()); inverseLinkDef.setLinkInverse(linkDef.getName()); inverseLinkDef.setLinkExtent(tableDef.getTableName()); extentTableDef.addFieldDefinition(inverseLinkDef); } else { Utils.require(inverseLinkDef.getType() == linkDef.getType() && // both link or xlink inverseLinkDef.getLinkExtent().equals(tableDef.getTableName()) && inverseLinkDef.getLinkInverse().equals(linkDef.getName()), "Link '%s' in table '%s' conflicts with inverse field '%s' in table '%s'", linkDef.getName(), tableDef.getTableName(), inverseLinkDef.getName(), extentTableDef.getTableName()); } }
java
private void verifyLink(TableDefinition tableDef, FieldDefinition linkDef) { String extent = linkDef.getLinkExtent(); TableDefinition extentTableDef = getTableDef(extent); if (extentTableDef == null) { extentTableDef = new TableDefinition(); extentTableDef.setTableName(extent); tableDef.getAppDef().addTable(extentTableDef); } String inverse = linkDef.getLinkInverse(); FieldDefinition inverseLinkDef = extentTableDef.getFieldDef(inverse); if (inverseLinkDef == null) { inverseLinkDef = new FieldDefinition(inverse); inverseLinkDef.setType(linkDef.getType()); inverseLinkDef.setLinkInverse(linkDef.getName()); inverseLinkDef.setLinkExtent(tableDef.getTableName()); extentTableDef.addFieldDefinition(inverseLinkDef); } else { Utils.require(inverseLinkDef.getType() == linkDef.getType() && // both link or xlink inverseLinkDef.getLinkExtent().equals(tableDef.getTableName()) && inverseLinkDef.getLinkInverse().equals(linkDef.getName()), "Link '%s' in table '%s' conflicts with inverse field '%s' in table '%s'", linkDef.getName(), tableDef.getTableName(), inverseLinkDef.getName(), extentTableDef.getTableName()); } }
[ "private", "void", "verifyLink", "(", "TableDefinition", "tableDef", ",", "FieldDefinition", "linkDef", ")", "{", "String", "extent", "=", "linkDef", ".", "getLinkExtent", "(", ")", ";", "TableDefinition", "extentTableDef", "=", "getTableDef", "(", "extent", ")", ";", "if", "(", "extentTableDef", "==", "null", ")", "{", "extentTableDef", "=", "new", "TableDefinition", "(", ")", ";", "extentTableDef", ".", "setTableName", "(", "extent", ")", ";", "tableDef", ".", "getAppDef", "(", ")", ".", "addTable", "(", "extentTableDef", ")", ";", "}", "String", "inverse", "=", "linkDef", ".", "getLinkInverse", "(", ")", ";", "FieldDefinition", "inverseLinkDef", "=", "extentTableDef", ".", "getFieldDef", "(", "inverse", ")", ";", "if", "(", "inverseLinkDef", "==", "null", ")", "{", "inverseLinkDef", "=", "new", "FieldDefinition", "(", "inverse", ")", ";", "inverseLinkDef", ".", "setType", "(", "linkDef", ".", "getType", "(", ")", ")", ";", "inverseLinkDef", ".", "setLinkInverse", "(", "linkDef", ".", "getName", "(", ")", ")", ";", "inverseLinkDef", ".", "setLinkExtent", "(", "tableDef", ".", "getTableName", "(", ")", ")", ";", "extentTableDef", ".", "addFieldDefinition", "(", "inverseLinkDef", ")", ";", "}", "else", "{", "Utils", ".", "require", "(", "inverseLinkDef", ".", "getType", "(", ")", "==", "linkDef", ".", "getType", "(", ")", "&&", "// both link or xlink\r", "inverseLinkDef", ".", "getLinkExtent", "(", ")", ".", "equals", "(", "tableDef", ".", "getTableName", "(", ")", ")", "&&", "inverseLinkDef", ".", "getLinkInverse", "(", ")", ".", "equals", "(", "linkDef", ".", "getName", "(", ")", ")", ",", "\"Link '%s' in table '%s' conflicts with inverse field '%s' in table '%s'\"", ",", "linkDef", ".", "getName", "(", ")", ",", "tableDef", ".", "getTableName", "(", ")", ",", "inverseLinkDef", ".", "getName", "(", ")", ",", "extentTableDef", ".", "getTableName", "(", ")", ")", ";", "}", "}" ]
has not been defined, add it automatically.
[ "has", "not", "been", "defined", "add", "it", "automatically", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java#L452-L477
138,485
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java
ApplicationDefinition.replaceAliaces
public String replaceAliaces(String str) { if(str == null) return str; // for performance if(str.indexOf(CommonDefs.ALIAS_FIRST_CHAR) < 0) return str; PriorityQueue<AliasDefinition> aliasQueue = new PriorityQueue<AliasDefinition>(11, new Comparator<AliasDefinition>() { public int compare(AliasDefinition alias1, AliasDefinition alias2) { return alias2.getName().length() - alias1.getName().length(); } }); for(TableDefinition tableDef : getTableDefinitions().values()) { for(AliasDefinition aliasDef : tableDef.getAliasDefinitions()) { aliasQueue.add(aliasDef); } } while(true) { String newstring = str; while (aliasQueue.size() != 0) { AliasDefinition aliasDef = aliasQueue.poll(); newstring = newstring.replace(aliasDef.getName(), aliasDef.getExpression()); } if(newstring.equals(str)) break; str = newstring; } return str; }
java
public String replaceAliaces(String str) { if(str == null) return str; // for performance if(str.indexOf(CommonDefs.ALIAS_FIRST_CHAR) < 0) return str; PriorityQueue<AliasDefinition> aliasQueue = new PriorityQueue<AliasDefinition>(11, new Comparator<AliasDefinition>() { public int compare(AliasDefinition alias1, AliasDefinition alias2) { return alias2.getName().length() - alias1.getName().length(); } }); for(TableDefinition tableDef : getTableDefinitions().values()) { for(AliasDefinition aliasDef : tableDef.getAliasDefinitions()) { aliasQueue.add(aliasDef); } } while(true) { String newstring = str; while (aliasQueue.size() != 0) { AliasDefinition aliasDef = aliasQueue.poll(); newstring = newstring.replace(aliasDef.getName(), aliasDef.getExpression()); } if(newstring.equals(str)) break; str = newstring; } return str; }
[ "public", "String", "replaceAliaces", "(", "String", "str", ")", "{", "if", "(", "str", "==", "null", ")", "return", "str", ";", "// for performance\r", "if", "(", "str", ".", "indexOf", "(", "CommonDefs", ".", "ALIAS_FIRST_CHAR", ")", "<", "0", ")", "return", "str", ";", "PriorityQueue", "<", "AliasDefinition", ">", "aliasQueue", "=", "new", "PriorityQueue", "<", "AliasDefinition", ">", "(", "11", ",", "new", "Comparator", "<", "AliasDefinition", ">", "(", ")", "{", "public", "int", "compare", "(", "AliasDefinition", "alias1", ",", "AliasDefinition", "alias2", ")", "{", "return", "alias2", ".", "getName", "(", ")", ".", "length", "(", ")", "-", "alias1", ".", "getName", "(", ")", ".", "length", "(", ")", ";", "}", "}", ")", ";", "for", "(", "TableDefinition", "tableDef", ":", "getTableDefinitions", "(", ")", ".", "values", "(", ")", ")", "{", "for", "(", "AliasDefinition", "aliasDef", ":", "tableDef", ".", "getAliasDefinitions", "(", ")", ")", "{", "aliasQueue", ".", "add", "(", "aliasDef", ")", ";", "}", "}", "while", "(", "true", ")", "{", "String", "newstring", "=", "str", ";", "while", "(", "aliasQueue", ".", "size", "(", ")", "!=", "0", ")", "{", "AliasDefinition", "aliasDef", "=", "aliasQueue", ".", "poll", "(", ")", ";", "newstring", "=", "newstring", ".", "replace", "(", "aliasDef", ".", "getName", "(", ")", ",", "aliasDef", ".", "getExpression", "(", ")", ")", ";", "}", "if", "(", "newstring", ".", "equals", "(", "str", ")", ")", "break", ";", "str", "=", "newstring", ";", "}", "return", "str", ";", "}" ]
Replaces of all occurences of aliases defined with this table, by their expressions. Now a simple string.replace is used. @param str string to replace @return string with replaced aliases. If there were no aliases, the string is unchanged.
[ "Replaces", "of", "all", "occurences", "of", "aliases", "defined", "with", "this", "table", "by", "their", "expressions", ".", "Now", "a", "simple", "string", ".", "replace", "is", "used", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/ApplicationDefinition.java#L486-L512
138,486
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/mbeans/MBeanBase.java
MBeanBase.register
public void register() { try { objectName = consObjectName(domain, type, keysString); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); mbs.registerMBean(this, objectName); } catch (Exception e) { objectName = null; throw new RuntimeException(e); } }
java
public void register() { try { objectName = consObjectName(domain, type, keysString); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); mbs.registerMBean(this, objectName); } catch (Exception e) { objectName = null; throw new RuntimeException(e); } }
[ "public", "void", "register", "(", ")", "{", "try", "{", "objectName", "=", "consObjectName", "(", "domain", ",", "type", ",", "keysString", ")", ";", "MBeanServer", "mbs", "=", "ManagementFactory", ".", "getPlatformMBeanServer", "(", ")", ";", "mbs", ".", "registerMBean", "(", "this", ",", "objectName", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "objectName", "=", "null", ";", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Registers this bean on platform MBeanServer.
[ "Registers", "this", "bean", "on", "platform", "MBeanServer", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/mbeans/MBeanBase.java#L45-L54
138,487
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/mbeans/MBeanBase.java
MBeanBase.deregister
public void deregister() { if(objectName == null) { return; } try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); if (mbs.isRegistered(objectName)) { mbs.unregisterMBean(objectName); } objectName = null; } catch (Exception e) { throw new RuntimeException(e); } }
java
public void deregister() { if(objectName == null) { return; } try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); if (mbs.isRegistered(objectName)) { mbs.unregisterMBean(objectName); } objectName = null; } catch (Exception e) { throw new RuntimeException(e); } }
[ "public", "void", "deregister", "(", ")", "{", "if", "(", "objectName", "==", "null", ")", "{", "return", ";", "}", "try", "{", "MBeanServer", "mbs", "=", "ManagementFactory", ".", "getPlatformMBeanServer", "(", ")", ";", "if", "(", "mbs", ".", "isRegistered", "(", "objectName", ")", ")", "{", "mbs", ".", "unregisterMBean", "(", "objectName", ")", ";", "}", "objectName", "=", "null", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Deregisters this bean on platform MBeanServer.
[ "Deregisters", "this", "bean", "on", "platform", "MBeanServer", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/mbeans/MBeanBase.java#L59-L73
138,488
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/mbeans/MBeanBase.java
MBeanBase.consObjectName
protected ObjectName consObjectName(String domain, String type, String keysString) { String d = domain != null && !"".equals(domain) ? domain : getDefaultDomain(); String t = type != null && !"".equals(type) ? type : getDefaultType(); String k = keysString != null && !"".equals(keysString) ? "," + keysString : ""; try { return new ObjectName(d + ":type=" + t + k); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException(e); } }
java
protected ObjectName consObjectName(String domain, String type, String keysString) { String d = domain != null && !"".equals(domain) ? domain : getDefaultDomain(); String t = type != null && !"".equals(type) ? type : getDefaultType(); String k = keysString != null && !"".equals(keysString) ? "," + keysString : ""; try { return new ObjectName(d + ":type=" + t + k); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException(e); } }
[ "protected", "ObjectName", "consObjectName", "(", "String", "domain", ",", "String", "type", ",", "String", "keysString", ")", "{", "String", "d", "=", "domain", "!=", "null", "&&", "!", "\"\"", ".", "equals", "(", "domain", ")", "?", "domain", ":", "getDefaultDomain", "(", ")", ";", "String", "t", "=", "type", "!=", "null", "&&", "!", "\"\"", ".", "equals", "(", "type", ")", "?", "type", ":", "getDefaultType", "(", ")", ";", "String", "k", "=", "keysString", "!=", "null", "&&", "!", "\"\"", ".", "equals", "(", "keysString", ")", "?", "\",\"", "+", "keysString", ":", "\"\"", ";", "try", "{", "return", "new", "ObjectName", "(", "d", "+", "\":type=\"", "+", "t", "+", "k", ")", ";", "}", "catch", "(", "MalformedObjectNameException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "e", ")", ";", "}", "}" ]
Constructs the ObjectName of bean. @param domain The domain part in object name of bean. It is a string of characters not including the character colon (:), wildcard characters asterisk (*), and question mark (?). It is recommended that the domain should not contain the string "//" also. If the domain is null or empty, it will be replaced by the package name of this bean's class. @param type A value of key 'type' in the object name of this bean. If the given value is null or empty, it will be replaced by the simple name of the bean's class. @param keysString A string that represents a set of additional keys and associated values in object name of this bean. Example: "key1=value1,key2=value2,...". See java-docs of the javax.management.ObjectName class for restrictions. Null value of the keysString is interpreted as an empty string.
[ "Constructs", "the", "ObjectName", "of", "bean", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/mbeans/MBeanBase.java#L96-L109
138,489
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/JSONAnnie.java
JSONAnnie.push
private void push(Construct construct) { // Make sure we don't blow the stack. check(m_stackPos < MAX_STACK_DEPTH, "Too many JSON nested levels (maximum=" + MAX_STACK_DEPTH + ")"); m_stack[m_stackPos++] = construct; }
java
private void push(Construct construct) { // Make sure we don't blow the stack. check(m_stackPos < MAX_STACK_DEPTH, "Too many JSON nested levels (maximum=" + MAX_STACK_DEPTH + ")"); m_stack[m_stackPos++] = construct; }
[ "private", "void", "push", "(", "Construct", "construct", ")", "{", "// Make sure we don't blow the stack.\r", "check", "(", "m_stackPos", "<", "MAX_STACK_DEPTH", ",", "\"Too many JSON nested levels (maximum=\"", "+", "MAX_STACK_DEPTH", "+", "\")\"", ")", ";", "m_stack", "[", "m_stackPos", "++", "]", "=", "construct", ";", "}" ]
Push the given node onto the node stack.
[ "Push", "the", "given", "node", "onto", "the", "node", "stack", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/JSONAnnie.java#L532-L536
138,490
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java
Command.call
public RESTResponse call(RESTClient restClient){ String methodName = getMethod(); String uri = getURI(); StringBuilder uriBuilder = new StringBuilder(Utils.isEmpty(restClient.getApiPrefix()) ? "" : "/" + restClient.getApiPrefix()); uriBuilder.append(substitute(uri)); uri = uriBuilder.toString(); try { byte[] body = getBody(methodName); RESTResponse response = sendRequest(restClient, methodName, uri, body); return response; } catch (Exception e) { throw new RuntimeException(e); } }
java
public RESTResponse call(RESTClient restClient){ String methodName = getMethod(); String uri = getURI(); StringBuilder uriBuilder = new StringBuilder(Utils.isEmpty(restClient.getApiPrefix()) ? "" : "/" + restClient.getApiPrefix()); uriBuilder.append(substitute(uri)); uri = uriBuilder.toString(); try { byte[] body = getBody(methodName); RESTResponse response = sendRequest(restClient, methodName, uri, body); return response; } catch (Exception e) { throw new RuntimeException(e); } }
[ "public", "RESTResponse", "call", "(", "RESTClient", "restClient", ")", "{", "String", "methodName", "=", "getMethod", "(", ")", ";", "String", "uri", "=", "getURI", "(", ")", ";", "StringBuilder", "uriBuilder", "=", "new", "StringBuilder", "(", "Utils", ".", "isEmpty", "(", "restClient", ".", "getApiPrefix", "(", ")", ")", "?", "\"\"", ":", "\"/\"", "+", "restClient", ".", "getApiPrefix", "(", ")", ")", ";", "uriBuilder", ".", "append", "(", "substitute", "(", "uri", ")", ")", ";", "uri", "=", "uriBuilder", ".", "toString", "(", ")", ";", "try", "{", "byte", "[", "]", "body", "=", "getBody", "(", "methodName", ")", ";", "RESTResponse", "response", "=", "sendRequest", "(", "restClient", ",", "methodName", ",", "uri", ",", "body", ")", ";", "return", "response", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Call method implementation @param restClient @return RESTResponse result object
[ "Call", "method", "implementation" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java#L111-L125
138,491
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java
Command.validate
public void validate(RESTClient restClient) { Utils.require(this.commandName != null, "missing command name"); //validate command name this.metadataJson = matchCommand(restMetadataJson, this.commandName, commandParams.containsKey(STORAGE_SERVICE) ? (String)commandParams.get(STORAGE_SERVICE): _SYSTEM); if (this.metadataJson == null) { //application command not found, look for system command if (commandParams.containsKey(STORAGE_SERVICE)) { this.metadataJson = matchCommand(restMetadataJson, this.commandName, _SYSTEM); } } if (this.metadataJson == null) { throw new RuntimeException("unsupported command name: " + this.commandName); } //validate required params validateRequiredParams(); }
java
public void validate(RESTClient restClient) { Utils.require(this.commandName != null, "missing command name"); //validate command name this.metadataJson = matchCommand(restMetadataJson, this.commandName, commandParams.containsKey(STORAGE_SERVICE) ? (String)commandParams.get(STORAGE_SERVICE): _SYSTEM); if (this.metadataJson == null) { //application command not found, look for system command if (commandParams.containsKey(STORAGE_SERVICE)) { this.metadataJson = matchCommand(restMetadataJson, this.commandName, _SYSTEM); } } if (this.metadataJson == null) { throw new RuntimeException("unsupported command name: " + this.commandName); } //validate required params validateRequiredParams(); }
[ "public", "void", "validate", "(", "RESTClient", "restClient", ")", "{", "Utils", ".", "require", "(", "this", ".", "commandName", "!=", "null", ",", "\"missing command name\"", ")", ";", "//validate command name ", "this", ".", "metadataJson", "=", "matchCommand", "(", "restMetadataJson", ",", "this", ".", "commandName", ",", "commandParams", ".", "containsKey", "(", "STORAGE_SERVICE", ")", "?", "(", "String", ")", "commandParams", ".", "get", "(", "STORAGE_SERVICE", ")", ":", "_SYSTEM", ")", ";", "if", "(", "this", ".", "metadataJson", "==", "null", ")", "{", "//application command not found, look for system command", "if", "(", "commandParams", ".", "containsKey", "(", "STORAGE_SERVICE", ")", ")", "{", "this", ".", "metadataJson", "=", "matchCommand", "(", "restMetadataJson", ",", "this", ".", "commandName", ",", "_SYSTEM", ")", ";", "}", "}", "if", "(", "this", ".", "metadataJson", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"unsupported command name: \"", "+", "this", ".", "commandName", ")", ";", "}", "//validate required params", "validateRequiredParams", "(", ")", ";", "}" ]
Validate the command @param restClient
[ "Validate", "the", "command" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java#L132-L148
138,492
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java
Command.validateRequiredParams
private void validateRequiredParams() { String[] uriStrings = getURI().split("\\?"); if (uriStrings.length > 0) { List<String> requiredParms = extractRequiredParamsInURI(uriStrings[0]); for (String param: requiredParms) { Utils.require(commandParams.containsKey(param), "missing param: " + param); } } if (metadataJson.containsKey(INPUT_ENTITY)) { String paramValue = metadataJson.getString(INPUT_ENTITY); if (paramValue != null) { JsonObject parametersNode = metadataJson.getJsonObject(PARAMETERS); if (parametersNode != null) { if (parametersNode.keySet().size() == 1) {//parent node usually "params" JsonObject params = parametersNode.getJsonObject(parametersNode.keySet().iterator().next()); for (String param: params.keySet()) { JsonObject paramNode = params.getJsonObject(param); if (paramNode.keySet().contains(_REQUIRED)) { setCompound(true); Utils.require(commandParams.containsKey(param), "missing param: " + param); } } } } else { Utils.require(commandParams.containsKey(paramValue), "missing param: " + paramValue); } } } }
java
private void validateRequiredParams() { String[] uriStrings = getURI().split("\\?"); if (uriStrings.length > 0) { List<String> requiredParms = extractRequiredParamsInURI(uriStrings[0]); for (String param: requiredParms) { Utils.require(commandParams.containsKey(param), "missing param: " + param); } } if (metadataJson.containsKey(INPUT_ENTITY)) { String paramValue = metadataJson.getString(INPUT_ENTITY); if (paramValue != null) { JsonObject parametersNode = metadataJson.getJsonObject(PARAMETERS); if (parametersNode != null) { if (parametersNode.keySet().size() == 1) {//parent node usually "params" JsonObject params = parametersNode.getJsonObject(parametersNode.keySet().iterator().next()); for (String param: params.keySet()) { JsonObject paramNode = params.getJsonObject(param); if (paramNode.keySet().contains(_REQUIRED)) { setCompound(true); Utils.require(commandParams.containsKey(param), "missing param: " + param); } } } } else { Utils.require(commandParams.containsKey(paramValue), "missing param: " + paramValue); } } } }
[ "private", "void", "validateRequiredParams", "(", ")", "{", "String", "[", "]", "uriStrings", "=", "getURI", "(", ")", ".", "split", "(", "\"\\\\?\"", ")", ";", "if", "(", "uriStrings", ".", "length", ">", "0", ")", "{", "List", "<", "String", ">", "requiredParms", "=", "extractRequiredParamsInURI", "(", "uriStrings", "[", "0", "]", ")", ";", "for", "(", "String", "param", ":", "requiredParms", ")", "{", "Utils", ".", "require", "(", "commandParams", ".", "containsKey", "(", "param", ")", ",", "\"missing param: \"", "+", "param", ")", ";", "}", "}", "if", "(", "metadataJson", ".", "containsKey", "(", "INPUT_ENTITY", ")", ")", "{", "String", "paramValue", "=", "metadataJson", ".", "getString", "(", "INPUT_ENTITY", ")", ";", "if", "(", "paramValue", "!=", "null", ")", "{", "JsonObject", "parametersNode", "=", "metadataJson", ".", "getJsonObject", "(", "PARAMETERS", ")", ";", "if", "(", "parametersNode", "!=", "null", ")", "{", "if", "(", "parametersNode", ".", "keySet", "(", ")", ".", "size", "(", ")", "==", "1", ")", "{", "//parent node usually \"params\" ", "JsonObject", "params", "=", "parametersNode", ".", "getJsonObject", "(", "parametersNode", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ".", "next", "(", ")", ")", ";", "for", "(", "String", "param", ":", "params", ".", "keySet", "(", ")", ")", "{", "JsonObject", "paramNode", "=", "params", ".", "getJsonObject", "(", "param", ")", ";", "if", "(", "paramNode", ".", "keySet", "(", ")", ".", "contains", "(", "_REQUIRED", ")", ")", "{", "setCompound", "(", "true", ")", ";", "Utils", ".", "require", "(", "commandParams", ".", "containsKey", "(", "param", ")", ",", "\"missing param: \"", "+", "param", ")", ";", "}", "}", "}", "}", "else", "{", "Utils", ".", "require", "(", "commandParams", ".", "containsKey", "(", "paramValue", ")", ",", "\"missing param: \"", "+", "paramValue", ")", ";", "}", "}", "}", "}" ]
Validate Required Params
[ "Validate", "Required", "Params" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java#L154-L184
138,493
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java
Command.extractRequiredParamsInURI
private List<String> extractRequiredParamsInURI(String uri) { List<String> matchList = new ArrayList<String>(); Pattern regex = Pattern.compile("\\{(.*?)\\}"); Matcher regexMatcher = regex.matcher(uri); while (regexMatcher.find()) { matchList.add(regexMatcher.group(1)); } return matchList; }
java
private List<String> extractRequiredParamsInURI(String uri) { List<String> matchList = new ArrayList<String>(); Pattern regex = Pattern.compile("\\{(.*?)\\}"); Matcher regexMatcher = regex.matcher(uri); while (regexMatcher.find()) { matchList.add(regexMatcher.group(1)); } return matchList; }
[ "private", "List", "<", "String", ">", "extractRequiredParamsInURI", "(", "String", "uri", ")", "{", "List", "<", "String", ">", "matchList", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "Pattern", "regex", "=", "Pattern", ".", "compile", "(", "\"\\\\{(.*?)\\\\}\"", ")", ";", "Matcher", "regexMatcher", "=", "regex", ".", "matcher", "(", "uri", ")", ";", "while", "(", "regexMatcher", ".", "find", "(", ")", ")", "{", "matchList", ".", "add", "(", "regexMatcher", ".", "group", "(", "1", ")", ")", ";", "}", "return", "matchList", ";", "}" ]
Extract Required Params In URI @param uri @return the list of required params
[ "Extract", "Required", "Params", "In", "URI" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java#L191-L199
138,494
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java
Command.substitute
private String substitute(String uri) { List<String> params = extractRequiredParamsInURI(uri); for (String param: params) { if (param.equals(PARAMS)) { uri = uri.replace("{" + PARAMS +"}", Utils.urlEncode(getParamsURI())); } else { uri = uri.replace("{" + param + "}", (String)commandParams.get(param)); } } return uri; }
java
private String substitute(String uri) { List<String> params = extractRequiredParamsInURI(uri); for (String param: params) { if (param.equals(PARAMS)) { uri = uri.replace("{" + PARAMS +"}", Utils.urlEncode(getParamsURI())); } else { uri = uri.replace("{" + param + "}", (String)commandParams.get(param)); } } return uri; }
[ "private", "String", "substitute", "(", "String", "uri", ")", "{", "List", "<", "String", ">", "params", "=", "extractRequiredParamsInURI", "(", "uri", ")", ";", "for", "(", "String", "param", ":", "params", ")", "{", "if", "(", "param", ".", "equals", "(", "PARAMS", ")", ")", "{", "uri", "=", "uri", ".", "replace", "(", "\"{\"", "+", "PARAMS", "+", "\"}\"", ",", "Utils", ".", "urlEncode", "(", "getParamsURI", "(", ")", ")", ")", ";", "}", "else", "{", "uri", "=", "uri", ".", "replace", "(", "\"{\"", "+", "param", "+", "\"}\"", ",", "(", "String", ")", "commandParams", ".", "get", "(", "param", ")", ")", ";", "}", "}", "return", "uri", ";", "}" ]
Substitute the params with values submittted via command builder @param uri the uri string @return the uri string after substitution
[ "Substitute", "the", "params", "with", "values", "submittted", "via", "command", "builder" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java#L207-L218
138,495
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java
Command.getBody
private byte[] getBody(String method) { byte[] body = null; String methodsWithInputEntity = HttpMethod.POST.name() + "|" + HttpMethod.PUT.name() + "|" + HttpMethod.DELETE.name(); if (method.matches(methodsWithInputEntity)) { if (isCompound()) { body = Utils.toBytes(getQueryInputEntity()); } else { if (metadataJson.containsKey(INPUT_ENTITY)) { JSONable data = (JSONable)commandParams.get(metadataJson.getString(INPUT_ENTITY)); if (data != null) { body = Utils.toBytes(data.toJSON()); } } } } return body; }
java
private byte[] getBody(String method) { byte[] body = null; String methodsWithInputEntity = HttpMethod.POST.name() + "|" + HttpMethod.PUT.name() + "|" + HttpMethod.DELETE.name(); if (method.matches(methodsWithInputEntity)) { if (isCompound()) { body = Utils.toBytes(getQueryInputEntity()); } else { if (metadataJson.containsKey(INPUT_ENTITY)) { JSONable data = (JSONable)commandParams.get(metadataJson.getString(INPUT_ENTITY)); if (data != null) { body = Utils.toBytes(data.toJSON()); } } } } return body; }
[ "private", "byte", "[", "]", "getBody", "(", "String", "method", ")", "{", "byte", "[", "]", "body", "=", "null", ";", "String", "methodsWithInputEntity", "=", "HttpMethod", ".", "POST", ".", "name", "(", ")", "+", "\"|\"", "+", "HttpMethod", ".", "PUT", ".", "name", "(", ")", "+", "\"|\"", "+", "HttpMethod", ".", "DELETE", ".", "name", "(", ")", ";", "if", "(", "method", ".", "matches", "(", "methodsWithInputEntity", ")", ")", "{", "if", "(", "isCompound", "(", ")", ")", "{", "body", "=", "Utils", ".", "toBytes", "(", "getQueryInputEntity", "(", ")", ")", ";", "}", "else", "{", "if", "(", "metadataJson", ".", "containsKey", "(", "INPUT_ENTITY", ")", ")", "{", "JSONable", "data", "=", "(", "JSONable", ")", "commandParams", ".", "get", "(", "metadataJson", ".", "getString", "(", "INPUT_ENTITY", ")", ")", ";", "if", "(", "data", "!=", "null", ")", "{", "body", "=", "Utils", ".", "toBytes", "(", "data", ".", "toJSON", "(", ")", ")", ";", "}", "}", "}", "}", "return", "body", ";", "}" ]
Build the body for request @param method @return
[ "Build", "the", "body", "for", "request" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java#L226-L243
138,496
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java
Command.sendRequest
private RESTResponse sendRequest(RESTClient restClient, String methodName, String uri, byte[] body) throws IOException { RESTResponse response = restClient.sendRequest(HttpMethod.methodFromString(methodName), uri, ContentType.APPLICATION_JSON, body); logger.debug("response: {}", response.toString()); return response; }
java
private RESTResponse sendRequest(RESTClient restClient, String methodName, String uri, byte[] body) throws IOException { RESTResponse response = restClient.sendRequest(HttpMethod.methodFromString(methodName), uri, ContentType.APPLICATION_JSON, body); logger.debug("response: {}", response.toString()); return response; }
[ "private", "RESTResponse", "sendRequest", "(", "RESTClient", "restClient", ",", "String", "methodName", ",", "String", "uri", ",", "byte", "[", "]", "body", ")", "throws", "IOException", "{", "RESTResponse", "response", "=", "restClient", ".", "sendRequest", "(", "HttpMethod", ".", "methodFromString", "(", "methodName", ")", ",", "uri", ",", "ContentType", ".", "APPLICATION_JSON", ",", "body", ")", ";", "logger", ".", "debug", "(", "\"response: {}\"", ",", "response", ".", "toString", "(", ")", ")", ";", "return", "response", ";", "}" ]
Make RESTful calls to Doradus server @param restClient @param methodName @param uri @param body @return @throws IOException
[ "Make", "RESTful", "calls", "to", "Doradus", "server" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java#L255-L261
138,497
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java
Command.matchCommand
public static JsonObject matchCommand(JsonObject commandsJson, String commandName, String storageService) { for (String key : commandsJson.keySet()) { if (key.equals(storageService)) { JsonObject commandCats = commandsJson.getJsonObject(key); if (commandCats.containsKey(commandName)) { return commandCats.getJsonObject(commandName); } } } return null; }
java
public static JsonObject matchCommand(JsonObject commandsJson, String commandName, String storageService) { for (String key : commandsJson.keySet()) { if (key.equals(storageService)) { JsonObject commandCats = commandsJson.getJsonObject(key); if (commandCats.containsKey(commandName)) { return commandCats.getJsonObject(commandName); } } } return null; }
[ "public", "static", "JsonObject", "matchCommand", "(", "JsonObject", "commandsJson", ",", "String", "commandName", ",", "String", "storageService", ")", "{", "for", "(", "String", "key", ":", "commandsJson", ".", "keySet", "(", ")", ")", "{", "if", "(", "key", ".", "equals", "(", "storageService", ")", ")", "{", "JsonObject", "commandCats", "=", "commandsJson", ".", "getJsonObject", "(", "key", ")", ";", "if", "(", "commandCats", ".", "containsKey", "(", "commandName", ")", ")", "{", "return", "commandCats", ".", "getJsonObject", "(", "commandName", ")", ";", "}", "}", "}", "return", "null", ";", "}" ]
Finds out if a command is supported by Doradus @param commandsJson @param commandName @param storageService @return
[ "Finds", "out", "if", "a", "command", "is", "supported", "by", "Doradus" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/dory/command/Command.java#L270-L280
138,498
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/schema/SchemaService.java
SchemaService.defineApplication
public void defineApplication(ApplicationDefinition appDef) { checkServiceState(); Tenant tenant = TenantService.instance().getDefaultTenant(); defineApplication(tenant, appDef); }
java
public void defineApplication(ApplicationDefinition appDef) { checkServiceState(); Tenant tenant = TenantService.instance().getDefaultTenant(); defineApplication(tenant, appDef); }
[ "public", "void", "defineApplication", "(", "ApplicationDefinition", "appDef", ")", "{", "checkServiceState", "(", ")", ";", "Tenant", "tenant", "=", "TenantService", ".", "instance", "(", ")", ".", "getDefaultTenant", "(", ")", ";", "defineApplication", "(", "tenant", ",", "appDef", ")", ";", "}" ]
Create the application with the given name in the default tenant. If the given application already exists, the request is treated as an application update. If the update is successfully validated, its schema is stored in the database, and the appropriate storage service is notified to implement required physical database changes, if any. @param appDef {@link ApplicationDefinition} of application to create or update. Note that appDef is updated with the "Tenant" option.
[ "Create", "the", "application", "with", "the", "given", "name", "in", "the", "default", "tenant", ".", "If", "the", "given", "application", "already", "exists", "the", "request", "is", "treated", "as", "an", "application", "update", ".", "If", "the", "update", "is", "successfully", "validated", "its", "schema", "is", "stored", "in", "the", "database", "and", "the", "appropriate", "storage", "service", "is", "notified", "to", "implement", "required", "physical", "database", "changes", "if", "any", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/schema/SchemaService.java#L117-L121
138,499
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/schema/SchemaService.java
SchemaService.defineApplication
public void defineApplication(Tenant tenant, ApplicationDefinition appDef) { checkServiceState(); appDef.setTenantName(tenant.getName()); ApplicationDefinition currAppDef = checkApplicationKey(appDef); StorageService storageService = verifyStorageServiceOption(currAppDef, appDef); storageService.validateSchema(appDef); initializeApplication(currAppDef, appDef); }
java
public void defineApplication(Tenant tenant, ApplicationDefinition appDef) { checkServiceState(); appDef.setTenantName(tenant.getName()); ApplicationDefinition currAppDef = checkApplicationKey(appDef); StorageService storageService = verifyStorageServiceOption(currAppDef, appDef); storageService.validateSchema(appDef); initializeApplication(currAppDef, appDef); }
[ "public", "void", "defineApplication", "(", "Tenant", "tenant", ",", "ApplicationDefinition", "appDef", ")", "{", "checkServiceState", "(", ")", ";", "appDef", ".", "setTenantName", "(", "tenant", ".", "getName", "(", ")", ")", ";", "ApplicationDefinition", "currAppDef", "=", "checkApplicationKey", "(", "appDef", ")", ";", "StorageService", "storageService", "=", "verifyStorageServiceOption", "(", "currAppDef", ",", "appDef", ")", ";", "storageService", ".", "validateSchema", "(", "appDef", ")", ";", "initializeApplication", "(", "currAppDef", ",", "appDef", ")", ";", "}" ]
Create the application with the given name in the given Tenant. If the given application already exists, the request is treated as an application update. If the update is successfully validated, its schema is stored in the database, and the appropriate storage service is notified to implement required physical database changes, if any. @param tenant {@link Tenant} in which application is being created or updated. @param appDef {@link ApplicationDefinition} of application to create or update. Note that appDef is updated with the "Tenant" option.
[ "Create", "the", "application", "with", "the", "given", "name", "in", "the", "given", "Tenant", ".", "If", "the", "given", "application", "already", "exists", "the", "request", "is", "treated", "as", "an", "application", "update", ".", "If", "the", "update", "is", "successfully", "validated", "its", "schema", "is", "stored", "in", "the", "database", "and", "the", "appropriate", "storage", "service", "is", "notified", "to", "implement", "required", "physical", "database", "changes", "if", "any", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/schema/SchemaService.java#L134-L141