Class BaseDriverAdapter<RESULT extends CycleOp<?>,SPACE extends Space>

  • Constructor Details

  • Method Details

    • getPreprocessor

      public final Function<Map<String,Object>,Map<String,Object>> getPreprocessor()
      BaseDriverAdapter will take any provided functions from getOpStmtRemappers() and getOpFieldRemappers() and construct a preprocessor list. These are applied successively to the op template fields so long as remapping occurs.
      Specified by:
      getPreprocessor in interface DriverAdapter<RESULT extends CycleOp<?>,SPACE extends Space>
      Returns:
      a list of preprocessors for op template fields
    • getOpStmtRemappers

      public List<Function<String,Optional<Map<String,Object>>>> getOpStmtRemappers()

      Provide a list of field remappers which operate exclusively on the 'stmt' field in the op template. These are useful, for example, for taking the 'stmt' field and parsing it into component fields which might otherwise be specified by the user. This allows users to specify String-form op templates which are automatically parsed and destructured into the canonical field-wise form for a given type of operation.


      Each function in this list is applied in order. If the function returns a value, then the 'stmt' field is removed and the resulting map is added to the other fields in the op template.


      If a driver adapter is meant to support the stmt field, then this must be provided. The use of the stmt field should be documented in the driver adapter user docs with examples for any supported formats. A default implementation does nothing, as it must be decided per-driver whether or not the stmt field will be used directly or whether it is short-hand for a more canonical form.


      If you want to automatically destructure stmt values into a map and inject its entries into the op template fields, simply provide an implementation like this:

       
           return List.of(stmt -> Optional.of(NBParams.one(stmt).getMap()));
       
       

      Returns:
      A list of optionally applied remapping functions.
    • getOpFieldRemappers

      public List<Function<Map<String,Object>,Map<String,Object>>> getOpFieldRemappers()

      Provide a list of field remappers which operate on arbitrary fields. Each function is applied to the op template fields.

      Specified by:
      getOpFieldRemappers in interface DriverAdapter<RESULT extends CycleOp<?>,SPACE extends Space>
      Returns:
      op field remappers, an empty list by default
    • getConfiguration

      public NBConfiguration getConfiguration()
      Description copied from interface: DriverAdapter
      Provides the configuration for this driver adapter, which comes from the superset of activity parameters given for the owning activity. Presently, the driver adapter acts as a proxy to set these parameters on the space, but this will likely be updated. Instead, the configuratin will be properly attached to the space directly, and the APIs supporting it will enforce this.
      Specified by:
      getConfiguration in interface DriverAdapter<RESULT extends CycleOp<?>,SPACE extends Space>
    • applyConfig

      public void applyConfig(NBConfiguration cfg)
      Description copied from interface: NBConfigurable
      Implementors should take care to ensure that this can be called after initial construction without unexpected interactions between construction parameters and configuration parameters.
      Specified by:
      applyConfig in interface NBCanConfigure
      Specified by:
      applyConfig in interface NBConfigurable
      Parameters:
      cfg - The configuration data to be applied to a new instance
    • applyReconfig

      public void applyReconfig(NBConfiguration reconf)
      Description copied from interface: NBReconfigurable
      This applies a configuration to an element AFTER the initial configuration from NBConfigurable.
      Specified by:
      applyReconfig in interface NBCanReconfigure
      Specified by:
      applyReconfig in interface NBReconfigurable
      Parameters:
      reconf - The configuration data to be applied to a new instance
    • getConfigModel

      public NBConfigModel getConfigModel()
      In order to be provided with config information, it is required that the driver adapter specify the valid configuration options, their types, and so on.
      Specified by:
      getConfigModel in interface NBConfigModelProvider
      Specified by:
      getConfigModel in interface NBConfigurable
      Returns:
      A valid configuration model for the implementing class
    • getReconfigModel

      public NBConfigModel getReconfigModel()
      Description copied from interface: NBReconfigurable
      Implement this method by returning an instance of ConfigModel. Any configuration which is provided to the NBReconfigurable.applyReconfig(NBConfiguration) method will be validated through this model. A configuration model is required in order to build a validated configuration from source data provided by a user.
      Specified by:
      getReconfigModel in interface NBReconfigModelProvider
      Specified by:
      getReconfigModel in interface NBReconfigurable
      Returns:
      A valid configuration model for the implementing class
    • getSpaceFunc

      public LongFunction<SPACE> getSpaceFunc(ParsedOp pop)
      Description copied from interface: DriverAdapter

      The function returned by DriverAdapter.getSpaceFunc(ParsedOp) provides access to a cache of all stateful objects needed within a single instance of a DriverAdapter. These are generally things needed by operations, or things needed during the construction of operations. Typically, a space is where you store a native driver instance which is expected to be created/initialized once and reused within an application. Generally, users can think of space as driver instance, or client instance, although there are driver adapters that do things other than wrap native drivers and clients.

      The value of the op field space is used to customize the instancing behavior of spaces. If none is provided by the user, then only a singular space will be created for a given adapter in an activity. This is normal, and what most users will expect to do. However, customizing the space selector can be a powerful way to test any system with high logical concurrency. For example, each instance of a native driver will typically maintain its own thread or connection pools, cached resources and so on. ( Unless the developers of said native driver are breaking encapsulation by using global singletons in the runtime, which is highly frowned upon.) The spaces feature allows any nosqlbench workload to be easily converted into an unreasonably parallel client topology test with a single change. It works the same way for any adapter or protocol supported by nosqlbench.

      The value of the op field space should be a Number type. Number.intValue() is used to determine which space instance is, if needed, initialized first, and then returned. If users provide a non-Number type, then an enumerating layer is added inline to convert any such value to an integer, which is less optimal.

      During op mapping or dispensing, you may need access to state held by a driver-specific implementation of DriverAdapter. In the initialization phase, you only have access to the space function itself. This is important to maintain a boundary betwen the explicitly stateless and stateful parts of the runtime. To use the space, incorporate the space function into the lambdas which produce the operation to be executed. This is typically done in the construtor of the related OpDispenser.

      Specified by:
      getSpaceFunc in interface DriverAdapter<RESULT extends CycleOp<?>,SPACE extends Space>
      Returns:
      A cache of named objects
    • beforeDetach

      public void beforeDetach()
      Specified by:
      beforeDetach in interface NBComponent
      Overrides:
      beforeDetach in class NBBaseComponent