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

[zoneminder] Added image channel, changed to jetty, Optimized performance #3583

Closed
wants to merge 1 commit into from

Conversation

Mr-Eskildsen
Copy link

@Mr-Eskildsen Mr-Eskildsen commented May 21, 2018

Signed-off-by: Martin Eskildsen martin@eskildsen.name (github:
Mr-Eskildsen)

ZoneMinder Binding
[zoneminder] Added Image channel to monitor
[zoneminder] Changed http client to jetty
[zoneminder] Optimized performance

JAR is available in the Eclipse IoT Marketplace, as well as here:
http://www.eskildsen.name/openHAB/zoneminder/org.openhab.binding.zoneminder-2.3.0-SNAPSHOT.jar

Signed-off-by: Martin Eskildsen <martin@eskildsen.name> (github:
Mr-Eskildsen)
@Mr-Eskildsen Mr-Eskildsen changed the title Added image channel, changed to jetty, Optimized performance [zoneminder] Added image channel, changed to jetty, Optimized performance May 21, 2018
@martinvw martinvw added this to the After 2.3 milestone May 25, 2018
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 the big update.

I added some comments, note that quite a few of them should be applied in a general way. I did not yet review the complete code but I think that I have a good view of what changed and hope that you can improve the pull request given the pointers I gave you.

If you have any questions or if you finished please ping me.

@@ -3,6 +3,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="lib" path="lib/zoneminder4j-0.9.7.jar"/>
<classpathentry kind="lib" path="lib/zoneminder4j-0.9.8.jar" sourcepath="D:/Development/Java/workspace/zoneminder4j"/>
Copy link
Member

Choose a reason for hiding this comment

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

The path looks very local to me?

<description>This binding interfaces a ZoneMinder Server</description>
<author>Martin S. Eskildsen</author>

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Copy link
Member

Choose a reason for hiding this comment

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

XML files should be formatted with tabs, like it was

@@ -0,0 +1,137 @@
<?xml version="1.0" encoding="UTF-8"?>
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 should be formatted using tabs

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
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 should formatted with tabs, note that the default openHAB setup using Eclipse should be able to do that for you , by just reformatting the file.

Copy link
Member

Choose a reason for hiding this comment

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

Please apply to all

@@ -1,20 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2010-2018 by the respective copyright holders.
Copy link
Member

Choose a reason for hiding this comment

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

Tabs

Copy link
Member

Choose a reason for hiding this comment

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

Or just remove this whole file and use DS annotations as I've done in https://github.com/openhab/openhab2-addons/pull/3382.

updateStatus(newStatus, statusDetail, statusDescription);

logger.error("{}: context='{}' state='{}' check='FAILED' - {}", getLogIdentifier(), context,
newStatus.toString(), statusDescription);
Copy link
Member

Choose a reason for hiding this comment

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

You don't have to call toString it will be called automatically, but only when the logging-level actually applies.

Please apply everywhere.

Note that this does not have to be error logging anymore because you already configured the thing status, it more likely that he will see that than that he will the error log.

return status;

} else if (config.getHost() == null) {
newStatus = ThingStatus.OFFLINE;
Copy link
Member

Choose a reason for hiding this comment

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

This method looks to have a lot of repetition, can you implement this in smarter way?

Copy link
Author

Choose a reason for hiding this comment

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

The "problem" is that I need to check every parameter, to be able to log a precise error.
All the repetetive assignments removed.


return;
}
newStatus = ThingStatus.OFFLINE;
Copy link
Member

Choose a reason for hiding this comment

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

Why OFFLINE, you are even connecting, maybe UNKNOW would be more suitable?

Copy link
Author

Choose a reason for hiding this comment

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

Nope, at that specific place I have verified that config in openHAB looks good, Now I have to verify the configuration in the ZoneMidner Server, which could also be wrong (eg. impossible to establish connection). The only way to find out is trial and error .... :-(. I will add a few comments in the code :-)

Copy link
Member

@martinvw martinvw May 30, 2018

Choose a reason for hiding this comment

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

Yes, but OFFLINE should not purely be about the connection but more about the state of the Thing to which you are connecting, so we don't know yet, but stating OFFLINE is premature.

