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

introduce history level auto, fixes #CAM-3444 #165

Closed

Conversation

jangalinski
Copy link
Contributor

This addresses the problem that when you configure multiple engines against one db, you have to explicitly set the right (unique) history level value, otherwise engine setup fails. WIth the new level "auto", the engine tries to guess the

  • new string constant "auto"
  • allow configuration with level "auto" to init() without choosing a historyLevel, this will be done during build() to avoid lifecycle mixup (db init ...)
  • during construction of the ProcessEngineImpl, it checks the already configured value via the OverwriteHistoryLevelCmd and overwrites auto/null with for example
    full/HistoryLevelFull.
  • afterwards, engine generation goes on as usual.
  • when auto is used for the first engine that creates the schema, the default fallback is "audit"

This addresses the problem that	    when you configure multiple engines against one	db, you	have to	explicitly set the right (unique) history level value, otherwise engine setup fails. WIth	   the new  level "auto", the engine tries to guess	the

- new string constant "auto"
- allow      configuration with level "auto"    to init() without choosing a historyLevel, this will be done during build() to avoid lifecycle mixup (db init ...)
- during construction of the ProcessEngineImpl, it checks the already configured value via the OverwriteHistoryLevelCmd and overwrites auto/null with for example \
full/HistoryLevelFull.
- afterwards, engine generation goes on as usual.
- when auto is used for the first engine that creates the schema, the default fallback is "audit"
@buildhive
Copy link

camunda BPM » camunda-bpm-platform #1545 SUCCESS
This pull request looks good
(what's this?)

import org.camunda.bpm.engine.impl.interceptor.CommandContext;


public class OverwriteHistoryLevelCmd implements Command<Void> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

After a good night sleep, I believe calling this "DetermineHistoryLevelCmd" and letting it return a history level would be more intuitive. We would still have to pass the list of available historyLevels, in case the use defined custom ones.

Its not a void command anymore, it returns the historyLevel
@buildhive
Copy link

camunda BPM » camunda-bpm-platform #1548 SUCCESS
This pull request looks good
(what's this?)

@ThorbenLindhauer
Copy link
Member

Hi Jan,

Thanks for your pull request which looks fine from a functionality point of view.

I have two more things to ask:

1: Can you please adhere to our code style and use camel case instead of underscores in method names?
2: Could you please add a test case that asserts that when no history level is set in the db and AUDIT is chosen as default, that the engine configuration's level is updated accordingly to AUDIT?

In addition, it would be great if you could submit a pull request to the docs.camunda.org repostory adding some explanation for the AUTO level. For example, it could go here: http://docs.camunda.org/7.3/guides/user-guide/#process-engine-history-and-audit-event-log-choosing-a-history-level (source: https://github.com/camunda/docs.camunda.org/blob/master/site/src/documents/guides/user-guide/chapters/01-process-engine/06-history.html.md)

Best regards,
Thorben

@ThorbenLindhauer
Copy link
Member

Hi Jan,

Here is one more thing: ;)

I think DetermineHistoryLevelCmd should fail when the database contains a not-null history level but the engine executing the command does not have this history level registered. With the current implementation, it would assume level AUDIT is correct (which then later fails when the history check is performed again). I think DetermineHistoryLevelCmd should already throw an exception at that point.

Also, have you considered making the AUTO logic part of the command SchemaOperationsProcessEngineBuild, in particular the method checkHistoryLevel? In case of AUTO, it could just react differently by setting the retrieved level for the current engine instead of throwing an exception. That would keep the history- and database-related logic in one place.

Cheers,
Thorben

* DatabaseHistoryPropertyAutoTest#usesDefaultValueAuditWhenNoValueIsConfigured() now checks if the configurations value is replaced
* moved auto-init from ProcessEngineImpl#init to SchemaOperationsProcessEngineBuild#checkHistoryLevel()
* minor: SchemaOperationsProcessEngineBuild is now Command<Void>, it returned null anyway
@jangalinski
Copy link
Contributor Author

Hi Thorben. I did some changes, please check the new commit:

  • Code Style: changed (although I would recommend to consider switching to this_is_what_the_test_does(), it is much more readable than "thisIsWhatTheTestDoes".) I am only talking about tests, of course
  • A test ensures that not only the DB value is overwritten but also the engine config is changed
  • the logic was moved to checkHistoryLevel, good idea, now everything is in one place.
  • an exception is thrown when a custom db level is not registered for the new engine

This should address your issues except documentation (will deal with that tomorrow).

@buildhive
Copy link

camunda BPM » camunda-bpm-platform #1561 SUCCESS
This pull request looks good
(what's this?)

@meyerdan
Copy link
Member

Code Style: changed (although I would recommend to consider switching to this_is_what_the_test_does(), it is much more readable than "thisIsWhatTheTestDoes".) I am only talking about tests, of course

Hi Jan,
I agree with you. Yet currently it is not done that way and we perfer keeping things consistent as much as possible. But: if you provide a pull request changing that in all the projects, we will merge it :)
For the time being we prefer working on more features and bugfixes...

@jangalinski
Copy link
Contributor Author

You mean, like this?

 find . -type f -name "*Test.java" -exec sed -r -i '/public void/ s/([a-z0-9])([A-Z])/\1_\L\2/g' {} \;

Should I really provide a PR? :-)

@meyerdan
Copy link
Member

Hi Jan,

Yes that would be great and thanks for the regular expression.

There may be some more things involved, like: when using the @Deployment annotation, the name of the deployed bpmn process is automatically determined based on the method name and things like that.

And: at the moment I am only speaking for myself. I am not sure the other guys agree.
=> If you seriously want to work on this we should open a new PR / thread.

Daniel

@jangalinski
Copy link
Contributor Author

I created https://app.camunda.com/jira/browse/CAM-4301 for further discussion. Could you perhaps fix the formatting? over and out.

@ThorbenLindhauer
Copy link
Member

Hi Jan,

I am about to merge your contribution and make some small changes.

I think about the case, where the history is set to "auto" and the level was fetched from the database. I would prefer only overriding the "historyLevel" property, not "history" in the engine config. Then, it is possible to determine later on whether an engine has been configured with AUTO or for example AUDIT. Is that fine for you?

Cheers,
Thorben

@jangalinski
Copy link
Contributor Author

Go ahead. I thought its best when those to attributes are in sync, but you have a good point too.

One more thing while you are on it: AUDIT is an implicit default value. Right now two or three locations use it to express default. It would be better to define a HISTORY_DEFAULT constant that references AUDIT, so we have an explicit default. Would be cleaner when one day FULL becomes the new default ....

@ThorbenLindhauer
Copy link
Member

Hi Jan,

Thanks for your efforts in providing this feature and incorporating my feedback. I just merged it to master: d914d46

Thanks for the remark on the default history setting. I added a constant and a method that gets the default level.

Cheers,
Thorben

@jangalinski
Copy link
Contributor Author

Nice, thanks. How do you want to continue with documentation? new PR?

@ThorbenLindhauer
Copy link
Member

Yes, a second pull request to https://github.com/camunda/docs.camunda.org would be nice. I'll keep the JIRA issue https://app.camunda.com/jira/browse/CAM-3444 open.

@jangalinski jangalinski deleted the CAM-3444_history_level_auto branch July 27, 2015 21:08
koevskinikola pushed a commit that referenced this pull request Aug 12, 2020
tasso94 pushed a commit that referenced this pull request Nov 10, 2020
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.

None yet

4 participants