github.com/m3db/m3@v1.5.0/src/dbnode/storage/options.go (about)

     1  // Copyright (c) 2016 Uber Technologies, Inc.
     2  //
     3  // Permission is hereby granted, free of charge, to any person obtaining a copy
     4  // of this software and associated documentation files (the "Software"), to deal
     5  // in the Software without restriction, including without limitation the rights
     6  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     7  // copies of the Software, and to permit persons to whom the Software is
     8  // furnished to do so, subject to the following conditions:
     9  //
    10  // The above copyright notice and this permission notice shall be included in
    11  // all copies or substantial portions of the Software.
    12  //
    13  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    14  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    15  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    16  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    17  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    18  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    19  // THE SOFTWARE.
    20  
    21  package storage
    22  
    23  import (
    24  	"errors"
    25  	"fmt"
    26  	"time"
    27  
    28  	"github.com/m3db/m3/src/dbnode/client"
    29  	"github.com/m3db/m3/src/dbnode/encoding"
    30  	"github.com/m3db/m3/src/dbnode/encoding/m3tsz"
    31  	"github.com/m3db/m3/src/dbnode/namespace"
    32  	"github.com/m3db/m3/src/dbnode/persist"
    33  	"github.com/m3db/m3/src/dbnode/persist/fs"
    34  	"github.com/m3db/m3/src/dbnode/persist/fs/commitlog"
    35  	"github.com/m3db/m3/src/dbnode/retention"
    36  	m3dbruntime "github.com/m3db/m3/src/dbnode/runtime"
    37  	"github.com/m3db/m3/src/dbnode/storage/block"
    38  	"github.com/m3db/m3/src/dbnode/storage/bootstrap"
    39  	"github.com/m3db/m3/src/dbnode/storage/index"
    40  	"github.com/m3db/m3/src/dbnode/storage/limits"
    41  	"github.com/m3db/m3/src/dbnode/storage/limits/permits"
    42  	"github.com/m3db/m3/src/dbnode/storage/repair"
    43  	"github.com/m3db/m3/src/dbnode/storage/series"
    44  	"github.com/m3db/m3/src/dbnode/ts/writes"
    45  	"github.com/m3db/m3/src/dbnode/x/xio"
    46  	"github.com/m3db/m3/src/dbnode/x/xpool"
    47  	"github.com/m3db/m3/src/x/clock"
    48  	"github.com/m3db/m3/src/x/context"
    49  	"github.com/m3db/m3/src/x/ident"
    50  	"github.com/m3db/m3/src/x/instrument"
    51  	"github.com/m3db/m3/src/x/mmap"
    52  	"github.com/m3db/m3/src/x/pool"
    53  	xsync "github.com/m3db/m3/src/x/sync"
    54  )
    55  
    56  const (
    57  	// defaultBytesPoolBucketCapacity is the default bytes buffer capacity for the default bytes pool bucket.
    58  	defaultBytesPoolBucketCapacity = 256
    59  
    60  	// defaultBytesPoolBucketCount is the default count of elements for the default bytes pool bucket.
    61  	defaultBytesPoolBucketCount = 4096
    62  
    63  	// defaultRepairEnabled enables repair by default.
    64  	defaultRepairEnabled = true
    65  
    66  	// defaultErrorWindowForLoad is the default error window for evaluating server load.
    67  	defaultErrorWindowForLoad = 10 * time.Second
    68  
    69  	// defaultErrorThresholdForLoad is the default error threshold for considering server overloaded.
    70  	defaultErrorThresholdForLoad = 1000
    71  
    72  	// defaultIndexingEnabled disables indexing by default.
    73  	defaultIndexingEnabled = false
    74  
    75  	// defaultNumLoadedBytesLimit is the default limit (2GiB) for the number of outstanding loaded bytes that
    76  	// the memory tracker will allow.
    77  	defaultNumLoadedBytesLimit = 2 << 30
    78  
    79  	defaultMediatorTickInterval = 5 * time.Second
    80  )
    81  
    82  var (
    83  	// defaultBootstrapProcessProvider is the default bootstrap provider for the database.
    84  	defaultBootstrapProcessProvider = bootstrap.NewNoOpProcessProvider()
    85  
    86  	// defaultPoolOptions are the pool options used by default.
    87  	defaultPoolOptions pool.ObjectPoolOptions
    88  )
    89  
    90  var (
    91  	errNamespaceInitializerNotSet = errors.New("namespace registry initializer not set")
    92  	errRepairOptionsNotSet        = errors.New("repair enabled but repair options are not set")
    93  	errIndexOptionsNotSet         = errors.New("index enabled but index options are not set")
    94  	errPersistManagerNotSet       = errors.New("persist manager is not set")
    95  	errIndexClaimsManagerNotSet   = errors.New("index claims manager is not set")
    96  	errBlockLeaserNotSet          = errors.New("block leaser is not set")
    97  	errOnColdFlushNotSet          = errors.New("on cold flush is not set, requires at least a no-op implementation")
    98  	errLimitsOptionsNotSet        = errors.New("limits options are not set")
    99  )
   100  
   101  // NewSeriesOptionsFromOptions creates a new set of database series options from provided options.
   102  func NewSeriesOptionsFromOptions(opts Options, ropts retention.Options) series.Options {
   103  	if ropts == nil {
   104  		ropts = retention.NewOptions()
   105  	}
   106  
   107  	return opts.SeriesOptions().
   108  		SetClockOptions(opts.ClockOptions()).
   109  		SetInstrumentOptions(opts.InstrumentOptions()).
   110  		SetRetentionOptions(ropts).
   111  		SetDatabaseBlockOptions(opts.DatabaseBlockOptions()).
   112  		SetCachePolicy(opts.SeriesCachePolicy()).
   113  		SetContextPool(opts.ContextPool()).
   114  		SetEncoderPool(opts.EncoderPool()).
   115  		SetMultiReaderIteratorPool(opts.MultiReaderIteratorPool()).
   116  		SetIdentifierPool(opts.IdentifierPool()).
   117  		SetBufferBucketPool(opts.BufferBucketPool()).
   118  		SetBufferBucketVersionsPool(opts.BufferBucketVersionsPool()).
   119  		SetRuntimeOptionsManager(opts.RuntimeOptionsManager())
   120  }
   121  
   122  type options struct {
   123  	clockOpts                       clock.Options
   124  	instrumentOpts                  instrument.Options
   125  	nsRegistryInitializer           namespace.Initializer
   126  	blockOpts                       block.Options
   127  	commitLogOpts                   commitlog.Options
   128  	runtimeOptsMgr                  m3dbruntime.OptionsManager
   129  	errWindowForLoad                time.Duration
   130  	errThresholdForLoad             int64
   131  	indexingEnabled                 bool
   132  	repairEnabled                   bool
   133  	truncateType                    series.TruncateType
   134  	transformOptions                series.WriteTransformOptions
   135  	indexOpts                       index.Options
   136  	repairOpts                      repair.Options
   137  	newEncoderFn                    encoding.NewEncoderFn
   138  	newDecoderFn                    encoding.NewDecoderFn
   139  	bootstrapProcessProvider        bootstrap.ProcessProvider
   140  	persistManager                  persist.Manager
   141  	indexClaimsManager              fs.IndexClaimsManager
   142  	blockRetrieverManager           block.DatabaseBlockRetrieverManager
   143  	poolOpts                        pool.ObjectPoolOptions
   144  	contextPool                     context.Pool
   145  	seriesCachePolicy               series.CachePolicy
   146  	seriesOpts                      series.Options
   147  	seriesPool                      series.DatabaseSeriesPool
   148  	bytesPool                       pool.CheckedBytesPool
   149  	encoderPool                     encoding.EncoderPool
   150  	segmentReaderPool               xio.SegmentReaderPool
   151  	readerIteratorPool              encoding.ReaderIteratorPool
   152  	multiReaderIteratorPool         encoding.MultiReaderIteratorPool
   153  	identifierPool                  ident.Pool
   154  	fetchBlockMetadataResultsPool   block.FetchBlockMetadataResultsPool
   155  	fetchBlocksMetadataResultsPool  block.FetchBlocksMetadataResultsPool
   156  	writeBatchPool                  *writes.WriteBatchPool
   157  	bufferBucketPool                *series.BufferBucketPool
   158  	bufferBucketVersionsPool        *series.BufferBucketVersionsPool
   159  	retrieveRequestPool             fs.RetrieveRequestPool
   160  	checkedBytesWrapperPool         xpool.CheckedBytesWrapperPool
   161  	schemaReg                       namespace.SchemaRegistry
   162  	blockLeaseManager               block.LeaseManager
   163  	onColdFlush                     OnColdFlush
   164  	forceColdWritesEnabled          bool
   165  	sourceLoggerBuilder             limits.SourceLoggerBuilder
   166  	iterationOptions                index.IterationOptions
   167  	memoryTracker                   MemoryTracker
   168  	mmapReporter                    mmap.Reporter
   169  	doNotIndexWithFieldsMap         map[string]string
   170  	namespaceRuntimeOptsMgrRegistry namespace.RuntimeOptionsManagerRegistry
   171  	mediatorTickInterval            time.Duration
   172  	adminClient                     client.AdminClient
   173  	newBackgroundProcessFns         []NewBackgroundProcessFn
   174  	namespaceHooks                  NamespaceHooks
   175  	tileAggregator                  TileAggregator
   176  	permitsOptions                  permits.Options
   177  	limitsOptions                   limits.Options
   178  	coreFn                          xsync.CoreFn
   179  }
   180  
   181  // NewOptions creates a new set of storage options with defaults.
   182  // NB: expensive, in tests use DefaultTestOptions instead.
   183  func NewOptions() Options {
   184  	return newOptions(defaultPoolOptions)
   185  }
   186  
   187  func newOptions(poolOpts pool.ObjectPoolOptions) Options {
   188  	bytesPool := pool.NewCheckedBytesPool(nil, poolOpts, func(s []pool.Bucket) pool.BytesPool {
   189  		return pool.NewBytesPool(s, poolOpts)
   190  	})
   191  	bytesPool.Init()
   192  	seriesOpts := series.NewOptions()
   193  
   194  	writeBatchPool := writes.NewWriteBatchPool(poolOpts, 0, nil)
   195  	writeBatchPool.Init()
   196  
   197  	segmentReaderPool := xio.NewSegmentReaderPool(poolOpts)
   198  	segmentReaderPool.Init()
   199  
   200  	retrieveRequestPool := fs.NewRetrieveRequestPool(segmentReaderPool, poolOpts)
   201  	retrieveRequestPool.Init()
   202  
   203  	bytesWrapperPool := xpool.NewCheckedBytesWrapperPool(poolOpts)
   204  	bytesWrapperPool.Init()
   205  
   206  	iOpts := instrument.NewOptions()
   207  	o := &options{
   208  		clockOpts:                clock.NewOptions(),
   209  		instrumentOpts:           iOpts,
   210  		blockOpts:                block.NewOptions(),
   211  		commitLogOpts:            commitlog.NewOptions(),
   212  		runtimeOptsMgr:           m3dbruntime.NewOptionsManager(),
   213  		errWindowForLoad:         defaultErrorWindowForLoad,
   214  		errThresholdForLoad:      defaultErrorThresholdForLoad,
   215  		indexingEnabled:          defaultIndexingEnabled,
   216  		indexOpts:                index.NewOptions(),
   217  		repairEnabled:            defaultRepairEnabled,
   218  		repairOpts:               repair.NewOptions(),
   219  		bootstrapProcessProvider: defaultBootstrapProcessProvider,
   220  		poolOpts:                 poolOpts,
   221  		contextPool: context.NewPool(context.NewOptions().
   222  			SetContextPoolOptions(poolOpts).
   223  			SetFinalizerPoolOptions(poolOpts)),
   224  		seriesCachePolicy:       series.DefaultCachePolicy,
   225  		seriesOpts:              seriesOpts,
   226  		seriesPool:              series.NewDatabaseSeriesPool(poolOpts),
   227  		bytesPool:               bytesPool,
   228  		encoderPool:             encoding.NewEncoderPool(poolOpts),
   229  		segmentReaderPool:       segmentReaderPool,
   230  		readerIteratorPool:      encoding.NewReaderIteratorPool(poolOpts),
   231  		multiReaderIteratorPool: encoding.NewMultiReaderIteratorPool(poolOpts),
   232  		identifierPool: ident.NewPool(bytesPool, ident.PoolOptions{
   233  			IDPoolOptions:           poolOpts,
   234  			TagsPoolOptions:         poolOpts,
   235  			TagsIteratorPoolOptions: poolOpts,
   236  		}),
   237  		fetchBlockMetadataResultsPool:   block.NewFetchBlockMetadataResultsPool(poolOpts, 0),
   238  		fetchBlocksMetadataResultsPool:  block.NewFetchBlocksMetadataResultsPool(poolOpts, 0),
   239  		writeBatchPool:                  writeBatchPool,
   240  		bufferBucketVersionsPool:        series.NewBufferBucketVersionsPool(poolOpts),
   241  		bufferBucketPool:                series.NewBufferBucketPool(poolOpts),
   242  		retrieveRequestPool:             retrieveRequestPool,
   243  		checkedBytesWrapperPool:         bytesWrapperPool,
   244  		schemaReg:                       namespace.NewSchemaRegistry(false, nil),
   245  		onColdFlush:                     &noOpColdFlush{},
   246  		memoryTracker:                   NewMemoryTracker(NewMemoryTrackerOptions(defaultNumLoadedBytesLimit)),
   247  		namespaceRuntimeOptsMgrRegistry: namespace.NewRuntimeOptionsManagerRegistry(),
   248  		mediatorTickInterval:            defaultMediatorTickInterval,
   249  		namespaceHooks:                  &noopNamespaceHooks{},
   250  		tileAggregator:                  &noopTileAggregator{},
   251  		permitsOptions:                  permits.NewOptions(),
   252  		limitsOptions:                   limits.DefaultLimitsOptions(iOpts),
   253  		coreFn:                          xsync.CPUCore,
   254  	}
   255  	return o.SetEncodingM3TSZPooled()
   256  }
   257  
   258  func (o *options) Validate() error {
   259  	// validate namespace registry
   260  	init := o.NamespaceInitializer()
   261  	if init == nil {
   262  		return errNamespaceInitializerNotSet
   263  	}
   264  
   265  	// validate commit log options
   266  	clOpts := o.CommitLogOptions()
   267  	if err := clOpts.Validate(); err != nil {
   268  		return fmt.Errorf("unable to validate commit log options: %v", err)
   269  	}
   270  
   271  	// validate repair options
   272  	if o.RepairEnabled() {
   273  		rOpts := o.RepairOptions()
   274  		if rOpts == nil {
   275  			return errRepairOptionsNotSet
   276  		}
   277  		if err := rOpts.Validate(); err != nil {
   278  			return fmt.Errorf("unable to validate repair options, err: %v", err)
   279  		}
   280  	}
   281  
   282  	// validate indexing options
   283  	iOpts := o.IndexOptions()
   284  	if iOpts == nil {
   285  		return errIndexOptionsNotSet
   286  	}
   287  	if err := iOpts.Validate(); err != nil {
   288  		return fmt.Errorf("unable to validate index options, err: %v", err)
   289  	}
   290  
   291  	// validate that persist manager is present, if not return
   292  	// error if error occurred during default creation otherwise
   293  	// it was set to nil by a caller
   294  	if o.persistManager == nil {
   295  		return errPersistManagerNotSet
   296  	}
   297  
   298  	// validate that index claims manager is present
   299  	if o.indexClaimsManager == nil {
   300  		return errIndexClaimsManagerNotSet
   301  	}
   302  
   303  	// validate series cache policy
   304  	if err := series.ValidateCachePolicy(o.seriesCachePolicy); err != nil {
   305  		return err
   306  	}
   307  
   308  	if o.blockLeaseManager == nil {
   309  		return errBlockLeaserNotSet
   310  	}
   311  
   312  	if o.onColdFlush == nil {
   313  		return errOnColdFlushNotSet
   314  	}
   315  
   316  	if o.limitsOptions == nil {
   317  		return errLimitsOptionsNotSet
   318  	}
   319  
   320  	return nil
   321  }
   322  
   323  func (o *options) SetClockOptions(value clock.Options) Options {
   324  	opts := *o
   325  	opts.clockOpts = value
   326  	opts.blockOpts = opts.blockOpts.SetClockOptions(value)
   327  	opts.commitLogOpts = opts.commitLogOpts.SetClockOptions(value)
   328  	opts.indexOpts = opts.indexOpts.SetClockOptions(value)
   329  	opts.seriesOpts = NewSeriesOptionsFromOptions(&opts, nil)
   330  	return &opts
   331  }
   332  
   333  func (o *options) ClockOptions() clock.Options {
   334  	return o.clockOpts
   335  }
   336  
   337  func (o *options) SetInstrumentOptions(value instrument.Options) Options {
   338  	opts := *o
   339  	opts.instrumentOpts = value
   340  	opts.commitLogOpts = opts.commitLogOpts.SetInstrumentOptions(value)
   341  	opts.indexOpts = opts.indexOpts.SetInstrumentOptions(value)
   342  	opts.seriesOpts = NewSeriesOptionsFromOptions(&opts, nil)
   343  	return &opts
   344  }
   345  
   346  func (o *options) InstrumentOptions() instrument.Options {
   347  	return o.instrumentOpts
   348  }
   349  
   350  func (o *options) SetNamespaceInitializer(value namespace.Initializer) Options {
   351  	opts := *o
   352  	opts.nsRegistryInitializer = value
   353  	return &opts
   354  }
   355  
   356  func (o *options) NamespaceInitializer() namespace.Initializer {
   357  	return o.nsRegistryInitializer
   358  }
   359  
   360  func (o *options) SetDatabaseBlockOptions(value block.Options) Options {
   361  	opts := *o
   362  	opts.blockOpts = value
   363  	opts.seriesOpts = NewSeriesOptionsFromOptions(&opts, nil)
   364  	return &opts
   365  }
   366  
   367  func (o *options) DatabaseBlockOptions() block.Options {
   368  	return o.blockOpts
   369  }
   370  
   371  func (o *options) SetCommitLogOptions(value commitlog.Options) Options {
   372  	opts := *o
   373  	opts.commitLogOpts = value
   374  	return &opts
   375  }
   376  
   377  func (o *options) CommitLogOptions() commitlog.Options {
   378  	return o.commitLogOpts
   379  }
   380  
   381  func (o *options) SetRuntimeOptionsManager(value m3dbruntime.OptionsManager) Options {
   382  	opts := *o
   383  	opts.runtimeOptsMgr = value
   384  	return &opts
   385  }
   386  
   387  func (o *options) RuntimeOptionsManager() m3dbruntime.OptionsManager {
   388  	return o.runtimeOptsMgr
   389  }
   390  
   391  func (o *options) SetErrorWindowForLoad(value time.Duration) Options {
   392  	opts := *o
   393  	opts.errWindowForLoad = value
   394  	return &opts
   395  }
   396  
   397  func (o *options) ErrorWindowForLoad() time.Duration {
   398  	return o.errWindowForLoad
   399  }
   400  
   401  func (o *options) SetErrorThresholdForLoad(value int64) Options {
   402  	opts := *o
   403  	opts.errThresholdForLoad = value
   404  	return &opts
   405  }
   406  
   407  func (o *options) ErrorThresholdForLoad() int64 {
   408  	return o.errThresholdForLoad
   409  }
   410  
   411  func (o *options) SetIndexOptions(value index.Options) Options {
   412  	opts := *o
   413  	opts.indexOpts = value
   414  	return &opts
   415  }
   416  
   417  func (o *options) IndexOptions() index.Options {
   418  	return o.indexOpts
   419  }
   420  
   421  func (o *options) SetRepairEnabled(b bool) Options {
   422  	opts := *o
   423  	opts.repairEnabled = b
   424  	return &opts
   425  }
   426  
   427  func (o *options) RepairEnabled() bool {
   428  	return o.repairEnabled
   429  }
   430  
   431  func (o *options) SetTruncateType(value series.TruncateType) Options {
   432  	opts := *o
   433  	opts.truncateType = value
   434  	return &opts
   435  }
   436  
   437  func (o *options) TruncateType() series.TruncateType {
   438  	return o.truncateType
   439  }
   440  
   441  func (o *options) SetWriteTransformOptions(
   442  	value series.WriteTransformOptions,
   443  ) Options {
   444  	opts := *o
   445  	opts.transformOptions = value
   446  	return &opts
   447  }
   448  
   449  func (o *options) WriteTransformOptions() series.WriteTransformOptions {
   450  	return o.transformOptions
   451  }
   452  
   453  func (o *options) SetRepairOptions(value repair.Options) Options {
   454  	opts := *o
   455  	opts.repairOpts = value
   456  	return &opts
   457  }
   458  
   459  func (o *options) RepairOptions() repair.Options {
   460  	return o.repairOpts
   461  }
   462  
   463  func (o *options) SetEncodingM3TSZPooled() Options {
   464  	opts := *o
   465  
   466  	buckets := []pool.Bucket{{
   467  		Capacity: defaultBytesPoolBucketCapacity,
   468  		Count:    defaultBytesPoolBucketCount,
   469  	}}
   470  	newBackingBytesPool := func(s []pool.Bucket) pool.BytesPool {
   471  		return pool.NewBytesPool(s, opts.poolOpts)
   472  	}
   473  	bytesPool := pool.NewCheckedBytesPool(buckets, o.poolOpts, newBackingBytesPool)
   474  	bytesPool.Init()
   475  	opts.bytesPool = bytesPool
   476  
   477  	// initialize context pool
   478  	opts.contextPool = context.NewPool(context.NewOptions().
   479  		SetContextPoolOptions(opts.poolOpts).
   480  		SetFinalizerPoolOptions(opts.poolOpts))
   481  
   482  	encoderPool := encoding.NewEncoderPool(opts.poolOpts)
   483  	readerIteratorPool := encoding.NewReaderIteratorPool(opts.poolOpts)
   484  
   485  	// initialize segment reader pool
   486  	segmentReaderPool := xio.NewSegmentReaderPool(opts.poolOpts)
   487  	segmentReaderPool.Init()
   488  	opts.segmentReaderPool = segmentReaderPool
   489  
   490  	encodingOpts := encoding.NewOptions().
   491  		SetBytesPool(bytesPool).
   492  		SetEncoderPool(encoderPool).
   493  		SetReaderIteratorPool(readerIteratorPool).
   494  		SetSegmentReaderPool(segmentReaderPool).
   495  		SetMetrics(encoding.NewMetrics(opts.InstrumentOptions().MetricsScope()))
   496  
   497  	// initialize encoder pool
   498  	encoderPool.Init(func() encoding.Encoder {
   499  		return m3tsz.NewEncoder(0, nil, m3tsz.DefaultIntOptimizationEnabled, encodingOpts)
   500  	})
   501  	opts.encoderPool = encoderPool
   502  
   503  	// initialize single reader iterator pool
   504  	readerIteratorPool.Init(m3tsz.DefaultReaderIteratorAllocFn(encodingOpts))
   505  	opts.readerIteratorPool = readerIteratorPool
   506  
   507  	// initialize multi reader iterator pool
   508  	multiReaderIteratorPool := encoding.NewMultiReaderIteratorPool(opts.poolOpts)
   509  	multiReaderIteratorPool.Init(m3tsz.DefaultReaderIteratorAllocFn(encodingOpts))
   510  	opts.multiReaderIteratorPool = multiReaderIteratorPool
   511  
   512  	opts.blockOpts = opts.blockOpts.
   513  		SetEncoderPool(encoderPool).
   514  		SetReaderIteratorPool(readerIteratorPool).
   515  		SetMultiReaderIteratorPool(multiReaderIteratorPool).
   516  		SetBytesPool(bytesPool)
   517  
   518  	opts.seriesOpts = NewSeriesOptionsFromOptions(&opts, nil)
   519  	return &opts
   520  }
   521  
   522  func (o *options) SetNewEncoderFn(value encoding.NewEncoderFn) Options {
   523  	opts := *o
   524  	opts.newEncoderFn = value
   525  	return &opts
   526  }
   527  
   528  func (o *options) NewEncoderFn() encoding.NewEncoderFn {
   529  	return o.newEncoderFn
   530  }
   531  
   532  func (o *options) SetNewDecoderFn(value encoding.NewDecoderFn) Options {
   533  	opts := *o
   534  	opts.newDecoderFn = value
   535  	return &opts
   536  }
   537  
   538  func (o *options) NewDecoderFn() encoding.NewDecoderFn {
   539  	return o.newDecoderFn
   540  }
   541  
   542  func (o *options) SetBootstrapProcessProvider(value bootstrap.ProcessProvider) Options {
   543  	opts := *o
   544  	opts.bootstrapProcessProvider = value
   545  	return &opts
   546  }
   547  
   548  func (o *options) BootstrapProcessProvider() bootstrap.ProcessProvider {
   549  	return o.bootstrapProcessProvider
   550  }
   551  
   552  func (o *options) SetPersistManager(value persist.Manager) Options {
   553  	opts := *o
   554  	opts.persistManager = value
   555  	return &opts
   556  }
   557  
   558  func (o *options) PersistManager() persist.Manager {
   559  	return o.persistManager
   560  }
   561  
   562  func (o *options) SetIndexClaimsManager(value fs.IndexClaimsManager) Options {
   563  	opts := *o
   564  	opts.indexClaimsManager = value
   565  	return &opts
   566  }
   567  
   568  func (o *options) IndexClaimsManager() fs.IndexClaimsManager {
   569  	return o.indexClaimsManager
   570  }
   571  
   572  func (o *options) SetDatabaseBlockRetrieverManager(value block.DatabaseBlockRetrieverManager) Options {
   573  	opts := *o
   574  	opts.blockRetrieverManager = value
   575  	return &opts
   576  }
   577  
   578  func (o *options) DatabaseBlockRetrieverManager() block.DatabaseBlockRetrieverManager {
   579  	return o.blockRetrieverManager
   580  }
   581  
   582  func (o *options) SetContextPool(value context.Pool) Options {
   583  	opts := *o
   584  	opts.contextPool = value
   585  	return &opts
   586  }
   587  
   588  func (o *options) ContextPool() context.Pool {
   589  	return o.contextPool
   590  }
   591  
   592  func (o *options) SetSeriesCachePolicy(value series.CachePolicy) Options {
   593  	opts := *o
   594  	opts.seriesCachePolicy = value
   595  	return &opts
   596  }
   597  
   598  func (o *options) SeriesCachePolicy() series.CachePolicy {
   599  	return o.seriesCachePolicy
   600  }
   601  
   602  func (o *options) SetSeriesOptions(value series.Options) Options {
   603  	opts := *o
   604  	opts.seriesOpts = value
   605  	return &opts
   606  }
   607  
   608  func (o *options) SeriesOptions() series.Options {
   609  	return o.seriesOpts
   610  }
   611  
   612  func (o *options) SetDatabaseSeriesPool(value series.DatabaseSeriesPool) Options {
   613  	opts := *o
   614  	opts.seriesPool = value
   615  	return &opts
   616  }
   617  
   618  func (o *options) DatabaseSeriesPool() series.DatabaseSeriesPool {
   619  	return o.seriesPool
   620  }
   621  
   622  func (o *options) SetBytesPool(value pool.CheckedBytesPool) Options {
   623  	opts := *o
   624  	opts.bytesPool = value
   625  	return &opts
   626  }
   627  
   628  func (o *options) BytesPool() pool.CheckedBytesPool {
   629  	return o.bytesPool
   630  }
   631  
   632  func (o *options) SetEncoderPool(value encoding.EncoderPool) Options {
   633  	opts := *o
   634  	opts.encoderPool = value
   635  	return &opts
   636  }
   637  
   638  func (o *options) EncoderPool() encoding.EncoderPool {
   639  	return o.encoderPool
   640  }
   641  
   642  func (o *options) SetSegmentReaderPool(value xio.SegmentReaderPool) Options {
   643  	opts := *o
   644  	opts.segmentReaderPool = value
   645  	return &opts
   646  }
   647  
   648  func (o *options) SegmentReaderPool() xio.SegmentReaderPool {
   649  	return o.segmentReaderPool
   650  }
   651  
   652  func (o *options) SetReaderIteratorPool(value encoding.ReaderIteratorPool) Options {
   653  	opts := *o
   654  	opts.readerIteratorPool = value
   655  	return &opts
   656  }
   657  
   658  func (o *options) ReaderIteratorPool() encoding.ReaderIteratorPool {
   659  	return o.readerIteratorPool
   660  }
   661  
   662  func (o *options) SetMultiReaderIteratorPool(value encoding.MultiReaderIteratorPool) Options {
   663  	opts := *o
   664  	opts.multiReaderIteratorPool = value
   665  	return &opts
   666  }
   667  
   668  func (o *options) MultiReaderIteratorPool() encoding.MultiReaderIteratorPool {
   669  	return o.multiReaderIteratorPool
   670  }
   671  
   672  func (o *options) SetIdentifierPool(value ident.Pool) Options {
   673  	opts := *o
   674  	opts.indexOpts = opts.indexOpts.SetIdentifierPool(value)
   675  	opts.identifierPool = value
   676  	return &opts
   677  }
   678  
   679  func (o *options) IdentifierPool() ident.Pool {
   680  	return o.identifierPool
   681  }
   682  
   683  func (o *options) SetFetchBlockMetadataResultsPool(value block.FetchBlockMetadataResultsPool) Options {
   684  	opts := *o
   685  	opts.fetchBlockMetadataResultsPool = value
   686  	return &opts
   687  }
   688  
   689  func (o *options) FetchBlockMetadataResultsPool() block.FetchBlockMetadataResultsPool {
   690  	return o.fetchBlockMetadataResultsPool
   691  }
   692  
   693  func (o *options) SetFetchBlocksMetadataResultsPool(value block.FetchBlocksMetadataResultsPool) Options {
   694  	opts := *o
   695  	opts.fetchBlocksMetadataResultsPool = value
   696  	return &opts
   697  }
   698  
   699  func (o *options) FetchBlocksMetadataResultsPool() block.FetchBlocksMetadataResultsPool {
   700  	return o.fetchBlocksMetadataResultsPool
   701  }
   702  
   703  func (o *options) SetWriteBatchPool(value *writes.WriteBatchPool) Options {
   704  	opts := *o
   705  	opts.writeBatchPool = value
   706  	return &opts
   707  }
   708  
   709  func (o *options) WriteBatchPool() *writes.WriteBatchPool {
   710  	return o.writeBatchPool
   711  }
   712  
   713  func (o *options) SetBufferBucketPool(value *series.BufferBucketPool) Options {
   714  	opts := *o
   715  	opts.bufferBucketPool = value
   716  	return &opts
   717  }
   718  
   719  func (o *options) BufferBucketPool() *series.BufferBucketPool {
   720  	return o.bufferBucketPool
   721  }
   722  
   723  func (o *options) SetBufferBucketVersionsPool(value *series.BufferBucketVersionsPool) Options {
   724  	opts := *o
   725  	opts.bufferBucketVersionsPool = value
   726  	return &opts
   727  }
   728  
   729  func (o *options) BufferBucketVersionsPool() *series.BufferBucketVersionsPool {
   730  	return o.bufferBucketVersionsPool
   731  }
   732  
   733  func (o *options) SetRetrieveRequestPool(value fs.RetrieveRequestPool) Options {
   734  	opts := *o
   735  	opts.retrieveRequestPool = value
   736  	return &opts
   737  }
   738  
   739  func (o *options) RetrieveRequestPool() fs.RetrieveRequestPool {
   740  	return o.retrieveRequestPool
   741  }
   742  
   743  func (o *options) SetCheckedBytesWrapperPool(value xpool.CheckedBytesWrapperPool) Options {
   744  	opts := *o
   745  	opts.checkedBytesWrapperPool = value
   746  	return &opts
   747  }
   748  
   749  func (o *options) CheckedBytesWrapperPool() xpool.CheckedBytesWrapperPool {
   750  	return o.checkedBytesWrapperPool
   751  }
   752  
   753  func (o *options) SetSchemaRegistry(registry namespace.SchemaRegistry) Options {
   754  	opts := *o
   755  	opts.schemaReg = registry
   756  	return &opts
   757  }
   758  
   759  func (o *options) SchemaRegistry() namespace.SchemaRegistry {
   760  	return o.schemaReg
   761  }
   762  
   763  func (o *options) SetBlockLeaseManager(leaseMgr block.LeaseManager) Options {
   764  	opts := *o
   765  	opts.blockLeaseManager = leaseMgr
   766  	return &opts
   767  }
   768  
   769  func (o *options) BlockLeaseManager() block.LeaseManager {
   770  	return o.blockLeaseManager
   771  }
   772  
   773  func (o *options) SetOnColdFlush(value OnColdFlush) Options {
   774  	opts := *o
   775  	opts.onColdFlush = value
   776  	return &opts
   777  }
   778  
   779  func (o *options) OnColdFlush() OnColdFlush {
   780  	return o.onColdFlush
   781  }
   782  
   783  func (o *options) SetForceColdWritesEnabled(value bool) Options {
   784  	opts := *o
   785  	opts.forceColdWritesEnabled = value
   786  	return &opts
   787  }
   788  
   789  func (o *options) ForceColdWritesEnabled() bool {
   790  	return o.forceColdWritesEnabled
   791  }
   792  
   793  func (o *options) SetSourceLoggerBuilder(value limits.SourceLoggerBuilder) Options {
   794  	opts := *o
   795  	opts.sourceLoggerBuilder = value
   796  	return &opts
   797  }
   798  
   799  func (o *options) SourceLoggerBuilder() limits.SourceLoggerBuilder {
   800  	return o.sourceLoggerBuilder
   801  }
   802  
   803  func (o *options) SetIterationOptions(value index.IterationOptions) Options {
   804  	opts := *o
   805  	opts.iterationOptions = value
   806  	return &opts
   807  }
   808  
   809  func (o *options) IterationOptions() index.IterationOptions {
   810  	return o.iterationOptions
   811  }
   812  
   813  func (o *options) SetMemoryTracker(memTracker MemoryTracker) Options {
   814  	opts := *o
   815  	opts.memoryTracker = memTracker
   816  	return &opts
   817  }
   818  
   819  func (o *options) MemoryTracker() MemoryTracker {
   820  	return o.memoryTracker
   821  }
   822  
   823  func (o *options) SetMmapReporter(mmapReporter mmap.Reporter) Options {
   824  	opts := *o
   825  	opts.mmapReporter = mmapReporter
   826  	return &opts
   827  }
   828  
   829  func (o *options) MmapReporter() mmap.Reporter {
   830  	return o.mmapReporter
   831  }
   832  
   833  func (o *options) SetDoNotIndexWithFieldsMap(value map[string]string) Options {
   834  	opts := *o
   835  	opts.doNotIndexWithFieldsMap = value
   836  	return &opts
   837  }
   838  
   839  func (o *options) DoNotIndexWithFieldsMap() map[string]string {
   840  	return o.doNotIndexWithFieldsMap
   841  }
   842  
   843  func (o *options) SetNamespaceRuntimeOptionsManagerRegistry(
   844  	value namespace.RuntimeOptionsManagerRegistry,
   845  ) Options {
   846  	opts := *o
   847  	opts.namespaceRuntimeOptsMgrRegistry = value
   848  	return &opts
   849  }
   850  
   851  func (o *options) NamespaceRuntimeOptionsManagerRegistry() namespace.RuntimeOptionsManagerRegistry {
   852  	return o.namespaceRuntimeOptsMgrRegistry
   853  }
   854  
   855  func (o *options) SetMediatorTickInterval(value time.Duration) Options {
   856  	opts := *o
   857  	opts.mediatorTickInterval = value
   858  	return &opts
   859  }
   860  
   861  func (o *options) MediatorTickInterval() time.Duration {
   862  	return o.mediatorTickInterval
   863  }
   864  
   865  func (o *options) SetAdminClient(value client.AdminClient) Options {
   866  	opts := *o
   867  	opts.adminClient = value
   868  	return &opts
   869  }
   870  
   871  func (o *options) AdminClient() client.AdminClient {
   872  	return o.adminClient
   873  }
   874  
   875  func (o *options) SetBackgroundProcessFns(fns []NewBackgroundProcessFn) Options {
   876  	opts := *o
   877  	opts.newBackgroundProcessFns = fns
   878  	return &opts
   879  }
   880  
   881  func (o *options) BackgroundProcessFns() []NewBackgroundProcessFn {
   882  	return o.newBackgroundProcessFns
   883  }
   884  
   885  func (o *options) SetNamespaceHooks(value NamespaceHooks) Options {
   886  	opts := *o
   887  	opts.namespaceHooks = value
   888  	return &opts
   889  }
   890  
   891  func (o *options) NamespaceHooks() NamespaceHooks {
   892  	return o.namespaceHooks
   893  }
   894  
   895  func (o *options) SetTileAggregator(value TileAggregator) Options {
   896  	opts := *o
   897  	opts.tileAggregator = value
   898  
   899  	return &opts
   900  }
   901  
   902  func (o *options) PermitsOptions() permits.Options {
   903  	return o.permitsOptions
   904  }
   905  
   906  func (o *options) SetPermitsOptions(value permits.Options) Options {
   907  	opts := *o
   908  	opts.permitsOptions = value
   909  
   910  	return &opts
   911  }
   912  
   913  func (o *options) LimitsOptions() limits.Options {
   914  	return o.limitsOptions
   915  }
   916  
   917  func (o *options) SetLimitsOptions(value limits.Options) Options {
   918  	opts := *o
   919  	opts.limitsOptions = value
   920  	return &opts
   921  }
   922  
   923  func (o *options) TileAggregator() TileAggregator {
   924  	return o.tileAggregator
   925  }
   926  
   927  func (o *options) CoreFn() xsync.CoreFn {
   928  	return o.coreFn
   929  }
   930  
   931  func (o *options) SetCoreFn(value xsync.CoreFn) Options {
   932  	opts := *o
   933  	opts.coreFn = value
   934  	return &opts
   935  }
   936  
   937  type noOpColdFlush struct{}
   938  
   939  func (n *noOpColdFlush) ColdFlushNamespace(Namespace, ColdFlushNsOpts) (OnColdFlushNamespace, error) {
   940  	return &persist.NoOpColdFlushNamespace{}, nil
   941  }
   942  
   943  type noopNamespaceHooks struct{}
   944  
   945  func (h *noopNamespaceHooks) OnCreatedNamespace(Namespace, GetNamespaceFn) error {
   946  	return nil
   947  }
   948  
   949  type noopTileAggregator struct{}
   950  
   951  func (a *noopTileAggregator) AggregateTiles(
   952  	ctx context.Context,
   953  	sourceNs, targetNs Namespace,
   954  	shardID uint32,
   955  	onFlushSeries persist.OnFlushSeries,
   956  	opts AggregateTilesOptions,
   957  ) (int64, int, error) {
   958  	return 0, 0, nil
   959  }