mirror of https://github.com/apache/lucene.git
SOLR-8476: Refactor and cleanup CoreAdminHandler
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1722788 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c54ef96f20
commit
c9b7af0450
|
@ -289,41 +289,34 @@ public class CoreAdminHandler extends RequestHandlerBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper method to add a task to a tracking map.
|
||||
* Helper method to add a task to a tracking type.
|
||||
*/
|
||||
void addTask(String map, TaskObject o, boolean limit) {
|
||||
synchronized (getRequestStatusMap(map)) {
|
||||
if(limit && getRequestStatusMap(map).size() == MAX_TRACKED_REQUESTS) {
|
||||
String key = getRequestStatusMap(map).entrySet().iterator().next().getKey();
|
||||
getRequestStatusMap(map).remove(key);
|
||||
void addTask(String type, TaskObject o, boolean limit) {
|
||||
synchronized (getRequestStatusMap(type)) {
|
||||
if(limit && getRequestStatusMap(type).size() == MAX_TRACKED_REQUESTS) {
|
||||
String key = getRequestStatusMap(type).entrySet().iterator().next().getKey();
|
||||
getRequestStatusMap(type).remove(key);
|
||||
}
|
||||
addTask(map, o);
|
||||
addTask(type, o);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void addTask(String map, TaskObject o) {
|
||||
synchronized (getRequestStatusMap(map)) {
|
||||
getRequestStatusMap(map).put(o.taskId, o);
|
||||
private void addTask(String type, TaskObject o) {
|
||||
synchronized (getRequestStatusMap(type)) {
|
||||
getRequestStatusMap(type).put(o.taskId, o);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to remove a task from a tracking map.
|
||||
*/
|
||||
void removeTask(String map, String taskId) {
|
||||
private void removeTask(String map, String taskId) {
|
||||
synchronized (getRequestStatusMap(map)) {
|
||||
getRequestStatusMap(map).remove(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to check if a map contains a taskObject with the given taskId.
|
||||
*/
|
||||
boolean mapContainsTask(String map, String taskId) {
|
||||
return getRequestStatusMap(map).containsKey(taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get a request status map given the name.
|
||||
*/
|
||||
|
|
|
@ -734,12 +734,12 @@ enum CoreAdminOperation {
|
|||
String requestId = params.get(CoreAdminParams.REQUESTID);
|
||||
log.info("Checking request status for : " + requestId);
|
||||
|
||||
if (callInfo.handler.mapContainsTask(RUNNING, requestId)) {
|
||||
if (callInfo.handler.getRequestStatusMap(RUNNING).containsKey(requestId)) {
|
||||
callInfo.rsp.add(RESPONSE_STATUS, RUNNING);
|
||||
} else if (callInfo.handler.mapContainsTask(COMPLETED, requestId)) {
|
||||
} else if (callInfo.handler.getRequestStatusMap(COMPLETED).containsKey(requestId)) {
|
||||
callInfo.rsp.add(RESPONSE_STATUS, COMPLETED);
|
||||
callInfo.rsp.add(RESPONSE, callInfo.handler.getRequestStatusMap(COMPLETED).get(requestId).getRspObject());
|
||||
} else if (callInfo.handler.mapContainsTask(FAILED, requestId)) {
|
||||
} else if (callInfo.handler.getRequestStatusMap(FAILED).containsKey(requestId)) {
|
||||
callInfo.rsp.add(RESPONSE_STATUS, FAILED);
|
||||
callInfo.rsp.add(RESPONSE, callInfo.handler.getRequestStatusMap(FAILED).get(requestId).getRspObject());
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue