1 // Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2 //  This source code is licensed under both the GPLv2 (found in the
3 //  COPYING file in the root directory) and Apache 2.0 License
4 //  (found in the LICENSE.Apache file in the root directory).
5 
6 package org.rocksdb;
7 
8 public class LogFile {
9   private final String pathName;
10   private final long logNumber;
11   private final WalFileType type;
12   private final long startSequence;
13   private final long sizeFileBytes;
14 
15   /**
16    * Called from JNI C++
17    */
LogFile(final String pathName, final long logNumber, final byte walFileTypeValue, final long startSequence, final long sizeFileBytes)18   private LogFile(final String pathName, final long logNumber,
19       final byte walFileTypeValue, final long startSequence,
20       final long sizeFileBytes) {
21     this.pathName = pathName;
22     this.logNumber = logNumber;
23     this.type = WalFileType.fromValue(walFileTypeValue);
24     this.startSequence = startSequence;
25     this.sizeFileBytes = sizeFileBytes;
26   }
27 
28   /**
29    * Returns log file's pathname relative to the main db dir
30    * Eg. For a live-log-file = /000003.log
31    * For an archived-log-file = /archive/000003.log
32    *
33    * @return log file's pathname
34    */
pathName()35   public String pathName() {
36     return pathName;
37   }
38 
39   /**
40    * Primary identifier for log file.
41    * This is directly proportional to creation time of the log file
42    *
43    * @return the log number
44    */
logNumber()45   public long logNumber() {
46     return logNumber;
47   }
48 
49   /**
50    * Log file can be either alive or archived.
51    *
52    * @return the type of the log file.
53    */
type()54   public WalFileType type() {
55     return type;
56   }
57 
58   /**
59    * Starting sequence number of writebatch written in this log file.
60    *
61    * @return the stating sequence number
62    */
startSequence()63   public long startSequence() {
64     return startSequence;
65   }
66 
67   /**
68    * Size of log file on disk in Bytes.
69    *
70    * @return size of log file
71    */
sizeFileBytes()72   public long sizeFileBytes() {
73     return sizeFileBytes;
74   }
75 }
76