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 enum WalFileType { 9 /** 10 * Indicates that WAL file is in archive directory. WAL files are moved from 11 * the main db directory to archive directory once they are not live and stay 12 * there until cleaned up. Files are cleaned depending on archive size 13 * (Options::WAL_size_limit_MB) and time since last cleaning 14 * (Options::WAL_ttl_seconds). 15 */ 16 kArchivedLogFile((byte)0x0), 17 18 /** 19 * Indicates that WAL file is live and resides in the main db directory 20 */ 21 kAliveLogFile((byte)0x1); 22 23 private final byte value; 24 WalFileType(final byte value)25 WalFileType(final byte value) { 26 this.value = value; 27 } 28 29 /** 30 * Get the internal representation value. 31 * 32 * @return the internal representation value 33 */ getValue()34 byte getValue() { 35 return value; 36 } 37 38 /** 39 * Get the WalFileType from the internal representation value. 40 * 41 * @return the wal file type. 42 * 43 * @throws IllegalArgumentException if the value is unknown. 44 */ fromValue(final byte value)45 static WalFileType fromValue(final byte value) { 46 for (final WalFileType walFileType : WalFileType.values()) { 47 if(walFileType.value == value) { 48 return walFileType; 49 } 50 } 51 52 throw new IllegalArgumentException( 53 "Illegal value provided for WalFileType: " + value); 54 } 55 } 56