[GitHub] JulianFeinauer commented on a change in pull request #26: connection manager for connection pool initial version

2018-09-30 Thread GitBox
JulianFeinauer commented on a change in pull request #26: connection manager 
for connection pool initial version
URL: https://github.com/apache/incubator-plc4x/pull/26#discussion_r221466943
 
 

 ##
 File path: 
plc4j/core/src/main/java/org/apache/plc4x/java/PlcDriverManagerInterface.java
 ##
 @@ -0,0 +1,29 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+package org.apache.plc4x.java;
+
+import org.apache.plc4x.java.api.authentication.PlcAuthentication;
+import org.apache.plc4x.java.api.connection.PlcConnection;
+import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
+
+public interface PlcDriverManagerInterface {
 
 Review comment:
   I dont like the name that much, but I see your problem (as we want to keep 
the name of the "original" PlcDriverMangager). Perhaps it is best to simply 
subclass the existing PlcDriverManager as we want to allow users to use the 
Proxy AS PlcDriverManager. So it should be:
   `PlcDriverManager manager = new ...`


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] JulianFeinauer commented on a change in pull request #26: connection manager for connection pool initial version

2018-09-30 Thread GitBox
JulianFeinauer commented on a change in pull request #26: connection manager 
for connection pool initial version
URL: https://github.com/apache/incubator-plc4x/pull/26#discussion_r221466969
 
 

 ##
 File path: 
plc4j/core/src/main/java/org/apache/plc4x/java/connectionpool/ConnectionProxy.java
 ##
 @@ -0,0 +1,24 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+package org.apache.plc4x.java.connectionpool;
+
+import org.apache.plc4x.java.api.connection.PlcConnection;
+
+public interface ConnectionProxy extends PlcConnection {
 
 Review comment:
   Do we need this? I guess not?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] JulianFeinauer commented on a change in pull request #26: connection manager for connection pool initial version

2018-09-30 Thread GitBox
JulianFeinauer commented on a change in pull request #26: connection manager 
for connection pool initial version
URL: https://github.com/apache/incubator-plc4x/pull/26#discussion_r221467015
 
 

 ##
 File path: 
plc4j/core/src/main/java/org/apache/plc4x/java/connectionpool/PlcConnectionManager.java
 ##
 @@ -0,0 +1,154 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+package org.apache.plc4x.java.connectionpool;
+
+import org.apache.plc4x.java.PlcDriverManager;
+import org.apache.plc4x.java.PlcDriverManagerInterface;
+import org.apache.plc4x.java.api.authentication.PlcAuthentication;
+import org.apache.plc4x.java.api.connection.PlcConnection;
+import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
+import org.apache.plc4x.java.exceptions.NoConnectionAvailableException;
+import org.apache.plc4x.java.exceptions.NotConnectedException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.PreDestroy;
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * Plc Connection Manager to act as a controller to give threads access to a 
connection in the pool only if it is not
+ * used by a different thread
+ */
+public class PlcConnectionManager implements PlcDriverManagerInterface {
+private static final Logger logger = 
LoggerFactory.getLogger(PlcConnectionManager.class);
+//TODO: implement connection Pool with more than one connection
+private Map connections = new HashMap<>();
 
 Review comment:
   I think we have to use a ConcurrentMap or to use locks to avoid 
ConcurrentModificationExceptions, as multiple threads could modify the list 
concurrently.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] JulianFeinauer commented on a change in pull request #26: connection manager for connection pool initial version

2018-09-30 Thread GitBox
JulianFeinauer commented on a change in pull request #26: connection manager 
for connection pool initial version
URL: https://github.com/apache/incubator-plc4x/pull/26#discussion_r221466988
 
 

 ##
 File path: 
plc4j/core/src/main/java/org/apache/plc4x/java/connectionpool/PlcConnectionManager.java
 ##
 @@ -0,0 +1,154 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+package org.apache.plc4x.java.connectionpool;
+
+import org.apache.plc4x.java.PlcDriverManager;
+import org.apache.plc4x.java.PlcDriverManagerInterface;
+import org.apache.plc4x.java.api.authentication.PlcAuthentication;
+import org.apache.plc4x.java.api.connection.PlcConnection;
+import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
+import org.apache.plc4x.java.exceptions.NoConnectionAvailableException;
+import org.apache.plc4x.java.exceptions.NotConnectedException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.PreDestroy;
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * Plc Connection Manager to act as a controller to give threads access to a 
connection in the pool only if it is not
+ * used by a different thread
+ */
+public class PlcConnectionManager implements PlcDriverManagerInterface {
 
 Review comment:
   Perhaps it is more intuitive to name the Thing PlcConnectionPool or 
something.
   And it should (as stated above) implement PlcDriverManager directly.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services