public class FileRefreshableDataSource<T> extends AutoRefreshDataSource<String,T>
A DataSource based on file. This class will automatically fetches the backend file every 3 seconds.
Limitations: default read buffer size is 1MB, if file size is greater than buffer size, exceeding bytes will be ignored. Default charset is UTF8.
recommendRefreshMsparser, property| Constructor and Description |
|---|
FileRefreshableDataSource(File file,
ConfigParser<String,T> configParser)
Create a file based
DataSource whose read buffer size is 1MB, charset is UTF8,
and read interval is 3 seconds. |
FileRefreshableDataSource(File file,
ConfigParser<String,T> configParser,
Charset charset) |
FileRefreshableDataSource(File file,
ConfigParser<String,T> configParser,
int bufSize) |
FileRefreshableDataSource(File file,
ConfigParser<String,T> configParser,
long recommendRefreshMs,
int bufSize,
Charset charset) |
FileRefreshableDataSource(String fileName,
ConfigParser<String,T> configParser) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the data source.
|
String |
readSource()
Read original data from the data source.
|
void |
writeDataSource(T values)
Write the
values to the data source. |
getProperty, loadConfig, loadConfigpublic FileRefreshableDataSource(File file, ConfigParser<String,T> configParser) throws FileNotFoundException
DataSource whose read buffer size is 1MB, charset is UTF8,
and read interval is 3 seconds.file - the file to read.configParser - the config parser.FileNotFoundExceptionpublic FileRefreshableDataSource(String fileName, ConfigParser<String,T> configParser) throws FileNotFoundException
FileNotFoundExceptionpublic FileRefreshableDataSource(File file, ConfigParser<String,T> configParser, int bufSize) throws FileNotFoundException
FileNotFoundExceptionpublic FileRefreshableDataSource(File file, ConfigParser<String,T> configParser, Charset charset) throws FileNotFoundException
FileNotFoundExceptionpublic FileRefreshableDataSource(File file, ConfigParser<String,T> configParser, long recommendRefreshMs, int bufSize, Charset charset) throws FileNotFoundException
FileNotFoundExceptionpublic String readSource() throws Exception
DataSourceExceptionpublic void close()
throws Exception
DataSourceclose in interface DataSource<String,T>close in class AutoRefreshDataSource<String,T>Exceptionpublic void writeDataSource(T values) throws Exception
DataSourcevalues to the data source.writeDataSource in interface DataSource<String,T>writeDataSource in class AbstractDataSource<String,T>ExceptionCopyright © 2018 Alibaba Group. All rights reserved.