Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
ADM Edge Configtype empty bug fix (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
sushilraje authored Dec 1, 2018
1 parent 794c13a commit 62761c5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ public CompletionStage<DeploymentServiceModel> getAsync(String id, boolean inclu
result.getDeploymentMetrics().setDeviceStatuses(deviceStatuses);
}

if (!(ConfigurationsHelper.isEdgeDeployment(deployment))) {
result.getDeploymentMetrics().setDeviceMetrics(this.calculateDeviceMetrics(deviceStatuses));
}
result.getDeploymentMetrics().setDeviceMetrics(this.calculateDeviceMetrics(deviceStatuses));

return CompletableFuture.supplyAsync(() -> result);
} catch (IotHubNotFoundException e) {
Expand All @@ -161,9 +159,17 @@ public CompletionStage<DeploymentServiceModel> createAsync(DeploymentServiceMode
verifyDeploymentParameter(DEVICE_GROUP_ID_PARAM, deployment.getDeviceGroup().getId());
verifyDeploymentParameter(DEVICE_GROUP_NAME_PARAM, deployment.getDeviceGroup().getId());
verifyDeploymentParameter(DEVICE_GROUP_QUERY_PARAM, deployment.getDeviceGroup().getQuery());
verifyDeploymentParameter(NAME_PARAM, deployment.getName());
verifyDeploymentParameter(CONFIG_TYPE_PARAM, deployment.getConfigType());
verifyDeploymentParameter(PACKAGE_CONTENT_PARAM, deployment.getPackageContent());
verifyDeploymentParameter(NAME_PARAM, deployment.getName());

// PackageType is an Enum and can be null, but cannot be an empty string.
if (deployment.getPackageType() == null) {
throw new InvalidInputException("Invalid input. Must provide a value to PackageType");
}

if (deployment.getPackageType().equals(PackageType.deviceConfiguration)) {
verifyDeploymentParameter(CONFIG_TYPE_PARAM, deployment.getConfigType());
}

if (deployment.getPriority() < 0) {
throw new InvalidInputException("Invalid input. A priority should be provided greater than 0.");
Expand Down Expand Up @@ -268,7 +274,6 @@ private Map<String, DeploymentStatus> getDeviceStatuses(Configuration deployment

private Set<String> getDevicesInQuery(String hubQuery, String deploymentId) throws IOException {
final String query = String.format(hubQuery, deploymentId);
final SqlQuery sqlQuery = SqlQuery.createSqlQuery("*", SqlQuery.FromType.MODULES, query, null);
final Query twinQuery;
final Set<String> deviceIds = new HashSet<>();

Expand All @@ -288,7 +293,7 @@ private Set<String> getDevicesInQuery(String hubQuery, String deploymentId) thro
}
}
catch (Exception ex) {
log.error("Error getting status of devices in query " + sqlQuery.toString());
log.error("Error getting status of devices in query " + query.toString());
}
return deviceIds;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class EdgeDeviceStatusQueries {
" AND configurations.[[%s]].status = 'Applied' " +
" AND properties.desired.$version = properties.reported.lastDesiredVersion " +
" AND properties.reported.lastDesiredStatus.code = 200");
put(DeviceStatusQueries.QueryType.FAILED, "SELECT * from devices WHERE " +
put(DeviceStatusQueries.QueryType.FAILED, "SELECT * from devices.modules WHERE " +
" moduleId = '$edgeAgent' " +
" AND configurations.[[%s]].status = 'Applied' " +
" AND properties.desired.$version = properties.reported.lastDesiredVersion " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public DeploymentMetricsApiModel(DeploymentMetrics metricsServiceModel) {
if (metricsServiceModel == null) return;

this.customMetrics = metricsServiceModel.getCustomMetrics();
this.systemMetrics = MapUtils.isEmpty(metricsServiceModel.getSystemMetrics()) ?
this.systemMetrics = !(MapUtils.isEmpty(metricsServiceModel.getSystemMetrics())) ?
metricsServiceModel.getSystemMetrics() : this.systemMetrics;
this.deviceStatuses = metricsServiceModel.getDeviceStatuses();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class DeploymentsTest {
private static final String DEPLOYMENT_GROUP_NAME_LABEL = "DeviceGroupName";
private static final String DEPLOYMENT_PACKAGE_NAME_LABEL = "PackageName";
private static final String RM_CREATED_LABEL = "RMDeployment";
private static final String CONFIG_TYPE="Edge";
private static final String CONFIG_TYPE = StringUtils.EMPTY;

@Mock
private RegistryManager registry;
Expand Down

0 comments on commit 62761c5

Please sign in to comment.