smiklosovic commented on a change in pull request #1051:
URL: https://github.com/apache/cassandra/pull/1051#discussion_r688349178



##########
File path: src/java/org/apache/cassandra/audit/AuditLogOptionsCompositeData.java
##########
@@ -0,0 +1,232 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.audit;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+
+import org.apache.cassandra.config.ParameterizedClass;
+import org.apache.cassandra.utils.Pair;
+
+import static 
org.apache.cassandra.audit.AuditLogOptionsCompositeData.AuditLogOption.option;
+
+public class AuditLogOptionsCompositeData
+{
+    public static class AuditLogOption
+    {
+        // TODO these constants will be used in upcoming audit log vtable too, 
see CASSANDRA-16725
+        public static final String AUDIT_LOGS_DIR = "audit_logs_dir";
+        public static final String ARCHIVE_COMMAND = "archive_command";
+        public static final String ROLL_CYCLE = "roll_cycle";
+        public static final String BLOCK = "block";
+        public static final String MAX_QUEUE_WEIGHT = "max_queue_weight";
+        public static final String MAX_LOG_SIZE = "max_log_size";
+        public static final String MAX_ARCHIVE_RETRIES = "max_archive_retries";
+        public static final String ENABLED = "enabled";
+        public static final String INCLUDED_KEYSPACES = "included_keyspaces";
+        public static final String EXCLUDED_KEYSPACES = "excluded_keyspaces";
+        public static final String INCLUDED_CATEGORIES = "included_categories";
+        public static final String EXCLUDED_CATEGORIES = "excluded_categories";
+        public static final String INCLUDED_USERS = "included_users";
+        public static final String EXCLUDED_USERS = "excluded_users";
+        public static final String LOGGER = "logger";
+
+        private final String name;
+        private final String description;
+        private final OpenType<?> type;
+        private final Function<AuditLogOptions, Object> toCompositeMapping;
+        private final BiConsumer<AuditLogOptions, Object> fromCompositeMapping;
+
+        public AuditLogOption(final String name,
+                              final String description,
+                              final OpenType<?> type,
+                              final Function<AuditLogOptions, Object> 
toCompositeMapping,
+                              final BiConsumer<AuditLogOptions, Object> 
fromCompositeMapping)
+        {
+            this.name = name;
+            this.description = description;
+            this.type = type;
+            this.toCompositeMapping = toCompositeMapping;
+            this.fromCompositeMapping = fromCompositeMapping;
+        }
+
+        public static AuditLogOption option(final String name,
+                                            final String description,
+                                            final OpenType<?> type,
+                                            final Function<AuditLogOptions, 
Object> toCompositeMapping,
+                                            final BiConsumer<AuditLogOptions, 
Object> fromCompositeMapping)
+        {
+            return new AuditLogOption(name, description, type, 
toCompositeMapping, fromCompositeMapping);
+        }
+    }
+
+    private static final AuditLogOption[] options = new AuditLogOption[]{
+    option(AuditLogOption.AUDIT_LOGS_DIR,
+           "directory where audit data are stored",
+           SimpleType.STRING,
+           o -> o.audit_logs_dir,
+           (opts, obj) -> opts.audit_logs_dir = (String) obj),
+
+    option(AuditLogOption.ARCHIVE_COMMAND,
+           "archive command for audit data",
+           SimpleType.STRING,
+           o -> o.archive_command,
+           (opts, obj) -> opts.archive_command = (String) obj),
+
+    option(AuditLogOption.ROLL_CYCLE,
+           "how often to roll BinLog segments so they can potentially be 
reclaimed",
+           SimpleType.STRING,
+           o -> o.roll_cycle,
+           (opts, obj) -> opts.roll_cycle = (String) obj),
+
+    option(AuditLogOption.BLOCK,
+           "indicates if the BinLog should block if the it falls behind or 
should drop bin log records",

Review comment:
       thanks




-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to