org.terracotta.toolkit.builder
Class ToolkitStoreConfigBuilder

java.lang.Object
  extended by org.terracotta.toolkit.builder.ToolkitStoreConfigBuilder

public final class ToolkitStoreConfigBuilder
extends Object

A helper to build a Configuration for ToolkitStore. Builds up configuration based on ToolkitConfigFields


Constructor Summary
ToolkitStoreConfigBuilder()
           
 
Method Summary
protected  void addFieldToApply(String name, Serializable value)
           
 void apply(ToolkitCache cache)
          Apply changes of this builder to the ToolkitStore parameter.
 void apply(ToolkitStore store)
          Apply changes of this builder to the ToolkitStore parameter.
 Configuration build()
          Builds a Configuration for ToolkitStore by filling in appropriate mappings.
 ToolkitStoreConfigBuilder compressionEnabled(boolean compressionEnabledParam)
          Sets compression enabled
 ToolkitStoreConfigBuilder concurrency(int concurrencyParam)
          Sets the concurrency config to the new value and returns this
 ToolkitStoreConfigBuilder configField(String fieldName, Serializable value)
           
 ToolkitStoreConfigBuilder consistency(ToolkitConfigFields.Consistency consistencyParam)
          Sets the ToolkitConfigFields.Consistency of the key-value store
 ToolkitStoreConfigBuilder copyOnReadEnabled(boolean copyOnReadEnabledParam)
          Sets copy on read enabled
 int getConcurrency()
          Concurrency of the store
 ToolkitConfigFields.Consistency getConsistency()
          Getter for consistency
 long getMaxBytesLocalHeap()
          Gets the max bytes local heap
 long getMaxBytesLocalOffheap()
          Gets the max bytes local offheap
 long getMaxCountLocalHeap()
          Gets the max count local heap
 boolean isCompressionEnabled()
          Compression enabled or not getter
 boolean isCopyOnReadEnabled()
          copy-on-read enabled or not getter
 boolean isLocalCacheEnabled()
          Query whether local cache is enabled or not
 boolean isOffheapEnabled()
          Returns true if offheap is enabled
 boolean isPinnedInLocalMemory()
           
 ToolkitStoreConfigBuilder localCacheEnabled(boolean localCacheEnabledParam)
          Sets local cache enabled
 ToolkitStoreConfigBuilder maxBytesLocalHeap(long maxBytesLocalHeapParam)
          Sets the maxBytesLocalHeap
 ToolkitStoreConfigBuilder maxBytesLocalOffheap(long maxBytesLocalOffheapParam)
          Sets the max bytes local offheap
 ToolkitStoreConfigBuilder maxCountLocalHeap(int maxCountLocalHeapParam)
          Sets the max count local heap
 ToolkitStoreConfigBuilder offheapEnabled(boolean offheapEnabledParam)
          Sets offheap enabled
 ToolkitStoreConfigBuilder pinnedInLocalMemory(boolean pinnedInLocalMemory)
          Sets whether entries should be pinned in local memory
protected  void setCompressionEnabled(boolean compressionEnabledParam)
          Sets compression enabled
protected  void setConcurrency(int concurrencyParam)
           
protected  void setConfigField(String fieldName, Serializable value)
           
protected  void setConsistency(ToolkitConfigFields.Consistency consistencyParam)
          Sets the ToolkitConfigFields.Consistency of the key-value store
protected  void setCopyOnReadEnabled(boolean copyOnReadEnabledParam)
          Sets copy on read enabled
protected  void setLocalCacheEnabled(boolean localCacheEnabledParam)
          Sets local cache enabled
protected  void setMaxBytesLocalHeap(long maxBytesLocalHeapParam)
          Sets the maxBytesLocalHeap
protected  void setMaxBytesLocalOffheap(long maxBytesLocalOffheapParam)
          Sets the max bytes local offheap
protected  void setMaxCountLocalHeap(int maxCountLocalHeapParam)
          Sets the max count local heap
protected  void setOffheapEnabled(boolean offheapEnabledParam)
          Sets offheap enabled
 void setPinnedInLocalMemory(boolean pinnedInLocalMemory)
          Sets whether entries should be pinned in local memory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ToolkitStoreConfigBuilder

public ToolkitStoreConfigBuilder()
Method Detail

concurrency

public ToolkitStoreConfigBuilder concurrency(int concurrencyParam)
                                      throws IllegalArgumentException
Sets the concurrency config to the new value and returns this

Returns:
same instance
Throws:
IllegalArgumentException - for non-positive concurrency params

consistency

public ToolkitStoreConfigBuilder consistency(ToolkitConfigFields.Consistency consistencyParam)
Sets the ToolkitConfigFields.Consistency of the key-value store

Returns:
same instance

pinnedInLocalMemory

public ToolkitStoreConfigBuilder pinnedInLocalMemory(boolean pinnedInLocalMemory)
Sets whether entries should be pinned in local memory

Returns:
same instance

maxBytesLocalHeap

public ToolkitStoreConfigBuilder maxBytesLocalHeap(long maxBytesLocalHeapParam)
                                            throws IllegalArgumentException
Sets the maxBytesLocalHeap

Returns:
same instance
Throws:
IllegalArgumentException - for negative values

maxBytesLocalOffheap

public ToolkitStoreConfigBuilder maxBytesLocalOffheap(long maxBytesLocalOffheapParam)
                                               throws IllegalArgumentException
Sets the max bytes local offheap

Returns:
same instance
Throws:
IllegalArgumentException - for negative values

maxCountLocalHeap

public ToolkitStoreConfigBuilder maxCountLocalHeap(int maxCountLocalHeapParam)
                                            throws IllegalArgumentException
