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

Improved the feature installation logic #256

Merged
merged 1 commit into from Dec 12, 2017
Merged

Conversation

kaikreuzer
Copy link
Member

  • wait for config update when online status has changed
  • removed static methods and logger
  • proper handling of "minimal" feature
  • introduced a sync job that checks if everything is installed as expected (which serves as a retry mechanism in case of failed downloads)

fixes openhab/openhab-distro#602

Signed-off-by: Kai Kreuzer kai@openhab.org

- wait for config update when online status has changed
- removed static methods and logger
- proper handling of "minimal" feature
- introduced a sync job that checks if everything is installed as expected (which serves as a retry mechanism in case of failed downloads)

fixes openhab/openhab-distro#602

Signed-off-by: Kai Kreuzer <kai@openhab.org>
Copy link
Member

@martinvw martinvw left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution ;-) I have added some minor comments.

Btw what is the main change which actually fixes openhab/openhab-distro#602

@@ -106,14 +116,34 @@ protected void activate(final Map<String, Object> config) {
setOnlineRepoUrl();
setLegacyRepoUrl();
modified(config);
scheduler = Executors.newSingleThreadScheduledExecutor();
Copy link
Member

Choose a reason for hiding this comment

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

I would maybe initialize where I declare it, for me that feels safer.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, because it needs to be (re-)initialized upon activation and shut down on deactivation.

logger.debug("Running scheduled sync job");
try {
Dictionary<String, Object> cfg = configurationAdmin.getConfiguration(ADDONS_PID).getProperties();
Iterator<String> keysIter = Iterators.forEnumeration(cfg.keys());
Copy link
Member

Choose a reason for hiding this comment

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

:-( unfortunately this is the best way which I can also find..

@@ -302,11 +332,13 @@ private boolean setOnlineStatus(boolean status) {
if (!repoCfg.contains(online_repo_url)) {
repoCfg.add(online_repo_url);
changed = true;
logger.debug("Added repo '{}' to feature repo list.", online_repo_url);
Copy link
Member

Choose a reason for hiding this comment

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

Not new, but

online_repo_url => does not follow naming conventions.

Copy link
Member Author

Choose a reason for hiding this comment

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

right, not new.

if (installFeature(featuresService, name)) {
configChanged = true;
String fullName = PREFIX + PREFIX_PACKAGE + ((String) packageName).trim();
if (currentPackage.equals(MINIMAL_PACKAGE)) {
Copy link
Member

Choose a reason for hiding this comment

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

Position literals first in String comparisons - that way if the String is null you won't get a NullPointerException, it'll just return false. source: PMD

Copy link
Member Author

Choose a reason for hiding this comment

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

We are inside an "instanceof String" check, so we can be sure it is not null.

Copy link
Member

Choose a reason for hiding this comment

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

But is still a good habit 😜

} else {
if (installFeature(featuresService, fullName)) {
configChanged = true;
}
Copy link
Member

Choose a reason for hiding this comment

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

Should we log anything here or is that already done inside installFeature in the case of failure.

Copy link
Member Author

Choose a reason for hiding this comment

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

that's done in installFeature.

@kaikreuzer
Copy link
Member Author

@martinvw martinvw merged commit 50c01f2 into openhab:master Dec 12, 2017
@kaikreuzer kaikreuzer deleted the featint branch December 12, 2017 11:19
@kaikreuzer kaikreuzer modified the milestone: 2.2 Dec 15, 2017
@kaikreuzer kaikreuzer added the enhancement An enhancement or new feature of the Core label Dec 15, 2017
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/why-is-openhab-server-calling-openhab-jfrog-io/45372/50

Rosi2143 pushed a commit to Rosi2143/openhab-core that referenced this pull request Dec 26, 2020
Signed-off-by: Ben Clark <ben@benjyc.uk>
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 11, 2023
- wait for config update when online status has changed
- removed static methods and logger
- proper handling of "minimal" feature
- introduced a sync job that checks if everything is installed as expected (which serves as a retry mechanism in case of failed downloads)

fixes openhab/openhab-distro#602

Signed-off-by: Kai Kreuzer <kai@openhab.org>
GitOrigin-RevId: 50c01f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

First startup is not doing its job (snapshot 1104 or 1119)
3 participants