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

add ENABLE_DTX_INGEST_BATCH option #799

Merged
merged 5 commits into from
Apr 12, 2017

Conversation

shintasmith
Copy link
Contributor

This PR adds a new configuration option: ENABLE_DTX_INGEST_BATCH. When set to true, blueflood will use unlogged batch statements during Ingest, if CASSANDRA_DRIVER is set to datastax. The default behavior for this option is false: i.e: use individual asynch INSERT statement (not unlogged batch).

If this option is set to true, both Basic metrics and Preaggregated metrics will use unlogged batches.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 74.909% when pulling a99a312 on shintasmith:ingest_batch into af8a387 on rackerlabs:master.

@@ -38,15 +37,13 @@
private static final String TENANT2 = "987654";
private static final String TENANT3 = "123789";

protected LocatorIO locatorIO = new DLocatorIO();
protected DelayedLocatorIO delayedLocatorIO = new DDelayedLocatorIO();
protected DLocatorIO locatorIO = new DLocatorIO();
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a big fan of this change. Cant you cast locatorIO to DLocatorIO where ever you need to call getBoundStatementForLocator? Now that I think about it, I dont know which one is less bad. Nevermind then.

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 think this is ok. Only the DBasicMetricsRW class needs locatorIO and DelayedLocatorIO for its constructor. The ABasicMetricsRW class doesn't need those IO classes. (Don't ask me why, tho). 😬 Since DBasicMetricsRW is Datastax specific, it is ok to pass in Datastax specific IO classes to its constructor.

* @param metric
* @return
*/
protected boolean isDelayed(IMetric metric) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice refactoring!

BatchStatement batch = new BatchStatement(BatchStatement.Type.UNLOGGED);

for (Locator locator : map.keySet()) {
for (IMetric metric : map.get(locator)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have Instrumentation call here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I will add Instrumentation, similar to insertMetricsIndividually()

Object metricValue = metric.getMetricValue();
if (!(metricValue instanceof BluefloodSetRollup)) {
throw new InvalidDataException(
String.format("getBoundStatementForMetric(locator=%s, granularity=%s): metric value %s is not type BfSetRollup",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we write the actual type BluefloodSetRollup instead of BfSetRollup in the exception message? This comment applies to other places like counter, gauge etc as well.

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 will change that.

* @param granularity
* @return
*/
protected abstract BoundStatement getBoundStatementForMetric(IMetric metric, Granularity granularity);
Copy link
Contributor

Choose a reason for hiding this comment

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

Cant we have some default implementation here? Since each sub classes seem to have similar implementation?

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 can't think of a useful way to provide default implementation here. If you look at the implementation of this method in the sub classes, each line requires knowledge of what object (BluefloodSetRollup, BasicRollup, etc) you are operating on. I briefly thought of using generic types but decided it's not worth it.

Do you have specific suggestions?

Copy link
Contributor

@ChandraAddala ChandraAddala Apr 11, 2017

Choose a reason for hiding this comment

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

Each of the subclasses override an abstract method called getRollupType() which returns (BluefloodSetRollup, BasicRollup, etc). The getBoundStatementForMetric calls getRollupType() to get the type. I dont know if that covers all the issues.

If its too much hassle, I am fine with leaving the way it is now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But we need to use this type in a cast, like this:

serDes.serialize( (BluefloodSetRollup) metricValue ),

private IOContainer(DriverType driver, boolean isRecordingDelayedMetrics) {
private IOContainer(DriverType driver,
boolean isRecordingDelayedMetrics,
boolean isDtxIngestBatchEnabled) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change actually bothers me more than the change from LocatorIO to DLocatorIO in DBasicMetricsRWIntegrationTest. But I can't think of a better way (but still simple) way to do it.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 74.972% when pulling 7be459e on shintasmith:ingest_batch into af8a387 on rackerlabs:master.

@shintasmith shintasmith merged commit c3ca050 into rax-maas:master Apr 12, 2017
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