Sets the max count local heap

Returns:
same instance
Throws:
IllegalArgumentException - for negative values

offheapEnabled

public ToolkitStoreConfigBuilder offheapEnabled(boolean offheapEnabledParam)
Sets offheap enabled

Returns:
same instance

localCacheEnabled

public ToolkitStoreConfigBuilder localCacheEnabled(boolean localCacheEnabledParam)
Sets local cache enabled

Returns:
same instance

compressionEnabled

public ToolkitStoreConfigBuilder compressionEnabled(boolean compressionEnabledParam)
Sets compression enabled

Returns:
same instance

copyOnReadEnabled

public ToolkitStoreConfigBuilder copyOnReadEnabled(boolean copyOnReadEnabledParam)
Sets copy on read enabled

Returns:
same instance

configField

public ToolkitStoreConfigBuilder configField(String fieldName,
                                             Serializable value)

addFieldToApply

protected void addFieldToApply(String name,
                               Serializable value)

getConcurrency

public int getConcurrency()
Concurrency of the store

Returns:
Concurrency of the store

getConsistency

public ToolkitConfigFields.Consistency getConsistency()
Getter for consistency

Returns:
ToolkitConfigFields.Consistency of the key-value store

getMaxBytesLocalHeap

public long getMaxBytesLocalHeap()
Gets the max bytes local heap

Returns:
max bytes local heap

getMaxBytesLocalOffheap

public long getMaxBytesLocalOffheap()
Gets the max bytes local offheap

Returns:
max bytes local offheap

getMaxCountLocalHeap

public long getMaxCountLocalHeap()
Gets the max count local heap

Returns:
max count local heap

isOffheapEnabled

public boolean isOffheapEnabled()
Returns true if offheap is enabled

Returns:
true if offheap is enabled, otherwise false

isLocalCacheEnabled

public boolean isLocalCacheEnabled()
Query whether local cache is enabled or not

Returns:
true if local cache is enabled, otherwise false

isCompressionEnabled

public boolean isCompressionEnabled()
Compression enabled or not getter

Returns:
whether compression is enabled

setPinnedInLocalMemory

public void setPinnedInLocalMemory(boolean pinnedInLocalMemory)
Sets whether entries should be pinned in local memory


isPinnedInLocalMemory

public boolean isPinnedInLocalMemory()

isCopyOnReadEnabled

public boolean isCopyOnReadEnabled()
copy-on-read enabled or not getter

Returns:
true if copy on read is enabled, otherwise false

setConcurrency

protected void setConcurrency(int concurrencyParam)
                       throws IllegalArgumentException
Throws:
IllegalArgumentException

setConsistency

protected void setConsistency(ToolkitConfigFields.Consistency consistencyParam)
Sets the ToolkitConfigFields.Consistency of the key-value store


setMaxBytesLocalHeap

protected void setMaxBytesLocalHeap(long maxBytesLocalHeapParam)
                             throws IllegalArgumentException
Sets the maxBytesLocalHeap

Throws:
IllegalArgumentException - for negative values

setMaxBytesLocalOffheap

protected void setMaxBytesLocalOffheap(long maxBytesLocalOffheapParam)
                                throws IllegalArgumentException
Sets the max bytes local offheap

Throws:
IllegalArgumentException - for negative values

setMaxCountLocalHeap

protected void setMaxCountLocalHeap(int maxCountLocalHeapParam)
                             throws IllegalArgumentException
Sets the max count local heap

Throws:
IllegalArgumentException - for negative values

setOffheapEnabled

protected void setOffheapEnabled(boolean offheapEnabledParam)
Sets offheap enabled


setLocalCacheEnabled

protected void setLocalCacheEnabled(boolean localCacheEnabledParam)
Sets local cache enabled


setCompressionEnabled

protected void setCompressionEnabled(boolean compressionEnabledParam)
Sets compression enabled


setCopyOnReadEnabled

protected void setCopyOnReadEnabled(boolean copyOnReadEnabledParam)
Sets copy on read enabled


setConfigField

protected void setConfigField(String fieldName,
                              Serializable value)

build

public Configuration build()
Builds a Configuration for ToolkitStore by filling in appropriate mappings. Only adds mappings for values which were set explicitly in this builder, and doesn’t fills in default values in the returned config. Consult ToolkitConfigFields for the various configs supported and its default values


apply

public void apply(ToolkitStore store)
Apply changes of this builder to the ToolkitStore parameter. The changes are the ones between each apply.

If the store's configuration has ToolkitConfigFields.MAX_BYTES_LOCAL_HEAP_FIELD_NAME property set then AbstractToolkitStoreCacheConfigBuilder.setMaxCountLocalHeap(int) would result in an error.

If the store's configuration has ToolkitConfigFields.MAX_COUNT_LOCAL_HEAP_FIELD_NAME property set then AbstractToolkitStoreCacheConfigBuilder.setMaxBytesLocalHeap(long) would result in an error.


apply

public void apply(ToolkitCache cache)
Apply changes of this builder to the ToolkitStore parameter. The changes are the ones between each apply.

If the store's configuration has ToolkitConfigFields.MAX_BYTES_LOCAL_HEAP_FIELD_NAME property set then AbstractToolkitStoreCacheConfigBuilder.setMaxCountLocalHeap(int) would result in an error.

If the store's configuration has ToolkitConfigFields.MAX_COUNT_LOCAL_HEAP_FIELD_NAME property set then AbstractToolkitStoreCacheConfigBuilder.setMaxBytesLocalHeap(long) would result in an error.



Copyright © 2014 Terracotta, Inc.. All Rights Reserved.