rmtfile.hpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef RMTFILE_HPP
  14. #define RMTFILE_HPP
  15. #include "jsocket.hpp"
  16. #include "jfile.hpp"
  17. #include "dafscommon.hpp"
  18. #include "rmtclient.hpp"
  19. #ifdef DAFSCLIENT_EXPORTS
  20. #define DAFSCLIENT_API DECL_EXPORT
  21. #else
  22. #define DAFSCLIENT_API DECL_IMPORT
  23. #endif
  24. extern DAFSCLIENT_API void filenameToUrl(StringBuffer & out, const char * filename);
  25. interface IDaFileSrvHook : extends IRemoteFileCreateHook
  26. {
  27. virtual void forceRemote(const char *pattern) = 0; // NB: forces all local files matching pattern to be remote reads
  28. virtual void addSubnetFilter(const char *subnet, const char *mask, const char *dir, const char *sourceRange, bool trace) = 0;
  29. virtual void addRangeFilter(const char *range, const char *dir, const char *sourceRange, bool trace) = 0;
  30. virtual IPropertyTree *addFilters(IPropertyTree *filters, const SocketEndpoint *ipAddress) = 0;
  31. virtual IPropertyTree *addMyFilters(IPropertyTree *filters, SocketEndpoint *myEp=NULL) = 0;
  32. virtual void clearFilters() = 0;
  33. };
  34. extern DAFSCLIENT_API IDaFileSrvHook *queryDaFileSrvHook();
  35. extern DAFSCLIENT_API void setDaliServixSocketCaching(bool set);
  36. extern DAFSCLIENT_API bool canAccessDirectly(const RemoteFilename & file);
  37. extern DAFSCLIENT_API IFile *createDaliServixFile(const RemoteFilename & file);
  38. extern DAFSCLIENT_API void enableForceRemoteReads(); // forces file reads to be remote reads if they match environment setting 'forceRemotePattern' pattern.
  39. extern DAFSCLIENT_API bool testForceRemote(const char *path); // return true if forceRemote setup/pattern will make this path a remote read.
  40. extern DAFSCLIENT_API IDirectoryIterator *createRemoteDirectorIterator(const SocketEndpoint &ep, const char *name, MemoryBuffer &state);
  41. extern DAFSCLIENT_API bool serializeRemoteDirectoryIterator(MemoryBuffer &tgt, IDirectoryIterator *iter, size32_t bufsize, bool first);
  42. extern DAFSCLIENT_API void serializeRemoteDirectoryDiff(MemoryBuffer &tgt, IDirectoryDifferenceIterator *iter);
  43. extern DAFSCLIENT_API void setLocalMountRedirect(const IpAddress &ip,const char *dir,const char *mountdir);
  44. // redirects a daliservix file to a local mount. To remove redirect use NULL for mount dir or NULL for dir
  45. extern DAFSCLIENT_API void remoteExtractBlobElements(const char * prefix, const RemoteFilename &file, ExtractedBlobArray & extracted);
  46. extern DAFSCLIENT_API void disconnectRemoteFile(IFile *file);
  47. extern DAFSCLIENT_API void disconnectRemoteIoOnExit(IFileIO *fileio,bool set=true);
  48. extern DAFSCLIENT_API bool resetRemoteFilename(IFile *file, const char *newname); // returns false if not remote
  49. extern DAFSCLIENT_API bool asyncCopyFileSection(const char *uuid, // from genUUID - must be same for subsequent calls
  50. IFile *from, // expected to be remote
  51. RemoteFilename &to,
  52. offset_t toofs, // (offset_t)-1 created file and copies to start
  53. offset_t fromofs,
  54. offset_t size, // (offset_t)-1 for all file
  55. ICopyFileProgress *progress,
  56. unsigned timeout // 0 to start, non-zero to wait
  57. ); // returns true when done
  58. extern DAFSCLIENT_API void setRemoteFileTimeouts(unsigned maxconnecttime,unsigned maxreadtime);
  59. #define DAFS_VALIDATE_CONNECT_FAIL (0x01)
  60. #define DAFS_VALIDATE_BAD_VERSION (0x02)
  61. #define DAFS_VALIDATE_WRITE_FAIL_DATA (0x12)
  62. #define DAFS_VALIDATE_READ_FAIL_DATA (0x14)
  63. #define DAFS_VALIDATE_DISK_FULL_DATA (0x18)
  64. #define DAFS_VALIDATE_WRITE_FAIL_MIRROR (0x22)
  65. #define DAFS_VALIDATE_READ_FAIL_MIRROR (0x24)
  66. #define DAFS_VALIDATE_DISK_FULL_MIRROR (0x28)
  67. #define DAFS_SCRIPT_FAIL (0x40)
  68. extern DAFSCLIENT_API unsigned validateNodes(const SocketEndpointArray &eps,const char *dataDir, const char *mirrorDir, bool chkver, SocketEndpointArray &failures, UnsignedArray &failedcodes, StringArray &failedmessages, const char *filename=NULL);
  69. extern DAFSCLIENT_API void installFileHooks(const char *filespec);
  70. extern DAFSCLIENT_API void installDefaultFileHooks(IPropertyTree * config);
  71. extern DAFSCLIENT_API void removeFileHooks(); // Should be called before closedown
  72. extern DAFSCLIENT_API void setRemoteOutputCompressionDefault(const char *type);
  73. extern DAFSCLIENT_API const char *queryOutputCompressionDefault();
  74. extern DAFSCLIENT_API void remoteExtractBlobElements(const SocketEndpoint &ep, const char * prefix, const char * filename, ExtractedBlobArray & extracted);
  75. //// legacy implementations of the streaming support (to be replaced by dafsstream.*)
  76. interface IOutputMetaData;
  77. class RowFilter;
  78. interface IRemoteFileIO : extends IFileIO
  79. {
  80. virtual void addVirtualFieldMapping(const char *fieldName, const char *fieldValue) = 0;
  81. virtual void ensureAvailable() = 0;
  82. };
  83. extern DAFSCLIENT_API IRemoteFileIO *createRemoteFilteredFile(SocketEndpoint &ep, const char * filename, IOutputMetaData *actual, IOutputMetaData *projected, const RowFilter &fieldFilters, bool compressed, bool grouped, unsigned __int64 chooseNLimit);
  84. interface IIndexLookup;
  85. extern DAFSCLIENT_API IIndexLookup *createRemoteFilteredKey(SocketEndpoint &ep, const char * filename, unsigned crc, IOutputMetaData *actual, IOutputMetaData *projected, const RowFilter &fieldFilters, unsigned __int64 chooseNLimit);
  86. ////
  87. #endif