You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2020/09/10 17:18:18 UTC

[GitHub] [cassandra] yifan-c opened a new pull request #749: Cassandra 16057 jvm dtest nodetool stdouterr

yifan-c opened a new pull request #749:
URL: https://github.com/apache/cassandra/pull/749


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] yifan-c commented on a change in pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
yifan-c commented on a change in pull request #749:
URL: https://github.com/apache/cassandra/pull/749#discussion_r487225878



##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Done. Move it to `CapturingConsoleOutputProvider` only




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] dcapwell commented on a change in pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
dcapwell commented on a change in pull request #749:
URL: https://github.com/apache/cassandra/pull/749#discussion_r487217701



##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Can we remove closable from the interface as the only thing that closes is Instance, and it uses its own type?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] dcapwell commented on a change in pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
dcapwell commented on a change in pull request #749:
URL: https://github.com/apache/cassandra/pull/749#discussion_r487217701



##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Can we remove closable from the interface as the only thing that closes is Instance, and it uses its own type?

##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Can we remove closable from the interface as the only thing that closes is Instance, and it uses its own type?

##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Can we remove closable from the interface as the only thing that closes is Instance, and it uses its own type?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] ifesdjeen commented on a change in pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
ifesdjeen commented on a change in pull request #749:
URL: https://github.com/apache/cassandra/pull/749#discussion_r489423461



##########
File path: src/java/org/apache/cassandra/tools/NodeTool.java
##########
@@ -284,26 +286,31 @@ private static void printHistory(String... args)
 
     protected void badUse(Exception e)
     {
-        System.out.println("nodetool: " + e.getMessage());
-        System.out.println("See 'nodetool help' or 'nodetool help <command>'.");
+        consoleOutputProvider.outStream().println("nodetool: " + e.getMessage());

Review comment:
       Same here, could be just `outputProvider` (or even `output` fwiw)

##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider
+{
+    PrintStream outStream();

Review comment:
       You can even just use `out` and `err`. Wdyt?

##########
File path: src/java/org/apache/cassandra/tools/NodeProbe.java
##########
@@ -270,6 +271,21 @@ public void close() throws IOException
         }
     }
 
+    public void setConsoleOutputProvider(OutputProvider outputProvider)

Review comment:
       Can also be just `setOutputProvider`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] yifan-c commented on a change in pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
yifan-c commented on a change in pull request #749:
URL: https://github.com/apache/cassandra/pull/749#discussion_r486707867



##########
File path: src/java/org/apache/cassandra/tools/NodeTool.java
##########
@@ -405,10 +415,12 @@ private NodeProbe connect()
                     nodeClient = nodeProbeFactory.create(host, parseInt(port));
                 else
                     nodeClient = nodeProbeFactory.create(host, parseInt(port), username, password);
+
+                nodeClient.setConsoleOutputProvider(consoleOutputProvider);

Review comment:
       OK with either. I will update the create method then.  
   (mutate the ref, so the change is slightly less)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] yifan-c commented on a change in pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
yifan-c commented on a change in pull request #749:
URL: https://github.com/apache/cassandra/pull/749#discussion_r486713583



##########
File path: src/java/org/apache/cassandra/tools/NodeTool.java
##########
@@ -405,10 +415,12 @@ private NodeProbe connect()
                     nodeClient = nodeProbeFactory.create(host, parseInt(port));
                 else
                     nodeClient = nodeProbeFactory.create(host, parseInt(port), username, password);
+
+                nodeClient.setConsoleOutputProvider(consoleOutputProvider);

Review comment:
       I take it back. If also changing the `NodeProbe` constructors, it will touch other 8+ files. So I'd prefer to have a separate `setConsoleOutputProvider()` method that alters at will.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] yifan-c commented on a change in pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
yifan-c commented on a change in pull request #749:
URL: https://github.com/apache/cassandra/pull/749#discussion_r487225878



##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Done. Move it to `CapturingConsoleOutputProvider` only

##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Done. Move it to `CapturingConsoleOutputProvider` only

##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Done. Move it to `CapturingConsoleOutputProvider` only

##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Done. Move it to `CapturingConsoleOutputProvider` only

##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Done. Move it to `CapturingConsoleOutputProvider` only

##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Done. Move it to `CapturingConsoleOutputProvider` only

