[GitHub] nifi pull request #1586: NIFI-3586: Fix for retrieving ProcessID for NiFi un...

2017-04-05 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/nifi/pull/1586


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1586: NIFI-3586: Fix for retrieving ProcessID for NiFi un...

2017-04-03 Thread PuspenduBanerjee
Github user PuspenduBanerjee commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1586#discussion_r109578440
  
--- Diff: nifi-assembly/NOTICE ---
@@ -373,6 +373,11 @@ The following binary components are provided under the 
Apache Software License v
 The following NOTICE information applies:
   Apache Commons Math
   Copyright 2001-2012 The Apache Software Foundation
+  
+  (ASLv2) Java Native Access Platform
+The following NOTICE information applies:
+  Java Native Access Platform
+  Copyright 2013 Timothy Wall, Matthias Bläsing
--- End diff --

@trkurc Review needed for "Copyright 2013 Timothy Wall, Matthias Bläsing" 
part.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1586: NIFI-3586: Fix for retrieving ProcessID for NiFi un...

2017-04-03 Thread trkurc
Github user trkurc commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1586#discussion_r109559111
  
--- Diff: 
nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/util/OSUtil.java ---
@@ -0,0 +1,81 @@
+/*
+ * 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.nifi.bootstrap.util;
+
+import java.lang.reflect.Field;
+
+import org.slf4j.Logger;
+import com.sun.jna.Pointer;
+import com.sun.jna.platform.win32.Kernel32;
+import com.sun.jna.platform.win32.WinNT;
+
+/**
+ * OS specific utilities with generic method interfaces
+ */
+public final class OSUtil {
--- End diff --

If I am reading the JNA license correctly, it looks like versions after 4.0 
are ASLv2, and possibly dual licensed (lgpl and ASLv2). Per 
https://www.apache.org/legal/resolved#mutually-exclusive , it would appear just 
ASLv2 would need to be noted. And since libffi is included in JNA, and is MIT 
style, I would expect it would need to be called out as well. If you look at 
nifi-assembly, there are already many dependencies called out and listed if you 
want examples to reference


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1586: NIFI-3586: Fix for retrieving ProcessID for NiFi un...

2017-04-03 Thread PuspenduBanerjee
Github user PuspenduBanerjee commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1586#discussion_r109557567
  
--- Diff: 
nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/util/OSUtil.java ---
@@ -0,0 +1,81 @@
+/*
+ * 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.nifi.bootstrap.util;
+
+import java.lang.reflect.Field;
+
+import org.slf4j.Logger;
+import com.sun.jna.Pointer;
+import com.sun.jna.platform.win32.Kernel32;
+import com.sun.jna.platform.win32.WinNT;
+
+/**
+ * OS specific utilities with generic method interfaces
+ */
+public final class OSUtil {
--- End diff --

So, net net, I am seeing 3 Licences in play:

- ASLv2
- LGPL v2.1
- MIT [ for libffi, OpenJDK and Cassandra is already using this]
So, please enlighten me, if I really need to add any License/Notice in 
assembly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1586: NIFI-3586: Fix for retrieving ProcessID for NiFi un...

2017-04-03 Thread phrocker
Github user phrocker commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1586#discussion_r109555028
  
--- Diff: 
nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/util/OSUtil.java ---
@@ -0,0 +1,81 @@
+/*
+ * 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.nifi.bootstrap.util;
+
+import java.lang.reflect.Field;
+
+import org.slf4j.Logger;
+import com.sun.jna.Pointer;
+import com.sun.jna.platform.win32.Kernel32;
+import com.sun.jna.platform.win32.WinNT;
+
+/**
+ * OS specific utilities with generic method interfaces
+ */
+public final class OSUtil {
--- End diff --

@trkurc From what I can tell you are correct. A quick dive into 
java-native-access shows an MIT style license. Top level POM includes the 
native module, which runs an ant build ( maven-antrun-plugin in the target 
compile-native) which builds the subtree, libff -- where @trkurc saw the MIT 
license. Ant will build the native libraries through the make files, but that 
still appears bundled.  

To further verify this you can look at the jar from Maven central, which 
shows the packaged shared objects.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1586: NIFI-3586: Fix for retrieving ProcessID for NiFi un...

2017-04-03 Thread trkurc
Github user trkurc commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1586#discussion_r109322091
  
--- Diff: 
nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/util/OSUtil.java ---
@@ -0,0 +1,81 @@
+/*
+ * 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.nifi.bootstrap.util;
+
+import java.lang.reflect.Field;
+
+import org.slf4j.Logger;
+import com.sun.jna.Pointer;
+import com.sun.jna.platform.win32.Kernel32;
+import com.sun.jna.platform.win32.WinNT;
+
+/**
+ * OS specific utilities with generic method interfaces
+ */
+public final class OSUtil {
+
+private static Long getUnicesPid(final Process process, final Logger 
logger) {
+try {
+final Class procClass = process.getClass();
+final Field pidField = procClass.getDeclaredField("pid");
+pidField.setAccessible(true);
+final Object pidObject = pidField.get(process);
+
+logger.debug("PID Object = {}", pidObject);
+
+if (pidObject instanceof Number) {
+return ((Number) pidObject).longValue();
+}
+return null;
+} catch (final IllegalAccessException | NoSuchFieldException nsfe) 
{
+logger.debug("Could not find PID for child process due to {}", 
nsfe);
+return null;
+}
+}
+
+private static Long getWindowsProcessId(final Process process, final 
Logger logger) {
+/* determine the pid on windows plattforms */
+try {
+Field f = process.getClass().getDeclaredField("handle");
+f.setAccessible(true);
+long handl = f.getLong(process);
+
+Kernel32 kernel = Kernel32.INSTANCE;
+WinNT.HANDLE handle = new WinNT.HANDLE();
+handle.setPointer(Pointer.createConstant(handl));
+int ret = kernel.GetProcessId(handle);
+logger.debug("Detected pid: {}", ret);
+return Long.valueOf(ret);
+} catch (final IllegalAccessException | NoSuchFieldException nsfe) 
{
+logger.debug("Could not find PID for child process due to {}", 
nsfe);
+}
+return null;
+}
+
+public static Long getProcessId(final Process process, final Logger 
logger) {
--- End diff --

@PuspenduBanerjee - With this dependency, we'll have to put something in 
the LICENSE and NOTICE for the nifi-assembly, as it will pull this in and some 
transitive dependencies. It is ASLv2 license, but it appears it may pull in 
libffi which is a MIT style license 
(https://github.com/java-native-access/jna/tree/4.3.0/native/libffi). How they 
are building their native libs that are in their jars are not a bit challenging 
without diving in deeper than I'd like to. @phrocker may have seen a build 
process like that here: 
https://github.com/java-native-access/jna/tree/4.3.0/native and may be able to 
confirm that it is bundled in


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1586: NIFI-3586: Fix for retrieving ProcessID for NiFi un...

2017-04-03 Thread trkurc
Github user trkurc commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1586#discussion_r109320713
  
--- Diff: nifi-bootstrap/pom.xml ---
@@ -47,5 +47,10 @@ language governing permissions and limitations under the 
License. -->
 org.apache.nifi
 nifi-properties-loader
 
+
+net.java.dev.jna
+   jna-platform
+   4.3.0
--- End diff --

There is a new version of this, '4.4.0', it didn't look like it changed the 
methods you used, but it may be worth bumping it up.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1586: NIFI-3586: Fix for retrieving ProcessID for NiFi un...

2017-04-03 Thread trkurc
Github user trkurc commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1586#discussion_r109320816
  
--- Diff: 
nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/util/OSUtil.java ---
@@ -0,0 +1,81 @@
+/*
+ * 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.nifi.bootstrap.util;
+
+import java.lang.reflect.Field;
+
+import org.slf4j.Logger;
+import com.sun.jna.Pointer;
+import com.sun.jna.platform.win32.Kernel32;
+import com.sun.jna.platform.win32.WinNT;
+
+/**
+ * OS specific utilities with generic method interfaces
+ */
+public final class OSUtil {
--- End diff --

Very minor comment - other utility classes in NiFi have been suffixed with 
Utils versus "Util"


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1586: NIFI-3586: Fix for retrieving ProcessID for NiFi un...

2017-04-02 Thread trkurc
Github user trkurc commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1586#discussion_r109320687
  
--- Diff: 
nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/util/OSUtil.java ---
@@ -0,0 +1,81 @@
+/*
+ * 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.nifi.bootstrap.util;
+
+import java.lang.reflect.Field;
+
+import org.slf4j.Logger;
+import com.sun.jna.Pointer;
+import com.sun.jna.platform.win32.Kernel32;
+import com.sun.jna.platform.win32.WinNT;
+
+/**
+ * OS specific utilities with generic method interfaces
+ */
+public final class OSUtil {
+
+private static Long getUnicesPid(final Process process, final Logger 
logger) {
+try {
+final Class procClass = process.getClass();
+final Field pidField = procClass.getDeclaredField("pid");
+pidField.setAccessible(true);
+final Object pidObject = pidField.get(process);
+
+logger.debug("PID Object = {}", pidObject);
+
+if (pidObject instanceof Number) {
+return ((Number) pidObject).longValue();
+}
+return null;
+} catch (final IllegalAccessException | NoSuchFieldException nsfe) 
{
+logger.debug("Could not find PID for child process due to {}", 
nsfe);
+return null;
+}
+}
+
+private static Long getWindowsProcessId(final Process process, final 
Logger logger) {
+/* determine the pid on windows plattforms */
+try {
+Field f = process.getClass().getDeclaredField("handle");
+f.setAccessible(true);
+long handl = f.getLong(process);
+
+Kernel32 kernel = Kernel32.INSTANCE;
+WinNT.HANDLE handle = new WinNT.HANDLE();
+handle.setPointer(Pointer.createConstant(handl));
+int ret = kernel.GetProcessId(handle);
+logger.debug("Detected pid: {}", ret);
+return Long.valueOf(ret);
+} catch (final IllegalAccessException | NoSuchFieldException nsfe) 
{
+logger.debug("Could not find PID for child process due to {}", 
nsfe);
+}
+return null;
+}
+
+public static Long getProcessId(final Process process, final Logger 
logger) {
--- End diff --

I know it wasn't there before when this was a private method before, but 
I'd LOVE to see a javadoc comment to describe the contract for this method. I 
think returning null is a bit counter-intuitive


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1586: NIFI-3586: Fix for retrieving ProcessID for NiFi un...

2017-03-10 Thread PuspenduBanerjee
Github user PuspenduBanerjee commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1586#discussion_r105522726
  
--- Diff: 
nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java ---
@@ -1131,9 +1131,9 @@ public boolean accept(final File dir, final String 
filename) {
 process = builder.start();
 handleLogging(process);
 
-pid = getPid(process, defaultLogger);
+pid = OSUtil.getProcessId(process, defaultLogger);
 if (pid == null) {
-cmdLogger.info("Launched Apache NiFi but could not 
obtain the Process ID");
+cmdLogger.error("Launched Apache NiFi but could 
not obtain the Process ID");
--- End diff --

Hi @alopresto , it should be warn. good catch. I shall change in-place.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1586: NIFI-3586: Fix for retrieving ProcessID for NiFi un...

2017-03-10 Thread alopresto
Github user alopresto commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1586#discussion_r105521647
  
--- Diff: 
nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java ---
@@ -1131,9 +1131,9 @@ public boolean accept(final File dir, final String 
filename) {
 process = builder.start();
 handleLogging(process);
 
-pid = getPid(process, defaultLogger);
+pid = OSUtil.getProcessId(process, defaultLogger);
 if (pid == null) {
-cmdLogger.info("Launched Apache NiFi but could not 
obtain the Process ID");
+cmdLogger.error("Launched Apache NiFi but could 
not obtain the Process ID");
--- End diff --

Why is this at `error` level when the same message above is at `warn`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1586: NIFI-3586: Fix for retrieving ProcessID for NiFi un...

2017-03-10 Thread PuspenduBanerjee
GitHub user PuspenduBanerjee opened a pull request:

https://github.com/apache/nifi/pull/1586

NIFI-3586: Fix for retrieving ProcessID for NiFi under windows.

Thank you for submitting a contribution to Apache NiFi.

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

### For all changes:
- [X] Is there a JIRA ticket associated with this PR? Is it referenced 
 in the commit message?

- [X] Does your PR title start with NIFI- where  is the JIRA number 
you are trying to resolve? Pay particular attention to the hyphen "-" character.

- [X] Has your PR been rebased against the latest commit within the target 
branch (typically master)?

- [ ] Is your initial contribution a single, squashed commit?

### For code changes:
- [X] Have you ensured that the full suite of tests is executed via mvn 
-Pcontrib-check clean install at the root nifi folder?
- [ ] Have you written or updated unit tests to verify your changes?
- [X] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)? 
- [X] If applicable, have you updated the LICENSE file, including the main 
LICENSE file under nifi-assembly?
- [ ] If applicable, have you updated the NOTICE file, including the main 
NOTICE file found under nifi-assembly?
- [X] If adding new Properties, have you added .displayName in addition to 
.name (programmatic access) for each of the new properties?

### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in 
which it is rendered?

### 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.


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/PuspenduBanerjee/nifi NIFI-3586

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/nifi/pull/1586.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1586


commit 5bb912e111bb476fec9ccc19abb100881cf6b747
Author: Puspendu Banerjee 
Date:   2017-03-10T21:09:49Z

NIFI-3586: Fix for retrieving ProcessID for NiFi under windows.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---