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

GEODE-4517: Remove CacheFactory.getAnyInstance call from CliUtil #1488

Merged
merged 2 commits into from Mar 2, 2018

Conversation

PurelyApplied
Copy link
Member

@PurelyApplied PurelyApplied commented Feb 22, 2018

Thank you for submitting a contribution to Apache Geode.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?

  • Has your PR been rebased against the latest commit within the target branch (typically develop)?

  • Is your initial contribution a single, squashed commit?

  • Does gradlew build run cleanly?

  • Have you written or updated unit tests to verify your changes?

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?

Note:

Please ensure that once the PR is submitted, you check travis-ci for build issues and
submit an update to your PR as soon as possible. If you need help, please send an
email to dev@geode.apache.org.

@PurelyApplied
Copy link
Member Author

PurelyApplied commented Feb 22, 2018

This PR is based off the HEAD of #1487

For initial review, ignore the first two commits.

#1487 has been committed and this PR subsequently rebased.

Copy link
Member

@jinmeiliao jinmeiliao left a comment

Choose a reason for hiding this comment

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

At one point I wanted to get rid of the CliUtil completely. Here are the steps I had in mind:

  1. get rid of the usage of CliUtils other than gfsh commands. I think part of your commits are doing exactly this.
    2). Since all gfsh commands extends GfshCommand, have GfshCommand do the real work, instead of having GfshCommand calling CliUtils. This way we get rid of CliUtils.
    3). Now GfshCommand needs to get ahold of cache. This is done by CommandManager, when initializing all the command, we can inject cache into each command.

@@ -45,10 +45,9 @@

private Logger logger;

private LogWrapper() {
private LogWrapper(Cache cache) {
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure why LogWrapper needs a cache instance. LogWrapper is used by gfsh logging. And on server/locators, we are solely using LogService now. Probably check with Kirk and see if we can get rid of the the usage of cache inside LogWrapper.

Copy link
Member Author

Choose a reason for hiding this comment

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

@kirklund Any insight? I looks like we're grabbing the cache's log handler so that things appear in the cache's logs? I would imagine there are places where the LogWrapper can't be replaced by the LogService.getLogger(), or else it would've been part of that initial rework.

[edit:] I think I was getting LogWrapper and LogWriter mixed up...

Copy link
Member Author

Choose a reason for hiding this comment

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

@metatype Someone mentioned elsewhere that you might have insight on how the java.util loggers and the cache's handlers interact?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we get delete LogWrapper and change GFSH code to use Log4J 2? You might want to try that in a branch and run as many tests as you can. Just change any GFSH class that uses JULI to instead get a Logger from LogService.

@PurelyApplied
Copy link
Member Author

@jinmeiliao @kirklund
I think that removing the LogWrapper is a good idea, but probably beyond the scope of this ticket. Passing the cache in to preserve behavior seems like a good idea to me until we can write some good tests surrounding logging behavior, and which point we can then remove the LogWrapper in favor of the LogService.

For what it's worth, some manual testing shows minor but probably trivial differences in replacing the LogWrapper with the LogService logger. In a locator-side GfshCommand execution, the LogWrapper includes in the logs:

open-jolly-cat.log:[info 2018/02/27 10:05:03.546 PST open-jolly-cat <RMI TCP Connection(1)-10.118.33.214> tid=0x53] (tid=83 msgId=0) PRHOMBERG testy test

where the LogService contained

bang-tender-pot.log:[info 2018/02/27 10:11:49.649 PST bang-tender-pot <RMI TCP Connection(2)-10.118.33.214> tid=0x56] PRHOMBERG testy test

I don't know what the tid and msgId info are, nevermind whether or not it is being meaningfully consumed, but there it is.

@PurelyApplied
Copy link
Member Author

Precheckin green.

* CliUtil.getCacheIfExists now takes supplier, but will squelch error and return null as before.
* LogWriter.getInstance now explicitly takes a Cache, to hook into the cache's LogWriter.
* GfshExecutionStrategy adopts the Gfsh shell's LogWriter, since the shell will necessarily have
* * finished instantiating the LogWriter's singleton before GfshExecutionStrategy can instantiate.
* In some instances, the LogWriter has been replaced with the Log4j LogService logger.
* Launcher explicitly passes a null Cache, since it does not yet exist.
* Other minor improvements: visibility, typo corrections, etc.
@PurelyApplied
Copy link
Member Author

Accidentally pushed the branch rebased on the newest develop, but no changes were made from the previous green precheckin.

@PurelyApplied PurelyApplied merged commit 7ec3956 into apache:develop Mar 2, 2018
@PurelyApplied PurelyApplied deleted the geode-4517 branch March 7, 2018 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants