-
Notifications
You must be signed in to change notification settings - Fork 0
WIP: Persistent logging Implementation #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
mpirvu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few inlined comments on the code.
General observations:
- Try to follow our coding conventions regarding placement of curly brackets and indentation
- Avoid the use of
iostream. Use printf/fprintf instead - If possible, use C strings instead of std::string. If that is not possible we need to find a way to allocate backing memory for those std::string with our region allocators which is freed automatically at the end of a compilation. In general be mindful of where memory is allocated and free it as soon as possible.
|
|
||
| class BasePersistentLogger { | ||
| protected: | ||
| std::string _databaseIP; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could be marked as const because they are set in the constructor and never changed afterwards
|
|
||
|
|
||
| public: | ||
| bool connect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
connect, disconnect and logMethod should be marked virtual and override. Not required, but we prefer it that way.
|
|
||
| #include <cassandra.h> | ||
| #include "BasePersistentLogger.hpp" | ||
| class CassandraLogger : public BasePersistentLogger { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow our coding conventions and place the curly bracket on the next line, indented by 3 spaces.
| @@ -0,0 +1,200 @@ | |||
| #include <time.h> | |||
| #include <iostream> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using iostream and use printf style if at all possible.
| #include <iostream> | ||
|
|
||
| #include "CassandraLogger.hpp" | ||
| CassandraLogger::CassandraLogger(std::string const &databaseIP, std::uint32_t databasePort, std::string const &databaseName): BasePersistentLogger(databaseIP, databasePort, databaseName){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow our coding conventions regarding the curly braces
runtime/compiler/control/rossa.cpp
Outdated
| } | ||
| #if defined(PERSISTENT_LOGGING_SUPPORT) | ||
| //TODO: FIx this flag | ||
| //if(TR::Options::getCmdLineOptions()->getOption(TR_PersistLogging)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This option should be used at the client in my opinion. The server should be controlled by those -XX: options. Do we need another option?
|
|
||
| class MongoLogger : public BasePersistentLogger { | ||
| private: | ||
| Omongoc_uri_t *_uri; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These pointers need to be initialized in the constructors.
|
|
||
| MongoLogger::~MongoLogger() { | ||
| //Clean up this mongoc logger. | ||
| Omongoc_collection_destroy(_collection); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to destroy NULL pointers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is. The mongoc functions will do nothing if they receive a NULL pointer.
| std::cout << "what is the persistent logging database Name ? " << persistentLoggingDatabaseName << std::endl; | ||
|
|
||
| #ifdef CASSANDRA_LOGGER | ||
| CassandraLogger* logger = new CassandraLogger(persistentLoggingDatabaseAddress, std::persistentLoggingDatabasePort, persistentLoggingDatabaseName,persistentLoggingDatabaseUsername, persistentLoggingDatabasePassword); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new logger is created dynamically, but who destroys it? If you plan on not reusing it, then allocate it on stack rather than with new.
| #endif // CASSANDRA_LOGGER | ||
|
|
||
| #ifdef MONGO_LOGGER | ||
| MongoLogger* logger = new MongoLogger(persistentLoggingDatabaseAddress, persistentLoggingDatabasePort, persistentLoggingDatabaseName,persistentLoggingDatabaseUsername, persistentLoggingDatabasePassword); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new logger is created dynamically, but who destroys it? If you plan on not reusing it, then allocate it on stack rather than with new.
4aabc31 to
7243fad
Compare
7243fad to
565e2e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes that the strings receives as parameters continue to exist after the object is constructed.
I'll have to verify if that's the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space after first (
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this below to the next section protected by #ifdef PERSISTENT_LOGGING_SUPPORT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No iostream please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra spaces here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some alignment issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's statically allocated you don't need allocators.The space is big though, so there is a danger of stack overflow. Maybe reducing that to 256 is sufficient.
runtime/compiler/control/rossa.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is executed when jitserver boostraps. We need a master option that enables persistent logging at runtime. Getting the option from the client will not do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can use some time routines from omr. Do you need the time in a specific format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this buffer that big? Only database name is variable, so I am guessing that 256 chars is enough.
Also use snprintf to avoid buffer overflow.
565e2e8 to
54dd396
Compare
fixed namespace error retrieved method signiture a new way of retrieving method full name changed to an easier way to retrieve compiled method signature attempted to add -XX:persistentLoggingDatabasePort flag, hit segmentation fault.. added if clause for persistent logging, retrieved clientUID info fixed namespace error retrieved method signiture Attempt to add logger to openj9. make Changes and stuff Add conditionals to check for mongo and cassandra support -XX flags needed for persistent logging completed Fix an issue with my previous merge IMplement environment variable ifdef wrapper thing port initialization on different DBMS added if clause for persistent logging, retrieved clientUID info a new way of retrieving method full name changed to an easier way to retrieve compiled method signature attempted to add -XX:persistentLoggingDatabasePort flag, hit segmentation fault.. retrieved method signiture Attempt to add logger to openj9. Add conditionals to check for mongo and cassandra support -XX flags needed for persistent logging completed IMplement environment variable ifdef wrapper thing add general persistent logging support flag for checking if persistent logging is enabled regardless of dbms fix more merge conflicts I forgot Add more env variable processing Add fix that allows you to enable the cassandra logger debug TR_PersistLogging flag Bring in changes by Ida for persistentLogger spec, dynamically load mongoc library addressed code review feedback addressed code review feedback addressed code review feedback added if clause for persistent logging, retrieved clientUID info fixed namespace error retrieved method signiture a new way of retrieving method full name changed to an easier way to retrieve compiled method signature attempted to add -XX:persistentLoggingDatabasePort flag, hit segmentation fault.. added if clause for persistent logging, retrieved clientUID info fixed namespace error retrieved method signiture Attempt to add logger to openj9. make Changes and stuff Add conditionals to check for mongo and cassandra support -XX flags needed for persistent logging completed Fix an issue with my previous merge IMplement environment variable ifdef wrapper thing port initialization on different DBMS added if clause for persistent logging, retrieved clientUID info a new way of retrieving method full name changed to an easier way to retrieve compiled method signature attempted to add -XX:persistentLoggingDatabasePort flag, hit segmentation fault.. retrieved method signiture Attempt to add logger to openj9. Add conditionals to check for mongo and cassandra support -XX flags needed for persistent logging completed IMplement environment variable ifdef wrapper thing add general persistent logging support flag for checking if persistent logging is enabled regardless of dbms fix more merge conflicts I forgot Add more env variable processing Add fix that allows you to enable the cassandra logger debug TR_PersistLogging flag Bring in changes by Ida for persistentLogger spec, dynamically load mongoc library addressed code review feedback addressed code review feedback addressed code review feedback Begin conversion of mongo to c strings and reformat to code conventions re-enable flags Reformat mongologger addressed code review feedback addressed code review feedback addressed code review feedback Address Feedback. Convert to C Strings. Cleanup Mongoc Finish making c style changes Re-add client UID setter and getter in J9PersistentInfo.cpp Dynamic Load Cassandra Fist address freedback stuff made error messages consistent Convert sprintf to snprintf Convert sprintf to snprintf Remove final debug print
54dd396 to
23486ae
Compare
mpirvu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some more comments on the code
| #include "runtime/Listener.hpp" | ||
| #endif | ||
| #if defined(MONGO_LOGGER) | ||
| #include "control/LoadDBLibs.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is "control/LoadDBLibs.hpp" needed? The only thing used in this file is the declaration for JITServer::cleanupMongoC().
| int32_t xxJITServerSSLCertArgIndex = FIND_ARG_IN_VMARGS(STARTSWITH_MATCH, xxJITServerSSLCertOption, 0); | ||
| int32_t xxJITServerSSLRootCertsArgIndex = FIND_ARG_IN_VMARGS(STARTSWITH_MATCH, xxJITServerSSLRootCertsOption, 0); | ||
|
|
||
| #if defined(MONGO_LOGGER) || defined(CASSANDRA_LOGGER) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we group this big block protected by defined(MONGO_LOGGER) || defined(CASSANDRA_LOGGER) with the next block protected by the same ifdef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| int32_t xxJITServerSSLRootCertsArgIndex = FIND_ARG_IN_VMARGS(STARTSWITH_MATCH, xxJITServerSSLRootCertsOption, 0); | ||
|
|
||
| #if defined(MONGO_LOGGER) || defined(CASSANDRA_LOGGER) | ||
| const char *xxJITServerPersistentLoggingOption = "-XX:JITServerPersistentLogging="; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the meaning for the values given to this option? It appears to use an integer.
We need some comments here.
If you just wanted to turn the feature on, then we we usually use: -XX:+EnableJITServerPersistentLogging
| @@ -0,0 +1,233 @@ | |||
| // | |||
| // Created by cmbuhler on 2020-03-11. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file needs to have our standard license information
| @@ -0,0 +1,248 @@ | |||
| // | |||
| // Created by cmbuhler on 2020-03-11. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All new files need to have our standard license information
| // Check if we have the database name | ||
| if (strcmp(_databaseName,"") == 0) | ||
| { | ||
| return "jitserver_logs"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In most cases we write something into _uri_string, but in this case we don't. For uniformity I would copy the database name into the _uri_string buffer.
| struct timespec t; | ||
| clock_gettime(CLOCK_REALTIME, &t); | ||
| int64_t timestamp = t.tv_sec * INT64_C(1000) + t.tv_nsec / 1000000; | ||
| char clientIDstr[20]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may need an extra char for the terminating NULL.
| @@ -0,0 +1,36 @@ | |||
| #ifndef MONGOLOGGER_HPP | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
License information missing
| } | ||
|
|
||
| #if defined(MONGO_LOGGER) || defined(CASSANDRA_LOGGER) | ||
| // TODO: Get Flag from command line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This TODO has been implemented, hasn't it?
| _JITServerPort(38400), | ||
| #if defined(MONGO_LOGGER) || defined(CASSANDRA_LOGGER) | ||
| _JITServerPersistentLogging(false), | ||
| #if defined(CASSANDRA_LOGGER) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In JIT code defines always start at first column
No description provided.