Search in sources :

Example 6 with MetadataCASUpdate

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);
    }
}
Also used : MetadataCASUpdate(org.apache.druid.metadata.MetadataCASUpdate) BasicAuthorizerUserMapBundle(org.apache.druid.security.basic.authorization.entity.BasicAuthorizerUserMapBundle) ArrayList(java.util.ArrayList) BasicSecurityDBResourceException(org.apache.druid.security.basic.BasicSecurityDBResourceException) IOException(java.io.IOException)

Aggregations

MetadataCASUpdate (org.apache.druid.metadata.MetadataCASUpdate)6 BasicSecurityDBResourceException (org.apache.druid.security.basic.BasicSecurityDBResourceException)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 BasicAuthorizerRoleMapBundle (org.apache.druid.security.basic.authorization.entity.BasicAuthorizerRoleMapBundle)3 BasicAuthorizerGroupMappingMapBundle (org.apache.druid.security.basic.authorization.entity.BasicAuthorizerGroupMappingMapBundle)2 BasicAuthorizerUserMapBundle (org.apache.druid.security.basic.authorization.entity.BasicAuthorizerUserMapBundle)2 BasicAuthenticatorUserMapBundle (org.apache.druid.security.basic.authentication.entity.BasicAuthenticatorUserMapBundle)1