bbeaudreault commented on a change in pull request #3536:
URL: https://github.com/apache/hbase/pull/3536#discussion_r685945658



##########
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/BalanceRequest.java
##########
@@ -0,0 +1,96 @@
+/*
+ *
+ * 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.hadoop.hbase;
+
+import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.yetus.audience.InterfaceStability;
+
+/**
+ * Encapsulates options for executing an unscheduled run of the Balancer.
+ */
[email protected]
[email protected]
+public class BalanceRequest {
+
+  private final boolean dryRun;

Review comment:
       This may touch on a philosophical difference. I specified both fields as 
optional in the spec because in my experience on protobuf projects, that is the 
best practice. It's worth noting that `required` is removed from the syntax in 
proto3, and it seems like this was a hot topic in proto2. This stackoverflow 
answer does a good job summarizing: https://stackoverflow.com/a/31814967
   
   The tl;dr is that `required` is unnecessarily strict and limits your ability 
to have backwards compatibility. The reason the new fields are `optional` in 
the protobuf right now are clear -- There are many hbase clients out there who 
will not know about this field. If I made these fields required, you would not 
be able to rolling upgrade clients and servers because the server would throw 
an error if the field was not sent. You'd have to first upgrade clients 
followed by servers. As a user who has had to do many hbase and other database 
upgrades, it's significantly preferred to not have to stage your client and 
server upgrades in a specific order.
   
   Here's another snippet from protobuf docs:
   
   > Required Is Forever You should be very careful about marking fields as 
required. If at some point you wish to stop writing or sending a required 
field, it will be problematic to change the field to an optional field – old 
readers will consider messages without this field to be incomplete and may 
reject or drop them unintentionally. You should consider writing 
application-specific custom validation routines for your buffers instead. 
**Within Google, required fields are strongly disfavored; most messages defined 
in proto2 syntax use optional and repeated only. (Proto3 does not support 
required fields at all.)**
   
   That said, I'm not sure why the private members of this class need to 
directly mirror the protobuf. While these are specified as private final 
boolean (i prefer immutability where ever possible), the actual factory methods 
used to create the BalanceRequest do reflect the optional nature -- with the 
defaults being false.




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to