-
Notifications
You must be signed in to change notification settings - Fork 390
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
New Implementation of the Connection-Cache #747
New Implementation of the Connection-Cache #747
Conversation
…ding the datatypes in case of raw address queries.
…read device telemetry from the PLC using MDP
…ch just contains the getConnection variants in preparation of building a drop-in replacement plc-connection cache.
…read device telemetry from the PLC using MDP - Added some more data to the example (now we have the memory usage in %)
- Mostly untested draft implementation ... tests are coming.
- Added some more tests
- Implemented the timeout for leases - Added some more tests for timeouts
- Updated the rest of the project to use the new cache and deleted the old implementations.
- Created 2 new interfaces PlcConnectionManager and PlcDriverManager - Renamed the previous PlcDriverManager to DefaultPlcDriverManager
…ection-cache-and-scraper-ng # Conflicts: # plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go # plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java
…ection-cache-and-scraper-ng # Conflicts: # plc4j/tools/opm/src/test/java/org/apache/plc4x/java/opm/PlcEntityInterceptorTest.java
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(PlcDriverManager.class); | ||
private static final Logger LOGGER = LoggerFactory.getLogger(org.apache.plc4x.java.DefaultPlcDriverManager.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static final Logger LOGGER = LoggerFactory.getLogger(org.apache.plc4x.java.DefaultPlcDriverManager.class); | |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultPlcDriverManager.class); |
* @return PlcConnection object. | ||
* @throws PlcConnectionException an exception if the connection attempt failed. | ||
*/ | ||
PlcConnection getConnection(String url, PlcAuthentication authentication) throws PlcConnectionException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrisdutz we should some day think about using the option pattern from Golang here to (the ones with the varargs options). This way we could combine the getConnection into one method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that is incompatible with the try-with-resources pattern ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least I think so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think that should be a Problem but maybe I don't see it :D
|
||
PlcConnection create() throws PlcConnectionException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should leave the create method as deprecated default implementation:
default PlcConnection create() {
return getConnectionManager().create();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What for? I mean ... we're obviously not using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it is part of the API package an might break exiting deployments from customers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's agree on not calling them "customers" as they are missing one important aspect of a typical customer relation.
I would say that "customers" have the chance to come forward and announce this would break things for them. I would consider it important to have backward compatibility once we are at 1.0.0. But I wouldn't object your proposal. Feel free to add it.
} | ||
//if (configuration.isLoadSymbolAndDataTypeTables()) { | ||
context.fireConnected(); | ||
// future.completeExceptionally(new PlcConnectionException( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the outcommmented code here an accident?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No ... it's a first step to make it possible to still connect to an ADS without loading the symbol table (if you just use raw addresses) ...
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
</project> | |
</project> | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seriously? Not willing to do a discussion on the usage of new-lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -27,7 +27,7 @@ | |||
</encoder> | |||
</appender> | |||
|
|||
<root level="error"> | |||
<root level="info"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<root level="info"> | |
<root level="error"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using the logging to output information on INFO level ... what good would the application be, if we set the log level to Error and just stripped all usable output? If yes, then you should have suggested a logger entry to explicitly set the log level of the application to info, but this change doesn't make any sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of months back I turned them all up to error as we just exceeded the logoutput because of the size of our build. Those changes where all in the test-logback.xml. Just noticed that this is the main logback file so that should be fine so nvm
|
||
public PlcConnection getConnection(String url) throws PlcConnectionException { | ||
ConnectionContainer connectionContainer; | ||
synchronized (connectionContainers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an alternative here might be the use of the ConcurrentHashMap
*/ | ||
@Test | ||
public void testSingleConnectionRequestTest() throws PlcConnectionException { | ||
PlcConnectionManager mockConnectionManager = Mockito.mock(PlcConnectionManager.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also the Mockito Annotation which is pretty cool to use
<root level="error"> | ||
<logger name="org.apache.plc4x.java.utils.cache" level="debug"/> | ||
|
||
<root level="info"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<root level="info"> | |
<root level="error"> |
@@ -27,7 +27,9 @@ | |||
</encoder> | |||
</appender> | |||
|
|||
<root level="error"> | |||
<logger name="org.apache.plc4x.java.utils.cache" level="debug"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<logger name="org.apache.plc4x.java.utils.cache" level="debug"/> | |
<logger name="org.apache.plc4x.java.utils.cache" level="error"/> |
</dependency> | ||
</dependencies> | ||
|
||
</project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
</project> | |
</project> | |
<artifactId>plc4j-connection-cache</artifactId> | ||
<version>0.11.0-SNAPSHOT</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
</project> | |
</project> | |
<description>Utility to efficiently collect a large number of items on multiple devices by different triggers.</description> | ||
|
||
<dependencies> | ||
<!--Jackson--> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe remove those outcommented deps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some suggestions which should be easy to apply
…ection-cache-and-scraper-ng
…ection-cache-and-scraper-ng
New-implementation of the Connection Cache and removal of both the old connection-cache as well as the connection-pool.
In addition some types in the API module were updated: