EdColeman commented on code in PR #4116: URL: https://github.com/apache/accumulo/pull/4116#discussion_r1464103384
########## server/tserver/src/main/java/org/apache/accumulo/tserver/log/CreateEmptyWal.java: ########## @@ -0,0 +1,110 @@ +/* + * 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 + * + * https://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.accumulo.tserver.log; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.nio.file.StandardOpenOption.CREATE_NEW; +import static org.apache.accumulo.tserver.log.DfsLogger.LOG_FILE_HEADER_V4; +import static org.apache.accumulo.tserver.logger.LogEvents.OPEN; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.apache.accumulo.core.cli.ConfigOpts; +import org.apache.accumulo.core.crypto.CryptoEnvironmentImpl; +import org.apache.accumulo.core.crypto.CryptoUtils; +import org.apache.accumulo.core.spi.crypto.CryptoEnvironment; +import org.apache.accumulo.core.spi.crypto.CryptoService; +import org.apache.accumulo.server.ServerContext; +import org.apache.accumulo.start.spi.KeywordExecutable; +import org.apache.accumulo.tserver.logger.LogFileKey; +import org.apache.accumulo.tserver.logger.LogFileValue; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.beust.jcommander.Parameter; +import com.google.auto.service.AutoService; +import com.google.common.annotations.VisibleForTesting; + +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + +@AutoService(KeywordExecutable.class) +public class CreateEmptyWal implements KeywordExecutable { + private static final Logger LOG = LoggerFactory.getLogger(CreateEmptyWal.class); + private static final LogFileValue EMPTY = new LogFileValue(); + + static class Opts extends ConfigOpts { + @Parameter( + description = " <path> the path / filename of the created empty wal file. The file cannot exist", + required = true) + String walFilename; Review Comment: If I recall, when needing to use an empty rfile it was convenient to have a "local" file. That file could the be reused when needed by using hadoop copyFromLocal to the desired directory and filename. The empty rfile utility was only needed when the empty.rf "seed" file was not available. It would seem this could be similar. If you have a recovery problem and you want to move on (and accept the data loss) you would identify the file(s) that are missing / corrupt and then copy an empty wal to replace them. If the files are corrupt or cannot be processed, would need to delete the current files and then replace them with the empty file. Rather than running this utility to create each empty file on demand, you could create an single file and then either use the command line or better, a simple script to do the delete / copy. The file could be created in hdfs, but then you would likely need to create a temporary directory in the proper namespace - in which case copyFromLocal is just as easy to use. If the intended usage is the utility would to create the files directly - you would still need to delete the original files. Overwriting is probably a bad idea - if there was mistake, you could clobber valid files. I assumed that the intention of this utility was to simply create the empty seed file. These changes can be done. but it seems to be unnecessarily complicating things to create that empty wal seed file. -- 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]
