1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2009 Oracle. All rights reserved. 5 * 6 */ 7using System; 8using System.Collections.Generic; 9using System.Text; 10 11namespace BerkeleyDB { 12 /// <summary> 13 /// A class representing configuration parameters for 14 /// <see cref="SecondaryQueueDatabase"/> 15 /// </summary> 16 public class SecondaryQueueDatabaseConfig : SecondaryDatabaseConfig { 17 internal bool lengthIsSet; 18 private uint len; 19 /// <summary> 20 /// Specify the length of records in the database. 21 /// </summary> 22 /// <remarks> 23 /// <para> 24 /// The record length must be enough smaller than 25 /// <see cref="DatabaseConfig.PageSize"/> that at least one record plus 26 /// the database page's metadata information can fit on each database 27 /// page. 28 /// </para> 29 /// <para> 30 /// Any records added to the database that are less than Length bytes 31 /// long are automatically padded (see <see cref="PadByte"/> for more 32 /// information). 33 /// </para> 34 /// <para> 35 /// Any attempt to insert records into the database that are greater 36 /// than Length bytes long will cause the call to fail immediately and 37 /// return an error. 38 /// </para> 39 /// <para> 40 /// If the database already exists, this setting will be ignored. 41 /// </para> 42 /// </remarks> 43 public uint Length { 44 get { return len; } 45 set { 46 lengthIsSet = true; 47 len = value; 48 } 49 } 50 51 /// <summary> 52 /// The policy for how to handle database creation. 53 /// </summary> 54 /// <remarks> 55 /// If the database does not already exist and 56 /// <see cref="CreatePolicy.NEVER"/> is set, 57 /// <see cref="SecondaryQueueDatabase.Open"/> will fail. 58 /// </remarks> 59 public CreatePolicy Creation; 60 internal new uint openFlags { 61 get { 62 uint flags = base.openFlags; 63 flags |= (uint)Creation; 64 return flags; 65 } 66 } 67 68 69 internal bool padIsSet; 70 private int pad; 71 /// <summary> 72 /// The padding character for short, fixed-length records. 73 /// </summary> 74 /// <remarks> 75 /// <para> 76 /// If no pad character is specified, space characters (that is, ASCII 77 /// 0x20) are used for padding. 78 /// </para> 79 /// <para> 80 /// If the database already exists, this setting will be ignored. 81 /// </para> 82 /// </remarks> 83 public int PadByte { 84 get { return pad; } 85 set { 86 padIsSet = true; 87 pad = value; 88 } 89 } 90 91 internal bool extentIsSet; 92 private uint extentSz; 93 /// <summary> 94 /// The size of the extents used to hold pages in a 95 /// <see cref="SecondaryQueueDatabase"/>, specified as a number of 96 /// pages. 97 /// </summary> 98 /// <remarks> 99 /// <para> 100 /// Each extent is created as a separate physical file. If no extent 101 /// size is set, the default behavior is to create only a single 102 /// underlying database file. 103 /// </para> 104 /// <para> 105 /// For information on tuning the extent size, see Selecting a extent 106 /// size in the Programmer's Reference Guide. 107 /// </para> 108 /// <para> 109 /// If the database already exists, this setting will be ignored. 110 /// </para> 111 /// </remarks> 112 public uint ExtentSize { 113 get { return extentSz; } 114 set { 115 extentIsSet = true; 116 extentSz = value; 117 } 118 } 119 120 /// <summary> 121 /// Instantiate a new SecondaryQueueDatabaseConfig object 122 /// </summary> 123 public SecondaryQueueDatabaseConfig( 124 Database PrimaryDB, SecondaryKeyGenDelegate KeyGenFunc) 125 : base(PrimaryDB, KeyGenFunc) { 126 lengthIsSet = false; 127 padIsSet = false; 128 extentIsSet = false; 129 DbType = DatabaseType.QUEUE; 130 } 131 } 132}