##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Done. Move it to `CapturingConsoleOutputProvider` only




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] yifan-c commented on a change in pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
yifan-c commented on a change in pull request #749:
URL: https://github.com/apache/cassandra/pull/749#discussion_r487225878



##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Done. Move it to `CapturingConsoleOutputProvider` only




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] yifan-c commented on a change in pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
yifan-c commented on a change in pull request #749:
URL: https://github.com/apache/cassandra/pull/749#discussion_r491093515



##########
File path: src/java/org/apache/cassandra/tools/NodeTool.java
##########
@@ -284,26 +286,31 @@ private static void printHistory(String... args)
 
     protected void badUse(Exception e)
     {
-        System.out.println("nodetool: " + e.getMessage());
-        System.out.println("See 'nodetool help' or 'nodetool help <command>'.");
+        consoleOutputProvider.outStream().println("nodetool: " + e.getMessage());

Review comment:
       sure.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] dcapwell commented on a change in pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
dcapwell commented on a change in pull request #749:
URL: https://github.com/apache/cassandra/pull/749#discussion_r486700286



##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       saw it in Instance, the usage doesn't need to be closed so you can avoid that; removing Closable will fix some of the compiler warnings as well.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] yifan-c closed pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
yifan-c closed pull request #749:
URL: https://github.com/apache/cassandra/pull/749


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] dcapwell commented on a change in pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
dcapwell commented on a change in pull request #749:
URL: https://github.com/apache/cassandra/pull/749#discussion_r487217701



##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Can we remove closable from the interface as the only thing that closes is Instance, and it uses its own type?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] yifan-c commented on a change in pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
yifan-c commented on a change in pull request #749:
URL: https://github.com/apache/cassandra/pull/749#discussion_r487225878



##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Done. Move it to `CapturingConsoleOutputProvider` only




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] dcapwell commented on a change in pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
dcapwell commented on a change in pull request #749:
URL: https://github.com/apache/cassandra/pull/749#discussion_r486689934



##########
File path: src/java/org/apache/cassandra/tools/NodeTool.java
##########
@@ -405,10 +415,12 @@ private NodeProbe connect()
                     nodeClient = nodeProbeFactory.create(host, parseInt(port));
                 else
                     nodeClient = nodeProbeFactory.create(host, parseInt(port), username, password);
+
+                nodeClient.setConsoleOutputProvider(consoleOutputProvider);

Review comment:
       rather than mutable ref, why not update the create method to take it?

##########
File path: src/java/org/apache/cassandra/tools/NodeProbe.java
##########
@@ -270,6 +272,21 @@ public void close() throws IOException
         }
     }
 
+    public void setConsoleOutputProvider(ConsoleOutputProvider consoleOutputProvider)

Review comment:
       this makes unit testing nodetool much easier!

