keith-turner commented on code in PR #2799:
URL: https://github.com/apache/accumulo/pull/2799#discussion_r921373960
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java:
##########
@@ -1017,6 +1019,30 @@ public void setProperty(final String tableName, final
String property, final Str
}
}
+ @Override
+ public void modifyProperties(String tableName, final
Consumer<Map<String,String>> mapMutator)
+ throws AccumuloException, AccumuloSecurityException,
IllegalArgumentException,
+ ConcurrentModificationException {
+ EXISTING_TABLE_NAME.validate(tableName);
+ checkArgument(mapMutator != null, "mapMutator is null");
+
+ final Map<String,String> properties =
ThriftClientTypes.CLIENT.execute(context,
Review Comment:
With some changes, this code may be able to gracefully handle multiple
clients concurrently modifying props. Not completely sure, but think something
like the following may work.
Create a thrift type to return version+props.
```java
class ThriftVersionedProperties {
long version;
Map<String, String> props;
}
```
The following code was written quickly and omits alot of details, trying to
show how we could pass a version back and forth over thrift and use that
version to detect concurrent changes and retry.
```java
public void modifyProperties(String tableName, final
Consumer<Map<String,String>> mapMutator)
throws AccumuloException, AccumuloSecurityException,
IllegalArgumentException,
ConcurrentModificationException {
while(true) {
// make thrift call to get props+version
ThriftVersionedProps tvp = client.getTableProperties(...);
// mutate the properties
mapMutator.accept(tvp.properties);
try {
// pass the modified props+version back to thrift call. The
thrift call will throw a thrift exception if the version has changed since we
read props above.
client.modifyTableProperties(...,tableName, tvp);
break;
} catch (PropertiesVersionChanged pvc) {
log.debug("Properties changed since reading, retrying...");
//TODO maybe sleep using retry object
} catch (TableNotFoundException e) {
throw new AccumuloException(e);
}
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]