Reimplemented from Impala::Util::ChannelServer. Definition at line 31 of file mainFileServer.cpp. References Impala::Util::ChannelServer::AcceptRequest(), Impala::Util::ChannelServer::AllowWrite(), Impala::Util::IOBuffer::Available(), Impala::Util::ChannelServer::ConnectionDescr(), Impala::Util::Channel::DATA_BUFFER_SIZE, ILOG_DEBUG, mIoBuf, Impala::Util::IOBufferFile::Read(), Impala::Util::IOBuffer::Size(), Impala::Util::IOBufferFile::Valid(), and Impala::Util::IOBufferFile::Write(). 00032 { 00033 String curCon = ConnectionDescr(); 00034 00035 int rcBase = ChannelServer::AcceptRequest(buf, len, bufSize, conn, port); 00036 if (rcBase >= 0) 00037 return rcBase; 00038 00039 else if (strncmp(buf, "get ", 4) == 0) 00040 { 00041 00042 ILOG_DEBUG("Doing get"); 00043 String fileName(buf+4); 00044 00045 ILOG_DEBUG("name : [" << fileName << "]"); 00046 mIoBuf = new IOBufferFile(fileName, true, false); 00047 if (!mIoBuf->Valid()) 00048 { 00049 delete mIoBuf; 00050 mIoBuf = 0; 00051 sprintf(buf, "ERROR : unable to open file %s\0", 00052 fileName.c_str()); 00053 return strlen(buf)+1; 00054 } 00055 int nrToSend = Min<Int64>(Channel::DATA_BUFFER_SIZE, mIoBuf->Size()); 00056 mIoBuf->Read(buf, nrToSend); 00057 if (nrToSend != Channel::DATA_BUFFER_SIZE) 00058 { 00059 delete mIoBuf; 00060 mIoBuf = 0; 00061 } 00062 return nrToSend; 00063 } 00064 00065 else if (strncmp(buf, "getmore", 7) == 0) 00066 { 00067 00068 ILOG_DEBUG("Doing getmore"); 00069 if (mIoBuf == 0) 00070 { 00071 sprintf(buf, "ERROR : no open file\0"); 00072 return strlen(buf)+1; 00073 } 00074 int nrToSend = Min<Int64>(Channel::DATA_BUFFER_SIZE, 00075 mIoBuf->Available()); 00076 mIoBuf->Read(buf, nrToSend); 00077 if (nrToSend != Channel::DATA_BUFFER_SIZE) 00078 { 00079 delete mIoBuf; 00080 mIoBuf = 0; 00081 } 00082 return nrToSend; 00083 } 00084 00085 else if (!AllowWrite(port)) 00086 { 00087 sprintf(buf, "ERROR : permission denied\0"); 00088 return strlen(buf)+1; 00089 } 00090 00091 else if (strncmp(buf, "put ", 4) == 0) 00092 { 00093 00094 ILOG_DEBUG("Doing put"); 00095 String fileName(buf+4); 00096 00097 ILOG_DEBUG("name : [" << fileName << "]"); 00098 mIoBuf = new IOBufferFile(fileName, false, false); 00099 if (!mIoBuf->Valid()) 00100 { 00101 delete mIoBuf; 00102 mIoBuf = 0; 00103 sprintf(buf, "ERROR : unable to open file %s\0", 00104 fileName.c_str()); 00105 return strlen(buf)+1; 00106 } 00107 sprintf(buf, "OK\0"); 00108 return strlen(buf)+1; 00109 } 00110 00111 else if (strncmp(buf, "putmore", 7) == 0) 00112 { 00113 00114 ILOG_DEBUG("Doing putmore"); 00115 if (mIoBuf == 0) 00116 { 00117 sprintf(buf, "ERROR : no open file\0"); 00118 return strlen(buf)+1; 00119 } 00120 mIoBuf->Write(buf+8, len-8); 00121 if (len != Channel::DATA_BUFFER_SIZE) 00122 { 00123 delete mIoBuf; 00124 mIoBuf = 0; 00125 } 00126 sprintf(buf, "OK\0"); 00127 return strlen(buf)+1; 00128 } 00129 00130 else 00131 return -1; 00132 }
Here is the call graph for this function:
|