-
Notifications
You must be signed in to change notification settings - Fork 380
/
CatalogManager.java
635 lines (559 loc) · 23.8 KB
/
CatalogManager.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
/*
* Copyright 2023 Datastrato.
* This software is licensed under the Apache License version 2.
*/
package com.datastrato.graviton.catalog;
import static com.datastrato.graviton.StringIdentifier.ID_KEY;
import com.datastrato.graviton.Catalog;
import com.datastrato.graviton.CatalogChange;
import com.datastrato.graviton.CatalogChange.RemoveProperty;
import com.datastrato.graviton.CatalogChange.SetProperty;
import com.datastrato.graviton.CatalogProvider;
import com.datastrato.graviton.Config;
import com.datastrato.graviton.Configs;
import com.datastrato.graviton.Entity.EntityType;
import com.datastrato.graviton.EntityAlreadyExistsException;
import com.datastrato.graviton.EntityStore;
import com.datastrato.graviton.NameIdentifier;
import com.datastrato.graviton.Namespace;
import com.datastrato.graviton.StringIdentifier;
import com.datastrato.graviton.SupportsCatalogs;
import com.datastrato.graviton.exceptions.CatalogAlreadyExistsException;
import com.datastrato.graviton.exceptions.NoSuchCatalogException;
import com.datastrato.graviton.exceptions.NoSuchEntityException;
import com.datastrato.graviton.exceptions.NoSuchMetalakeException;
import com.datastrato.graviton.meta.AuditInfo;
import com.datastrato.graviton.meta.CatalogEntity;
import com.datastrato.graviton.rel.SupportsSchemas;
import com.datastrato.graviton.rel.TableCatalog;
import com.datastrato.graviton.storage.IdGenerator;
import com.datastrato.graviton.utils.IsolatedClassLoader;
import com.datastrato.graviton.utils.ThrowableFunction;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.Scheduler;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Streams;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.ServiceLoader;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** Manages the catalog instances and operations. */
public class CatalogManager implements SupportsCatalogs, Closeable {
private static final Logger LOG = LoggerFactory.getLogger(CatalogManager.class);
/** Wrapper class for a catalog instance and its class loader. */
public static class CatalogWrapper {
private BaseCatalog catalog;
private IsolatedClassLoader classLoader;
public CatalogWrapper(BaseCatalog catalog, IsolatedClassLoader classLoader) {
this.catalog = catalog;
this.classLoader = classLoader;
}
public <R> R doWithSchemaOps(ThrowableFunction<SupportsSchemas, R> fn) throws Exception {
return classLoader.withClassLoader(
cl -> {
if (asSchemas() == null) {
throw new UnsupportedOperationException("Catalog does not support schema operations");
}
return fn.apply(asSchemas());
});
}
public <R> R doWithTableOps(ThrowableFunction<TableCatalog, R> fn) throws Exception {
return classLoader.withClassLoader(
cl -> {
if (asTables() == null) {
throw new UnsupportedOperationException("Catalog does not support table operations");
}
return fn.apply(asTables());
});
}
public <R> R doWithPropertiesMeta(ThrowableFunction<HasPropertyMetadata, R> fn)
throws Exception {
return classLoader.withClassLoader(cl -> fn.apply(catalog.ops()));
}
public void close() {
try {
classLoader.withClassLoader(
cl -> {
if (catalog != null) {
catalog.ops().close();
}
catalog = null;
return null;
});
} catch (Exception e) {
LOG.warn("Failed to close catalog", e);
}
classLoader.close();
}
private SupportsSchemas asSchemas() {
return catalog.ops() instanceof SupportsSchemas ? (SupportsSchemas) catalog.ops() : null;
}
private TableCatalog asTables() {
return catalog.ops() instanceof TableCatalog ? (TableCatalog) catalog.ops() : null;
}
}
private final Config config;
@VisibleForTesting final Cache<NameIdentifier, CatalogWrapper> catalogCache;
private final EntityStore store;
private final IdGenerator idGenerator;
/**
* Constructs a CatalogManager instance.
*
* @param config The configuration for the manager.
* @param store The entity store to use.
* @param idGenerator The id generator to use.
*/
public CatalogManager(Config config, EntityStore store, IdGenerator idGenerator) {
this.config = config;
this.store = store;
this.idGenerator = idGenerator;
long cacheEvictionIntervalInMs = config.get(Configs.CATALOG_CACHE_EVICTION_INTERVAL_MS);
this.catalogCache =
Caffeine.newBuilder()
.expireAfterAccess(cacheEvictionIntervalInMs, TimeUnit.MILLISECONDS)
.removalListener(
(k, v, c) -> {
LOG.info("Closing catalog {}.", k);
((CatalogWrapper) v).close();
})
.scheduler(
Scheduler.forScheduledExecutorService(
new ScheduledThreadPoolExecutor(
1,
new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat("catalog-cleaner-%d")
.build())))
.build();
}
/**
* Closes the CatalogManager and releases any resources associated with it. This method
* invalidates all cached catalog instances and clears the cache.
*/
@Override
public void close() {
catalogCache.invalidateAll();
}
/**
* Lists the catalogs within the specified namespace.
*
* @param namespace The namespace for which to list catalogs.
* @return An array of NameIdentifier objects representing the catalogs.
* @throws NoSuchMetalakeException If the specified metalake does not exist.
*/
@Override
public NameIdentifier[] listCatalogs(Namespace namespace) throws NoSuchMetalakeException {
NameIdentifier metalakeIdent = NameIdentifier.of(namespace.levels());
boolean metalakeExists;
try {
metalakeExists = store.exists(metalakeIdent, EntityType.METALAKE);
} catch (IOException e) {
LOG.error("Failed to do storage operation", e);
throw new RuntimeException(e);
}
if (!metalakeExists) {
throw new NoSuchMetalakeException("Metalake " + metalakeIdent + " does not exist");
}
try {
return store.list(namespace, CatalogEntity.class, EntityType.CATALOG).stream()
.map(entity -> NameIdentifier.of(namespace, entity.name()))
.toArray(NameIdentifier[]::new);
} catch (IOException ioe) {
LOG.error("Failed to list catalogs in metalake {}", metalakeIdent, ioe);
throw new RuntimeException(ioe);
}
}
/**
* Loads the catalog with the specified identifier.
*
* @param ident The identifier of the catalog to load.
* @return The loaded catalog.
* @throws NoSuchCatalogException If the specified catalog does not exist.
*/
@Override
public Catalog loadCatalog(NameIdentifier ident) throws NoSuchCatalogException {
return loadCatalogAndWrap(ident).catalog;
}
/**
* Creates a new catalog with the provided details.
*
* @param ident The identifier of the new catalog.
* @param type The type of the new catalog.
* @param provider The provider of the new catalog.
* @param comment The comment for the new catalog.
* @param properties The properties of the new catalog.
* @return The created catalog.
* @throws NoSuchMetalakeException If the specified metalake does not exist.
* @throws CatalogAlreadyExistsException If a catalog with the same identifier already exists.
*/
@Override
public Catalog createCatalog(
NameIdentifier ident,
Catalog.Type type,
String provider,
String comment,
Map<String, String> properties)
throws NoSuchMetalakeException, CatalogAlreadyExistsException {
// load catalog-related configuration from catalog-specific configuration file
Map<String, String> catalogSpecificConfig = loadCatalogSpecificConfig(provider);
Map<String, String> mergedConfig = mergeConf(properties, catalogSpecificConfig);
long uid = idGenerator.nextId();
StringIdentifier stringId = StringIdentifier.fromId(uid);
CatalogEntity e =
new CatalogEntity.Builder()
.withId(uid)
.withName(ident.name())
.withNamespace(ident.namespace())
.withType(type)
.withProvider(provider)
.withComment(comment)
.withProperties(StringIdentifier.addToProperties(stringId, mergedConfig))
.withAuditInfo(
new AuditInfo.Builder()
.withCreator("graviton") /* TODO. Should change to real user */
.withCreateTime(Instant.now())
.build())
.build();
try {
store.executeInTransaction(
() -> {
NameIdentifier metalakeIdent = NameIdentifier.of(ident.namespace().levels());
if (!store.exists(metalakeIdent, EntityType.METALAKE)) {
LOG.warn("Metalake {} does not exist", metalakeIdent);
throw new NoSuchMetalakeException("Metalake " + metalakeIdent + " does not exist");
}
store.put(e, false /* overwrite */);
return null;
});
CatalogWrapper wrapper = catalogCache.get(ident, id -> createCatalogWrapper(e));
return wrapper.catalog;
} catch (EntityAlreadyExistsException e1) {
LOG.warn("Catalog {} already exists", ident, e1);
throw new CatalogAlreadyExistsException("Catalog " + ident + " already exists");
} catch (IllegalArgumentException | NoSuchMetalakeException e2) {
throw e2;
} catch (Exception e3) {
LOG.error("Failed to create catalog {}", ident, e3);
throw new RuntimeException(e3);
}
}
private Pair<Map<String, String>, Map<String, String>> getCatalogAlterProperty(
CatalogChange... catalogChanges) {
Map<String, String> upserts = Maps.newHashMap();
Map<String, String> deletes = Maps.newHashMap();
Arrays.stream(catalogChanges)
.forEach(
tableChange -> {
if (tableChange instanceof SetProperty) {
SetProperty setProperty = (SetProperty) tableChange;
upserts.put(setProperty.getProperty(), setProperty.getValue());
} else if (tableChange instanceof RemoveProperty) {
RemoveProperty removeProperty = (RemoveProperty) tableChange;
deletes.put(removeProperty.getProperty(), removeProperty.getProperty());
}
});
return Pair.of(upserts, deletes);
}
/**
* Alters an existing catalog with the specified changes.
*
* @param ident The identifier of the catalog to alter.
* @param changes The changes to apply to the catalog.
* @return The altered catalog.
* @throws NoSuchCatalogException If the specified catalog does not exist.
* @throws IllegalArgumentException If an unsupported catalog change is provided.
*/
@Override
public Catalog alterCatalog(NameIdentifier ident, CatalogChange... changes)
throws NoSuchCatalogException, IllegalArgumentException {
// There could be a race issue that someone is using the catalog from cache while we are
// updating it.
CatalogWrapper catalogWrapper = loadCatalogAndWrap(ident);
if (catalogWrapper == null) {
throw new NoSuchCatalogException("Catalog " + ident + " does not exist");
}
try {
catalogWrapper.doWithPropertiesMeta(
f -> {
Pair<Map<String, String>, Map<String, String>> alterProperty =
getCatalogAlterProperty(changes);
f.catalogPropertiesMetadata()
.validatePropertyForAlter(alterProperty.getLeft(), alterProperty.getRight());
return null;
});
} catch (IllegalArgumentException e1) {
throw e1;
} catch (Exception e) {
LOG.error("Failed to alter catalog {}", ident, e);
throw new RuntimeException(e);
}
catalogCache.invalidate(ident);
try {
CatalogEntity updatedCatalog =
store.update(
ident,
CatalogEntity.class,
EntityType.CATALOG,
catalog -> {
CatalogEntity.Builder newCatalogBuilder =
new CatalogEntity.Builder()
.withId(catalog.id())
.withName(catalog.name())
.withNamespace(ident.namespace())
.withType(catalog.getType())
.withProvider(catalog.getProvider())
.withComment(catalog.getComment());
AuditInfo newInfo =
new AuditInfo.Builder()
.withCreator(catalog.auditInfo().creator())
.withCreateTime(catalog.auditInfo().createTime())
.withLastModifier(
catalog.auditInfo().creator()) /* TODO. We should use real user */
.withLastModifiedTime(Instant.now())
.build();
newCatalogBuilder.withAuditInfo(newInfo);
Map<String, String> newProps =
catalog.getProperties() == null
? new HashMap<>()
: new HashMap<>(catalog.getProperties());
newCatalogBuilder = updateEntity(newCatalogBuilder, newProps, changes);
return newCatalogBuilder.build();
});
return catalogCache.get(
updatedCatalog.nameIdentifier(), id -> createCatalogWrapper(updatedCatalog))
.catalog;
} catch (NoSuchEntityException ne) {
LOG.warn("Catalog {} does not exist", ident, ne);
throw new NoSuchCatalogException("Catalog " + ident + " does not exist");
} catch (IllegalArgumentException iae) {
LOG.warn("Failed to alter catalog {} with unknown change", ident, iae);
throw iae;
} catch (IOException ioe) {
LOG.error("Failed to alter catalog {}", ident, ioe);
throw new RuntimeException(ioe);
}
}
/**
* Drops (deletes) the catalog with the specified identifier.
*
* @param ident The identifier of the catalog to drop.
* @return {@code true} if the catalog was successfully dropped, {@code false} otherwise.
*/
@Override
public boolean dropCatalog(NameIdentifier ident) {
// There could be a race issue that someone is using the catalog while we are dropping it.
catalogCache.invalidate(ident);
try {
return store.delete(ident, EntityType.CATALOG);
} catch (IOException ioe) {
LOG.error("Failed to drop catalog {}", ident, ioe);
throw new RuntimeException(ioe);
}
}
/**
* Loads the catalog with the specified identifier, wraps it in a CatalogWrapper, and caches the
* wrapper for reuse.
*
* @param ident The identifier of the catalog to load.
* @return The wrapped CatalogWrapper containing the loaded catalog.
* @throws NoSuchCatalogException If the specified catalog does not exist.
*/
public CatalogWrapper loadCatalogAndWrap(NameIdentifier ident) throws NoSuchCatalogException {
return catalogCache.get(ident, this::loadCatalogInternal);
}
private CatalogWrapper loadCatalogInternal(NameIdentifier ident) throws NoSuchCatalogException {
try {
CatalogEntity entity = store.get(ident, EntityType.CATALOG, CatalogEntity.class);
return createCatalogWrapper(entity);
} catch (NoSuchEntityException ne) {
LOG.warn("Catalog {} does not exist", ident, ne);
throw new NoSuchCatalogException("Catalog " + ident + " does not exist");
} catch (IOException ioe) {
LOG.error("Failed to load catalog {}", ident, ioe);
throw new RuntimeException(ioe);
}
}
private CatalogWrapper createCatalogWrapper(CatalogEntity entity) {
Map<String, String> conf = entity.getProperties();
String provider = entity.getProvider();
IsolatedClassLoader classLoader;
if (config.get(Configs.CATALOG_LOAD_ISOLATED)) {
String pkgPath = buildPkgPath(conf, provider);
String confPath = buildConfPath(provider);
classLoader = IsolatedClassLoader.buildClassLoader(Lists.newArrayList(pkgPath, confPath));
} else {
// This will use the current class loader, it is mainly used for test.
classLoader =
new IsolatedClassLoader(
Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
}
// Load Catalog class instance
BaseCatalog<?> catalog = createCatalogInstance(classLoader, provider);
catalog.withCatalogConf(conf).withCatalogEntity(entity);
CatalogWrapper wrapper = new CatalogWrapper(catalog, classLoader);
// Validate catalog properties and initialize the config
classLoader.withClassLoader(
cl -> {
Map<String, String> configWithoutId = Maps.newHashMap(conf);
configWithoutId.remove(ID_KEY);
catalog.ops().catalogPropertiesMetadata().validatePropertyForCreate(configWithoutId);
// Call wrapper.catalog.properties() to make BaseCatalog#properties in IsolatedClassLoader
// not null. Why we do this? Because wrapper.catalog.properties() need to be called in the
// IsolatedClassLoader, it needs to load the specific catalog class such as HiveCatalog or
// so. For simply, We will preload the value of properties and thus AppClassLoader can get
// the value of properties.
wrapper.catalog.properties();
return null;
},
IllegalArgumentException.class);
return wrapper;
}
private BaseCatalog<?> createCatalogInstance(IsolatedClassLoader classLoader, String provider) {
BaseCatalog<?> catalog;
try {
catalog =
classLoader.withClassLoader(
cl -> {
try {
Class<? extends CatalogProvider> providerClz =
lookupCatalogProvider(provider, cl);
return (BaseCatalog) providerClz.newInstance();
} catch (Exception e) {
LOG.error("Failed to load catalog with provider: {}", provider, e);
throw new RuntimeException(e);
}
});
} catch (Exception e) {
LOG.error("Failed to load catalog with class loader", e);
throw new RuntimeException(e);
}
if (catalog == null) {
throw new RuntimeException("Failed to load catalog with provider: " + provider);
}
return catalog;
}
private Map<String, String> loadCatalogSpecificConfig(String provider) {
if ("test".equals(provider)) {
return Maps.newHashMap();
}
String catalogSpecificConfigFile = provider + ".conf";
Map<String, String> catalogSpecificConfig = Maps.newHashMap();
String fullPath = buildConfPath(provider) + File.separator + catalogSpecificConfigFile;
try (InputStream inputStream = FileUtils.openInputStream(new File(fullPath))) {
Properties loadProperties = new Properties();
loadProperties.load(inputStream);
loadProperties.forEach(
(key, value) -> catalogSpecificConfig.put(key.toString(), value.toString()));
} catch (Exception e) {
LOG.warn(
"Failed to load catalog specific configurations, file name: '{}'",
catalogSpecificConfigFile,
e);
}
return catalogSpecificConfig;
}
static Map<String, String> mergeConf(Map<String, String> properties, Map<String, String> conf) {
Map<String, String> mergedConf = conf != null ? Maps.newHashMap(conf) : Maps.newHashMap();
Optional.ofNullable(properties).ifPresent(mergedConf::putAll);
return Collections.unmodifiableMap(mergedConf);
}
/**
* Build the config path from the specific provider. Usually, the configuration file is under the
* conf and conf and package are under the same directory.
*/
private String buildConfPath(String provider) {
String gravitonHome = System.getenv("GRAVITON_HOME");
Preconditions.checkArgument(gravitonHome != null, "GRAVITON_HOME not set");
boolean testEnv = System.getenv("GRAVITON_TEST") != null;
if (testEnv) {
return String.join(
File.separator,
gravitonHome,
"catalogs",
"catalog-" + provider,
"build",
"resources",
"main");
}
return String.join(File.separator, gravitonHome, "catalogs", provider, "conf");
}
private String buildPkgPath(Map<String, String> conf, String provider) {
String gravitonHome = System.getenv("GRAVITON_HOME");
Preconditions.checkArgument(gravitonHome != null, "GRAVITON_HOME not set");
boolean testEnv = System.getenv("GRAVITON_TEST") != null;
String pkg = conf.get(Catalog.PROPERTY_PACKAGE);
String pkgPath;
if (pkg != null) {
pkgPath = pkg;
} else if (testEnv) {
// In test, the catalog package is under the build directory.
pkgPath =
String.join(
File.separator, gravitonHome, "catalogs", "catalog-" + provider, "build", "libs");
} else {
// In real environment, the catalog package is under the catalog directory.
pkgPath = String.join(File.separator, gravitonHome, "catalogs", provider, "libs");
}
return pkgPath;
}
private Class<? extends CatalogProvider> lookupCatalogProvider(String provider, ClassLoader cl) {
ServiceLoader<CatalogProvider> loader = ServiceLoader.load(CatalogProvider.class, cl);
List<Class<? extends CatalogProvider>> providers =
Streams.stream(loader.iterator())
.filter(p -> p.shortName().equalsIgnoreCase(provider))
.map(CatalogProvider::getClass)
.collect(Collectors.toList());
if (providers.size() == 0) {
throw new IllegalArgumentException("No catalog provider found for: " + provider);
} else if (providers.size() > 1) {
throw new IllegalArgumentException("Multiple catalog providers found for: " + provider);
} else {
return Iterables.getOnlyElement(providers);
}
}
private CatalogEntity.Builder updateEntity(
CatalogEntity.Builder builder, Map<String, String> newProps, CatalogChange... changes) {
for (CatalogChange change : changes) {
if (change instanceof CatalogChange.RenameCatalog) {
CatalogChange.RenameCatalog rename = (CatalogChange.RenameCatalog) change;
builder.withName(rename.getNewName());
} else if (change instanceof CatalogChange.UpdateCatalogComment) {
CatalogChange.UpdateCatalogComment updateComment =
(CatalogChange.UpdateCatalogComment) change;
builder.withComment(updateComment.getNewComment());
} else if (change instanceof CatalogChange.SetProperty) {
CatalogChange.SetProperty setProperty = (CatalogChange.SetProperty) change;
newProps.put(setProperty.getProperty(), setProperty.getValue());
} else if (change instanceof CatalogChange.RemoveProperty) {
CatalogChange.RemoveProperty removeProperty = (CatalogChange.RemoveProperty) change;
newProps.remove(removeProperty.getProperty());
} else {
throw new IllegalArgumentException(
"Unsupported catalog change: " + change.getClass().getSimpleName());
}
}
return builder.withProperties(newProps);
}
}