invoked by s3_export(), need to be exception safe
| 63 | |
| 64 | // invoked by s3_export(), need to be exception safe |
| 65 | GPWriter* writer_init(const char* url_with_options, const char* format) { |
| 66 | GPWriter* writer = NULL; |
| 67 | s3extErrorMessage.clear(); |
| 68 | |
| 69 | try { |
| 70 | if (!url_with_options) { |
| 71 | return NULL; |
| 72 | } |
| 73 | |
| 74 | string urlWithOptions(url_with_options); |
| 75 | |
| 76 | S3Params params = InitConfig(urlWithOptions); |
| 77 | |
| 78 | InitRemoteLog(); |
| 79 | |
| 80 | // Prepare memory to be used for thread chunk buffer. |
| 81 | PrepareS3MemContext(params); |
| 82 | |
| 83 | string extName = params.isAutoCompress() ? string(format) + ".gz" : format; |
| 84 | writer = new GPWriter(params, extName); |
| 85 | if (writer == NULL) { |
| 86 | return NULL; |
| 87 | } |
| 88 | |
| 89 | writer->open(params); |
| 90 | return writer; |
| 91 | } catch (S3Exception& e) { |
| 92 | delete writer; |
| 93 | s3extErrorMessage = |
| 94 | "writer_init caught a " + e.getType() + " exception: " + e.getFullMessage(); |
| 95 | S3ERROR("writer_init caught %s: %s", e.getType().c_str(), s3extErrorMessage.c_str()); |
| 96 | return NULL; |
| 97 | } catch (...) { |
| 98 | delete writer; |
| 99 | S3ERROR("Caught an unexpected exception."); |
| 100 | s3extErrorMessage = "Caught an unexpected exception."; |
| 101 | return NULL; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | // invoked by s3_export(), need to be exception safe |
| 106 | bool writer_transfer_data(GPWriter* writer, char* data_buf, int data_len) { |
no test coverage detected