sockfile.hpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 SOCKFILE_HPP
  14. #define SOCKFILE_HPP
  15. #include "jsocket.hpp"
  16. #include "jfile.hpp"
  17. #ifdef REMOTE_EXPORTS
  18. #define REMOTE_API DECL_EXPORT
  19. #else
  20. #define REMOTE_API DECL_IMPORT
  21. #endif
  22. enum ThrottleClass
  23. {
  24. ThrottleStd,
  25. ThrottleSlow,
  26. ThrottleClassMax
  27. };
  28. // RemoteFileServer throttling defaults
  29. #define DEFAULT_THREADLIMIT 100
  30. #define DEFAULT_THREADLIMITDELAYMS (60*1000)
  31. #define DEFAULT_ASYNCCOPYMAX 10
  32. #define DEFAULT_STDCMD_PARALLELREQUESTLIMIT 80
  33. #define DEFAULT_STDCMD_THROTTLEDELAYMS 1000
  34. #define DEFAULT_STDCMD_THROTTLECPULIMIT 85
  35. #define DEFAULT_STDCMD_THROTTLEQUEUELIMIT 1000
  36. #define DEFAULT_SLOWCMD_PARALLELREQUESTLIMIT 20
  37. #define DEFAULT_SLOWCMD_THROTTLEDELAYMS 5000
  38. #define DEFAULT_SLOWCMD_THROTTLECPULIMIT 75
  39. #define DEFAULT_SLOWCMD_THROTTLEQUEUELIMIT 1000
  40. interface IRemoteFileServer : extends IInterface
  41. {
  42. virtual void run(DAFSConnectCfg connectMethod, SocketEndpoint &listenep, unsigned sslPort=0) = 0;
  43. virtual void stop() = 0;
  44. virtual unsigned idleTime() = 0; // in ms
  45. virtual void setThrottle(ThrottleClass throttleClass, unsigned limit, unsigned delayMs=DEFAULT_STDCMD_THROTTLEDELAYMS, unsigned cpuThreshold=DEFAULT_STDCMD_THROTTLECPULIMIT, unsigned queueLimit=DEFAULT_STDCMD_THROTTLEQUEUELIMIT) = 0;
  46. virtual StringBuffer &getStats(StringBuffer &stats, bool reset) = 0;
  47. };
  48. #define FILESRV_VERSION 22 // don't forget VERSTRING in sockfile.cpp
  49. interface IKeyManager;
  50. interface IDelayedFile;
  51. extern REMOTE_API IFile * createRemoteFile(SocketEndpoint &ep,const char * _filename);
  52. extern REMOTE_API unsigned getRemoteVersion(ISocket * _socket, StringBuffer &ver);
  53. extern REMOTE_API unsigned stopRemoteServer(ISocket * _socket);
  54. extern REMOTE_API const char *remoteServerVersionString();
  55. extern REMOTE_API IRemoteFileServer * createRemoteFileServer(unsigned maxThreads=DEFAULT_THREADLIMIT, unsigned maxThreadsDelayMs=DEFAULT_THREADLIMITDELAYMS, unsigned maxAsyncCopy=DEFAULT_ASYNCCOPYMAX);
  56. extern REMOTE_API int setDafsTrace(ISocket * socket,byte flags);
  57. extern REMOTE_API int setDafsThrottleLimit(ISocket * socket, ThrottleClass throttleClass, unsigned throttleLimit, unsigned throttleDelayMs, unsigned throttleCPULimit, unsigned queueLimit, StringBuffer *errMsg=NULL);
  58. extern REMOTE_API bool enableDafsAuthentication(bool on);
  59. extern REMOTE_API void remoteExtractBlobElements(const SocketEndpoint &ep, const char * prefix, const char * filename, ExtractedBlobArray & extracted);
  60. extern REMOTE_API int getDafsInfo(ISocket * socket, unsigned level, StringBuffer &retstr);
  61. extern REMOTE_API void setDafsEndpointPort(SocketEndpoint &ep);
  62. extern REMOTE_API void setDafsLocalMountRedirect(const IpAddress &ip,const char *dir,const char *mountdir);
  63. extern REMOTE_API ISocket *connectDafs(SocketEndpoint &ep, unsigned timeoutms); // NOTE: might alter ep.port if configured for multiple ports ...
  64. extern REMOTE_API ISocket *checkSocketSecure(ISocket *socket);
  65. interface IOutputMetaData;
  66. class RowFilter;
  67. interface IRemoteFileIO : extends IFileIO
  68. {
  69. virtual void addVirtualFieldMapping(const char *fieldName, const char *fieldValue) = 0;
  70. virtual void ensureAvailable() = 0;
  71. };
  72. extern REMOTE_API IRemoteFileIO *createRemoteFilteredFile(SocketEndpoint &ep, const char * filename, IOutputMetaData *actual, IOutputMetaData *projected, const RowFilter &fieldFilters, bool compressed, bool grouped, unsigned __int64 chooseNLimit);
  73. interface IIndexLookup;
  74. extern REMOTE_API IIndexLookup *createRemoteFilteredKey(SocketEndpoint &ep, const char * filename, IOutputMetaData *actual, IOutputMetaData *projected, const RowFilter &fieldFilters, unsigned __int64 chooseNLimit);
  75. // client only
  76. extern void clientSetDaliServixSocketCaching(bool set);
  77. extern void clientDisconnectRemoteFile(IFile *file);
  78. extern void clientDisconnectRemoteIoOnExit(IFileIO *fileio,bool set);
  79. extern bool clientResetFilename(IFile *file, const char *newname); // returns false if not remote
  80. extern bool clientAsyncCopyFileSection(const char *uuid, // from genUUID - must be same for subsequent calls
  81. IFile *from, // expected to be remote
  82. RemoteFilename &to,
  83. offset_t toofs, // (offset_t)-1 created file and copies to start
  84. offset_t fromofs,
  85. offset_t size, // (offset_t)-1 for all file
  86. ICopyFileProgress *progress,
  87. unsigned timeout // 0 to start, non-zero to wait
  88. ); // returns true when done
  89. extern void clientSetRemoteFileTimeouts(unsigned maxconnecttime,unsigned maxreadtime);
  90. extern void clientAddSocketToCache(SocketEndpoint &ep,ISocket *socket);
  91. #endif