public class FileRefreshableDataSource<T> extends AutoRefreshDataSource<String,T>
A ReadableDataSource based on file. This class will automatically
fetches the backend file every isModified period.
Limitations: Default read buffer size is 1 MB. If file size is greater than buffer size, exceeding bytes will be ignored. Default charset is UTF-8.
recommendRefreshMsparser, property| Constructor and Description |
|---|
FileRefreshableDataSource(File file,
Converter<String,T> configParser)
Create a file based
ReadableDataSource whose read buffer size is
1MB, charset is UTF8, and read interval is 3 seconds. |
FileRefreshableDataSource(File file,
Converter<String,T> configParser,
Charset charset) |
FileRefreshableDataSource(File file,
Converter<String,T> configParser,
int bufSize) |
FileRefreshableDataSource(File file,
Converter<String,T> configParser,
long recommendRefreshMs,
int bufSize,
Charset charset) |
FileRefreshableDataSource(String fileName,
Converter<String,T> configParser) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the data source.
|
protected boolean |
isModified() |
String |
readSource()
Read original data from the data source.
|
getProperty, loadConfig, loadConfigpublic FileRefreshableDataSource(File file, Converter<String,T> configParser) throws FileNotFoundException
ReadableDataSource whose read buffer size is
1MB, charset is UTF8, and read interval is 3 seconds.file - the file to readconfigParser - the config decoder (parser)FileNotFoundExceptionpublic FileRefreshableDataSource(String fileName, Converter<String,T> configParser) throws FileNotFoundException
FileNotFoundExceptionpublic FileRefreshableDataSource(File file, Converter<String,T> configParser, int bufSize) throws FileNotFoundException
FileNotFoundExceptionpublic FileRefreshableDataSource(File file, Converter<String,T> configParser, Charset charset) throws FileNotFoundException
FileNotFoundExceptionpublic FileRefreshableDataSource(File file, Converter<String,T> configParser, long recommendRefreshMs, int bufSize, Charset charset) throws FileNotFoundException
FileNotFoundExceptionpublic String readSource() throws Exception
ReadableDataSourceException - IO or other error occursprotected boolean isModified()
isModified in class AutoRefreshDataSource<String,T>public void close()
throws Exception
ReadableDataSourceclose in interface ReadableDataSource<String,T>close in class AutoRefreshDataSource<String,T>Exception - IO or other error occursCopyright © 2022 Alibaba Group. All rights reserved.