zookeeper-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [zookeeper] arshadmohammad commented on a change in pull request #1105: ZOOKEEPER-1260:Audit logging in ZooKeeper servers.
Date Thu, 03 Oct 2019 18:12:38 GMT
arshadmohammad commented on a change in pull request #1105: ZOOKEEPER-1260:Audit logging in
ZooKeeper servers.
URL: https://github.com/apache/zookeeper/pull/1105#discussion_r331180435
 
 

 ##########
 File path: zookeeper-server/src/test/java/org/apache/zookeeper/audit/ZKAuditLoggerPerformance.java
 ##########
 @@ -0,0 +1,151 @@
+/**
+ * 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.zookeeper.audit;
+
+import java.io.IOException;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.ZooDefs.Ids;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.common.Time;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.test.ClientBase.CountdownWatcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ZKAuditLoggerPerformance {
+    private static final Logger LOG = LoggerFactory
+            .getLogger(ZKAuditLoggerPerformance.class);
+    private ZooKeeper zkClient;
+    private String parentPath;
+    private int numberOfRecords;
+
+    public ZKAuditLoggerPerformance(ZooKeeper zkClient, String parentPath,
+            int numberOfRecords) {
+        this.zkClient = zkClient;
+        this.parentPath = parentPath;
+        this.numberOfRecords = numberOfRecords;
+    }
+
+    public void create() throws Exception {
+        for (int i = 0; i < numberOfRecords; i++) {
+            zkClient.create(getPath(i), "0123456789".getBytes(),
+                    Ids.OPEN_ACL_UNSAFE,
+                    CreateMode.PERSISTENT);
+
+        }
+    }
+
+    public void setData() throws Exception {
+        for (int i = 0; i < numberOfRecords; i++) {
+            zkClient.setData(getPath(i), "9876543210".getBytes(), -1);
+        }
+    }
+
+    public void delete() throws Exception {
+        for (int i = 0; i < numberOfRecords; i++) {
+            zkClient.delete(getPath(i), -1);
+        }
+    }
+
+    public AuditLogPerfReading doOperations() throws Exception {
+        AuditLogPerfReading perfReading = new AuditLogPerfReading();
+        // create
+        long startTime = Time.currentElapsedTime();
+        create();
+        perfReading.setCreate(Time.currentElapsedTime() - startTime);
+
+        // setData
+        startTime = Time.currentElapsedTime();
+        setData();
+        perfReading.setSetData(Time.currentElapsedTime() - startTime);
+
+        // delete
+        startTime = Time.currentElapsedTime();
+        delete();
+        perfReading.setDelete(Time.currentElapsedTime() - startTime);
+        return perfReading;
+    }
+
+    private String getPath(int i) {
+        return parentPath + "zNode" + i;
+    }
+
+    public static void main(String[] args) {
 
 Review comment:
   This program was just to see the performance impact of audit log. I added here so anybody
can run and see the audit log impact on their environment. Also it is added test folder.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message