sockfile.hpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. #define RFEnoerror 0
  23. enum ThrottleClass
  24. {
  25. ThrottleStd,
  26. ThrottleSlow,
  27. ThrottleClassMax
  28. };
  29. // RemoteFileServer throttling defaults
  30. #define DEFAULT_THREADLIMIT 100
  31. #define DEFAULT_THREADLIMITDELAYMS (60*1000)
  32. #define DEFAULT_ASYNCCOPYMAX 10
  33. #define DEFAULT_STDCMD_PARALLELREQUESTLIMIT 80
  34. #define DEFAULT_STDCMD_THROTTLEDELAYMS 1000
  35. #define DEFAULT_STDCMD_THROTTLECPULIMIT 85
  36. #define DEFAULT_STDCMD_THROTTLEQUEUELIMIT 1000
  37. #define DEFAULT_SLOWCMD_PARALLELREQUESTLIMIT 20
  38. #define DEFAULT_SLOWCMD_THROTTLEDELAYMS 5000
  39. #define DEFAULT_SLOWCMD_THROTTLECPULIMIT 75
  40. #define DEFAULT_SLOWCMD_THROTTLEQUEUELIMIT 1000
  41. interface IRemoteFileServer : extends IInterface
  42. {
  43. virtual void run(SocketEndpoint &listenep, bool useSSL = false) = 0;
  44. virtual void stop() = 0;
  45. virtual unsigned idleTime() = 0; // in ms
  46. virtual void setThrottle(ThrottleClass throttleClass, unsigned limit, unsigned delayMs=DEFAULT_STDCMD_THROTTLEDELAYMS, unsigned cpuThreshold=DEFAULT_STDCMD_THROTTLECPULIMIT, unsigned queueLimit=DEFAULT_STDCMD_THROTTLEQUEUELIMIT) = 0;
  47. virtual StringBuffer &getStats(StringBuffer &stats, bool reset) = 0;
  48. };
  49. #define FILESRV_VERSION 19 // don't forget VERSTRING in sockfile.cpp
  50. extern REMOTE_API IFile * createRemoteFile(SocketEndpoint &ep,const char * _filename); // takes ownershop of socket
  51. extern REMOTE_API unsigned getRemoteVersion(ISocket * _socket, StringBuffer &ver);
  52. extern REMOTE_API unsigned stopRemoteServer(ISocket * _socket);
  53. extern REMOTE_API const char *remoteServerVersionString();
  54. extern REMOTE_API IRemoteFileServer * createRemoteFileServer(unsigned maxThreads=DEFAULT_THREADLIMIT, unsigned maxThreadsDelayMs=DEFAULT_THREADLIMITDELAYMS, unsigned maxAsyncCopy=DEFAULT_ASYNCCOPYMAX);
  55. extern REMOTE_API int setDafsTrace(ISocket * socket,byte flags);
  56. extern REMOTE_API int setDafsThrottleLimit(ISocket * socket, ThrottleClass throttleClass, unsigned throttleLimit, unsigned throttleDelayMs, unsigned throttleCPULimit, unsigned queueLimit, StringBuffer *errMsg=NULL);
  57. extern REMOTE_API bool enableDafsAuthentication(bool on);
  58. extern int remoteExec(ISocket * socket, const char *cmdline, const char *workdir,bool sync,
  59. size32_t insize, void *inbuf, MemoryBuffer *outbuf);
  60. extern void remoteExtractBlobElements(const SocketEndpoint &ep, const char * prefix, const char * filename, ExtractedBlobArray & extracted);
  61. extern int getDafsInfo(ISocket * socket, unsigned level, StringBuffer &retstr);
  62. extern void setDafsEndpointPort(SocketEndpoint &ep);
  63. extern void setDafsLocalMountRedirect(const IpAddress &ip,const char *dir,const char *mountdir);
  64. // client only
  65. extern void clientSetDaliServixSocketCaching(bool set);
  66. extern void clientDisconnectRemoteFile(IFile *file);
  67. extern void clientDisconnectRemoteIoOnExit(IFileIO *fileio,bool set);
  68. extern bool clientResetFilename(IFile *file, const char *newname); // returns false if not remote
  69. extern bool clientAsyncCopyFileSection(const char *uuid, // from genUUID - must be same for subsequent calls
  70. IFile *from, // expected to be remote
  71. RemoteFilename &to,
  72. offset_t toofs, // (offset_t)-1 created file and copies to start
  73. offset_t fromofs,
  74. offset_t size, // (offset_t)-1 for all file
  75. ICopyFileProgress *progress,
  76. unsigned timeout // 0 to start, non-zero to wait
  77. ); // returns true when done
  78. extern void clientSetRemoteFileTimeouts(unsigned maxconnecttime,unsigned maxreadtime);
  79. extern void clientAddSocketToCache(SocketEndpoint &ep,ISocket *socket);
  80. #endif