Package com.killcoding.file
Class RemoteFile
java.lang.Object
com.killcoding.file.BaseFile
com.killcoding.file.RemoteFile
- All Implemented Interfaces:
RemoteFileSQL
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static Filestatic Integerstatic Longstatic Integerprivate static final Map<String,ConfigProperties> protected ConfigPropertiesstatic booleanprivate static final Map<String,ConfigProperties> protected DriverDataSourceprotected DriverDataSourceprotected Stringprotected Integerprivate static final Map<String,DriverDataSource> private DriverDataSourceprivate Stringprivate DriverDataSourceprivate Stringstatic Stringstatic Dateprotected Stringprotected Stringprivate Integerprotected static booleanprivate static IdentityCardprivate Booleanprivate Stringprivate Stringprivate Integerprivate Loggerstatic Doublestatic Integerstatic Integerstatic Longstatic Doublestatic Integerstatic Integerprivate static ExecutorServiceprivate Timestampprivate Stringstatic booleanstatic booleanstatic Dateprotected StringFields inherited from class com.killcoding.file.BaseFile
CACHE_ARRAY_FILTER_TIMER, CHARSET, LOGIC_ACCESS_TIMEOUT_MS, LOGIC_CHECK_TIMEOUT_MS, LOGIC_TIMEOUT_MS, origin, stopSync, SYNC_PATH_ALLOWED, SYNC_PATH_IGNORED, syncRoot, TEMP_DIR, TMP_EXT_ACCESS_FILE, TMP_EXT_CHECK_FILE, TMP_EXT_MODIFY_FILE, TMP_MATCHES_EDIT, TMP_MATCHES_VI_SWP, TMP_WRITING_FILE, TMP_WRITING_FOR_REPLACE, TMP_WRITING_SWPFields inherited from interface com.killcoding.file.RemoteFileSQL
SQL_DELETE_BY_FILE_ID_FROM_FILE, SQL_DELETE_BY_RF_ID_FROM_FILE_DATA, SQL_INSERT_INTO_FILE, SQL_INSERT_INTO_FILE_DATA, SQL_SELECT_BY_PATH_FOR_CHECK_EXISTS, SQL_SELECT_BY_RF_ID_FROM_FILE_DATA, SQL_SELECT_CHECK_COMPLETED, SQL_SELECT_FILE, SQL_SELECT_FILE_HAVE_DATA, SQL_SELECT_FOR_ALL_TIMEOUT, SQL_SELECT_FOR_ARCHIVE_DELETED, SQL_SELECT_FOR_ARCHIVE_FILE_DELETED, SQL_SELECT_FOR_COMPLETED, SQL_SELECT_FOR_COUNT_ALL_SUB_FILES, SQL_SELECT_FOR_FIRST_CREATED_AT, SQL_SELECT_FOR_FIRST_FILE, SQL_SELECT_FOR_LAST_FILE_PART, SQL_SELECT_FOR_LAST_UPDATE, SQL_SELECT_FOR_LIST_ALL, SQL_SELECT_FOR_LIST_ALL_DELETE, SQL_SELECT_FOR_LIST_ALL_SCAN_DELETE, SQL_SELECT_FOR_LIST_ALL_SYNC, SQL_SELECT_FOR_MAX_DATA_TABLE, SQL_SELECT_FOR_SUM_FILE_PART_SIZE_INDEX, SQL_SELECT_FOR_TIMEOUT, SQL_SELECT_GET_RECORD_BY_FILE_ID, SQL_SELECT_GET_RECORD_BY_ID, SQL_UPDATE_BY_FILE_ID_FOR_CLEAR_FILE_DATA, SQL_UPDATE_FOR_COMPLETED, SQL_UPDATE_FOR_DELETE_ALL, SQL_UPDATE_FOR_DELETE_FILE_LINK, SQL_UPDATE_FOR_DELETED_TO_DISK, SQL_UPDATE_FOR_DELETED_TO_DISK_SUB_FILES, SQL_UPDATE_FOR_SYNCED_TO_DISK, SQL_UPDATE_FOR_TIMEOUT_DELETE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static booleanaddQueuePathMapping(String path) voidafterCreateLink(String target) voidafterDelete(boolean realDeleted) voidvoidbooleanbeforeCreateLink(String target) booleanbeforeDelete(boolean realDeleted) booleanbooleanprotected static voidcalculateDataMappingDataSourceReader(RemoteFile rf, Map<String, Object> rfRecord) protected static voidstatic booleanbooleancomplete()private booleancomplete(int filePartLastIndex, long fileSize) protected voidvoidprivate intcountAllSubFiles(String fileParentPath, String fileName) private booleanbooleancreateLink(String target) private booleancreateStructureFile(long fileSize) private static voiddebugLog(String point, RemoteFile rf, CacheArrayFilter filter) private byte[]decrypt(byte[] encData) booleandelete()booleandelete(boolean realDeleted) protected booleanprivate byte[]encrypt(byte[] data) private voidexecuteSyncRunnable(CacheArrayFilter filter, Map<String, Object> item, DiskFile df, RemoteFile rf) booleanexists()booleanexists(boolean refresh) booleanbooleanforceDelete(boolean realDeleted, String fileType) booleanforceDeleteAll(boolean realDeleted) booleanforceDeleteDir(boolean realDeleted) booleanforceDeleteFile(boolean realDeleted) booleanforceDeleteLink(boolean realDeleted) private static StringgenerateDataId(boolean identityCardEnable, String identityCardName, int identityCardSuffix, RemoteFile theRf) private static StringgenerateId(boolean identityCardEnable, String identityCardName, String identityCardPrefix, int identityCardSuffix) protected static ConfigPropertiesgetDataMapping(RemoteFile rf, int index) protected Stringprivate Stringstatic Map<String,DriverDataSource> protected Timestampprotected Timestampprotected Timestampprotected Stringprotected IntegergetRecordByFileId(Object fileId) getRecordById(Object id) private RunnablegetSyncRunnable(CacheArrayFilter filter, Map<String, Object> item, RemoteFile rf, DiskFile df) private voidinit()private voidstatic voidinitPool(int poolSize) booleanprotected booleanbooleanbooleanisFile()protected booleanprotected booleanbooleanisLink()protected booleanprotected booleanbooleanbooleanisTimeout(long timeoutMs) list()voidlistAll(CacheArray rows) voidlistAll(String likeFileName, CacheArray rows) voidlistAll(String likeFolderName, String likeFileName, CacheArray rows) protected voidlistAllForDelete(String likeFolderName, String likeFileName, CacheArray rows) protected voidlistAllForScanDelete(Integer filePartDataTable, CacheArray rows) protected voidlistAllForSync(String likeFolderName, String likeFileName, CacheArray rows) protected static voidvoidbooleanmkdirs()booleanmkdirs(boolean checkSourceHostname) voidbyte[]private byte[]readLink()private voidreload()protected static voidremoveQueuePathMapping(String path) voidsetModifyTime(Timestamp modifyTime) voidsetModifyUserId(String modifyUserId) longsize()voidstartArchiveForDeleted(long timerMs, long archiveMs) voidstartArchiveForDeleted(long timerMs, long archiveMs, Runnable completedCallback) voidstartArchiveForDeleted(long timerMs, String archiveTime) voidstartArchiveForDeleted(long timerMs, String archiveTime, Runnable completedCallback) voidstartArchiveForFileDeleted(long timerMs, long archiveMs) voidstartArchiveForFileDeleted(long timerMs, long archiveMs, Runnable completedCallback) voidstartArchiveForFileDeleted(long timerMs, String archiveTime) voidstartArchiveForFileDeleted(long timerMs, String archiveTime, Runnable completedCallback) voidstartArchiveForTimeout(long timerMs) voidstartArchiveForTimeout(long timerMs, Runnable completedCallback) voidstartFullAsync(long timerMs) voidstartFullAsync(long timerMs, Runnable completedCallback) voidstartFullAsync(long timerMs, String replaceTo) voidstartFullAsync(long timerMs, String replaceTo, Runnable completedCallback) private voidstartFullAsyncThread(boolean subFolders, long timerMs, String replaceTo, Runnable completedCallback) private voidstartFullAsyncThreadForDelete(boolean subFolders, long timerMs, String replaceTo, Runnable completedCallback) protected booleanbooleanwrite(byte[] data) booleanwrite(byte[] data, boolean append) booleanbooleanbooleanwriteBlock(byte[] data, boolean append) private booleanwriteTo(byte[] data, boolean append) private booleanwriteToBatch(int currentFilePartStartIndex, List<byte[]> partDataList) writeToDisk(DiskFile diskFile) writeToDisk(String path) Methods inherited from class com.killcoding.file.BaseFile
checkSyncPathAvailable, checkUsage, debugLog, getOrigin, getParent, getParents, getPath, isDebug, isDir, isHidden, isStopSync, memoryUsage, memoryUsage, memoryUsing, parsePath, replacePath, setTmpDir, stopSync, timeZoneConver, toAccessTmpFilePath, toCheckTmpFilePath, toModifyTmpFilePath, write
-
Field Details
-
DATASOURCE_REMOTE_FILE
-
CONFIG_PROPS_REMOTE_FILE
-
QUEUE_PATH_MAPPING
-
DATA_MAPPING
-
DATA_MAPPING_LIST
-
DATA_MAPPING_INDEX
-
FIRST_LOADED
-
MAX_POOL_SIZE
-
MAX_CONNECT_USAGE
-
MAX_MEMORY_USAGE
-
MAX_QUEUE_SIZE
-
MAX_FILE_SZIE
-
SHOW_LINK
-
SHOW_HIDDEN
-
COPY_STRUCTURE_ONLY
-
MAX_FILE_PARENT_PATH_LENGTH
-
MAX_FILE_NAME_LENGTH
-
CACHE_SECONDS
-
SYNC_CUTOFF_TIME
-
DELETE_CUTOFF_TIME
-
identityCard
-
appRemoteFile
-
dataSourceReader
-
dataSourceWriter
-
dataSourceReaderPath
-
dataSourceWriterPath
-
modifyUserId
-
filePartSize
-
identityCardEnable
-
identityCardName
-
identityCardPrefix
-
identityCardSuffix
-
modifyTime
-
configProperties
-
fileId
-
tableName
-
dataMappingTable
-
dataMappingDs
-
dataMappingDataSourceReader
-
dataMappingDataSourceWriter
-
dsKey
-
BEFORE_THE_QUEUE_TIME
-
BATCH_SIZE
-
DEFAULE_MODIFY_USER_ID
-
log
-
mergePool
-
-
Constructor Details
-
RemoteFile
-
-
Method Details
-
initPool
-
init
-
initGlobal
-
reload
-
formatSql
-
formatSqlForFilePartData
-
writeToDisk
- Throws:
IOException
-
writeToDisk
- Throws:
IOException
-
writeToDisk
- Throws:
IOException
-
isCompleted
- Throws:
IOException
-
getCompletedRecord
- Throws:
IOException
-
getRecordById
- Throws:
IOException
-
getRecordByFileId
- Throws:
IOException
-
getLastUpdateRecord
- Throws:
IOException
-
getFirstCreatedAt
- Throws:
IOException
-
getMaxFilePartDataTable
- Throws:
IOException
-
getSelectByPathForCheckExists
- Throws:
IOException
-
countAllSubFiles
- Throws:
IOException
-
getFirstFilePart
- Throws:
IOException
-
getFirstFilePartRefresh
- Throws:
IOException
-
getLastIndexRecord
- Throws:
IOException
-
isTimeout
- Throws:
IOException
-
readPart
- Throws:
IOException
-
merge
- Throws:
IOException
-
copyFrom
- Throws:
IOException
-
createEmptyFile
- Throws:
IOException
-
createStructureFile
- Throws:
IOException
-
syncedToDisk
- Throws:
IOException
-
deletedToDiskAndSub
- Throws:
IOException
-
complete
- Throws:
IOException
-
complete
- Specified by:
completein classBaseFile- Throws:
IOException
-
forceDelete
- Throws:
IOException
-
forceDeleteDir
- Throws:
IOException
-
forceDeleteLink
- Throws:
IOException
-
forceDeleteFile
- Throws:
IOException
-
forceDelete
- Throws:
IOException
-
forceDeleteAll
- Throws:
IOException
-
delete
- Specified by:
deletein classBaseFile- Throws:
IOException
-
delete
- Throws:
IOException
-
beforeDelete
- Specified by:
beforeDeletein classBaseFile
-
afterDelete
- Specified by:
afterDeletein classBaseFile
-
beforeMkdirs
- Specified by:
beforeMkdirsin classBaseFile
-
afterMkdirs
- Specified by:
afterMkdirsin classBaseFile
-
beforeCreateLink
- Specified by:
beforeCreateLinkin classBaseFile
-
afterCreateLink
- Specified by:
afterCreateLinkin classBaseFile
-
beforeWrite
- Specified by:
beforeWritein classBaseFile
-
afterWrite
- Specified by:
afterWritein classBaseFile
-
exists
- Specified by:
existsin classBaseFile- Throws:
IOException
-
exists
- Throws:
IOException
-
mkdirs
- Specified by:
mkdirsin classBaseFile- Throws:
IOException
-
mkdirs
- Throws:
IOException
-
write
- Specified by:
writein classBaseFile- Throws:
IOException
-
writeBlock
- Throws:
IOException
-
writeToBatch
private boolean writeToBatch(int currentFilePartStartIndex, List<byte[]> partDataList) throws IOException - Throws:
IOException
-
writeTo
- Throws:
IOException
-
write
- Specified by:
writein classBaseFile- Throws:
IOException
-
write
- Specified by:
writein classBaseFile- Throws:
IOException
-
write
- Specified by:
writein classBaseFile- Throws:
IOException
-
createLink
- Specified by:
createLinkin classBaseFile- Throws:
IOException
-
readLink
- Specified by:
readLinkin classBaseFile- Throws:
IOException
-
readAllBytes
- Specified by:
readAllBytesin classBaseFile- Throws:
IOException
-
readAllBytesFrom
- Throws:
IOException
-
isFile
- Specified by:
isFilein classBaseFile- Throws:
IOException
-
isDirectory
- Specified by:
isDirectoryin classBaseFile- Throws:
IOException
-
isLink
- Specified by:
isLinkin classBaseFile- Throws:
IOException
-
readAllString
- Specified by:
readAllStringin classBaseFile- Throws:
IOException
-
size
- Specified by:
sizein classBaseFile- Throws:
IOException
-
list
- Throws:
IOException
-
list
- Throws:
IOException
-
list
- Throws:
IOException
-
listAll
- Throws:
IOException
-
listAll
- Throws:
IOException
-
listAll
- Throws:
IOException
-
listAllForDelete
protected void listAllForDelete(String likeFolderName, String likeFileName, CacheArray rows) throws IOException - Throws:
IOException
-
listAllForSync
protected void listAllForSync(String likeFolderName, String likeFileName, CacheArray rows) throws IOException - Throws:
IOException
-
setModifyUserId
-
getDefaultModifyUserId
-
setModifyTime
- Specified by:
setModifyTimein classBaseFile- Throws:
IOException
-
getModifyTime
- Specified by:
getModifyTimein classBaseFile- Throws:
IOException
-
isTimeout
- Throws:
IOException
-
copyTo
- Specified by:
copyToin classBaseFile- Throws:
IOException
-
moveTo
- Specified by:
moveToin classBaseFile- Throws:
IOException
-
startFullAsyncThreadForDelete
private void startFullAsyncThreadForDelete(boolean subFolders, long timerMs, String replaceTo, Runnable completedCallback) -
startFullAsyncThread
private void startFullAsyncThread(boolean subFolders, long timerMs, String replaceTo, Runnable completedCallback) -
startFullAsync
- Throws:
IOException
-
startFullAsync
- Throws:
IOException
-
startFullAsync
- Throws:
IOException
-
startFullAsync
public void startFullAsync(long timerMs, String replaceTo, Runnable completedCallback) throws IOException - Throws:
IOException
-
getDataSourceReader
-
getDataSourceWriter
-
getConfigProperties
-
encrypt
- Throws:
Exception
-
decrypt
- Throws:
Exception
-
getSyncedOnHostnames
- Throws:
IOException
-
getDeletedOnHostnames
- Throws:
IOException
-
getSourceHostname
- Throws:
IOException
-
getLastSourceHostname
- Throws:
IOException
-
getLastOperateTime
- Throws:
IOException
-
getLastModifyTime
- Throws:
IOException
-
isLastOperateDelete
- Throws:
IOException
-
isLastOperateRealDelete
- Throws:
IOException
-
listAllForScanDelete
- Throws:
IOException
-
isSyncedOnHostname
- Throws:
IOException
-
isSyncedOnHostname
- Throws:
IOException
-
isDeletedOnHostname
- Throws:
IOException
-
getParentFile
-
executeSyncRunnable
private void executeSyncRunnable(CacheArrayFilter filter, Map<String, Object> item, DiskFile df, RemoteFile rf) -
getSyncRunnable
private Runnable getSyncRunnable(CacheArrayFilter filter, Map<String, Object> item, RemoteFile rf, DiskFile df) -
startArchiveForFileDeleted
- Throws:
IOException
-
startArchiveForFileDeleted
- Throws:
IOException
-
startArchiveForFileDeleted
public void startArchiveForFileDeleted(long timerMs, String archiveTime, Runnable completedCallback) throws IOException - Throws:
IOException
-
startArchiveForFileDeleted
public void startArchiveForFileDeleted(long timerMs, long archiveMs, Runnable completedCallback) throws IOException - Throws:
IOException
-
startArchiveForDeleted
- Throws:
IOException
-
startArchiveForDeleted
- Throws:
IOException
-
startArchiveForDeleted
public void startArchiveForDeleted(long timerMs, String archiveTime, Runnable completedCallback) throws IOException - Throws:
IOException
-
startArchiveForDeleted
public void startArchiveForDeleted(long timerMs, long archiveMs, Runnable completedCallback) throws IOException - Throws:
IOException
-
startArchiveForTimeout
- Throws:
IOException
-
startArchiveForTimeout
- Throws:
IOException
-
getDriverDataSourceMap
-
generateId
private static String generateId(boolean identityCardEnable, String identityCardName, String identityCardPrefix, int identityCardSuffix) throws SQLException - Throws:
SQLException
-
generateDataId
private static String generateDataId(boolean identityCardEnable, String identityCardName, int identityCardSuffix, RemoteFile theRf) throws SQLException - Throws:
SQLException
-
addQueuePathMapping
-
checkQueuePathMapping
-
removeQueuePathMapping
-
getQueuePathMapping
-
loadDataMapping
- Throws:
Exception
-
calculateDataMappingDataSourceReader
protected static void calculateDataMappingDataSourceReader(RemoteFile rf, Map<String, Object> rfRecord) -
calculateDataMappingDataSourceWriter
-
getDataMapping
-
getDataMappingTableName
-
debugLog
-