forcedPriority = RefreshPriority.UNKNOWN;
if (updateConnection) {
try {
setConnected(false);
Copy link
Member

Choose a reason for hiding this comment

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

If this method is not a setter, which is suggested by the number of exceptions it throws, it might be better to call it disconnect. Because now it confuse me as the reader

private boolean isDirty;
private String logIdentifier = "";

private IZoneMinderEventData activeEvent = null;
Copy link
Member

Choose a reason for hiding this comment

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

These values would also be assigned here, if you left out the null

@@ -0,0 +1,300 @@
[INFO] Scanning for projects...
Copy link
Member

Choose a reason for hiding this comment

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

Remove this file.

| streamingUser | X | If 'useSpecificUserStreaming' is true, username must be specified here |
| streamingPassword | X | If 'useSpecificUserStreaming' is true, password must be specified here |

#### Monitor Configuration
Copy link
Member

Choose a reason for hiding this comment

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

Add new line after each header.


### Things configuration

#### Bridge Configuration
Copy link
Member

Choose a reason for hiding this comment

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

Add new line after each header.

| imageScale | X | Size (scale) of image. Default: 100 |


### Things file
Copy link
Member

Choose a reason for hiding this comment

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

Add new line after each header.

@@ -7,3 +7,4 @@ bin.includes = META-INF/,\
lib/,\
about.html


Copy link
Member

Choose a reason for hiding this comment

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

Please remove this unnecessary change.

logger.error(
"{}: context='fetchMonitorDaemonStatus' error in call to 'getAnalysisDaemonStatus' - Exception='{}' ",
getLogIdentifier(), zme.getClass().getCanonicalName(), zme.getCause());
} catch (Exception ex) {
Copy link
Member

Choose a reason for hiding this comment

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

Please catch specific exceptions instead of catching all exceptions. That way it is more clear what exceptions need to be handled and how this is done.

logger.error(
"{}: context='fetchMonitorDaemonStatus' error in call to 'getFrameDaemonStatus' - Exception='{}'",
getLogIdentifier(), zme.getClass().getCanonicalName(), zme.getCause());
} catch (Exception ex) {
Copy link
Member

Choose a reason for hiding this comment

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

Please catch specific exceptions instead of catching all exceptions. That way it is more clear what exceptions need to be handled and how this is done.

@@ -893,14 +1194,28 @@ public String getLogIdentifier() {

try {
if (config != null) {

result = String.format("[MONITOR-%s]", config.getZoneMinderId().toString());
}

} catch (Exception ex) {
Copy link
Member

Choose a reason for hiding this comment

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

Please catch specific exceptions instead of catching all exceptions. That way it is more clear what exceptions need to be handled and how this is done.

if (getChannelStateHandler(channelUID) != null) {
getChannelStateHandler(channelUID).subscribe();
}
} catch (Exception ex) {
Copy link
Member

Choose a reason for hiding this comment

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

Please catch specific exceptions instead of catching all exceptions. That way it is more clear what exceptions need to be handled and how this is done.

logger.debug("{}: Monitor Id: {}", getLogIdentifier(), config.getZoneMinderId());

super.initialize();
logger.info("{}: context='initialize' Monitor Handler Initialized", getLogIdentifier());
Copy link
Member

Choose a reason for hiding this comment

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

Reduce to debug.

import org.eclipse.smarthome.core.types.State;

/**
* The {@link GenericThingState} is responsible for handling commands, which are
Copy link
Member

Choose a reason for hiding this comment

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

GenericThingState? Please add an appropriate JavaDoc.

import org.eclipse.smarthome.core.types.UnDefType;

/**
* The {@link GenericThingState} is responsible for handling commands, which are
Copy link
Member

Choose a reason for hiding this comment

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

GenericThingState? Please add an appropriate JavaDoc.

import org.eclipse.smarthome.core.types.UnDefType;

/**
* The {@link GenericThingState} is responsible for handling commands, which are
Copy link
Member

Choose a reason for hiding this comment

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

GenericThingState? Please add an appropriate JavaDoc.

@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/zoneminder-binding-in-marketplace-beta/39697/31

@martinvw
Copy link
Member

@Mr-Eskildsen thanks for your contribution, do you expect to be able to wrap up this PR? Thanks for keeping us updated!

@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/zoneminder-binding-in-marketplace-beta/39697/48

@wborn wborn removed this from the 2.4 milestone Dec 19, 2018
@wborn
Copy link
Member

wborn commented Jan 25, 2019

Any plans for addressing the review comments @Mr-Eskildsen ? We've got several PRs waiting on this PR. Or is it OK with you that we merge #3382 and #4037?

@Mr-Eskildsen
Copy link
Author

Mr-Eskildsen commented Jan 25, 2019 via email

@wborn
Copy link
Member

wborn commented Jan 25, 2019

Thanks for the update! 👍 We'll then merge the other two PRs. It would be awesome if you can still find some time at a later moment to continue your great work on this PR!

@J-N-K
Copy link
Member

J-N-K commented Apr 12, 2019

Any progress here? We would like to move the binding to the bnd build system.

@davidgraeff
Copy link
Member

I'd say we close this for now. @Mr-Eskildsen maybe you can copy paste part of the this PR back to master later on and provide smaller pull requests that result in faster merges :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants