use of org.apache.druid.metadata.MetadataCASUpdate in project druid by druid-io.
the class CoordinatorBasicAuthorizerMetadataStorageUpdater method tryUpdateUserMap.
private boolean tryUpdateUserMap(String prefix, Map<String, BasicAuthorizerUser> userMap, byte[] oldUserMapValue, byte[] newUserMapValue) {
try {
List<MetadataCASUpdate> updates = new ArrayList<>();
if (userMap != null) {
updates.add(createMetadataCASUpdate(prefix, oldUserMapValue, newUserMapValue, USERS));
boolean succeeded = connector.compareAndSwap(updates);
if (succeeded) {
cachedUserMaps.put(prefix, new BasicAuthorizerUserMapBundle(userMap, newUserMapValue));
byte[] serializedUserAndRoleMap = getCurrentUserAndRoleMapSerialized(prefix);
cacheNotifier.addUpdateUser(prefix, serializedUserAndRoleMap);
return true;
} else {
return false;
}
}
return false;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations