From bd159cdcc8d228cfbe5750187579a87e42c2000c Mon Sep 17 00:00:00 2001 From: magicsquirrel <1748670423@qq.com> Date: Tue, 26 Jul 2022 20:56:40 +0800 Subject: [PATCH] Fixed errors --- .../controller/ConnectController.java | 26 +++++++++++++++---- .../model/connect/WorkerConnector.java | 16 ++++++++++++ .../dashboard/model/connect/WorkerInfo.java | 16 ++++++++++++ .../dashboard/model/connect/WorkerTask.java | 16 ++++++++++++ .../dashboard/service/ConnectService.java | 16 ++++++++++++ .../service/impl/ConnectServiceImpl.java | 20 +++++++++++--- .../dashboard/util/HttpRequestUtil.java | 25 ++++++++++++++++-- 7 files changed, 124 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/apache/rocketmq/dashboard/controller/ConnectController.java b/src/main/java/org/apache/rocketmq/dashboard/controller/ConnectController.java index a60f330..45511cd 100644 --- a/src/main/java/org/apache/rocketmq/dashboard/controller/ConnectController.java +++ b/src/main/java/org/apache/rocketmq/dashboard/controller/ConnectController.java @@ -1,15 +1,31 @@ +/* + * 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.rocketmq.dashboard.controller; -import org.apache.rocketmq.dashboard.model.connect.WorkerConnector; -import org.apache.rocketmq.dashboard.model.connect.WorkerInfo; -import org.apache.rocketmq.dashboard.model.connect.WorkerTask; import org.apache.rocketmq.dashboard.permisssion.Permission; import org.apache.rocketmq.dashboard.service.ConnectService; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; -import java.util.List; import java.util.Map; @Controller diff --git a/src/main/java/org/apache/rocketmq/dashboard/model/connect/WorkerConnector.java b/src/main/java/org/apache/rocketmq/dashboard/model/connect/WorkerConnector.java index 909a6b5..9270406 100644 --- a/src/main/java/org/apache/rocketmq/dashboard/model/connect/WorkerConnector.java +++ b/src/main/java/org/apache/rocketmq/dashboard/model/connect/WorkerConnector.java @@ -1,3 +1,19 @@ +/* + * 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.rocketmq.dashboard.model.connect; import java.util.Map; diff --git a/src/main/java/org/apache/rocketmq/dashboard/model/connect/WorkerInfo.java b/src/main/java/org/apache/rocketmq/dashboard/model/connect/WorkerInfo.java index f91740d..52a0f2d 100644 --- a/src/main/java/org/apache/rocketmq/dashboard/model/connect/WorkerInfo.java +++ b/src/main/java/org/apache/rocketmq/dashboard/model/connect/WorkerInfo.java @@ -1,3 +1,19 @@ +/* + * 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.rocketmq.dashboard.model.connect; import org.slf4j.Logger; diff --git a/src/main/java/org/apache/rocketmq/dashboard/model/connect/WorkerTask.java b/src/main/java/org/apache/rocketmq/dashboard/model/connect/WorkerTask.java index 0074177..53f662b 100644 --- a/src/main/java/org/apache/rocketmq/dashboard/model/connect/WorkerTask.java +++ b/src/main/java/org/apache/rocketmq/dashboard/model/connect/WorkerTask.java @@ -1,3 +1,19 @@ +/* + * 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.rocketmq.dashboard.model.connect; import java.util.Map; diff --git a/src/main/java/org/apache/rocketmq/dashboard/service/ConnectService.java b/src/main/java/org/apache/rocketmq/dashboard/service/ConnectService.java index 8e63984..cc21579 100644 --- a/src/main/java/org/apache/rocketmq/dashboard/service/ConnectService.java +++ b/src/main/java/org/apache/rocketmq/dashboard/service/ConnectService.java @@ -1,3 +1,19 @@ +/* + * 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.rocketmq.dashboard.service; diff --git a/src/main/java/org/apache/rocketmq/dashboard/service/impl/ConnectServiceImpl.java b/src/main/java/org/apache/rocketmq/dashboard/service/impl/ConnectServiceImpl.java index fe0aa66..10bc997 100644 --- a/src/main/java/org/apache/rocketmq/dashboard/service/impl/ConnectServiceImpl.java +++ b/src/main/java/org/apache/rocketmq/dashboard/service/impl/ConnectServiceImpl.java @@ -1,3 +1,19 @@ +/* + * 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.rocketmq.dashboard.service.impl; import com.alibaba.fastjson.JSON; @@ -84,10 +100,6 @@ public class ConnectServiceImpl implements ConnectService { } - public static void test1() { - System.out.println(ipAddr); - } - @Override public String getConnectorStatus(String connectorName) { return HttpRequestUtil.requestString("/connectors/" + connectorName + "/status"); diff --git a/src/main/java/org/apache/rocketmq/dashboard/util/HttpRequestUtil.java b/src/main/java/org/apache/rocketmq/dashboard/util/HttpRequestUtil.java index 0c647a7..c3dd921 100644 --- a/src/main/java/org/apache/rocketmq/dashboard/util/HttpRequestUtil.java +++ b/src/main/java/org/apache/rocketmq/dashboard/util/HttpRequestUtil.java @@ -1,3 +1,19 @@ +/* + * 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.rocketmq.dashboard.util; import com.alibaba.fastjson.JSONObject; @@ -6,7 +22,12 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -import java.io.*; +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; @@ -66,7 +87,7 @@ public class HttpRequestUtil { String state = getStringFromInputStream(is); return state; } else { - log.info("访问失败" + responseCode); + log.info("Failed to request! Code: " + responseCode); }