You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by "advancedxy (via GitHub)" <gi...@apache.org> on 2023/07/31 02:56:39 UTC
[GitHub] [incubator-uniffle] advancedxy commented on a diff in pull request #1053: [#960][part-1] feat(dashboard): Add some dashboard interfaces.
advancedxy commented on code in PR #1053:
URL: https://github.com/apache/incubator-uniffle/pull/1053#discussion_r1278702426
##########
coordinator/src/main/java/org/apache/uniffle/coordinator/web/resource/CoordinatorServerResource.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.uniffle.coordinator.web.resource;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.servlet.ServletContext;
+
+import org.apache.hbase.thirdparty.javax.ws.rs.GET;
+import org.apache.hbase.thirdparty.javax.ws.rs.Path;
+import org.apache.hbase.thirdparty.javax.ws.rs.Produces;
+import org.apache.hbase.thirdparty.javax.ws.rs.core.Context;
+import org.apache.hbase.thirdparty.javax.ws.rs.core.MediaType;
+
+import org.apache.uniffle.common.util.RssUtils;
+import org.apache.uniffle.coordinator.CoordinatorConf;
+import org.apache.uniffle.coordinator.CoordinatorServer;
+import org.apache.uniffle.coordinator.util.CoordinatorUtils;
+import org.apache.uniffle.coordinator.web.Response;
+import org.apache.uniffle.coordinator.web.vo.CoordinatorConfVO;
+
+@Produces({MediaType.APPLICATION_JSON})
+public class CoordinatorServerResource extends BaseResource {
+
+ @Context protected ServletContext servletContext;
+
+ @GET
+ @Path("/info")
+ public Response<List> getCoordinatorInfo() {
+ return execute(
+ () -> {
+ CoordinatorConf coordinatorConf = getCoordinatorServer().getCoordinatorConf();
+ Set<Map.Entry<String, Object>> allEntry = coordinatorConf.getAllEntry();
Review Comment:
I see why getAllEntry is added.
But I'd rather to defined it as `Map<String, String> getAll()`
##########
common/src/main/java/org/apache/uniffle/common/config/RssConf.java:
##########
@@ -662,6 +662,10 @@ public String toString() {
return this.settings.toString();
}
+ public Set<Map.Entry<String, Object>> getAllEntry() {
Review Comment:
Why is this needed?
##########
coordinator/src/main/java/org/apache/uniffle/coordinator/web/vo/AppInfoVO.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.uniffle.coordinator.web.vo;
+
+public class AppInfoVO {
Review Comment:
what does VO stands for? And is there any design principle for this?
##########
coordinator/src/main/java/org/apache/uniffle/coordinator/web/resource/ApplicationResource.java:
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.uniffle.coordinator.web.resource;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.servlet.ServletContext;
+
+import org.apache.hbase.thirdparty.javax.ws.rs.GET;
+import org.apache.hbase.thirdparty.javax.ws.rs.Path;
+import org.apache.hbase.thirdparty.javax.ws.rs.Produces;
+import org.apache.hbase.thirdparty.javax.ws.rs.core.Context;
+import org.apache.hbase.thirdparty.javax.ws.rs.core.MediaType;
+
+import org.apache.uniffle.coordinator.ApplicationManager;
+import org.apache.uniffle.coordinator.web.Response;
+import org.apache.uniffle.coordinator.web.vo.AppInfoVO;
+import org.apache.uniffle.coordinator.web.vo.UserAppNumVO;
+
+@Produces({MediaType.APPLICATION_JSON})
+public class ApplicationResource extends BaseResource {
Review Comment:
@slfan1989 added some related applications interface in #964 , Maybe you guys should be in sync and decide which paths to added
##########
coordinator/src/main/java/org/apache/uniffle/coordinator/web/resource/CoordinatorServerResource.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.uniffle.coordinator.web.resource;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.servlet.ServletContext;
+
+import org.apache.hbase.thirdparty.javax.ws.rs.GET;
+import org.apache.hbase.thirdparty.javax.ws.rs.Path;
+import org.apache.hbase.thirdparty.javax.ws.rs.Produces;
+import org.apache.hbase.thirdparty.javax.ws.rs.core.Context;
+import org.apache.hbase.thirdparty.javax.ws.rs.core.MediaType;
+
+import org.apache.uniffle.common.util.RssUtils;
+import org.apache.uniffle.coordinator.CoordinatorConf;
+import org.apache.uniffle.coordinator.CoordinatorServer;
+import org.apache.uniffle.coordinator.util.CoordinatorUtils;
+import org.apache.uniffle.coordinator.web.Response;
+import org.apache.uniffle.coordinator.web.vo.CoordinatorConfVO;
+
+@Produces({MediaType.APPLICATION_JSON})
+public class CoordinatorServerResource extends BaseResource {
+
+ @Context protected ServletContext servletContext;
+
+ @GET
+ @Path("/info")
Review Comment:
Seems the api route is wrong.
This is more like coordinator conf.
The L63-L65 lines are more like a info path.
##########
integration-test/common/src/test/java/org/apache/uniffle/test/ServletTest.java:
##########
@@ -61,8 +61,8 @@ public class ServletTest extends IntegrationTestBase {
private static final String URL_PREFIX = "http://127.0.0.1:12345/api/";
private static final String SINGLE_NODE_URL = URL_PREFIX + "server/nodes/%s";
private static final String NODES_URL = URL_PREFIX + "server/nodes";
- private static final String LOSTNODES_URL = URL_PREFIX + "server/nodes?status=LOST";
- private static final String UNHEALTHYNODES_URL = URL_PREFIX + "server/nodes?status=UNHEALTHY";
+ private static final String LOSTNODES_URL = URL_PREFIX + "server/nodes/LOST";
+ private static final String UNHEALTHYNODES_URL = URL_PREFIX + "server/nodes/UNHEALTHY";
Review Comment:
Like commented earlier, this would be inappropriate
##########
coordinator/src/main/java/org/apache/uniffle/coordinator/web/resource/ServerResource.java:
##########
@@ -45,33 +48,38 @@ public class ServerResource extends BaseResource {
@Context protected ServletContext servletContext;
@GET
- @Path("/nodes/{id}")
+ @Path("/{id}")
public Response<ServerNode> node(@PathParam("id") String id) {
return execute(() -> getClusterManager().getServerNodeById(id));
}
@GET
@Path("/nodes")
- public Response<List<ServerNode>> nodes(@QueryParam("status") String status) {
+ public Response<List<ServerNode>> nodes() {
+ return nodes(null);
+ }
+
+ @GET
+ @Path("/nodes/{status}")
Review Comment:
ditto
##########
coordinator/src/main/java/org/apache/uniffle/coordinator/web/resource/ServerResource.java:
##########
@@ -45,33 +48,38 @@ public class ServerResource extends BaseResource {
@Context protected ServletContext servletContext;
@GET
- @Path("/nodes/{id}")
+ @Path("/{id}")
public Response<ServerNode> node(@PathParam("id") String id) {
return execute(() -> getClusterManager().getServerNodeById(id));
}
@GET
@Path("/nodes")
- public Response<List<ServerNode>> nodes(@QueryParam("status") String status) {
+ public Response<List<ServerNode>> nodes() {
Review Comment:
I don't think this is the right REST api to add.
I think we have agreed to use `/nodes/`, '/nodes/:id` as our REST API style in the #1000
##########
common/src/main/java/org/apache/uniffle/common/web/filter/CrossFilter.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.uniffle.common.web.filter;
+
+import java.io.IOException;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.http.HttpServletResponse;
+
+@WebFilter
+public class CrossFilter implements Filter {
+
+ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
+ throws IOException, ServletException {
+ HttpServletResponse response = (HttpServletResponse) res;
+ response.setHeader("Access-Control-Allow-Origin", "*");
Review Comment:
why cors should be enabled?
##########
coordinator/src/main/java/org/apache/uniffle/coordinator/web/resource/ServerResource.java:
##########
@@ -121,6 +129,26 @@ public Response<Object> decommission(@PathParam("id") String serverId) {
});
}
+ @GET
+ @Path("/nodestatustotal")
Review Comment:
Maybe `/nodes/summary` would be better.
--
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: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org