Skip to content
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

HPCC-32717 Create basic Elastic sink component #19158

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

kenrowland
Copy link
Contributor

@kenrowland kenrowland commented Sep 26, 2024

Created new skeleton component and added to the build

Signed-Off-By: Kenneth Rowland [email protected]

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Cloud-compatibility
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Smoketest:

  • Send notifications about my Pull Request position in Smoketest queue.
  • Test my draft Pull Request.

Testing:

Copy link

Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-32717

Jirabot Action Result:
Assigning user: [email protected]
Workflow Transition To: Merge Pending
Updated PR

Copy link
Member

@rpastrana rpastrana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kenrowland seems reasonable shell. Spotted a few minor issues.

@@ -0,0 +1,59 @@
/*##############################################################################
HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems®.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong date.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -0,0 +1,53 @@
/*##############################################################################
HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems®.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong date

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

#include <cstdio>
#include "platform.h"


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra new lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

// doesn't work with format-nonliteral as an error
//
#if defined(__clang__) || defined(__GNUC__)
#pragma GCC diagnostic push
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are all of these necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not included, the following build errors are generated:

In file included from /home/krowland/hpcc/src/system/metrics/sinks/elastic/elasticSink.hpp:30,
from /home/krowland/hpcc/src/system/metrics/sinks/elastic/elasticSink.cpp:14:
/home/krowland/hpcc/src/system/httplib/httplib.h: In instantiation of ‘ssize_t httplib::Stream::write_format(const char*, const Args& ...) [with Args = {int, const char*}; ssize_t = long int]’:
/home/krowland/hpcc/src/system/httplib/httplib.h:3940:61: required from here
/home/krowland/hpcc/src/system/httplib/httplib.h:3635:21: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
3635 | auto sn = snprintf(buf.data(), buf.size() - 1, fmt, args...);
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/krowland/hpcc/src/system/httplib/httplib.h:3652:19: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
3652 | snprintf(&glowable_buf[0], glowable_buf.size() - 1, fmt, args...));
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/krowland/hpcc/src/system/httplib/httplib.h: In instantiation of ‘ssize_t httplib::Stream::write_format(const char*, const Args& ...) [with Args = {const char*, const char*}; ssize_t = long int]’:
/home/krowland/hpcc/src/system/httplib/httplib.h:4805:76: required from here
/home/krowland/hpcc/src/system/httplib/httplib.h:3635:21: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
3635 | auto sn = snprintf(buf.data(), buf.size() - 1, fmt, args...);
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/krowland/hpcc/src/system/httplib/httplib.h:3652:19: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
3652 | snprintf(&glowable_buf[0], glowable_buf.size() - 1, fmt, args...));
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There is a similar error w/o the #undef for INVALID_SOCKET

@kenrowland
Copy link
Contributor Author

@ghalliday please merge

Copy link
Member

@ghalliday ghalliday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kenrowland a few minor issues to clean up.

@@ -1,5 +1,5 @@
###############################################################################
# HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems®.
# HPCC SYSTEMS software Copyright (C) 20214HPCC Systems®.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial: typo in the edit



ElasticMetricSink::ElasticMetricSink(const char *name, const IPropertyTree *pSettingsTree) :
PeriodicMetricSink(name, "file", pSettingsTree),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"file" -> "elastic"


ElasticMetricSink::ElasticMetricSink(const char *name, const IPropertyTree *pSettingsTree) :
PeriodicMetricSink(name, "file", pSettingsTree),
ignoreZeroMetrics(false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: less error prone to use a default initializer on the member definition instead.

#endif

#undef INVALID_SOCKET
#include "httplib.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these #includes needed in the header file?

The implementation should be private, and if the class implementation requires members, publish a factory method instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved #include "nlohmann/json.hpp" to the cpp file since it may not be used for a class member variable.

However, I left httplib since I currently plan on adding a protected member variable for a class defined in that header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I move forward on the next step, it looks like a protected member variable will not be the direction. The include was moved to the spp file.

~ElasticMetricSink() override = default;

protected:
void prepareToStartCollecting() override;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: The rest of the code base includes the virtual qualifier on override functions, even though it is not technically required.

@@ -0,0 +1,80 @@
/*##############################################################################
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was added by mistake - please remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, removed.

@kenrowland kenrowland force-pushed the HPCC-32717 branch 2 times, most recently from 2f4bd62 to 0112aa8 Compare October 4, 2024 12:44
@kenrowland kenrowland requested a review from ghalliday October 4, 2024 12:46
#include "jptree.hpp"
#include "jstring.hpp"

#ifdef ELASTICINK_EXPORTS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: should be ELASTICSINK_EXPORTS

This is causing the windows build error

Created new skeleton component and added to the build

Signed-Off-By: Kenneth Rowland [email protected]
@ghalliday ghalliday merged commit d75da84 into hpcc-systems:master Oct 16, 2024
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants