public class DefaultStreamCachingStrategy extends ServiceSupport implements CamelContextAware, StreamCachingStrategy
StreamCachingStrategy
StreamCachingStrategy.SpoolRule, StreamCachingStrategy.SpoolUsedHeapMemoryLimit, StreamCachingStrategy.Statistics
Modifier and Type | Field and Description |
---|---|
static String |
BUFFER_SIZE
Deprecated.
|
static String |
CIPHER_TRANSFORMATION
Deprecated.
|
static String |
TEMP_DIR
Deprecated.
|
static String |
THRESHOLD
Deprecated.
|
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
Constructor and Description |
---|
DefaultStreamCachingStrategy() |
Modifier and Type | Method and Description |
---|---|
void |
addSpoolRule(StreamCachingStrategy.SpoolRule rule)
Adds the
StreamCachingStrategy.SpoolRule rule to be used. |
StreamCache |
cache(Exchange exchange)
Caches the body aas a
StreamCache . |
protected String |
customResolveManagementName(String pattern) |
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
int |
getBufferSize() |
CamelContext |
getCamelContext()
Get the
CamelContext |
String |
getSpoolChiper() |
String |
getSpoolCipher() |
File |
getSpoolDirectory() |
long |
getSpoolThreshold() |
StreamCachingStrategy.SpoolUsedHeapMemoryLimit |
getSpoolUsedHeapMemoryLimit() |
int |
getSpoolUsedHeapMemoryThreshold() |
StreamCachingStrategy.Statistics |
getStatistics()
Gets the utilization statistics.
|
boolean |
isAnySpoolRules() |
boolean |
isEnabled() |
boolean |
isRemoveSpoolDirectoryWhenStopping() |
protected String |
resolveSpoolDirectory(String path) |
void |
setAnySpoolRules(boolean anySpoolTasks)
Sets whether if just any of the
StreamCachingStrategy.SpoolRule rules
returns true then StreamCachingStrategy.shouldSpoolCache(long) returns true. |
void |
setBufferSize(int bufferSize)
Sets the buffer size to use when allocating in-memory buffers used for in-memory stream caches.
|
void |
setCamelContext(CamelContext camelContext)
Injects the
CamelContext |
void |
setEnabled(boolean enabled)
Sets whether the stream caching is enabled.
|
void |
setRemoveSpoolDirectoryWhenStopping(boolean removeSpoolDirectoryWhenStopping)
Whether to remove the temporary directory when stopping.
|
void |
setSpoolChiper(String spoolChiper)
Sets a chiper name to use when spooling to disk to write with encryption.
|
void |
setSpoolCipher(String spoolCipher)
Sets a cipher name to use when spooling to disk to write with encryption.
|
void |
setSpoolDirectory(File path)
Sets the spool (temporary) directory to use for overflow and spooling to disk.
|
void |
setSpoolDirectory(String path) |
void |
setSpoolThreshold(long spoolThreshold)
Threshold in bytes when overflow to disk is activated.
|
void |
setSpoolUsedHeapMemoryLimit(StreamCachingStrategy.SpoolUsedHeapMemoryLimit spoolUsedHeapMemoryLimit)
Sets what the upper bounds should be when
StreamCachingStrategy.setSpoolUsedHeapMemoryThreshold(int)
is in use. |
void |
setSpoolUsedHeapMemoryThreshold(int spoolHeapMemoryWatermarkThreshold)
Sets a percentage (1-99) of used heap memory threshold to activate spooling to disk.
|
boolean |
shouldSpoolCache(long length)
Determines if the stream should be spooled or not.
|
String |
toString() |
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
@Deprecated public static final String THRESHOLD
@Deprecated public static final String BUFFER_SIZE
@Deprecated public static final String TEMP_DIR
@Deprecated public static final String CIPHER_TRANSFORMATION
public DefaultStreamCachingStrategy()
public CamelContext getCamelContext()
CamelContextAware
CamelContext
getCamelContext
in interface CamelContextAware
public void setCamelContext(CamelContext camelContext)
CamelContextAware
CamelContext
setCamelContext
in interface CamelContextAware
camelContext
- the Camel contextpublic boolean isEnabled()
isEnabled
in interface StreamCachingStrategy
public void setEnabled(boolean enabled)
StreamCachingStrategy
setEnabled
in interface StreamCachingStrategy
public void setSpoolDirectory(String path)
setSpoolDirectory
in interface StreamCachingStrategy
public void setSpoolDirectory(File path)
StreamCachingStrategy
setSpoolDirectory
in interface StreamCachingStrategy
public File getSpoolDirectory()
getSpoolDirectory
in interface StreamCachingStrategy
public long getSpoolThreshold()
getSpoolThreshold
in interface StreamCachingStrategy
public int getSpoolUsedHeapMemoryThreshold()
getSpoolUsedHeapMemoryThreshold
in interface StreamCachingStrategy
public void setSpoolUsedHeapMemoryThreshold(int spoolHeapMemoryWatermarkThreshold)
StreamCachingStrategy
setSpoolUsedHeapMemoryThreshold
in interface StreamCachingStrategy
spoolHeapMemoryWatermarkThreshold
- percentage of used heap memory.public StreamCachingStrategy.SpoolUsedHeapMemoryLimit getSpoolUsedHeapMemoryLimit()
getSpoolUsedHeapMemoryLimit
in interface StreamCachingStrategy
public void setSpoolUsedHeapMemoryLimit(StreamCachingStrategy.SpoolUsedHeapMemoryLimit spoolUsedHeapMemoryLimit)
StreamCachingStrategy
StreamCachingStrategy.setSpoolUsedHeapMemoryThreshold(int)
is in use.setSpoolUsedHeapMemoryLimit
in interface StreamCachingStrategy
spoolUsedHeapMemoryLimit
- the boundspublic void setSpoolThreshold(long spoolThreshold)
StreamCachingStrategy
StreamCache.DEFAULT_SPOOL_THRESHOLD
bytes (eg 128kb).
Use -1 to disable overflow to disk.setSpoolThreshold
in interface StreamCachingStrategy
public String getSpoolChiper()
getSpoolChiper
in interface StreamCachingStrategy
public void setSpoolChiper(String spoolChiper)
StreamCachingStrategy
setSpoolChiper
in interface StreamCachingStrategy
public String getSpoolCipher()
getSpoolCipher
in interface StreamCachingStrategy
public void setSpoolCipher(String spoolCipher)
StreamCachingStrategy
setSpoolCipher
in interface StreamCachingStrategy
public int getBufferSize()
getBufferSize
in interface StreamCachingStrategy
public void setBufferSize(int bufferSize)
StreamCachingStrategy
IOHelper.DEFAULT_BUFFER_SIZE
setBufferSize
in interface StreamCachingStrategy
public boolean isRemoveSpoolDirectoryWhenStopping()
isRemoveSpoolDirectoryWhenStopping
in interface StreamCachingStrategy
public void setRemoveSpoolDirectoryWhenStopping(boolean removeSpoolDirectoryWhenStopping)
StreamCachingStrategy
setRemoveSpoolDirectoryWhenStopping
in interface StreamCachingStrategy
public boolean isAnySpoolRules()
isAnySpoolRules
in interface StreamCachingStrategy
public void setAnySpoolRules(boolean anySpoolTasks)
StreamCachingStrategy
StreamCachingStrategy.SpoolRule
rules
returns true then StreamCachingStrategy.shouldSpoolCache(long)
returns true.
If this option is false, then all the StreamCachingStrategy.SpoolRule
must
return true.
The default value is false which means that all the rules must return true.setAnySpoolRules
in interface StreamCachingStrategy
public StreamCachingStrategy.Statistics getStatistics()
StreamCachingStrategy
getStatistics
in interface StreamCachingStrategy
public boolean shouldSpoolCache(long length)
StreamCachingStrategy
shouldSpoolCache
in interface StreamCachingStrategy
length
- the length of the streampublic void addSpoolRule(StreamCachingStrategy.SpoolRule rule)
StreamCachingStrategy
StreamCachingStrategy.SpoolRule
rule to be used.addSpoolRule
in interface StreamCachingStrategy
public StreamCache cache(Exchange exchange)
StreamCachingStrategy
StreamCache
.cache
in interface StreamCachingStrategy
exchange
- the exchangeStreamCache
, or null if not possible or no need to cache the bodyprotected String resolveSpoolDirectory(String path)
protected String customResolveManagementName(String pattern)
protected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.doStart
in class ServiceSupport
Exception
ServiceSupport.doStop()
protected void doStop() throws Exception
ServiceSupport
ServiceSupport.doStop()
method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext
is shutting down.doStop
in class ServiceSupport
Exception
ServiceSupport.doStart()
Apache Camel