Skip to content

[3.5 M3] Clearable Object Store

Mariano Gonzalez edited this page Sep 9, 2013 · 3 revisions

Motivation / Context

There're use cases for components that make intensive use of ObjectStore. We need a way to cleanly and quickly delete all the entries in that store so that its allocated resources can be reclaimed.

The ObjectStoreManager interface already has a dispose() method, but its implementation does not fit the requirements because:

  • It's tightly coupled to the ObjectStore implementation
  • Because it's tightly coupled, the ObjectStore is forced to expose details about its implementation
  • It works using each particular implementation's API. So, for example, if the ObjectStore is a Listable one, the remove method will be invoked for each key. This is highly inefficient.
  • Only partitionable and listable Object Stores are supported. This method does not work for any other kind of Object Store
  • Finally, this method also invokes the dispose() method on the ObjectStore (if available), which is not necessarily what you want/need when you're simply asking to delete all items

Design

Add a clear() method to the ObjectStore interface. The contract exposed by this method would imply that:

  • Items should be cleared in the fastest way possible.
  • If the store implementation is thread safe, then this method should be also. If the implementation is not thread safe, then no assumptions should be done on this method
  • the store should still be usable after performing a clear. This is not a close() nor a dispose()

Behavior

  • In case of persistent object store, the actual files backing the content will be deleted
  • In case of transient object stores, the reference to the items will be severed.
  • ObjectStoreManager's dispose() method should first delegate into the store's clear method and then dispose() it if necessary.

Migration Impact

  • All the OS implementations that ship with Mule will be updated by our dev team, but any extension shipping with a custom implementation of OS will need to addd support for this feature.
  • The object store module extension will need to add support for this feature.
  • CloudHub will have to add support for this feature.

Documentation impact

Right now the ObjectStore documentation does not include information about its contract, so no impact initially but docs around stores should be improved.