[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-13 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/drill/pull/1021


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-09 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/1021#discussion_r149997750
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileUtil.java
 ---
@@ -0,0 +1,57 @@
+/*
+ * 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.drill.exec.server.rest.profile;
+
+import org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState;
+
+import java.util.Collections;
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+
+public class ProfileUtil {
+  // Mapping query state names to display names
+  private static final Map queryStateDisplayName;
+
+  static {
+Map displayNames = Maps.newHashMap();
--- End diff --

1. Please use `Map` since you're already receiving 
`QueryState` as in parameter in method.
Besides, it would guarantee you did not make mistake writing query state 
enum names.
2. `queryStateDisplayName` -> `queryStateDisplayNames`


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-09 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/1021#discussion_r149998367
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileUtil.java
 ---
@@ -0,0 +1,57 @@
+/*
+ * 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.drill.exec.server.rest.profile;
+
+import org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState;
+
+import java.util.Collections;
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+
+public class ProfileUtil {
+  // Mapping query state names to display names
+  private static final Map queryStateDisplayName;
+
+  static {
+Map displayNames = Maps.newHashMap();
+displayNames.put("STARTING", "Starting");
+displayNames.put("RUNNING", "Running");
+displayNames.put("COMPLETED", "Succeeded");
+displayNames.put("CANCELED", "Canceled");
+displayNames.put("FAILED", "Failed");
+displayNames.put("CANCELLATION_REQUESTED", "Cancellation Requested");
+displayNames.put("ENQUEUED", "Enqueued");
+queryStateDisplayName = Collections.unmodifiableMap(displayNames);
+  }
+
+
+  /**
+   * Utility to return display name for query state
+   * @param queryState
+   * @return display string for query state
+   */
+  public final static String getQueryStateDisplayName(QueryState 
queryState) {
+String state = queryState.name();
+if (queryStateDisplayName.containsKey(state)) {
--- End diff --

This would be more optimal:
```
String state = queryStateDisplayNames.get(queryState);
if (state == null) {
   state = "Unknown State"
}
return state;
```


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-09 Thread prasadns14
Github user prasadns14 commented on a diff in the pull request:

https://github.com/apache/drill/pull/1021#discussion_r149974787
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/QueryStateDisplayName.java
 ---
@@ -0,0 +1,35 @@
+/**
+ * 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.drill.exec.server.rest.profile;
+
+import org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState;
+
+public class QueryStateDisplayName {
+  // Values should correspond to the QueryState enum in UserBitShared.proto
--- End diff --

@arina-ielchiieva 
yes, map will definitely make it to easier to visualize the mapping. 
Made the changes


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-09 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/1021#discussion_r149889024
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/QueryStateDisplayName.java
 ---
@@ -0,0 +1,35 @@
+/**
+ * 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.drill.exec.server.rest.profile;
+
+import org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState;
+
+public class QueryStateDisplayName {
+  // Values should correspond to the QueryState enum in UserBitShared.proto
--- End diff --

@prasadns14 
1. When using array you depend on enum value order. If for some reason 
value order changes, your approach will be working incorrectly.
2. Having map will show which key is mapped to which value and it will be 
much easier to understand that, for example, completed is mapped to succeeded.

I recommend you use map approach.


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-08 Thread prasadns14
Github user prasadns14 commented on a diff in the pull request:

https://github.com/apache/drill/pull/1021#discussion_r149846069
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/QueryStateDisplayName.java
 ---
@@ -0,0 +1,35 @@
+/**
+ * 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.drill.exec.server.rest.profile;
+
+import org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState;
+
+public class QueryStateDisplayName {
+  // Values should correspond to the QueryState enum in UserBitShared.proto
--- End diff --

QueryState is an enum.
I feel having an array is simple. We could use the QueryState ordinal as 
index to fetch the display name from the array. I can add a check to check for 
array index overflow, and return some default value like "Unknown state".


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-08 Thread prasadns14
Github user prasadns14 commented on a diff in the pull request:

https://github.com/apache/drill/pull/1021#discussion_r149844559
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/QueryStateDisplayName.java
 ---
@@ -0,0 +1,35 @@
+/**
+ * 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.drill.exec.server.rest.profile;
+
+import org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState;
+
+public class QueryStateDisplayName {
--- End diff --

sure will give a generic name


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-08 Thread prasadns14
Github user prasadns14 commented on a diff in the pull request:

https://github.com/apache/drill/pull/1021#discussion_r149844423
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/QueryStateDisplayName.java
 ---
@@ -0,0 +1,35 @@
+/**
--- End diff --

will fix it


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-08 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/1021#discussion_r149596833
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/QueryStateDisplayName.java
 ---
@@ -0,0 +1,35 @@
+/**
+ * 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.drill.exec.server.rest.profile;
+
+import org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState;
+
+public class QueryStateDisplayName {
--- End diff --

Let's name this class more generically since in future we might wan't add 
some other helper methods as well. 
For example, `ProfileUtil`.


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-08 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/1021#discussion_r149596974
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/QueryStateDisplayName.java
 ---
@@ -0,0 +1,35 @@
+/**
+ * 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.drill.exec.server.rest.profile;
+
+import org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState;
+
+public class QueryStateDisplayName {
+  // Values should correspond to the QueryState enum in UserBitShared.proto
--- End diff --

Not quite right, value do not correspond to QueryState enum, it's rather a 
mapping to QueryState enum. To be more clear here I suggest you create a map 
with `QueryState` as a key and `String` as value:
```
STARTING -> Starting
COMPLETED -> Succeeded
```
Thus you'll be able to get desired representation value by `QueryState` and 
in case if value is null return some default, like `Unknown State`.


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-08 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/1021#discussion_r149596636
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/QueryStateDisplayName.java
 ---
@@ -0,0 +1,35 @@
+/**
--- End diff --

Please use comment, not Java doc for header.


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-05 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/1021#discussion_r148967310
  
--- Diff: exec/java-exec/src/main/resources/rest/profile/profile.ftl ---
@@ -135,6 +135,8 @@ table.sortable thead .sorting_desc { background-image: 
url("/static/img/black-de
 
   <#assign queueName = model.getProfile().getQueueName() />
   <#assign queued = queueName != "" && queueName != "-" />
+  <#assign queryStateDisplayName = ["Starting", "Running", "Succeeded", 
"Canceled", "Failed",
--- End diff --

Prasad, maybe you can come up with different way to avoid display names 
duplication?


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-05 Thread prasadns14
Github user prasadns14 commented on a diff in the pull request:

https://github.com/apache/drill/pull/1021#discussion_r148963451
  
--- Diff: exec/java-exec/src/main/resources/rest/profile/profile.ftl ---
@@ -135,6 +135,8 @@ table.sortable thead .sorting_desc { background-image: 
url("/static/img/black-de
 
   <#assign queueName = model.getProfile().getQueueName() />
   <#assign queued = queueName != "" && queueName != "-" />
+  <#assign queryStateDisplayName = ["Starting", "Running", "Succeeded", 
"Canceled", "Failed",
--- End diff --

Yes, I could create a common freemarker function. But if the changes are 
not made in ProfileResources.java then the REST API /profile will still show 
the query state as "COMPLETED". It won't be in sync with the UI.


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-05 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/1021#discussion_r148961643
  
--- Diff: exec/java-exec/src/main/resources/rest/profile/profile.ftl ---
@@ -135,6 +135,8 @@ table.sortable thead .sorting_desc { background-image: 
url("/static/img/black-de
 
   <#assign queueName = model.getProfile().getQueueName() />
   <#assign queued = queueName != "" && queueName != "-" />
+  <#assign queryStateDisplayName = ["Starting", "Running", "Succeeded", 
"Canceled", "Failed",
--- End diff --

Maybe you can create common freemarker function which list.ftl and 
profile.ftl will use to decode the state name thus we won't duplicate display 
names and always be sure they are in sync.


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-04 Thread prasadns14
Github user prasadns14 commented on a diff in the pull request:

https://github.com/apache/drill/pull/1021#discussion_r148945878
  
--- Diff: exec/java-exec/src/main/resources/rest/profile/profile.ftl ---
@@ -135,6 +135,8 @@ table.sortable thead .sorting_desc { background-image: 
url("/static/img/black-de
 
   <#assign queueName = model.getProfile().getQueueName() />
   <#assign queued = queueName != "" && queueName != "-" />
+  <#assign queryStateDisplayName = ["Starting", "Running", "Succeeded", 
"Canceled", "Failed",
--- End diff --

Query state is displayed in two places - list.ftl (accessed via 
ProfileResources.java) and profile.ftl (accessed via QueryProfile.proto). So, I 
had to duplicate the array once in ProfileResources.java & once in profile.ftl


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-03 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/1021#discussion_r148860361
  
--- Diff: exec/java-exec/src/main/resources/rest/profile/profile.ftl ---
@@ -135,6 +135,8 @@ table.sortable thead .sorting_desc { background-image: 
url("/static/img/black-de
 
   <#assign queueName = model.getProfile().getQueueName() />
   <#assign queued = queueName != "" && queueName != "-" />
+  <#assign queryStateDisplayName = ["Starting", "Running", "Succeeded", 
"Canceled", "Failed",
--- End diff --

Why do we have need duplicated state display name array here and in 
`ProfileResources.java`. Is there a possibility to not duplicate it?


---


[GitHub] drill pull request #1021: DRILL-5923: Display name for query state

2017-11-02 Thread prasadns14
GitHub user prasadns14 opened a pull request:

https://github.com/apache/drill/pull/1021

DRILL-5923: Display name for query state

Defined display names for query state. 
@paul-rogers please review

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

$ git pull https://github.com/prasadns14/drill DRILL-5922

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

https://github.com/apache/drill/pull/1021.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 #1021


commit 39c5e18c705728a9c47b827a18f5cd44d53dde27
Author: Prasad Nagaraj Subramanya 
Date:   2017-11-02T18:36:53Z

DRILL-5923: Display name for query state




---