##########
File path: src/java/org/apache/cassandra/tools/nodetool/Sjk.java
##########
@@ -143,7 +145,7 @@ else if (isListCommands())
                 {
                     for (String cmd : commands.keySet())
                     {
-                        System.out.println(String.format("%8s - %s", cmd, parser.getCommandDescription(cmd)));

Review comment:
       missing `parser.usage`, you can override it but sadly its annoying.
   
   `parser.usage();` replace with
   
   ```
   StringBuilder sb = new StringBuilder();
   parser.usage(sb);
   outStream.println(sb);
   ```
   
   and `parser.usage(cmd);` replace with 
   
   ```
   StringBuilder sb = new StringBuilder();
   parser.usage(cmd, sb);
   outStream.println(sb);
   ```

##########
File path: src/java/org/apache/cassandra/tools/nodetool/Sjk.java
##########
@@ -143,7 +145,7 @@ else if (isListCommands())
                 {
                     for (String cmd : commands.keySet())
                     {
-                        System.out.println(String.format("%8s - %s", cmd, parser.getCommandDescription(cmd)));
+                        outStream.println(String.format("%8s - %s", cmd, parser.getCommandDescription(cmd)));

Review comment:
       in the catch block for `CommandAbortedError` there are other logging commands, can replace them as well.

##########
File path: test/distributed/org/apache/cassandra/distributed/impl/Instance.java
##########
@@ -599,20 +602,61 @@ public int liveMemberCount()
     public NodeToolResult nodetoolResult(boolean withNotifications, String... commandAndArgs)
     {
         return sync(() -> {
-            DTestNodeTool nodetool = new DTestNodeTool(withNotifications);
-            int rc =  nodetool.execute(commandAndArgs);
-            return new NodeToolResult(commandAndArgs, rc, new ArrayList<>(nodetool.notifications.notifications), nodetool.latestError);
+            try (CapturingConsoleOutputProvider provider = new CapturingConsoleOutputProvider())
+            {
+                DTestNodeTool nodetool = new DTestNodeTool(withNotifications, provider);
+                int rc = nodetool.execute(commandAndArgs);
+                return new NodeToolResult(commandAndArgs, rc,
+                                          new ArrayList<>(nodetool.notifications.notifications),
+                                          nodetool.latestError,
+                                          provider.getOutString(),
+                                          provider.getErrString());
+            }
         }).call();
     }
 
+    private static class CapturingConsoleOutputProvider implements ConsoleOutputProvider
+    {
+        private final ByteArrayOutputStream outBase = new ByteArrayOutputStream();
+        private final ByteArrayOutputStream errBase = new ByteArrayOutputStream();
+        private final PrintStream out = new PrintStream(outBase, true);
+        private final PrintStream err = new PrintStream(errBase, true);
+
+        public PrintStream outStream()
+        {
+            return out;
+        }
+
+        public PrintStream errStream()
+        {
+            return err;
+        }
+
+        public String getOutString()
+        {
+            return outBase.toString();
+        }
+
+        public String getErrString()
+        {
+            return errBase.toString();
+        }
+
+        public void close()

Review comment:
       don't need to close `ByteArrayOutputStream`, here is the implementation of close http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/io/ByteArrayOutputStream.java#l267

##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       why `Closeable `?  I don't see anything closing it so this will cause compiler warnings.

##########
File path: test/distributed/org/apache/cassandra/distributed/impl/Instance.java
##########
@@ -599,20 +602,61 @@ public int liveMemberCount()
     public NodeToolResult nodetoolResult(boolean withNotifications, String... commandAndArgs)
     {
         return sync(() -> {
-            DTestNodeTool nodetool = new DTestNodeTool(withNotifications);
-            int rc =  nodetool.execute(commandAndArgs);
-            return new NodeToolResult(commandAndArgs, rc, new ArrayList<>(nodetool.notifications.notifications), nodetool.latestError);
+            try (CapturingConsoleOutputProvider provider = new CapturingConsoleOutputProvider())
+            {
+                DTestNodeTool nodetool = new DTestNodeTool(withNotifications, provider);
+                int rc = nodetool.execute(commandAndArgs);
+                return new NodeToolResult(commandAndArgs, rc,
+                                          new ArrayList<>(nodetool.notifications.notifications),
+                                          nodetool.latestError,
+                                          provider.getOutString(),
+                                          provider.getErrString());
+            }
         }).call();
     }
 
+    private static class CapturingConsoleOutputProvider implements ConsoleOutputProvider
+    {
+        private final ByteArrayOutputStream outBase = new ByteArrayOutputStream();

Review comment:
       this will cause a compiler warning, will need something like `@SuppressWarnings("resources)` to avoid




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] dcapwell commented on a change in pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
dcapwell commented on a change in pull request #749:
URL: https://github.com/apache/cassandra/pull/749#discussion_r487217701



##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Can we remove closable from the interface as the only thing that closes is Instance, and it uses its own type?

##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Can we remove closable from the interface as the only thing that closes is Instance, and it uses its own type?

##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Can we remove closable from the interface as the only thing that closes is Instance, and it uses its own type?

##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Can we remove closable from the interface as the only thing that closes is Instance, and it uses its own type?

##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.Closeable;
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider extends Closeable

Review comment:
       Can we remove closable from the interface as the only thing that closes is Instance, and it uses its own type?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] ifesdjeen commented on a change in pull request #749: CASSANDRA-16057: Should update in-jvm dtest to expose stdout and stderr for nodetool

Posted by GitBox <gi...@apache.org>.
ifesdjeen commented on a change in pull request #749:
URL: https://github.com/apache/cassandra/pull/749#discussion_r489380317



##########
File path: src/java/org/apache/cassandra/tools/ConsoleOutputProvider.java
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.cassandra.tools;
+
+import java.io.PrintStream;
+
+public interface ConsoleOutputProvider

Review comment:
       We can even call it just `OutputProvier`, given the default implementation is "console".




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org