Skip to content

Commit 5ad727b

Browse files
committed
Merge branch 'master' into DS-1801.a
# Conflicts: # xyz-util/src/main/java/com/here/xyz/util/db/pg/Script.java # xyz-util/src/main/resources/sql/common.sql # xyz-util/src/main/resources/sql/feature_writer.sql
2 parents 11bbea6 + e64a626 commit 5ad727b

File tree

20 files changed

+809
-543
lines changed

20 files changed

+809
-543
lines changed

xyz-connectors/src/main/java/com/here/xyz/connectors/EntryConnectorHandler.java

Lines changed: 212 additions & 214 deletions
Large diffs are not rendered by default.

xyz-hub-service/src/main/java/com/here/xyz/hub/rest/FeatureApi.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private void getFeatures(final RoutingContext context, List<String> ids, ApiResp
189189
* Creates or replaces a feature.
190190
*/
191191
private void putFeature(final RoutingContext context) throws HttpException {
192-
if (Config.instance.USE_WRITE_FEATURES_EVENT)
192+
if (useWFE(context))
193193
executeWriteFeatures(context, FEATURE,
194194
toFeatureModificationList(readFeature(context).withId(getFeatureId(context)), IfNotExists.CREATE, IfExists.REPLACE,
195195
ConflictResolution.ERROR), getSpaceContext(context));
@@ -198,6 +198,10 @@ private void putFeature(final RoutingContext context) throws HttpException {
198198
ConflictResolution.ERROR);
199199
}
200200

201+
private boolean useWFE(RoutingContext context) {
202+
return Config.instance.USE_WRITE_FEATURES_EVENT && getSpaceId(context).contains("drgnstn");
203+
}
204+
201205
private FeatureModificationList toFeatureModificationList(Feature feature, IfNotExists ifNotExists, IfExists ifExists,
202206
ConflictResolution conflictResolution) {
203207
return toFeatureModificationList(new FeatureCollection().withFeatures(List.of(feature)), ifNotExists, ifExists, conflictResolution);
@@ -230,7 +234,7 @@ private FeatureModificationList toFeatureModificationList(List<String> featureId
230234
*/
231235
private void putFeatures(final RoutingContext context) throws HttpException {
232236
ApiResponseType responseType = getEmptyResponseTypeOr(context, FEATURE_COLLECTION);
233-
if (Config.instance.USE_WRITE_FEATURES_EVENT)
237+
if (useWFE(context))
234238
executeWriteFeatures(context, responseType,
235239
toFeatureModificationList(readFeatureOrFeatureCollection(context), IfNotExists.CREATE, IfExists.REPLACE, ConflictResolution.ERROR),
236240
getSpaceContext(context));
@@ -366,7 +370,7 @@ private Future<Void> updateContentUpdatedAt(Marker marker, Space space) {
366370
* Patches a feature
367371
*/
368372
private void patchFeature(final RoutingContext context) throws HttpException {
369-
if (Config.instance.USE_WRITE_FEATURES_EVENT)
373+
if (useWFE(context))
370374
executeWriteFeatures(context, FEATURE,
371375
toFeatureModificationList(readFeature(context).withId(getFeatureId(context)), IfNotExists.RETAIN, PATCH, ConflictResolution.ERROR),
372376
getSpaceContext(context));
@@ -385,7 +389,7 @@ private void postFeatures(final RoutingContext context) throws HttpException {
385389
ApiResponseType responseType = getEmptyResponseTypeOr(context, FEATURE_COLLECTION);
386390
String contentType = context.parsedHeaders().contentType().value();
387391

388-
if (Config.instance.USE_WRITE_FEATURES_EVENT) {
392+
if (useWFE(context)) {
389393
FeatureModificationList featureModificationList = APPLICATION_VND_HERE_FEATURE_MODIFICATION_LIST.equals(contentType)
390394
? readFeatureModificationList(context, ifExists, ifNotExists, conflictResolution)
391395
: toFeatureModificationList(readFeatureOrFeatureCollection(context), ifNotExists, ifExists, conflictResolution);
@@ -404,7 +408,7 @@ private void deleteFeature(final RoutingContext context) throws HttpException {
404408
String featureId = context.pathParam(Path.FEATURE_ID);
405409
final SpaceContext spaceContext = getSpaceContext(context);
406410

407-
if (Config.instance.USE_WRITE_FEATURES_EVENT)
411+
if (useWFE(context))
408412
executeDeleteFeatures(context, EMPTY, List.of(featureId), spaceContext, true);
409413
else
410414
executeConditionalOperationChain(true, context, ApiResponseType.EMPTY, IfExists.DELETE, IfNotExists.RETAIN,
@@ -426,7 +430,7 @@ private void deleteFeatures(final RoutingContext context) throws HttpException {
426430
sendErrorResponse(context, new DetailedHttpException("E318406"));
427431
else {
428432
//Delete features by IDs
429-
if (Config.instance.USE_WRITE_FEATURES_EVENT && !eraseContent)
433+
if (useWFE(context) && !eraseContent)
430434
executeDeleteFeatures(context, responseType, featureIds, spaceContext, false);
431435
else
432436
executeConditionalOperationChain(false, context, responseType, IfExists.DELETE, IfNotExists.RETAIN, true,

xyz-hub-test/src/main/java/com/here/xyz/benchmarks/tools/PerformanceTestHelper.java

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,13 @@ public static Typed readFeaturesByRefQuadAndGlobalVersions(StorageConnector conn
145145
}
146146

147147
public static Typed readFeaturesByRefQuadAndGlobalVersions(StorageConnector connector, List<String> spaceNames, String refQuad,
148-
List<Integer> globalVersions, int limit, boolean isCount)
148+
List<Integer> globalVersions, int limit, boolean isCount) throws Exception {
149+
return readFeaturesByRefQuadAndGlobalVersions(connector, spaceNames, refQuad, globalVersions, limit, isCount, null);
150+
}
151+
152+
public static Typed readFeaturesByRefQuadAndGlobalVersions(StorageConnector connector, List<String> spaceNames, String refQuad,
153+
List<Integer> globalVersions, int limit, boolean isCount, Integer
154+
refQuadLevel)
149155
throws Exception {
150156
Event searchForFeaturesEvent;
151157

@@ -169,8 +175,32 @@ public static Typed readFeaturesByRefQuadAndGlobalVersions(StorageConnector conn
169175
.withLimit(limit)
170176
.withPropertiesQuery(propertiesQuery);
171177

172-
if (isCount)
173-
((SearchForFeaturesEvent) searchForFeaturesEvent).setSelection(List.of("f.refQuadCount"));
178+
if (isCount) {
179+
String selectionParam = "f.refQuadCount";
180+
if(refQuadLevel != null)
181+
selectionParam += "@"+refQuadLevel;
182+
183+
((SearchForFeaturesEvent) searchForFeaturesEvent).setSelection(List.of(selectionParam));
184+
}
185+
186+
return handleRequest(connector, (ContextAwareEvent<?>) searchForFeaturesEvent, spaceNames);
187+
}
188+
189+
public static Typed readStatus(StorageConnector connector, List<String> spaceNames, String operations)
190+
throws Exception {
191+
Event searchForFeaturesEvent;
192+
193+
PropertiesQuery propertiesQuery = new PropertiesQuery();
194+
PropertyQueryList queries = new PropertyQueryList();
195+
196+
queries.add(new PropertyQuery()
197+
.withKey("properties.status")
198+
.withOperation(EQUALS)
199+
.withValues(List.of(operations)));
200+
201+
propertiesQuery.add(queries);
202+
searchForFeaturesEvent = new SearchForFeaturesEvent()
203+
.withPropertiesQuery(propertiesQuery);
174204

175205
return handleRequest(connector, (ContextAwareEvent<?>) searchForFeaturesEvent, spaceNames);
176206
}

xyz-hub-test/src/test/resources/log4j2.properties renamed to xyz-hub-test/src/main/resources/log4j2.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#
1616
# SPDX-License-Identifier: Apache-2.0
1717
# License-Filename: LICENSE
18-
rootLogger.level = WARN
18+
rootLogger.level = OFF
1919

2020
#packages = com.amazonaws.services.lambda.runtime.log4j2
2121
#appender.LAMBDA.type = Lambda

xyz-psql-connector/src/main/java/com/here/xyz/psql/DatabaseHandler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import com.here.xyz.util.db.datasource.DatabaseSettings;
5656
import com.here.xyz.util.db.datasource.DatabaseSettings.ScriptResourcePath;
5757
import com.here.xyz.util.runtime.FunctionRuntime;
58+
import com.here.xyz.util.runtime.LambdaFunctionRuntime;
5859
import java.sql.BatchUpdateException;
5960
import java.sql.Connection;
6061
import java.sql.SQLException;
@@ -68,8 +69,6 @@
6869
import java.util.Optional;
6970
import java.util.stream.Collectors;
7071
import java.util.stream.Stream;
71-
72-
import com.here.xyz.util.runtime.LambdaFunctionRuntime;
7372
import org.apache.logging.log4j.LogManager;
7473
import org.apache.logging.log4j.Logger;
7574

@@ -165,7 +164,7 @@ private boolean retryCausedOnServerlessDB(Exception e) {
165164
return false;
166165
}
167166
if (!retryAttempted) {
168-
logger.warn("{} Retry based on serverless scaling detected! RemainingTime: {} ", traceItem, remainingSeconds, e);
167+
logger.warn("{} Retryable error detected! RemainingTime: {} ", traceItem, remainingSeconds, e);
169168
return true;
170169
}
171170
}

0 commit comments

Comments
 (0)