public class DefaultStreamCachingStrategy extends ServiceSupport implements CamelContextAware, StreamCachingStrategy
StreamCachingStrategyStreamCachingStrategy.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() |
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 |
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, 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 CamelContext getCamelContext()
CamelContextAwareCamelContextgetCamelContext in interface CamelContextAwarepublic void setCamelContext(CamelContext camelContext)
CamelContextAwareCamelContextsetCamelContext in interface CamelContextAwarecamelContext - the Camel contextpublic boolean isEnabled()
isEnabled in interface StreamCachingStrategypublic void setEnabled(boolean enabled)
StreamCachingStrategysetEnabled in interface StreamCachingStrategypublic void setSpoolDirectory(String path)
setSpoolDirectory in interface StreamCachingStrategypublic void setSpoolDirectory(File path)
StreamCachingStrategysetSpoolDirectory in interface StreamCachingStrategypublic File getSpoolDirectory()
getSpoolDirectory in interface StreamCachingStrategypublic long getSpoolThreshold()
getSpoolThreshold in interface StreamCachingStrategypublic int getSpoolUsedHeapMemoryThreshold()
getSpoolUsedHeapMemoryThreshold in interface StreamCachingStrategypublic void setSpoolUsedHeapMemoryThreshold(int spoolHeapMemoryWatermarkThreshold)
StreamCachingStrategysetSpoolUsedHeapMemoryThreshold in interface StreamCachingStrategyspoolHeapMemoryWatermarkThreshold - percentage of used heap memory.public StreamCachingStrategy.SpoolUsedHeapMemoryLimit getSpoolUsedHeapMemoryLimit()
getSpoolUsedHeapMemoryLimit in interface StreamCachingStrategypublic void setSpoolUsedHeapMemoryLimit(StreamCachingStrategy.SpoolUsedHeapMemoryLimit spoolUsedHeapMemoryLimit)
StreamCachingStrategyStreamCachingStrategy.setSpoolUsedHeapMemoryThreshold(int)
is in use.setSpoolUsedHeapMemoryLimit in interface StreamCachingStrategyspoolUsedHeapMemoryLimit - the boundspublic void setSpoolThreshold(long spoolThreshold)
StreamCachingStrategyStreamCache.DEFAULT_SPOOL_THRESHOLD bytes (eg 128kb).
Use -1 to disable overflow to disk.setSpoolThreshold in interface StreamCachingStrategypublic String getSpoolChiper()
getSpoolChiper in interface StreamCachingStrategypublic void setSpoolChiper(String spoolChiper)
StreamCachingStrategysetSpoolChiper in interface StreamCachingStrategypublic int getBufferSize()
getBufferSize in interface StreamCachingStrategypublic void setBufferSize(int bufferSize)
StreamCachingStrategyIOHelper.DEFAULT_BUFFER_SIZEsetBufferSize in interface StreamCachingStrategypublic boolean isRemoveSpoolDirectoryWhenStopping()
isRemoveSpoolDirectoryWhenStopping in interface StreamCachingStrategypublic void setRemoveSpoolDirectoryWhenStopping(boolean removeSpoolDirectoryWhenStopping)
StreamCachingStrategysetRemoveSpoolDirectoryWhenStopping in interface StreamCachingStrategypublic boolean isAnySpoolRules()
isAnySpoolRules in interface StreamCachingStrategypublic void setAnySpoolRules(boolean anySpoolTasks)
StreamCachingStrategyStreamCachingStrategy.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 StreamCachingStrategypublic StreamCachingStrategy.Statistics getStatistics()
StreamCachingStrategygetStatistics in interface StreamCachingStrategypublic boolean shouldSpoolCache(long length)
StreamCachingStrategyshouldSpoolCache in interface StreamCachingStrategylength - the length of the streampublic void addSpoolRule(StreamCachingStrategy.SpoolRule rule)
StreamCachingStrategyStreamCachingStrategy.SpoolRule rule to be used.addSpoolRule in interface StreamCachingStrategypublic StreamCache cache(Exchange exchange)
StreamCachingStrategyStreamCache.cache in interface StreamCachingStrategyexchange - the exchangeStreamCache, or null if not possible or no need to cache the bodyprotected void doStart()
throws Exception
ServiceSupportServiceSupport.doStop() for more details.doStart in class ServiceSupportExceptionServiceSupport.doStop()protected void doStop()
throws Exception
ServiceSupportServiceSupport.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 ServiceSupportExceptionServiceSupport.doStart()Apache Camel