Mmuzaf commented on code in PR #3412: URL: https://github.com/apache/cassandra/pull/3412#discussion_r1767009249
########## test/unit/org/apache/cassandra/db/virtual/StorageOperationsTableCleanupTest.java: ########## @@ -0,0 +1,133 @@ +/* + * 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 org.junit.After; + +import org.apache.cassandra.db.CleanupTest; +import org.apache.cassandra.db.compaction.CompactionManager; +import org.apache.cassandra.db.compaction.OperationType; +import org.apache.cassandra.schema.SchemaConstants; +import org.apache.cassandra.tools.ToolRunner; + +import static org.apache.cassandra.tools.ToolRunner.invokeNodetool; + +public class StorageOperationsTableCleanupTest extends CleanupTest Review Comment: Fixed this one. ########## src/java/org/apache/cassandra/service/StorageService.java: ########## @@ -2578,16 +2578,14 @@ public int forceKeyspaceCleanup(int jobs, String keyspaceName, String... tableNa if (isLocalSystemKeyspace(keyspaceName)) throw new RuntimeException("Cleanup of the system keyspace is neither necessary nor wise"); - CompactionManager.AllSSTableOpStatus status = CompactionManager.AllSSTableOpStatus.SUCCESSFUL; logger.info("Starting {} on {}.{}", OperationType.CLEANUP, keyspaceName, Arrays.toString(tableNames)); - for (ColumnFamilyStore cfStore : getValidColumnFamilies(false, false, keyspaceName, tableNames)) - { - CompactionManager.AllSSTableOpStatus oneStatus = cfStore.forceCleanup(jobs); - if (oneStatus != CompactionManager.AllSSTableOpStatus.SUCCESSFUL) - status = oneStatus; - } - logger.info("Completed {} with status {}", OperationType.CLEANUP, status); - return status.statusCode; + CompactionManager.AllSSTableOpStatus result = CompactionManager.instance Review Comment: Fixed. ########## src/java/org/apache/cassandra/db/virtual/model/StorageOperationsRow.java: ########## @@ -0,0 +1,96 @@ +/* + * 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.model; + +import java.util.Map; + +import org.apache.cassandra.db.compaction.CompactionManager; +import org.apache.cassandra.utils.TimeUUID; + +import static java.lang.String.format; + +/** + * Representation of operation for a {@link org.apache.cassandra.db.virtual.CollectionVirtualTableAdapter}. + */ +public class StorageOperationsRow +{ + private static final String UNDEFINED = "undefined"; + private final Map.Entry<TimeUUID, CompactionManager.OperationInfo> entry; + + public StorageOperationsRow(Map.Entry<TimeUUID, CompactionManager.OperationInfo> entry) + { + this.entry = entry; + } + + @Column(type = Column.Type.PARTITION_KEY) + public String operationId() + { + return entry.getKey().toString(); + } + + @Column + public String operationType() + { + return entry.getValue().operationType.toString(); + } + + @Column + public String keyspaces() + { + return String.join(", ", entry.getValue().keyspaceNames); + } + + @Column + public String tables() + { + return entry.getValue().processedCfs().keySet().toString(); + } + + @Column + public String operationResult() + { + CompactionManager.AllSSTableOpStatus status = entry.getValue().result(); + return status == null ? UNDEFINED : status.toString(); + } + + @Column + public String operationResultByTable() + { + return formatMap(entry.getValue().processedCfs()); + } + + @Column + public String processedByKeyspace() + { + return formatMap(entry.getValue().processedSStables()); + } + + private static String formatMap(Map<?, ?> map) + { + return format("[%s]", map.entrySet().stream() Review Comment: Fixed. -- 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]

