Skip to content
Snippets Groups Projects
Commit 58e2828d authored by Zhibin Mai's avatar Zhibin Mai
Browse files

Merge branch 'remove-shape-decimation-FF' into 'master'

Enable the feature flag for geo-shape decimation by default

See merge request !486
parents da8eb48b 4a255306
No related branches found
No related tags found
1 merge request!486Enable the feature flag for geo-shape decimation by default
Pipeline #167511 passed with warnings
......@@ -397,8 +397,8 @@ The following software have components provided under the terms of this license:
- Google APIs Client Library for Java (from https://repo1.maven.org/maven2/com/google/api-client/google-api-client)
- Google App Engine extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-appengine)
- Google Cloud Core (from https://github.com/googleapis/google-cloud-java, https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core, https://github.com/googleapis/java-core)
- Google Cloud Core HTTP (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-core-http, https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-http, https://github.com/googleapis/java-core)
- Google Cloud Core gRPC (from https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-grpc, https://github.com/googleapis/java-core)
- Google Cloud Core HTTP (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-core-http, https://github.com/googleapis/google-cloud-java, https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-http, https://github.com/googleapis/java-core)
- Google Cloud Core gRPC (from https://github.com/googleapis/google-cloud-java, https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-grpc, https://github.com/googleapis/java-core)
- Google Cloud Datastore (from https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-datastore, https://github.com/googleapis/java-datastore)
- Google Cloud IAM Service Account Credentials (from https://github.com/googleapis/google-cloud-java, https://github.com/googleapis/java-iamcredentials)
- Google Cloud Logging (from https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-logging, https://github.com/googleapis/java-logging)
......
......@@ -8,17 +8,18 @@ by implementing Ramer–Douglas–Peucker algorithm:
- Polygon
- MultiPolygon
In order to reduce the risk when extended evaluation of the solution is still on going, a feature flag that is managed by
the Partition Service is applied to the solution.
Here is an example to enable this feature by setting the property "indexer-decimation-enabled" in a given data partition:
The feature is enabled by default for all data partitions. If client does not want the geo-shape to be decimated in their
data partitions, they can disable geo-shape decimation through the Partition Service.
Here is an example to disable this feature by setting the property "indexer-decimation-enabled" in a given data partition:
```
{
"indexer-decimation-enabled": {
"sensitive": false,
"value": "true"
"value": "false"
}
}
```
If the property "indexer-decimation-enabled" is not created or the property value is set to "false" (String type) in the
given data partition, the geo-shape decimation will be ignored.
If the property "indexer-decimation-enabled" is not created or the property value is set to "true" (String type) in the
given data partition, the geo-shape decimation will be enabled.
......@@ -51,14 +51,13 @@ public class GeoShapeDecimationSetting {
if (cache != null && cache.containsKey(cacheKey))
return cache.get(cacheKey);
boolean decimationEnabled = false;
boolean decimationEnabled = true;
try {
PartitionInfo partitionInfo = getPartitionInfo(dataPartitionId);
decimationEnabled = getDecimationSetting(partitionInfo);
} catch (Exception e) {
this.logger.error(String.format("PartitionService: Error getting %s for dataPartition with Id: %s", PROPERTY_NAME, dataPartitionId), e);
this.logger.error(String.format("PartitionService: Error getting %s for dataPartition with Id: %s. Turn on the feature flag by default.", PROPERTY_NAME, dataPartitionId), e);
}
this.cache.put(cacheKey, decimationEnabled);
return decimationEnabled;
}
......@@ -78,12 +77,12 @@ public class GeoShapeDecimationSetting {
private boolean getDecimationSetting(PartitionInfo partitionInfo) {
if(partitionInfo == null || partitionInfo.getProperties() == null)
return false;
return true;
if(partitionInfo.getProperties().containsKey(PROPERTY_NAME)) {
Property property = partitionInfo.getProperties().get(PROPERTY_NAME);
return Boolean.parseBoolean((String)property.getValue());
}
return false;
return true;
}
}
......@@ -91,18 +91,20 @@ public class GeoShapeDecimationSettingTest {
}
@Test
public void isDecimationEnabled_return_false_when_property_does_not_exist() throws PartitionException {
public void isDecimationEnabled_return_true_when_property_does_not_exist() throws PartitionException {
// The feature flag is enabled by default
PartitionInfo partitionInfo = new PartitionInfo();
when(this.partitionProvider.get(anyString())).thenReturn(partitionInfo);
boolean enabled = sut.isDecimationEnabled();
Assert.assertFalse(enabled);
Assert.assertTrue(enabled);
}
@Test
public void isDecimationEnabled_return_false_when_partitionProvider_throws_exception() throws PartitionException {
public void isDecimationEnabled_return_true_when_partitionProvider_throws_exception() throws PartitionException {
// The feature flag is enabled by default
when(this.partitionProvider.get(anyString())).thenThrow(PartitionException.class);
boolean enabled = sut.isDecimationEnabled();
Assert.assertFalse(enabled);
Assert.assertTrue(enabled);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment