Skip to content

Commit

Permalink
Improve QueryTask performance for some queries
Browse files Browse the repository at this point in the history
- Convert some simple queries to direct.
- Decrease wait interval for async queries to 300 msec (same as Xenon helper class).

Change-Id: I58a34656b280f3b898a80ca5347d3d9554505835
Reviewed-on: http://bellevue-ci.eng.vmware.com:8080/13538
Compute-Verified: jenkins <[email protected]>
Closures-Verified: jenkins <[email protected]>
Upgrade-Verified: jenkins <[email protected]>
Bellevue-Verified: jenkins <[email protected]>
CS-Verified: jenkins <[email protected]>
Reviewed-by: Lazarin Lazarov <[email protected]>
  • Loading branch information
jdillet committed Jul 19, 2017
1 parent eb7190c commit 1bc5f7d
Show file tree
Hide file tree
Showing 11 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class QueryUtil {

public static final long QUERY_RETRY_INTERVAL_MILLIS = Long.getLong(
"com.vmware.admiral.common.util.query.retry.interval.millis", 500);
"com.vmware.admiral.common.util.query.retry.interval.millis", 300);

/**
* prefix for tenants. e.g. /tenants/t1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ private void retrieveAndUpdatePlacements(PlacementCapacityUpdateTaskState state)
.addFieldClause(GroupResourcePlacementState.FIELD_NAME_RESOURCE_POOL_LINK,
state.resourcePoolLink)
.build();
QueryTask queryTask = QueryTask.Builder.create()
QueryTask queryTask = QueryTask.Builder.createDirectTask()
.setQuery(query)
.addOption(QueryOption.EXPAND_CONTENT)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ public void handleDelete(Operation delete) {
}

private QueryTask createGroupResourcePlacementQueryTask(GroupResourcePlacementState state) {
QueryTask q = QueryUtil.buildQuery(GroupResourcePlacementState.class, false);
QueryTask q = QueryUtil.buildQuery(GroupResourcePlacementState.class, true);

QueryTask.Query resourcePoolClause = new QueryTask.Query()
.setTermPropertyName(GroupResourcePlacementPoolState.FIELD_NAME_RESOURCE_POOL_LINK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private void disableContainerHosts(ContainerHostRemovalTaskState state, String s
}

private void queryContainers(ContainerHostRemovalTaskState state) {
QueryTask containerQuery = QueryUtil.buildQuery(ContainerState.class, false);
QueryTask containerQuery = QueryUtil.buildQuery(ContainerState.class, true);

QueryUtil.addListValueClause(containerQuery,
ContainerState.FIELD_NAME_PARENT_LINK, state.resourceLinks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ private void getContextContainerStates(ContainerNetworkProvisionTaskState state,
QueryTask q = QueryUtil.buildPropertyQuery(ContainerState.class,
ContainerState.FIELD_NAME_COMPOSITE_COMPONENT_LINK, UriUtils.buildUriPath(
CompositeComponentFactoryService.SELF_LINK, contextId));
q.taskInfo.isDirect = false;
QueryUtil.addExpandOption(q);

Map<String, List<ContainerState>> containersByDescriptionLink = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ private void getContextContainerStates(ContainerVolumeProvisionTaskState state,
QueryTask q = QueryUtil.buildPropertyQuery(ContainerState.class,
ContainerState.FIELD_NAME_COMPOSITE_COMPONENT_LINK, UriUtils.buildUriPath(
CompositeComponentFactoryService.SELF_LINK, contextId));
q.taskInfo.isDirect = false;
QueryUtil.addExpandOption(q);

Map<String, List<ContainerState>> containersByDescriptionLink = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected static class CallbackCompleteResponse extends ServiceTaskCallbackRespo

private void queryResourceNamePrefixes(ResourceNamePrefixTaskState state, boolean globalSearch) {
// match on group property:
QueryTask q = QueryUtil.buildQuery(ResourceNamePrefixState.class, false);
QueryTask q = QueryUtil.buildQuery(ResourceNamePrefixState.class, true);
q.tenantLinks = state.tenantLinks;

List<String> documentLinks = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ protected void findContainers(final PlacementHostSelectionTaskState state,
QueryTask q = QueryUtil.buildPropertyQuery(ContainerState.class,
ContainerState.FIELD_NAME_COMPOSITE_COMPONENT_LINK, UriUtils.buildUriPath(
CompositeComponentFactoryService.SELF_LINK, state.contextId));
q.taskInfo.isDirect = false;
q.querySpec.resultLimit = ServiceDocumentQuery.DEFAULT_QUERY_RESULT_LIMIT;
QueryUtil.addExpandOption(q);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected void findCompositeDescriptions(final PlacementHostSelectionTaskState s
final HostSelectionFilterCompletion callback) {

// get descriptionLinks for the containers in the same component as the current container
QueryTask q = QueryUtil.buildQuery(ContainerState.class, false);
QueryTask q = QueryUtil.buildQuery(ContainerState.class, true);
String contextId = state.customProperties.get(RequestUtils.FIELD_NAME_CONTEXT_ID_KEY);
String contextLink = UriUtils.buildUriPath(CompositeComponentFactoryService.SELF_LINK, contextId);
QueryTask.Query contextClause = new QueryTask.Query()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ private void queryContainers(PlacementHostSelectionTaskState state,
QueryTask q = QueryUtil.buildPropertyQuery(ContainerState.class,
ContainerState.FIELD_NAME_COMPOSITE_COMPONENT_LINK, UriUtils.buildUriPath(
CompositeComponentFactoryService.SELF_LINK, state.contextId));
q.taskInfo.isDirect = false;
QueryUtil.addExpandOption(q);

QueryUtil.addListValueClause(q,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ protected void findContainers(final PlacementHostSelectionTaskState state,
QueryTask q = QueryUtil.buildPropertyQuery(ContainerState.class,
ContainerState.FIELD_NAME_COMPOSITE_COMPONENT_LINK, UriUtils.buildUriPath(
CompositeComponentFactoryService.SELF_LINK, state.contextId));
q.taskInfo.isDirect = false;
q.querySpec.resultLimit = ServiceDocumentQuery.DEFAULT_QUERY_RESULT_LIMIT;
QueryUtil.addExpandOption(q);

Expand Down

0 comments on commit 1bc5f7d

Please sign in to comment.