use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.
the class AzureNetworkEnumerationAdapterService method disassociateSubnetStates.
/**
* Delete subnet states that no longer exist in Azure.
* <p>
* The logic works by recording a timestamp when enumeration starts. This timestamp is used to
* lookup resources which haven't been touched as part of current enumeration cycle and belong
* to networks touched by this enumeration cycle (either created/updated/deleted).
*/
private void disassociateSubnetStates(NetworkEnumContext context, NetworkEnumStages next) {
Builder qBuilder = Query.Builder.create().addKindFieldClause(SubnetState.class).addFieldClause(SubnetState.FIELD_NAME_LIFECYCLE_STATE, LifecycleState.PROVISIONING.name(), MatchType.TERM, Occurance.MUST_NOT_OCCUR).addRangeClause(SubnetState.FIELD_NAME_UPDATE_TIME_MICROS, NumericRange.createLessThanRange(context.enumerationStartTimeInMicros));
QueryByPages<SubnetState> queryLocalStates = new QueryByPages<>(getHost(), qBuilder.build(), SubnetState.class, context.parentCompute.tenantLinks, null, /* endpoint */
context.parentCompute.documentSelfLink).setMaxPageSize(QueryUtils.MAX_RESULT_LIMIT).setClusterType(ServiceTypeCluster.INVENTORY_SERVICE);
disassociateResourceStates(queryLocalStates, context, next);
}
use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.
the class AzureNetworkEnumerationAdapterService method querySubnetStates.
/**
* Query subnet states stored in the local document store based on the retrieved azure subnets.
*/
private void querySubnetStates(NetworkEnumContext context, NetworkEnumStages next) {
if (context.subnets == null || context.subnets.isEmpty()) {
handleSubStage(context, next);
return;
}
logFine(() -> "Query Subnet States from local document store.");
Builder qBuilder = Query.Builder.create().addKindFieldClause(SubnetState.class).addInClause(SubnetState.FIELD_NAME_ID, context.subnets.keySet());
QueryByPages<SubnetState> queryLocalStates = new QueryByPages<>(getHost(), qBuilder.build(), SubnetState.class, context.parentCompute.tenantLinks, null, /* endpoint */
context.parentCompute.documentSelfLink).setMaxPageSize(QueryUtils.MAX_RESULT_LIMIT).setClusterType(ServiceTypeCluster.INVENTORY_SERVICE);
queryLocalStates.queryDocuments(subnet -> context.subnetStates.put(subnet.id, subnet.documentSelfLink)).whenComplete(thenHandleSubStage(context, next));
}
use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.
the class AzureNetworkEnumerationAdapterService method disassociateNetworkStates.
/**
* Delete local network states that no longer exist in Azure.
* <p>
* The logic works by recording a timestamp when enumeration starts. This timestamp is used to
* lookup resources which haven't been touched as part of current enumeration cycle.
*/
private void disassociateNetworkStates(NetworkEnumContext context, NetworkEnumStages next) {
Builder qBuilder = Query.Builder.create().addKindFieldClause(NetworkState.class).addRangeClause(NetworkState.FIELD_NAME_UPDATE_TIME_MICROS, NumericRange.createLessThanRange(context.enumerationStartTimeInMicros));
QueryByPages<NetworkState> queryLocalStates = new QueryByPages<>(getHost(), qBuilder.build(), NetworkState.class, context.parentCompute.tenantLinks, null, /* endpoint */
context.parentCompute.documentSelfLink).setMaxPageSize(QueryUtils.MAX_RESULT_LIMIT).setClusterType(ServiceTypeCluster.INVENTORY_SERVICE);
disassociateResourceStates(queryLocalStates, context, next);
}
use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.
the class VSphereNetworkEnumerationHelper method queryForNetwork.
private static QueryTask queryForNetwork(EnumerationProgress ctx, NetworkOverlay net) {
URI adapterManagementReference = ctx.getRequest().adapterManagementReference;
String regionId = ctx.getRegionId();
Builder builder = Builder.create().addFieldClause(NetworkState.FIELD_NAME_ADAPTER_MANAGEMENT_REFERENCE, adapterManagementReference.toString()).addKindFieldClause(NetworkState.class).addFieldClause(NetworkState.FIELD_NAME_REGION_ID, regionId).addCompositeFieldClause(ComputeState.FIELD_NAME_CUSTOM_PROPERTIES, CustomProperties.MOREF, VimUtils.convertMoRefToString(net.getId()), Occurance.MUST_OCCUR);
QueryUtils.addEndpointLink(builder, NetworkState.class, ctx.getRequest().endpointLink);
QueryUtils.addTenantLinks(builder, ctx.getTenantLinks());
return QueryTask.Builder.createDirectTask().setQuery(builder.build()).setResultLimit(1).build();
}
use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.
the class VSphereNetworkEnumerationHelper method queryForSubnet.
private static QueryTask queryForSubnet(EnumerationProgress ctx, NetworkOverlay portgroup, ManagedObjectReference parent) {
String moref = VimUtils.convertMoRefToString(portgroup.getId());
Builder builder = Builder.create().addKindFieldClause(SubnetState.class).addCompositeFieldClause(ResourceState.FIELD_NAME_CUSTOM_PROPERTIES, CustomProperties.MOREF, moref);
if (parent != null) {
String dvsLink = buildStableDvsLink(parent, ctx.getRequest().endpointLink);
builder.addFieldClause(SubnetState.FIELD_NAME_NETWORK_LINK, dvsLink);
}
QueryUtils.addEndpointLink(builder, NetworkState.class, ctx.getRequest().endpointLink);
QueryUtils.addTenantLinks(builder, ctx.getTenantLinks());
return QueryTask.Builder.createDirectTask().setQuery(builder.build()).build();
}
Aggregations