/* * Copyright (c) 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// Interface for a compression implementation. class AbstractCompressor : public CHeapObj<mtInternal> { public: virtual ~AbstractCompressor() { }
// Initializes the compressor. Returns a static error message in case of an error. // Otherwise initializes the needed out and tmp size for the given block size. virtualcharconst* init(size_t block_size, size_t* needed_out_size,
size_t* needed_tmp_size) = 0;
// Does the actual compression. Returns NULL on success and a static error // message otherwise. Sets the 'compressed_size'. virtualcharconst* compress(char* in, size_t in_size, char* out, size_t out_size, char* tmp, size_t tmp_size, size_t* compressed_size) = 0;
};
// Interface for a writer implementation. class AbstractWriter : public CHeapObj<mtInternal> { public: virtual ~AbstractWriter() { }
// Opens the writer. Returns NULL on success and a static error message otherwise. virtualcharconst* open_writer() = 0;
// Does the write. Returns NULL on success and a static error message otherwise. virtualcharconst* write_buf(char* buf, ssize_t size) = 0;
};
// A writer for a file. class FileWriter : public AbstractWriter { private: charconst* _path; bool _overwrite; int _fd;
// Return true if the list is empty. bool is_empty() { return _head._next == &_head; }
// Adds to the beginning of the list. void add_first(WriteWork* work) { insert(&_head, work); }
// Adds to the end of the list. void add_last(WriteWork* work) { insert(_head._prev, work); }
// Adds so the ids are ordered. void add_by_id(WriteWork* work);
// Returns the first element.
WriteWork* first() { return is_empty() ? NULL : _head._next; }
// Returns the last element.
WriteWork* last() { return is_empty() ? NULL : _head._prev; }
// Removes the first element. Returns NULL if empty.
WriteWork* remove_first() { return remove(first()); }
// Removes the last element. Returns NULL if empty.
WriteWork* remove_last() { return remove(first()); }
};
class Monitor;
// This class is used by the DumpWriter class. It supplies the DumpWriter with // chunks of memory to write the heap dump data into. When the DumpWriter needs a // new memory chunk, it calls get_new_buffer(), which commits the old chunk used // and returns a new chunk. The old chunk is then added to a queue to be compressed // and then written in the background. class CompressionBackend : StackObj { bool _active; charconst * _err;
int _nr_of_threads; int _works_created; bool _work_creation_failed;
public: // compressor can be NULL if no compression is used. // Takes ownership of the writer and compressor. // block_size is the buffer size of a WriteWork. // max_waste is the maximum number of bytes to leave // empty in the buffer when it is written.
CompressionBackend(AbstractWriter* writer, AbstractCompressor* compressor,
size_t block_size, size_t max_waste);
~CompressionBackend();
size_t get_written() const { return _written; }
charconst* error() const { return _err; }
// Sets up an internal buffer, fills with external buffer, and sends to compressor. void flush_external_buffer(char* buffer, size_t used, size_t max);
// Commits the old buffer (using the value in *used) and sets up a new one. void get_new_buffer(char** buffer, size_t* used, size_t* max, bool force_reset = false);
// The entry point for a worker thread. void thread_loop();
// Shuts down the backend, releasing all threads. void deactivate();
// Flush all compressed data in buffer to file void flush_buffer();
};
#endif// SHARE_SERVICES_HEAPDUMPERCOMPRESSION_HPP
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.