readability cleanup
This commit is contained in:
+52
-46
@@ -13,15 +13,12 @@ import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.index.shard.Floc;
|
||||
import org.alfresco.repo.index.shard.Shard;
|
||||
import org.alfresco.repo.index.shard.ShardInstance;
|
||||
import org.alfresco.repo.index.shard.ShardRegistry;
|
||||
import org.alfresco.repo.index.shard.ShardState;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.slf4j.Logger;
|
||||
@@ -151,7 +148,10 @@ public abstract class AbstractNodeActionService implements DisposableBean {
|
||||
}
|
||||
}
|
||||
|
||||
private Future<Void> _action(long nodeDbId, ActionCallback callback, Long fullQueueExpireTimeMillis) throws TimeoutException, InterruptedException {
|
||||
private Future<Void> _action(
|
||||
final long nodeDbId,
|
||||
final ActionCallback callback,
|
||||
Long fullQueueExpireTimeMillis) throws TimeoutException, InterruptedException {
|
||||
List<com.inteligr8.alfresco.asie.model.ShardInstance> eligibleInstances = this.findPossibleShardInstances(nodeDbId);
|
||||
this.logger.debug("Will attempt to {} ACS node against {} shard instances: {}", this.getActionName(), eligibleInstances.size(), nodeDbId);
|
||||
|
||||
@@ -164,49 +164,12 @@ public abstract class AbstractNodeActionService implements DisposableBean {
|
||||
Callable<Void> callable = new Callable<>() {
|
||||
@Override
|
||||
public Void call() {
|
||||
String core = instance.extractShard().getCoreName();
|
||||
SolrHost host = instance.extractNode();
|
||||
URL url = host.toUrl(apiService.isSecure() ? "https" : "http");
|
||||
CoreAdminApi api = apiService.createApi(url.toString(), CoreAdminApi.class);
|
||||
|
||||
try {
|
||||
logger.debug("Performing {} of ACS node against shard instance: {}: {}", getActionName(), nodeDbId, instance);
|
||||
BaseResponse apiResponse = execute(api, core, nodeDbId);
|
||||
logger.trace("Performed {} of ACS node against shard instance: {}: {}", getActionName(), nodeDbId, instance);
|
||||
|
||||
Action action = null;
|
||||
if (apiResponse instanceof ActionCoreResponse<?>) {
|
||||
action = ((ActionCoreResponse<Action>) apiResponse).getCores().getByCore(core);
|
||||
} else if (apiResponse instanceof ActionResponse<?>) {
|
||||
action = ((ActionResponse<Action>) apiResponse).getAction();
|
||||
}
|
||||
|
||||
if (action == null) {
|
||||
callback.unknownResult(instance);
|
||||
} else {
|
||||
switch (action.getStatus()) {
|
||||
case Scheduled:
|
||||
callback.scheduled(instance);
|
||||
break;
|
||||
case Success:
|
||||
callback.success(instance);
|
||||
break;
|
||||
default:
|
||||
if (apiResponse instanceof com.inteligr8.alfresco.asie.model.BaseResponse) {
|
||||
com.inteligr8.alfresco.asie.model.BaseResponse asieResponse = (com.inteligr8.alfresco.asie.model.BaseResponse) apiResponse;
|
||||
logger.debug("Performance of {} of ACS node against shard instance failed: {}: {}: {}", getActionName(), nodeDbId, instance, asieResponse.getException());
|
||||
callback.error(instance, asieResponse.getException());
|
||||
} else {
|
||||
logger.debug("Performance of {} of ACS node against shard instance failed: {}: {}: {}", getActionName(), nodeDbId, instance, apiResponse.getResponseHeader().getStatus());
|
||||
callback.error(instance, String.valueOf(apiResponse.getResponseHeader().getStatus()));
|
||||
}
|
||||
}
|
||||
}
|
||||
actionToShard(nodeDbId, callback, instance);
|
||||
} catch (Exception e) {
|
||||
logger.error("An exception occurred", e);
|
||||
logger.error("An unexpected exception occurred", e);
|
||||
callback.error(instance, e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@@ -221,15 +184,58 @@ public abstract class AbstractNodeActionService implements DisposableBean {
|
||||
return future;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void actionToShard(long nodeDbId, ActionCallback callback, com.inteligr8.alfresco.asie.model.ShardInstance instance) {
|
||||
String core = instance.extractShard().getCoreName();
|
||||
SolrHost host = instance.extractNode();
|
||||
URL url = host.toUrl(this.apiService.isSecure() ? "https" : "http");
|
||||
CoreAdminApi api = this.apiService.createApi(url.toString(), CoreAdminApi.class);
|
||||
|
||||
this.logger.debug("Performing {} of ACS node against shard instance: {}: {}", this.getActionName(), nodeDbId, instance);
|
||||
BaseResponse apiResponse = execute(api, core, nodeDbId);
|
||||
this.logger.trace("Performed {} of ACS node against shard instance: {}: {}", this.getActionName(), nodeDbId, instance);
|
||||
|
||||
Action action = null;
|
||||
if (apiResponse instanceof ActionCoreResponse<?>) {
|
||||
action = ((ActionCoreResponse<Action>) apiResponse).getCores().getByCore(core);
|
||||
} else if (apiResponse instanceof ActionResponse<?>) {
|
||||
action = ((ActionResponse<Action>) apiResponse).getAction();
|
||||
}
|
||||
|
||||
if (action == null) {
|
||||
callback.unknownResult(instance);
|
||||
} else {
|
||||
switch (action.getStatus()) {
|
||||
case Scheduled:
|
||||
callback.scheduled(instance);
|
||||
break;
|
||||
case Success:
|
||||
callback.success(instance);
|
||||
break;
|
||||
default:
|
||||
if (apiResponse instanceof com.inteligr8.alfresco.asie.model.BaseResponse) {
|
||||
com.inteligr8.alfresco.asie.model.BaseResponse asieResponse = (com.inteligr8.alfresco.asie.model.BaseResponse) apiResponse;
|
||||
this.logger.debug("Performance of {} of ACS node against shard instance failed: {}: {}: {}",
|
||||
this.getActionName(), nodeDbId, instance, asieResponse.getException());
|
||||
callback.error(instance, asieResponse.getException());
|
||||
} else {
|
||||
this.logger.debug("Performance of {} of ACS node against shard instance failed: {}: {}: {}",
|
||||
this.getActionName(), nodeDbId, instance, apiResponse.getResponseHeader().getStatus());
|
||||
callback.error(instance, String.valueOf(apiResponse.getResponseHeader().getStatus()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract BaseResponse execute(CoreAdminApi api, String core, long nodeDbId);
|
||||
|
||||
private List<com.inteligr8.alfresco.asie.model.ShardInstance> findPossibleShardInstances(long nodeDbId) {
|
||||
if (this.shardRegistry == null)
|
||||
throw new UnsupportedOperationException("ACS instances without a sharding configuration are not yet implemented");
|
||||
|
||||
SearchParameters searchParams = new SearchParameters();
|
||||
searchParams.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
|
||||
searchParams.setQuery("@" + this.formatForFts(ContentModel.PROP_NODE_DBID) + ":" + nodeDbId);
|
||||
// SearchParameters searchParams = new SearchParameters();
|
||||
// searchParams.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
|
||||
// searchParams.setQuery("@" + this.formatForFts(ContentModel.PROP_NODE_DBID) + ":" + nodeDbId);
|
||||
|
||||
List<com.inteligr8.alfresco.asie.model.ShardInstance> instances = new LinkedList<>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user