You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2022/10/17 19:25:37 UTC

[GitHub] [cassandra] driftx commented on a diff in pull request #1900: CASSANDRA-17948 Get logs via virtual table

driftx commented on code in PR #1900:
URL: https://github.com/apache/cassandra/pull/1900#discussion_r997415787


##########
src/java/org/apache/cassandra/db/virtual/LogMessagesTable.java:
##########
@@ -0,0 +1,192 @@
+/*
+ * 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.db.virtual;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import com.google.common.annotations.VisibleForTesting;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.spi.LoggingEvent;
+import org.apache.cassandra.config.CassandraRelevantProperties;
+import org.apache.cassandra.db.DecoratedKey;
+import org.apache.cassandra.db.marshal.Int32Type;
+import org.apache.cassandra.db.marshal.TimestampType;
+import org.apache.cassandra.db.marshal.UTF8Type;
+import org.apache.cassandra.dht.LocalPartitioner;
+import org.apache.cassandra.schema.TableMetadata;
+
+/**
+ * Virtual table for holding Cassandra logs. Entries to this table are added via log appender.
+ * <p>
+ * The virtual table is bounded in its size. If a new log message is appended to virtual table,
+ * the oldest one is removed.
+ * <p>
+ * This virtual table can be truncated.
+ *
+ * @see org.apache.cassandra.utils.logging.VirtualTableAppender
+ */
+public final class LogMessagesTable extends AbstractMutableVirtualTable
+{
+    private static final Logger logger = LoggerFactory.getLogger(LogMessagesTable.class);
+
+    public static final int LOGS_VIRTUAL_TABLE_MIN_ROWS = 1000;
+    public static final int LOGS_VIRTUAL_TABLE_DEFAULT_ROWS = 50_000;
+    public static final int LOGS_VIRTUAL_TABLE_MAX_ROWS = 100_000;
+
+    public static final String TABLE_NAME = "logs";

Review Comment:
   I think we should be more descriptive and use something like "system_logs" in case there are other types in the future.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org