zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject [zookeeper] branch master updated: ZOOKEEPER-3666: remove the deprecated LogFormatter tool
Date Tue, 21 Jan 2020 17:19:00 GMT
This is an automated email from the ASF dual-hosted git repository.

andor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new 97f89ce  ZOOKEEPER-3666: remove the deprecated LogFormatter tool
97f89ce is described below

commit 97f89ceb2ac22a45d886e0430e2bcbf4d337094d
Author: Nishanth Entoor <entoor.nishanth@gmail.com>
AuthorDate: Tue Jan 21 18:18:51 2020 +0100

    ZOOKEEPER-3666: remove the deprecated LogFormatter tool
    
    As per [ZOOKEEPER-3666](https://issues.apache.org/jira/browse/ZOOKEEPER-3666), we need
to remove the deprecated LogFormatter tool. For this I made the following changes:
    - Removed LogFormatter class
    - Removed testLogFormatter test from InvalidSnapshotTest
    - Changed zookeeperAdmin.md file
    
    Please let me know if additional changes are required.
    
    Author: Nishanth Entoor <entoor.nishanth@gmail.com>
    
    Reviewers: eolivelli@apache.org, andor@apache.org
    
    Closes #1200 from nishanth-entoor/ZOOKEEPER-3666
---
 .../src/main/resources/markdown/zookeeperAdmin.md  |   4 +-
 .../org/apache/zookeeper/server/LogFormatter.java  | 125 ---------------------
 .../apache/zookeeper/test/InvalidSnapshotTest.java |  12 --
 3 files changed, 1 insertion(+), 140 deletions(-)

diff --git a/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md b/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md
index 785494b..7e28cc7 100644
--- a/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md
+++ b/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md
@@ -2424,9 +2424,7 @@ a running replicated ZooKeeper server to a development machine with
a
 stand-alone ZooKeeper server for troubleshooting.
 
 Using older log and snapshot files, you can look at the previous
-state of ZooKeeper servers and even restore that state. The
-LogFormatter class allows an administrator to look at the transactions
-in a log.
+state of ZooKeeper servers and even restore that state.
 
 The ZooKeeper server creates snapshot and log files, but
 never deletes them. The retention policy of the data and log
diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/server/LogFormatter.java
b/zookeeper-server/src/main/java/org/apache/zookeeper/server/LogFormatter.java
deleted file mode 100644
index 81392df..0000000
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/LogFormatter.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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.server;
-
-import java.io.EOFException;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.util.Date;
-import java.util.zip.Adler32;
-import java.util.zip.Checksum;
-import org.apache.jute.BinaryInputArchive;
-import org.apache.jute.Record;
-import org.apache.yetus.audience.InterfaceAudience;
-import org.apache.zookeeper.ZKUtil;
-import org.apache.zookeeper.server.persistence.FileHeader;
-import org.apache.zookeeper.server.persistence.FileTxnLog;
-import org.apache.zookeeper.server.util.SerializeUtils;
-import org.apache.zookeeper.txn.TxnDigest;
-import org.apache.zookeeper.txn.TxnHeader;
-import org.apache.zookeeper.util.ServiceUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @deprecated deprecated in 3.5.5, use @see TxnLogToolkit instead
- */
-@Deprecated
-@InterfaceAudience.Public
-public class LogFormatter {
-
-    private static final Logger LOG = LoggerFactory.getLogger(LogFormatter.class);
-
-    /**
-     * @param args
-     */
-    public static void main(String[] args) throws Exception {
-        if (args.length != 1) {
-            System.err.println("USAGE: LogFormatter log_file");
-            ServiceUtils.requestSystemExit(ExitCode.INVALID_INVOCATION.getValue());
-        }
-
-        String error = ZKUtil.validateFileInput(args[0]);
-        if (null != error) {
-            System.err.println(error);
-            ServiceUtils.requestSystemExit(ExitCode.INVALID_INVOCATION.getValue());
-        }
-
-        FileInputStream fis = new FileInputStream(args[0]);
-        BinaryInputArchive logStream = BinaryInputArchive.getArchive(fis);
-        FileHeader fhdr = new FileHeader();
-        fhdr.deserialize(logStream, "fileheader");
-
-        if (fhdr.getMagic() != FileTxnLog.TXNLOG_MAGIC) {
-            System.err.println("Invalid magic number for " + args[0]);
-            ServiceUtils.requestSystemExit(ExitCode.INVALID_INVOCATION.getValue());
-        }
-        System.out.println("ZooKeeper Transactional Log File with dbid "
-                           + fhdr.getDbid()
-                           + " txnlog format version "
-                           + fhdr.getVersion());
-
-        // enable digest
-        ZooKeeperServer.setDigestEnabled(true);
-
-        int count = 0;
-        while (true) {
-            long crcValue;
-            byte[] bytes;
-            try {
-                crcValue = logStream.readLong("crcvalue");
-
-                bytes = logStream.readBuffer("txnEntry");
-            } catch (EOFException e) {
-                System.out.println("EOF reached after " + count + " txns.");
-                return;
-            }
-            if (bytes.length == 0) {
-                // Since we preallocate, we define EOF to be an
-                // empty transaction
-                System.out.println("EOF reached after " + count + " txns.");
-                return;
-            }
-            Checksum crc = new Adler32();
-            crc.update(bytes, 0, bytes.length);
-            if (crcValue != crc.getValue()) {
-                throw new IOException("CRC doesn't match " + crcValue + " vs " + crc.getValue());
-            }
-            TxnLogEntry entry = SerializeUtils.deserializeTxn(bytes);
-            TxnHeader hdr = entry.getHeader();
-            Record txn = entry.getTxn();
-            TxnDigest digest = entry.getDigest();
-            System.out.println(
-                DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).format(new
Date(hdr.getTime()))
-                + " session 0x" + Long.toHexString(hdr.getClientId())
-                + " cxid 0x" + Long.toHexString(hdr.getCxid())
-                + " zxid 0x" + Long.toHexString(hdr.getZxid())
-                + " " + Request.op2String(hdr.getType())
-                + " " + txn
-                + " " + digest);
-            if (logStream.readByte("EOR") != 'B') {
-                LOG.error("Last transaction was partial.");
-                throw new EOFException("Last transaction was partial.");
-            }
-            count++;
-        }
-    }
-
-}
diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/test/InvalidSnapshotTest.java
b/zookeeper-server/src/test/java/org/apache/zookeeper/test/InvalidSnapshotTest.java
index 9f458cb..9003bb6 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/test/InvalidSnapshotTest.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/test/InvalidSnapshotTest.java
@@ -40,18 +40,6 @@ public class InvalidSnapshotTest extends ZKTestCase {
     private static final File testData = new File(System.getProperty("test.data.dir", "src/test/resources/data"));
 
     /**
-     * Verify the LogFormatter by running it on a known file.
-     */
-    @SuppressWarnings("deprecation")
-    @Test
-    public void testLogFormatter() throws Exception {
-        File snapDir = new File(testData, "invalidsnap");
-        File logfile = new File(new File(snapDir, "version-2"), "log.274");
-        String[] args = {logfile.getCanonicalFile().toString()};
-        org.apache.zookeeper.server.LogFormatter.main(args);
-    }
-
-    /**
      * Verify the SnapshotFormatter by running it on a known file.
      */
     @Test


Mime
View raw message