From ad921826a735181e879938de671bee621c4c0b24 Mon Sep 17 00:00:00 2001 From: iamazy <1448588084@qq.com> Date: Mon, 7 Dec 2020 18:23:45 +0800 Subject: [PATCH 1/7] =?UTF-8?q?Command=E7=B1=BBoverwrite=E7=88=B6=E7=B1=BB?= =?UTF-8?q?=E7=9A=84add,update,delete=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joyqueue/api/Impl/OpenAPIServiceImpl.java | 2 +- .../nsr/PartitionGroupServerService.java | 3 + .../impl/PartitionGroupServerServiceImpl.java | 13 ++ .../org/joyqueue/service/TopicService.java | 8 +- .../service/impl/ApplicationServiceImpl.java | 6 + .../service/impl/TopicServiceImpl.java | 9 +- .../src/views/monitor/consumerConfigForm.vue | 4 +- .../joyqueue-portal/src/views/topic/index.vue | 18 ++- .../src/main/resources/routing.xml | 4 +- .../handler/routing/aspect/OperLogAspect.java | 140 ------------------ .../application/ApplicationCommand.java | 22 ++- .../application/ApplicationUserCommand.java | 8 + .../application/SyncApplicationCommand.java | 16 +- .../routing/command/broker/BrokerCommand.java | 18 ++- .../command/broker/BrokerGroupCommand.java | 22 ++- .../routing/command/chart/MetricCommand.java | 9 +- .../routing/command/config/ConfigCommand.java | 17 ++- .../command/config/DataCenterCommand.java | 15 +- .../command/monitor/ConsumerCommand.java | 8 +- .../command/monitor/ProducerCommand.java | 29 +++- .../ProducerConfigAddOrUpdateCommand.java | 66 --------- .../command/topic/NamespaceCommand.java | 23 +++ .../topic/PartitionGroupReplicaCommand.java | 8 + .../routing/command/topic/TopicCommand.java | 19 ++- .../topic/TopicPartitionGroupCommand.java | 15 ++ .../routing/command/user/UserCommand.java | 10 +- .../services/com.jd.laf.web.vertx.Command | 1 - .../broker/consumer/ConsumeManager.java | 2 +- 28 files changed, 257 insertions(+), 258 deletions(-) delete mode 100644 joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/aspect/OperLogAspect.java delete mode 100644 joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ProducerConfigAddOrUpdateCommand.java diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/api/Impl/OpenAPIServiceImpl.java b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/api/Impl/OpenAPIServiceImpl.java index b29a671a6..811826bf3 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/api/Impl/OpenAPIServiceImpl.java +++ b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/api/Impl/OpenAPIServiceImpl.java @@ -335,7 +335,7 @@ public Topic createTopic(Topic topic, List select, Identity operator) th //计算总数 topic.setPartitions(topic.getPartitions() * select.size()); topic.setBrokers(select); - topicService.addWithBrokerGroup(topic, topic.getBrokerGroup(), topic.getBrokers(), operator); + topicService.addWithBrokerGroup(topic); return topicService.findById(topic.getId()); } @Override diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/nsr/PartitionGroupServerService.java b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/nsr/PartitionGroupServerService.java index 7cc33c63b..baf392f44 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/nsr/PartitionGroupServerService.java +++ b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/nsr/PartitionGroupServerService.java @@ -15,6 +15,7 @@ */ package org.joyqueue.nsr; +import org.joyqueue.domain.Replica; import org.joyqueue.model.domain.TopicPartitionGroup; import java.util.List; @@ -27,4 +28,6 @@ public interface PartitionGroupServerService extends NsrService findByTopic(String topic,String namespace); TopicPartitionGroup findByTopicAndGroup(String namespace, String topic, Integer groupNo); + + List getByBrokerId(Integer brokerId); } diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/nsr/impl/PartitionGroupServerServiceImpl.java b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/nsr/impl/PartitionGroupServerServiceImpl.java index 603f6d6ce..8c405471c 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/nsr/impl/PartitionGroupServerServiceImpl.java +++ b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/nsr/impl/PartitionGroupServerServiceImpl.java @@ -18,11 +18,13 @@ import com.alibaba.fastjson.JSON; import org.joyqueue.convert.NsrPartitionGroupConverter; import org.joyqueue.domain.PartitionGroup; +import org.joyqueue.domain.Replica; import org.joyqueue.model.domain.OperLog; import org.joyqueue.model.domain.TopicPartitionGroup; import org.joyqueue.nsr.NameServerBase; import org.joyqueue.nsr.PartitionGroupServerService; import org.joyqueue.nsr.model.PartitionGroupQuery; +import org.joyqueue.nsr.model.ReplicaQuery; import org.springframework.stereotype.Service; import java.util.List; @@ -39,6 +41,8 @@ public class PartitionGroupServerServiceImpl extends NameServerBase implements P public static final String GETBYID_PARTITIONGROUP="/partitiongroup/getById"; public static final String GETBYTOPIC_PARTITIONGROUP="/partitiongroup/getByTopic"; public static final String GETBYTOPICANDGROUP_PARTITIONGROUP="/partitiongroup/getByTopicAndGroup"; + public static final String POSTBY_REPLICA_BROKER = "/replica/getByBroker"; + private NsrPartitionGroupConverter nsrPartitionGroupConverter = new NsrPartitionGroupConverter(); @Override @@ -91,4 +95,13 @@ public List findByTopic(String topic, String namespace) { List partitionGroups = JSON.parseArray(result, PartitionGroup.class); return partitionGroups.stream().map(partitionGroup -> nsrPartitionGroupConverter.revert(partitionGroup)).collect(Collectors.toList()); } + + @Override + public List getByBrokerId(Integer brokerId) { + ReplicaQuery replicaQuery = new ReplicaQuery(); + replicaQuery.setBrokerId(brokerId); + String result = post(POSTBY_REPLICA_BROKER, replicaQuery); + List replicas = JSON.parseArray(result, Replica.class); + return null; + } } diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/TopicService.java b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/TopicService.java index 4d0e1931a..de3000dfd 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/TopicService.java +++ b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/TopicService.java @@ -19,9 +19,6 @@ import org.joyqueue.model.PageResult; import org.joyqueue.model.QPageQuery; import org.joyqueue.model.domain.AppUnsubscribedTopic; -import org.joyqueue.model.domain.Broker; -import org.joyqueue.model.domain.BrokerGroup; -import org.joyqueue.model.domain.Identity; import org.joyqueue.model.domain.Topic; import org.joyqueue.model.query.QTopic; import org.joyqueue.nsr.NsrService; @@ -38,11 +35,8 @@ public interface TopicService extends NsrService { /** * 保存:带分组和Broker信息 * @param topic - * @param brokerGroup - * @param brokers - * @param operator 操作人 */ - void addWithBrokerGroup(Topic topic, BrokerGroup brokerGroup, List brokers, Identity operator); + void addWithBrokerGroup(Topic topic); /** * 查询未订阅的topics diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/ApplicationServiceImpl.java b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/ApplicationServiceImpl.java index 271b43eca..eac98311b 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/ApplicationServiceImpl.java +++ b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/ApplicationServiceImpl.java @@ -116,6 +116,12 @@ public int delete(final Application app) { return super.delete(app); } + @Override + @Transactional(propagation = Propagation.REQUIRED, readOnly = false) + public int update(Application model) { + return super.update(model); + } + @Override public Application findByCode(final String code) { if (code == null || code.isEmpty()) { diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/TopicServiceImpl.java b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/TopicServiceImpl.java index 82e0fcb40..4f003faa0 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/TopicServiceImpl.java +++ b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/TopicServiceImpl.java @@ -25,9 +25,7 @@ import org.joyqueue.model.QPageQuery; import org.joyqueue.model.domain.AppUnsubscribedTopic; import org.joyqueue.model.domain.Broker; -import org.joyqueue.model.domain.BrokerGroup; import org.joyqueue.model.domain.Consumer; -import org.joyqueue.model.domain.Identity; import org.joyqueue.model.domain.Namespace; import org.joyqueue.model.domain.PartitionGroupReplica; import org.joyqueue.model.domain.Topic; @@ -74,13 +72,16 @@ public class TopicServiceImpl implements TopicService { @Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false) - public void addWithBrokerGroup(Topic topic, BrokerGroup brokerGroup, List brokers, Identity operator) { + public void addWithBrokerGroup(Topic topic) { Namespace namespace = topic.getNamespace(); Topic oldTopic = findByCode(namespace == null?null:namespace.getCode(),topic.getCode()); if (oldTopic != null) { throw new DuplicateKeyException("topic aleady exist"); } - + List brokers = topic.getBrokers(); + if (brokers == null) { + brokers = new ArrayList<>(); + } if (EnvironmentUtil.isTest()) { topic.setElectType(TopicPartitionGroup.ElectType.fix.type()); brokers = Lists.newArrayList(brokers.get(0)); diff --git a/joyqueue-console/joyqueue-portal/src/views/monitor/consumerConfigForm.vue b/joyqueue-console/joyqueue-portal/src/views/monitor/consumerConfigForm.vue index 569ed1d4d..41d49e77f 100644 --- a/joyqueue-console/joyqueue-portal/src/views/monitor/consumerConfigForm.vue +++ b/joyqueue-console/joyqueue-portal/src/views/monitor/consumerConfigForm.vue @@ -203,9 +203,9 @@ export default { type: 'number', trigger: 'change', min: 1, - max: 1000, + max: 100, adminMax: 30000, - hint: '批量大小范围为1~1000', + hint: '批量大小范围为1~100', adminHint: '批量大小范围为1~30000', required: false } diff --git a/joyqueue-console/joyqueue-portal/src/views/topic/index.vue b/joyqueue-console/joyqueue-portal/src/views/topic/index.vue index 5378c85f7..22c51f3d8 100644 --- a/joyqueue-console/joyqueue-portal/src/views/topic/index.vue +++ b/joyqueue-console/joyqueue-portal/src/views/topic/index.vue @@ -247,7 +247,11 @@ export default { for (let policy in this.policies) { if (this.policies.hasOwnProperty(policy)) { if (this.policies[policy].key === 'storeMaxTime') { - this.topic.policy[this.policies[policy].key] = this.policies[policy].value * (1000 * 60 * 60) + if (this.policies[policy].value) { + this.topic.policy[this.policies[policy].key] = this.policies[policy].value * (1000 * 60 * 60) + } else { + this.topic.policy[this.policies[policy].key] = undefined + } } else { this.topic.policy[this.policies[policy].key] = this.policies[policy].value } @@ -256,9 +260,7 @@ export default { apiRequest.put(this.urlOrigin.edit + '/' + encodeURIComponent(this.topic.id), {}, this.topic).then((data) => { this.policyDialog.visible = false if (data.code === 200) { - this.$Dialog.success({ - content: '更新成功' - }) + this.$Message.info('更新成功') } this.getList() this.policies = undefined @@ -277,11 +279,13 @@ export default { this.topic.policy = {} } this.policies.push({ - key: '存储最长时间', - value: item.policy.storeMaxTime / (1000 * 60 * 60) + key: 'storeMaxTime', + txt: '存储最长时间(h)', + value: item.policy.storeMaxTime !== undefined ? item.policy.storeMaxTime / (1000 * 60 * 60) : undefined }) this.policies.push({ - key: '保留未消费数据', + key: 'storeCleanKeepUnconsumed', + txt: '保留未消费数据', value: item.policy.storeCleanKeepUnconsumed }) for (let policy in this.policy) { diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-application/src/main/resources/routing.xml b/joyqueue-console/joyqueue-web/joyqueue-web-application/src/main/resources/routing.xml index 71da37473..ea7a2ccf9 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-application/src/main/resources/routing.xml +++ b/joyqueue-console/joyqueue-web/joyqueue-web-application/src/main/resources/routing.xml @@ -320,7 +320,7 @@ @@ -487,7 +487,7 @@ errors="error"/> - * Licensed 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.joyqueue.handler.routing.aspect; - -import com.alibaba.fastjson.JSON; -import com.jd.laf.web.vertx.annotation.Path; -import org.apache.commons.lang3.StringUtils; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.reflect.MethodSignature; -import org.joyqueue.context.GlobalApplicationContext; -import org.joyqueue.handler.routing.command.NsrCommandSupport; -import org.joyqueue.handler.routing.command.application.ApplicationTokenCommand; -import org.joyqueue.handler.routing.command.broker.BrokerCommand; -import org.joyqueue.handler.routing.command.config.ConfigCommand; -import org.joyqueue.handler.routing.command.config.DataCenterCommand; -import org.joyqueue.handler.routing.command.monitor.ConsumerCommand; -import org.joyqueue.handler.routing.command.monitor.ProducerCommand; -import org.joyqueue.handler.routing.command.topic.NamespaceCommand; -import org.joyqueue.handler.routing.command.topic.PartitionGroupReplicaCommand; -import org.joyqueue.handler.routing.command.topic.TopicCommand; -import org.joyqueue.handler.routing.command.topic.TopicPartitionGroupCommand; -import org.joyqueue.model.domain.Identity; -import org.joyqueue.model.domain.OperLog; -import org.joyqueue.nsr.NsrServiceProvider; -import com.jd.laf.web.vertx.response.Response; -import org.joyqueue.service.OperLogService; -import org.joyqueue.util.LocalSession; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Arrays; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - - -/** - * @author jiangnan53 - * @date 2020/6/2 - **/ -@Aspect -public class OperLogAspect { - - private static final Logger logger = LoggerFactory.getLogger(OperLogAspect.class); - - private final Set> exceptCommandClasses = new HashSet<>( - Arrays.asList(TopicCommand.class, NamespaceCommand.class, ConsumerCommand.class, - ProducerCommand.class, ApplicationTokenCommand.class, BrokerCommand.class, - TopicPartitionGroupCommand.class, PartitionGroupReplicaCommand.class, - ConfigCommand.class, DataCenterCommand.class, NsrCommandSupport.class) - ); - - @Around("@annotation(com.jd.laf.web.vertx.annotation.Path)") - public Object around(ProceedingJoinPoint joinPoint) throws Throwable { - Object result = joinPoint.proceed(); - if (result instanceof Response) { - Response response = (Response) result; - Class clazz = joinPoint.getSignature().getDeclaringType(); - if (response.getCode() == 200 && !exceptCommandClasses.contains(clazz)) { - MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); - Path path = methodSignature.getMethod().getAnnotation(Path.class); - int operType = -1; - if (StringUtils.containsIgnoreCase(path.value(), "add")) { - operType = OperLog.OperType.ADD.value(); - } else if (StringUtils.containsIgnoreCase(path.value(), "delete")) { - operType = OperLog.OperType.DELETE.value(); - } else if (StringUtils.containsIgnoreCase(path.value(), "update")) { - operType = OperLog.OperType.UPDATE.value(); - } - if (operType >= 1 && operType <= 3) { - addOperLog(clazz.getSimpleName(), path.value(), joinPoint.getArgs(), operType); - } - } - } - return result; - } - - private void addOperLog(String className, String pathValue, Object[] args, int operType) { - OperLog operLog = null; - StringBuilder target = new StringBuilder(); - //组装数据 - try { - //记录操作日志 - operLog = new OperLog(); - operLog.setType(0); - operLog.setOperType(operType); - NsrServiceProvider nsrServiceProvider = GlobalApplicationContext.getBean(NsrServiceProvider.class); - target.append(nsrServiceProvider.getBaseUrl()).append(",") - .append("class#").append(className).append(",") - .append("path#").append(pathValue).append(",") - .append(JSON.toJSONString(args)); - } catch (Exception e) { - target.append(",").append(e.getMessage()); - logger.error("post exception", e); - throw new RuntimeException("post exception", e); - } finally { - //执行记录日志 - try { - //最长200 - String targetStr = target.toString(); - if (targetStr.length() > 500) { - targetStr = targetStr.substring(0, 490); - } - - if (LocalSession.getSession() != null && LocalSession.getSession().getUser() != null) { - Long id = LocalSession.getSession().getUser().getId(); - operLog.setUpdateBy(new Identity(id)); - operLog.setCreateBy(new Identity(id)); - } else { - operLog.setUpdateBy(new Identity(0L)); - operLog.setCreateBy(new Identity(0L)); - } - operLog.setCreateTime(new Date()); - operLog.setIdentity(className.replace("Command", "")); - operLog.setTarget(targetStr); - OperLogService operLogService = GlobalApplicationContext.getBean(OperLogService.class); - operLogService.add(operLog); - } catch (Exception e) { - logger.error("operLogService add", e); - } - } - } - -} diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/ApplicationCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/ApplicationCommand.java index 7309ef9a3..f623dfe6b 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/ApplicationCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/ApplicationCommand.java @@ -16,6 +16,7 @@ package org.joyqueue.handler.routing.command.application; import com.jd.laf.binding.annotation.Value; +import com.jd.laf.web.vertx.annotation.Body; import com.jd.laf.web.vertx.annotation.Path; import com.jd.laf.web.vertx.annotation.QueryParam; import com.jd.laf.web.vertx.response.Response; @@ -38,6 +39,8 @@ import javax.validation.constraints.NotNull; +import static org.joyqueue.handler.Constants.ID; + /** * Created by wangxiaofei1 on 2018/10/19. */ @@ -91,7 +94,7 @@ public Response findAll() throws Exception { } @Path("setOwner") - public Response setOwner(@QueryParam(Constants.ID) Long id, @QueryParam(Constants.USER_ID) Long userId) throws Exception { + public Response setOwner(@QueryParam(ID) Long id, @QueryParam(Constants.USER_ID) Long userId) throws Exception { Application application = service.findById(id); User user = userService.findById(userId); application.setOwner(new Identity(user.getId(), user.getCode())); @@ -103,4 +106,21 @@ public Response getByCode(@QueryParam(Constants.APP_CODE) String appCode) throws return Responses.success(service.findByCode(appCode)); } + @Path("add") + @Override + public Response add(@Body Application model) throws Exception { + return super.add(model); + } + + @Path("update") + @Override + public Response update(@QueryParam(ID)Long id,@Body Application model) throws Exception { + return super.update(id, model); + } + + @Path("delete") + @Override + public Response delete(@QueryParam(ID)Long id) throws Exception { + return super.delete(id); + } } diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/ApplicationUserCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/ApplicationUserCommand.java index b428f4cf5..ae2b9078e 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/ApplicationUserCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/ApplicationUserCommand.java @@ -36,6 +36,8 @@ import java.util.Date; +import static org.joyqueue.handler.Constants.ID; + /** * Created by wangxiaofei1 on 2018/10/23. @@ -116,6 +118,12 @@ public Response getByAppCode(@QueryParam(Constants.APP_CODE) String appCode) thr return super.pageQuery(qPageQuery); } + @Path("update") + @Override + public Response update(@QueryParam(ID)Long id, @Body ApplicationUser model) throws Exception { + return super.update(id, model); + } + @Path("delete") public Response delete(@QueryParam(Constants.APP_ID) Long appId, @QueryParam(Constants.USER_ID) Long userId) throws Exception { // 权限约束:普通用户只有该应用下用户才能添加用户 diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/SyncApplicationCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/SyncApplicationCommand.java index 1c0aa2778..db3a7a84a 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/SyncApplicationCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/SyncApplicationCommand.java @@ -16,6 +16,7 @@ package org.joyqueue.handler.routing.command.application; +import com.jd.laf.web.vertx.annotation.Path; import org.joyqueue.handler.error.ConfigException; import org.joyqueue.handler.error.ErrorCode; import org.joyqueue.handler.Constants; @@ -47,21 +48,11 @@ public class SyncApplicationCommand implements Command, Poolable { @Value(nullable = false) protected SyncService syncService; - @Body(type = JSON) - @NotNull - protected Application application; @Value(Constants.USER_KEY) protected User session; - @CVertx - private Vertx vertx; - @Override - public String type() { - return "syncApp"; - } - - @Override - public Response execute() throws Exception { + @Path("syncApp") + public Response add(@Body Application application) throws Exception { application.setErp(session.getCode()); ApplicationInfo info = syncService.syncApp(application); if (info == null) { @@ -73,7 +64,6 @@ public Response execute() throws Exception { @Override public void clean() { - application = null; session = null; } diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerCommand.java index 6b8546e38..cc7a0ba17 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerCommand.java @@ -32,6 +32,8 @@ import org.joyqueue.service.BrokerService; import org.apache.commons.net.telnet.TelnetClient; +import static org.joyqueue.handler.Constants.ID; + /** * @author wylixiaobin * Date: 2018/10/17 @@ -47,7 +49,7 @@ public Response pageQuery(@PageQuery QPageQuery qPageQuery) throws Exce @Override @Path("delete") - public Response delete(@QueryParam(Constants.ID) String id) throws Exception { + public Response delete(@QueryParam(ID) String id) throws Exception { Broker newModel = service.findById(Integer.valueOf(id)); int count = service.delete(newModel); if (count <= 0) { @@ -58,7 +60,7 @@ public Response delete(@QueryParam(Constants.ID) String id) throws Exception { } @Path("get") - public Response get(@QueryParam(Constants.ID) Long id) throws Exception { + public Response get(@QueryParam(ID) Long id) throws Exception { Broker newModel = service.findById(Integer.valueOf(String.valueOf(id))); if (newModel == null) { throw new ConfigException(getErrorCode()); @@ -82,4 +84,16 @@ public Response telnet(@QueryParam("ip") String ip,@QueryParam("port") int port) } return Responses.success(); } + + @Path("add") + @Override + public Response add(@Body Broker model) throws Exception { + return super.add(model); + } + + @Path("update") + @Override + public Response update(@QueryParam(ID)String id,@Body Broker model) throws Exception { + return super.update(id, model); + } } diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerGroupCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerGroupCommand.java index dac04afe6..b7a9676a2 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerGroupCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerGroupCommand.java @@ -37,6 +37,8 @@ import java.util.stream.Collectors; +import static org.joyqueue.handler.Constants.ID; + /** * 分组 处理器 @@ -52,7 +54,7 @@ public Response findAll() throws Exception { } @Path("updateBroker") - public Response updateBroker(@QueryParam(Constants.ID) String id, @Body Broker model) throws Exception { + public Response updateBroker(@QueryParam(ID) String id, @Body Broker model) throws Exception { try { service.updateBroker(model); } catch (ValidationException e) { @@ -90,4 +92,22 @@ public Response mvBatchBrokerGroup(@QueryParam("group") String group,@Body List< } return Responses.success(); } + + @Path("add") + @Override + public Response add(@Body BrokerGroup model) throws Exception { + return super.add(model); + } + + @Path("update") + @Override + public Response update(@QueryParam(ID)Long id, @Body BrokerGroup model) throws Exception { + return super.update(id, model); + } + + @Path("delete") + @Override + public Response delete(@QueryParam(ID)Long id) throws Exception { + return super.delete(id); + } } diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/chart/MetricCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/chart/MetricCommand.java index 04b699736..b9bbfebed 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/chart/MetricCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/chart/MetricCommand.java @@ -30,6 +30,7 @@ import static org.joyqueue.exception.ValidationException.NOT_FOUND_EXCEPTION_STATUS; import static org.joyqueue.exception.ValidationException.UNIQUE_EXCEPTION_STATUS; +import static org.joyqueue.handler.Constants.ID; /** * Created by libinghui3 on 2019/3/7. @@ -50,7 +51,7 @@ public Response add(@Body Metric metric) throws Exception { } @Path("update") - public Response update(@QueryParam(Constants.ID) Long id, @Body Metric metric) throws Exception { + public Response update(@QueryParam(ID) Long id, @Body Metric metric) throws Exception { //validate metric code and alias code, unique if (service.findByCode(metric.getCode()) == null) { throw new ValidationException(NOT_FOUND_EXCEPTION_STATUS, "code|不存在"); @@ -68,4 +69,10 @@ public Response findAll() throws Exception { public Response findByPermission(@QueryParam("userPermission") Boolean userPermission) throws Exception { return Responses.success(service.findByQuery(new ListQuery<>(new QMetric(userPermission)))); } + + @Path("delete") + @Override + public Response delete(@QueryParam(ID)Long id) throws Exception { + return super.delete(id); + } } diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/ConfigCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/ConfigCommand.java index 29c53203d..eaf8102f9 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/ConfigCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/ConfigCommand.java @@ -15,6 +15,7 @@ */ package org.joyqueue.handler.routing.command.config; +import com.jd.laf.web.vertx.annotation.Body; import com.jd.laf.web.vertx.annotation.Path; import com.jd.laf.web.vertx.annotation.QueryParam; import com.jd.laf.web.vertx.response.Response; @@ -34,6 +35,8 @@ import java.util.ArrayList; import java.util.List; +import static org.joyqueue.handler.Constants.ID; + /** * Created by wangxiaofei1 on 2018/10/17. @@ -76,7 +79,7 @@ public Response pageQuery(@PageQuery QPageQuery qPageQuery) throws Exce @Override @Path("delete") - public Response delete(@QueryParam(Constants.ID) String id) throws Exception { + public Response delete(@QueryParam(ID) String id) throws Exception { Config newModel = service.findById(id); int count = service.delete(newModel); if (count <= 0) { @@ -86,4 +89,16 @@ public Response delete(@QueryParam(Constants.ID) String id) throws Exception { return Responses.success(); } + @Path("add") + @Override + public Response add(@Body Config model) throws Exception { + return super.add(model); + } + + @Path("update") + @Override + public Response update(@QueryParam(ID)String id,@Body Config model) throws Exception { + return super.update(id, model); + } + } diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/DataCenterCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/DataCenterCommand.java index e150de45e..4d4321f45 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/DataCenterCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/DataCenterCommand.java @@ -37,6 +37,8 @@ import java.util.List; import java.util.stream.Collectors; +import static org.joyqueue.handler.Constants.ID; + /** * Created by wangxiaofei1 on 2018/10/19. */ @@ -72,7 +74,7 @@ public Response findAll() throws Exception { @Override @Path("delete") - public Response delete(@QueryParam(Constants.ID) String id) throws Exception { + public Response delete(@QueryParam(ID) String id) throws Exception { DataCenter newModel = service.findById(id); int count = service.delete(newModel); if (count <= 0) { @@ -87,4 +89,15 @@ public Response findByIps(@Body List ips) throws Exception { return Responses.success(dataCenters); } + @Path("add") + @Override + public Response add(@Body DataCenter model) throws Exception { + return super.add(model); + } + + @Path("update") + @Override + public Response update(@QueryParam(ID)String id,@Body DataCenter model) throws Exception { + return super.update(id, model); + } } diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ConsumerCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ConsumerCommand.java index 2ff0cde5f..5b72af048 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ConsumerCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ConsumerCommand.java @@ -49,6 +49,7 @@ import java.util.List; import java.util.stream.Collectors; +import static org.joyqueue.handler.Constants.ID; import static org.joyqueue.handler.routing.command.monitor.ProducerCommand.CAN_OPERATE_PROPERTY; @@ -136,7 +137,7 @@ public Response add(@Body Consumer consumer) throws Exception { @Override @Path("delete") - public Response delete(@QueryParam(Constants.ID) String id) throws Exception { + public Response delete(@QueryParam(ID) String id) throws Exception { Consumer consumer = service.findById(id); int count = service.delete(consumer); if (count <= 0) { @@ -243,4 +244,9 @@ public Response findAppsByTopic(@QueryParam(Constants.TOPIC)String topic) throws return Responses.success(service.findAppsByTopic(topic)); } + @Path("update") + @Override + public Response update(@QueryParam(ID)String id,@Body Consumer model) throws Exception { + return super.update(id, model); + } } diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ProducerCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ProducerCommand.java index 83b2f0fbd..7e1c09414 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ProducerCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ProducerCommand.java @@ -16,6 +16,7 @@ package org.joyqueue.handler.routing.command.monitor; import com.alibaba.fastjson.JSONObject; +import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.jd.laf.binding.annotation.Value; import com.jd.laf.web.vertx.annotation.Body; @@ -45,6 +46,8 @@ import java.util.Map; import java.util.stream.Collectors; +import static org.joyqueue.handler.Constants.ID; + public class ProducerCommand extends NsrCommandSupport { private final Logger logger = LoggerFactory.getLogger(ProducerCommand.class); @@ -133,7 +136,7 @@ public Response queryByTopic(@Body QProducer qProducer) throws Exception { @Override @Path("delete") - public Response delete(@QueryParam(Constants.ID) String id) throws Exception { + public Response delete(@QueryParam(ID) String id) throws Exception { Producer producer = service.findById(id); int count = service.delete(producer); if (count <= 0) { @@ -143,7 +146,7 @@ public Response delete(@QueryParam(Constants.ID) String id) throws Exception { } @Path("weight") - public Response findPartitionGroupWeight(@QueryParam(Constants.ID) String id) throws Exception { + public Response findPartitionGroupWeight(@QueryParam(ID) String id) throws Exception { Producer producer = service.findById(id); List currentWeights = new ArrayList<>(); if (!NullUtil.isEmpty(producer)) { @@ -180,7 +183,7 @@ public Response findPartitionGroupWeight(@QueryParam(Constants.ID) String id) th } @Path("updateWeight") - public Response updateWeight(@QueryParam(Constants.ID) String id, @Body Map body) throws Exception { + public Response updateWeight(@QueryParam(ID) String id, @Body Map body) throws Exception { Producer producer = service.findById(id); if (body.containsKey("weight")) { if (producer.getConfig() == null) { @@ -192,6 +195,15 @@ public Response updateWeight(@QueryParam(Constants.ID) String id, @Body Map, Poolable { - private final Logger logger = LoggerFactory.getLogger(ProducerConfigAddOrUpdateCommand.class); - - @Value(nullable = false) - protected ProducerService producerService; - - @Body(type = JSON) - @NotNull - protected ProducerConfig producerConfig; - @Operator - protected Identity operator; - - @Override - public String type() { - return "addOrUpdateProducerConfig"; - } - - @Override - public Response execute() throws Exception { - Preconditions.checkArgument(null!=producerConfig, "invalid argument"); - Producer producer = producerService.findById(producerConfig.getProducerId()); - producer.setConfig(producerConfig); - return Responses.success(producerService.update(producer)); - } - - @Override - public void clean() { - producerConfig = null; - } -} diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/NamespaceCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/NamespaceCommand.java index fcf35121e..b343bfa17 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/NamespaceCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/NamespaceCommand.java @@ -15,7 +15,9 @@ */ package org.joyqueue.handler.routing.command.topic; +import com.jd.laf.web.vertx.annotation.Body; import com.jd.laf.web.vertx.annotation.Path; +import com.jd.laf.web.vertx.annotation.QueryParam; import com.jd.laf.web.vertx.response.Response; import com.jd.laf.web.vertx.response.Responses; import org.apache.commons.lang3.StringUtils; @@ -31,6 +33,8 @@ import java.util.ArrayList; import java.util.List; +import static org.joyqueue.handler.Constants.ID; + /** * 命名空间 处理器 * Created by chenyanying3 on 2018-11-14. @@ -75,4 +79,23 @@ public Response findAll() throws Exception { return Responses.success(service.findAll()); } + @Path("add") + @Override + public Response add(@Body Namespace model) throws Exception { + return super.add(model); + } + + @Path("update") + @Override + public Response update(@QueryParam(ID)String id, @Body Namespace model) throws Exception { + return super.update(id, model); + } + + @Path("delete") + @Override + public Response delete(@QueryParam(ID)String id) throws Exception { + return super.delete(id); + } + + } diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/PartitionGroupReplicaCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/PartitionGroupReplicaCommand.java index 23a047ece..367862dbe 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/PartitionGroupReplicaCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/PartitionGroupReplicaCommand.java @@ -49,6 +49,8 @@ import java.util.LinkedList; import java.util.List; +import static org.joyqueue.handler.Constants.ID; + /** * 主题队列-Broker分组 处理器 * Created by wylixiaobin on 2018-10-19 @@ -256,4 +258,10 @@ public Response findPartitionGroupReplica(@QueryParam("brokerId") Integer broker return Responses.error(500, e.getMessage()); } } + + @Path("update") + @Override + public Response update(@QueryParam(ID)String id,@Body PartitionGroupReplica model) throws Exception { + return super.update(id, model); + } } diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/TopicCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/TopicCommand.java index dcde30365..8ddefbc41 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/TopicCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/TopicCommand.java @@ -19,6 +19,7 @@ import com.jd.laf.binding.annotation.Value; import com.jd.laf.web.vertx.annotation.Body; import com.jd.laf.web.vertx.annotation.Path; +import com.jd.laf.web.vertx.annotation.QueryParam; import com.jd.laf.web.vertx.response.Response; import com.jd.laf.web.vertx.response.Responses; import org.apache.commons.collections.CollectionUtils; @@ -45,6 +46,8 @@ import java.util.List; import java.util.stream.Collectors; +import static org.joyqueue.handler.Constants.ID; + /** * 主题 处理器 * Created by chenyanying3 on 2018-10-18. @@ -74,7 +77,7 @@ public Response addWithBrokerGroup(@Body Topic topic) throws Exception { new ConfigException(ErrorCode.BadRequest); } if (topic.getReplica() > topic.getBrokers().size()) topic.setReplica(topic.getBrokers().size()); - service.addWithBrokerGroup(topic, topic.getBrokerGroup(), topic.getBrokers(), operator); + service.addWithBrokerGroup(topic); return Responses.success(topic); } @@ -94,7 +97,7 @@ public Response addTopic(@Body Topic topic) throws Exception { Preconditions.checkArgument(null == brokerList || brokerList.size() < 1, topic.getBrokerGroup().getCode() + "分组暂时无可用broker"); topic.setBrokers(brokerList); if (topic.getReplica() > brokerList.size()) topic.setReplica(brokerList.size()); - service.addWithBrokerGroup(topic, topic.getBrokerGroup(), topic.getBrokers(), operator); + service.addWithBrokerGroup(topic); return Responses.success(topic); } @@ -129,4 +132,16 @@ public Response getById(@Body Topic model) { } } + @Path("add") + @Override + public Response add(@Body Topic model) throws Exception { + return super.add(model); + } + + @Path("update") + @Override + public Response update(@QueryParam(ID)String id, @Body Topic model) throws Exception { + return super.update(id, model); + } + } diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/TopicPartitionGroupCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/TopicPartitionGroupCommand.java index 12c92f152..8570a3aec 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/TopicPartitionGroupCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/topic/TopicPartitionGroupCommand.java @@ -18,6 +18,7 @@ import com.jd.laf.web.vertx.annotation.Body; import com.jd.laf.web.vertx.annotation.Path; +import com.jd.laf.web.vertx.annotation.QueryParam; import com.jd.laf.web.vertx.response.Response; import com.jd.laf.web.vertx.response.Responses; import org.joyqueue.handler.annotation.PageQuery; @@ -35,6 +36,8 @@ import java.util.Comparator; import java.util.List; +import static org.joyqueue.handler.Constants.ID; + /** * Topic partition group command * Created by chenyanying3 on 2018-10-19 @@ -88,4 +91,16 @@ public Response delete(@Body TopicPartitionGroup model) throws Exception { return Responses.success(); } + @Path("add") + @Override + public Response add(@Body TopicPartitionGroup model) throws Exception { + return super.add(model); + } + + @Path("update") + @Override + public Response update(@QueryParam(ID)String id, @Body TopicPartitionGroup model) throws Exception { + return super.update(id, model); + } + } diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/user/UserCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/user/UserCommand.java index b11c40893..74171de00 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/user/UserCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/user/UserCommand.java @@ -32,6 +32,8 @@ import com.jd.laf.web.vertx.response.Response; import com.jd.laf.web.vertx.response.Responses; +import static org.joyqueue.handler.Constants.ID; + /** * @author wylixiaobin * Date: 2018/10/17 @@ -60,7 +62,7 @@ public Response pageQuery(@PageQuery QPageQuery qPageQuery) throws Except @Override @Path("update") - public Response update(@QueryParam(Constants.ID) Long id, @Body User model) throws Exception { + public Response update(@QueryParam(ID) Long id, @Body User model) throws Exception { if (operator == null || operator.getRole() != User.UserRole.ADMIN.value()) { throw new ConfigException(ErrorCode.NoPrivilege); } @@ -78,4 +80,10 @@ public Response getByRole(@QueryParam(Constants.ROLE) Integer role) { } + @Path("delete") + @Override + public Response delete(@QueryParam(ID) Long id) throws Exception { + return super.delete(id); + } + } diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/resources/META-INF/services/com.jd.laf.web.vertx.Command b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/resources/META-INF/services/com.jd.laf.web.vertx.Command index 683f6f053..d6ec72f14 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/resources/META-INF/services/com.jd.laf.web.vertx.Command +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/resources/META-INF/services/com.jd.laf.web.vertx.Command @@ -14,7 +14,6 @@ org.joyqueue.handler.routing.command.topic.PartitionGroupReplicaCommand org.joyqueue.handler.routing.command.topic.TopicPartitionGroupCommand org.joyqueue.handler.routing.command.monitor.ConsumerCommand org.joyqueue.handler.routing.command.monitor.ProducerCommand -org.joyqueue.handler.routing.command.monitor.ProducerConfigAddOrUpdateCommand org.joyqueue.handler.routing.command.monitor.BrokerMonitorCommand org.joyqueue.handler.routing.command.log.OperLogCommand org.joyqueue.handler.routing.command.retry.RetryCommand diff --git a/joyqueue-server/joyqueue-broker-core/src/main/java/org/joyqueue/broker/consumer/ConsumeManager.java b/joyqueue-server/joyqueue-broker-core/src/main/java/org/joyqueue/broker/consumer/ConsumeManager.java index 75d46b4d9..b3161a03b 100644 --- a/joyqueue-server/joyqueue-broker-core/src/main/java/org/joyqueue/broker/consumer/ConsumeManager.java +++ b/joyqueue-server/joyqueue-broker-core/src/main/java/org/joyqueue/broker/consumer/ConsumeManager.java @@ -202,7 +202,7 @@ protected void doStop() { super.doStop(); Close.close(partitionConsumption); Close.close(messageRetry); - Close.close(partitionConsumption); + Close.close(positionManager); Close.close(concurrentConsumption); resetBroadcastIndexTimer.cancel(); partitionManager.close(); From 56595bc10041956af8c20439e683bf97bd2245d3 Mon Sep 17 00:00:00 2001 From: iamazy <1448588084@qq.com> Date: Mon, 7 Dec 2020 19:18:38 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=AF=B7=E6=B1=82url=E8=BD=AC=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- joyqueue-console/joyqueue-portal/src/mixins/crud.js | 2 +- .../joyqueue-portal/src/views/monitor/consumerBase.vue | 2 +- .../joyqueue-portal/src/views/monitor/producerBase.vue | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/joyqueue-console/joyqueue-portal/src/mixins/crud.js b/joyqueue-console/joyqueue-portal/src/mixins/crud.js index 73447cc6f..9b1ed896e 100644 --- a/joyqueue-console/joyqueue-portal/src/mixins/crud.js +++ b/joyqueue-console/joyqueue-portal/src/mixins/crud.js @@ -164,7 +164,7 @@ export default { if (typeof (_this.beforeDel) === 'function') { _this.beforeDel(item) } - apiRequest.delete(_this.urlOrigin.del + '/' + item.id).then((data) => { + apiRequest.delete(_this.urlOrigin.del + '/' + encodeURIComponent(item.id)).then((data) => { if (data.code !== this.$store.getters.successCode) { this.$Dialog.error({ content: '删除失败' diff --git a/joyqueue-console/joyqueue-portal/src/views/monitor/consumerBase.vue b/joyqueue-console/joyqueue-portal/src/views/monitor/consumerBase.vue index 0a9bee7c7..2512dcf57 100644 --- a/joyqueue-console/joyqueue-portal/src/views/monitor/consumerBase.vue +++ b/joyqueue-console/joyqueue-portal/src/views/monitor/consumerBase.vue @@ -337,7 +337,7 @@ export default { title: '提示', content: '确定要取消订阅吗?' }).then(() => { - apiRequest.delete(_this.urls.del + '/' + item.id).then((data) => { + apiRequest.delete(_this.urls.del + '/' + encodeURIComponent(item.id)).then((data) => { if (data.code !== this.$store.getters.successCode) { this.$Dialog.error({ content: '取消订阅失败' diff --git a/joyqueue-console/joyqueue-portal/src/views/monitor/producerBase.vue b/joyqueue-console/joyqueue-portal/src/views/monitor/producerBase.vue index f5d5dfc95..72358ceff 100644 --- a/joyqueue-console/joyqueue-portal/src/views/monitor/producerBase.vue +++ b/joyqueue-console/joyqueue-portal/src/views/monitor/producerBase.vue @@ -261,7 +261,7 @@ export default { title: '提示', content: '确定要取消订阅吗?' }).then(() => { - apiRequest.delete(_this.urls.del + '/' + item.id).then((data) => { + apiRequest.delete(_this.urls.del + '/' + encodeURIComponent(item.id)).then((data) => { if (data.code !== this.$store.getters.successCode) { this.$Dialog.error({ content: '取消订阅失败' From 606de382d74d775a83cd437bc1a7cd8740e54180 Mon Sep 17 00:00:00 2001 From: iamazy <1448588084@qq.com> Date: Mon, 7 Dec 2020 19:54:37 +0800 Subject: [PATCH 3/7] remove unused import --- .../routing/command/application/SyncApplicationCommand.java | 6 ------ .../handler/routing/command/broker/BrokerCommand.java | 1 - .../handler/routing/command/broker/BrokerGroupCommand.java | 1 - .../handler/routing/command/chart/MetricCommand.java | 1 - .../handler/routing/command/config/ConfigCommand.java | 1 - .../handler/routing/command/config/DataCenterCommand.java | 1 - .../handler/routing/command/monitor/ProducerCommand.java | 1 - 7 files changed, 12 deletions(-) diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/SyncApplicationCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/SyncApplicationCommand.java index db3a7a84a..26a34d90c 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/SyncApplicationCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/application/SyncApplicationCommand.java @@ -28,15 +28,9 @@ import com.jd.laf.binding.annotation.Value; import com.jd.laf.web.vertx.Command; import com.jd.laf.web.vertx.annotation.Body; -import com.jd.laf.web.vertx.annotation.CVertx; import com.jd.laf.web.vertx.pool.Poolable; import com.jd.laf.web.vertx.response.Response; import com.jd.laf.web.vertx.response.Responses; -import io.vertx.core.Vertx; - -import javax.validation.constraints.NotNull; - -import static com.jd.laf.web.vertx.annotation.Body.BodyType.JSON; /** * 同步应用 diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerCommand.java index cc7a0ba17..8bd6b2490 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerCommand.java @@ -24,7 +24,6 @@ import org.joyqueue.handler.annotation.PageQuery; import org.joyqueue.handler.error.ConfigException; import org.joyqueue.handler.routing.command.NsrCommandSupport; -import org.joyqueue.handler.Constants; import org.joyqueue.model.PageResult; import org.joyqueue.model.QPageQuery; import org.joyqueue.model.domain.Broker; diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerGroupCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerGroupCommand.java index b7a9676a2..e605ff9c5 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerGroupCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/broker/BrokerGroupCommand.java @@ -19,7 +19,6 @@ import org.joyqueue.exception.ValidationException; import org.joyqueue.handler.error.ErrorCode; import org.joyqueue.handler.routing.command.CommandSupport; -import org.joyqueue.handler.Constants; import org.joyqueue.model.Pagination; import org.joyqueue.model.QPageQuery; import org.joyqueue.model.domain.Broker; diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/chart/MetricCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/chart/MetricCommand.java index b9bbfebed..40e52fa93 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/chart/MetricCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/chart/MetricCommand.java @@ -15,7 +15,6 @@ */ package org.joyqueue.handler.routing.command.chart; -import org.joyqueue.handler.Constants; import org.joyqueue.handler.routing.command.CommandSupport; import org.joyqueue.model.ListQuery; import org.joyqueue.exception.ValidationException; diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/ConfigCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/ConfigCommand.java index eaf8102f9..1452bb0c3 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/ConfigCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/ConfigCommand.java @@ -23,7 +23,6 @@ import org.joyqueue.handler.annotation.PageQuery; import org.joyqueue.handler.error.ConfigException; import org.joyqueue.handler.routing.command.NsrCommandSupport; -import org.joyqueue.handler.Constants; import org.joyqueue.model.PageResult; import org.joyqueue.model.Pagination; import org.joyqueue.model.QPageQuery; diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/DataCenterCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/DataCenterCommand.java index 4d4321f45..021e27bee 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/DataCenterCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/config/DataCenterCommand.java @@ -25,7 +25,6 @@ import org.joyqueue.handler.annotation.PageQuery; import org.joyqueue.handler.error.ConfigException; import org.joyqueue.handler.routing.command.NsrCommandSupport; -import org.joyqueue.handler.Constants; import org.joyqueue.model.PageResult; import org.joyqueue.model.Pagination; import org.joyqueue.model.QPageQuery; diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ProducerCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ProducerCommand.java index 7e1c09414..6b6b289b7 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ProducerCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ProducerCommand.java @@ -26,7 +26,6 @@ import com.jd.laf.web.vertx.response.Responses; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import org.joyqueue.handler.Constants; import org.joyqueue.handler.annotation.PageQuery; import org.joyqueue.handler.error.ConfigException; import org.joyqueue.handler.routing.command.NsrCommandSupport; From 6adc462e5ac5176d17e91fdb10a835f545b14cb7 Mon Sep 17 00:00:00 2001 From: iamazy <1448588084@qq.com> Date: Wed, 16 Dec 2020 14:34:08 +0800 Subject: [PATCH 4/7] =?UTF-8?q?broker=E7=AE=A1=E7=90=86=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=88=86=E5=8C=BA=E6=8E=A5=E5=8F=A3=E6=94=B9=E4=B8=BA=E4=BB=8E?= =?UTF-8?q?nameserver=E4=B8=AD=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ApplicationUserRepository.java | 4 ++ .../main/resources/mapper/ApplicationUser.xml | 8 ++++ .../impl/PartitionGroupServerServiceImpl.java | 3 +- .../service/ApplicationUserService.java | 3 ++ .../service/BrokerTopicMonitorService.java | 1 + .../impl/ApplicationUserServiceImpl.java | 7 ++++ .../impl/BrokerTopicMonitorServiceImpl.java | 39 +++++++++++++++++++ .../command/monitor/BrokerMonitorCommand.java | 6 ++- 8 files changed, 68 insertions(+), 3 deletions(-) diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-repository/joyqueue-data-repository-api/src/main/java/org/joyqueue/repository/ApplicationUserRepository.java b/joyqueue-console/joyqueue-data/joyqueue-data-repository/joyqueue-data-repository-api/src/main/java/org/joyqueue/repository/ApplicationUserRepository.java index ab2f0a64b..b4b5e9e78 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-repository/joyqueue-data-repository-api/src/main/java/org/joyqueue/repository/ApplicationUserRepository.java +++ b/joyqueue-console/joyqueue-data/joyqueue-data-repository/joyqueue-data-repository-api/src/main/java/org/joyqueue/repository/ApplicationUserRepository.java @@ -15,11 +15,14 @@ */ package org.joyqueue.repository; +import org.apache.ibatis.annotations.Param; import org.joyqueue.model.Uniqueable; import org.joyqueue.model.domain.ApplicationUser; import org.joyqueue.model.query.QApplicationUser; import org.springframework.stereotype.Repository; +import java.util.List; + /** * 应用-用户关联关系 仓库 * Created by chenyanying3 on 2018-10-15 @@ -28,4 +31,5 @@ public interface ApplicationUserRepository extends PageRepository, Uniqueable { ApplicationUser findByUserApp(ApplicationUser applicationUser); int deleteByAppId(long appId); + List findAppByUser(@Param("user") String user); } diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-repository/joyqueue-data-repository-mybatis/src/main/resources/mapper/ApplicationUser.xml b/joyqueue-console/joyqueue-data/joyqueue-data-repository/joyqueue-data-repository-mybatis/src/main/resources/mapper/ApplicationUser.xml index b8a5ad04e..4586a1a74 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-repository/joyqueue-data-repository-mybatis/src/main/resources/mapper/ApplicationUser.xml +++ b/joyqueue-console/joyqueue-data/joyqueue-data-repository/joyqueue-data-repository-mybatis/src/main/resources/mapper/ApplicationUser.xml @@ -124,4 +124,12 @@ WHERE app_code = #{application.code} and user_code=#{user.code} + + \ No newline at end of file diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/nsr/impl/PartitionGroupServerServiceImpl.java b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/nsr/impl/PartitionGroupServerServiceImpl.java index 8c405471c..7d915355f 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/nsr/impl/PartitionGroupServerServiceImpl.java +++ b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/nsr/impl/PartitionGroupServerServiceImpl.java @@ -101,7 +101,6 @@ public List getByBrokerId(Integer brokerId) { ReplicaQuery replicaQuery = new ReplicaQuery(); replicaQuery.setBrokerId(brokerId); String result = post(POSTBY_REPLICA_BROKER, replicaQuery); - List replicas = JSON.parseArray(result, Replica.class); - return null; + return JSON.parseArray(result, Replica.class); } } diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/ApplicationUserService.java b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/ApplicationUserService.java index d880d7370..1f9ff85cf 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/ApplicationUserService.java +++ b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/ApplicationUserService.java @@ -19,6 +19,8 @@ import org.joyqueue.model.domain.ApplicationUser; import org.joyqueue.model.query.QApplicationUser; +import java.util.List; + /** * 应用-用户关联关系 服务 * Created by chenyanying on 2018-10-17. @@ -26,4 +28,5 @@ public interface ApplicationUserService extends PageService, Uniqueable { ApplicationUser findByUserApp(String user, String app); int deleteByAppId(long appId); + List findAppByUser(String user); } \ No newline at end of file diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/BrokerTopicMonitorService.java b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/BrokerTopicMonitorService.java index 89fc9858c..947b7537c 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/BrokerTopicMonitorService.java +++ b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/BrokerTopicMonitorService.java @@ -35,4 +35,5 @@ public interface BrokerTopicMonitorService { BrokerMonitorInfo findBrokerMonitor(Long brokerId); BrokerStartupInfo getStartupInfo(Long brokerId) throws Exception; List queryTopicList(Long brokerId) throws Exception; + List queryTopicsPartitionMonitors(Integer brokerId); } diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/ApplicationUserServiceImpl.java b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/ApplicationUserServiceImpl.java index 09f09e120..8a154ec6d 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/ApplicationUserServiceImpl.java +++ b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/ApplicationUserServiceImpl.java @@ -22,6 +22,8 @@ import org.joyqueue.service.ApplicationUserService; import org.springframework.stereotype.Service; +import java.util.List; + /** * 应用-用户关联关系 服务 * Created by chenyanying3 on 2018-10-15 @@ -41,4 +43,9 @@ public ApplicationUser findByUserApp(String user, String app){ public int deleteByAppId(long appId) { return repository.deleteByAppId(appId); } + + @Override + public List findAppByUser(String user) { + return repository.findAppByUser(user); + } } diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/BrokerTopicMonitorServiceImpl.java b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/BrokerTopicMonitorServiceImpl.java index 8307ea529..34cbefdd6 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/BrokerTopicMonitorServiceImpl.java +++ b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/BrokerTopicMonitorServiceImpl.java @@ -17,6 +17,7 @@ import com.alibaba.fastjson.JSONObject; import org.joyqueue.convert.CodeConverter; +import org.joyqueue.domain.Replica; import org.joyqueue.manage.PartitionGroupMetric; import org.joyqueue.model.PageResult; import org.joyqueue.model.Pagination; @@ -35,6 +36,7 @@ import org.joyqueue.monitor.ConsumerMonitorInfo; import org.joyqueue.monitor.ProducerMonitorInfo; import org.joyqueue.monitor.RestResponse; +import org.joyqueue.nsr.PartitionGroupServerService; import org.joyqueue.other.HttpRestService; import org.joyqueue.service.BrokerService; import org.joyqueue.service.BrokerTopicMonitorService; @@ -48,7 +50,9 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -65,6 +69,8 @@ public class BrokerTopicMonitorServiceImpl implements BrokerTopicMonitorService private ConsumerService consumerService; @Autowired private ProducerService producerService; + @Autowired + private PartitionGroupServerService partitionGroupServerService; @Override @@ -181,6 +187,23 @@ public List queryTopicList(Long brokerId) throws Exception { return queryTopicList(broker); } + @Override + public List queryTopicsPartitionMonitors(Integer brokerId) { + List brokerTopicMonitorList = new ArrayList<>(); + try { + Map> partitionGroupMetricMap = getPartitionGroupMetricMap(brokerId); + for (Map.Entry> entry: partitionGroupMetricMap.entrySet()) { + BrokerTopicMonitor brokerTopicMonitor = new BrokerTopicMonitor(); + brokerTopicMonitor.setTopic(entry.getKey()); + brokerTopicMonitor.setPartitionGroupMetricList(entry.getValue()); + brokerTopicMonitorList.add(brokerTopicMonitor); + } + } catch (Exception e) { + logger.error("queryTopicsPartitionMointor exception", e); + } + return brokerTopicMonitorList; + } + private BrokerTopicMonitor getMonitorByAppAndTopic(String topic, List appList, Broker broker, SubscribeType type) throws Exception { BrokerTopicMonitor brokerTopicMonitor = new BrokerTopicMonitor(); List brokerMonitorRecordList = new ArrayList<>(); @@ -335,6 +358,22 @@ private List getPartitionGroup(String topic, Broker broker return null; } + private Map> getPartitionGroupMetricMap(Integer brokerId) { + Map> replicaMap = partitionGroupServerService.getByBrokerId(brokerId) + .stream().collect(Collectors.groupingBy(replica -> replica.getTopic().getCode())); + Map> map = new HashMap<>(); + for (Map.Entry> entry: replicaMap.entrySet()) { + List metrics = new ArrayList<>(entry.getValue().size()); + for (Replica replica: entry.getValue()) { + PartitionGroupMetric metric = new PartitionGroupMetric(); + metric.setPartitionGroup(replica.getGroup()); + metrics.add(metric); + } + map.put(entry.getKey(), metrics); + } + return map; + } + private JSONObject queryMonitorConsumers(Broker broker, int page, int pageSize) { String path = "consumerInfos"; String[] args = new String[4]; diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/BrokerMonitorCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/BrokerMonitorCommand.java index f1f3e3c01..922701710 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/BrokerMonitorCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/BrokerMonitorCommand.java @@ -31,6 +31,7 @@ import org.joyqueue.handler.error.ErrorCode; import org.joyqueue.model.BrokerMetadata; import org.joyqueue.model.PageResult; +import org.joyqueue.model.Pagination; import org.joyqueue.model.QPageQuery; import org.joyqueue.model.domain.BrokerClient; import org.joyqueue.model.domain.BrokerMonitorInfoWithDC; @@ -244,7 +245,10 @@ public Response brokerMonitor(@PageQuery QPageQuery qPageQuery){ @Path("partitionGroupMonitor") public Response partitionGroupMonitor(@PageQuery QPageQuery qPageQuery){ try { - PageResult pageResult = brokerTopicMonitorService.queryTopicsPartitionMointor(qPageQuery); + List brokerTopicMonitors = brokerTopicMonitorService.queryTopicsPartitionMonitors(Integer.valueOf(String.valueOf(qPageQuery.getQuery().getBrokerId()))); + PageResult pageResult = new PageResult<>(); + pageResult.setResult(brokerTopicMonitors); + pageResult.setPagination(new Pagination(0, brokerTopicMonitors.size() - 1)); return new Response(pageResult.getResult(), pageResult.getPagination()); } catch (Exception e) { logger.error("query broker monitor info error.", e); From 0edcdde9cd6721ae4233121364510f734ac68a93 Mon Sep 17 00:00:00 2001 From: iamazy <1448588084@qq.com> Date: Thu, 17 Dec 2020 16:16:12 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=B7=BB=E5=8A=A0status=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E6=9F=A5=E5=88=B0=E5=A4=9A=E6=9D=A1=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/ApplicationUser.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-repository/joyqueue-data-repository-mybatis/src/main/resources/mapper/ApplicationUser.xml b/joyqueue-console/joyqueue-data/joyqueue-data-repository/joyqueue-data-repository-mybatis/src/main/resources/mapper/ApplicationUser.xml index 4586a1a74..8e3fa0891 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-repository/joyqueue-data-repository-mybatis/src/main/resources/mapper/ApplicationUser.xml +++ b/joyqueue-console/joyqueue-data/joyqueue-data-repository/joyqueue-data-repository-mybatis/src/main/resources/mapper/ApplicationUser.xml @@ -121,7 +121,7 @@ FROM application_user - WHERE app_code = #{application.code} and user_code=#{user.code} + WHERE app_code = #{application.code} and user_code=#{user.code} and status != -1 \ No newline at end of file From 8e5abc7188bde11f17ffdcb53e99c3d07a6836d3 Mon Sep 17 00:00:00 2001 From: iamazy <1448588084@qq.com> Date: Wed, 23 Dec 2020 14:22:39 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E6=9C=BA?= =?UTF-8?q?=E6=88=BF=E5=8D=8F=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../setting/brokerPartitionGroupMonitor.vue | 18 ------- .../src/main/resources/routing.xml | 6 +++ .../command/monitor/ConsumerCommand.java | 52 +++++++++++++++++++ .../store/PartitionGroupStoreManager.java | 2 +- 4 files changed, 59 insertions(+), 19 deletions(-) diff --git a/joyqueue-console/joyqueue-portal/src/views/setting/brokerPartitionGroupMonitor.vue b/joyqueue-console/joyqueue-portal/src/views/setting/brokerPartitionGroupMonitor.vue index 594434bf3..6acf1221c 100644 --- a/joyqueue-console/joyqueue-portal/src/views/setting/brokerPartitionGroupMonitor.vue +++ b/joyqueue-console/joyqueue-portal/src/views/setting/brokerPartitionGroupMonitor.vue @@ -59,24 +59,6 @@ export default { } return h('div', {}, html) } - }, - { - title: 'partition', - key: 'partitionGroupMetricList', - render: (h, params) => { - var list = params.item.partitionGroupMetricList; - if (list!= null && list.length > 0) { - list = list.slice().sort((a,b) => a.partitionGroup-b.partitionGroup) - } - var html = [] - if (list != undefined) { - for (var i = 0; i < list.length; i++) { - var p = h('div', {style: 'border-bottom: 1px solid #ECECEC;'}, mergePartitionGroup(JSON.parse('[' + list[i].partitions + ']'))) - html.push(p) - } - } - return h('div', {}, html) - } } ] // 表格操作,如果需要根据特定值隐藏显示, 设置bindKey对应的属性名和bindVal对应的属性值 diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-application/src/main/resources/routing.xml b/joyqueue-console/joyqueue-web/joyqueue-web-application/src/main/resources/routing.xml index ea7a2ccf9..50927a485 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-application/src/main/resources/routing.xml +++ b/joyqueue-console/joyqueue-web/joyqueue-web-application/src/main/resources/routing.xml @@ -330,6 +330,12 @@ + + diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ConsumerCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ConsumerCommand.java index 5b72af048..84674eb14 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ConsumerCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ConsumerCommand.java @@ -249,4 +249,56 @@ public Response findAppsByTopic(@QueryParam(Constants.TOPIC)String topic) throws public Response update(@QueryParam(ID)String id,@Body Consumer model) throws Exception { return super.update(id, model); } + + @Path("checkRegion") + public Response checkRegion(@QueryParam("app") String app, + @QueryParam("subscribeGroup") String subscribeGroup, + @QueryParam("region") String region) throws Exception { + if (StringUtils.isNotBlank(app) && StringUtils.isNotBlank(region)) { + List consumers = consumerNameServerService.findByApp(app); + if (StringUtils.isNotBlank(subscribeGroup)) { + consumers = consumers.stream().filter(consumer -> subscribeGroup.equals(consumer.getSubscribeGroup())) + .collect(Collectors.toList()); + } + consumers = consumers.stream().filter(consumer -> consumer.getConfig() != null + && StringUtils.isNotBlank(consumer.getConfig().getRegion()) + && !region.equals(consumer.getConfig().getRegion())) + .collect(Collectors.toList()); + return Responses.success(consumers.size() == 0); + + } + return Responses.error(500, "app, region can't be empty"); + } + + @Path("updateRegion") + public Response updateRegion(@QueryParam("consumerId") String consumerId, + @QueryParam("region") String region) throws Exception { + if (StringUtils.isNotBlank(consumerId)) { + Consumer consumer = service.findById(consumerId); + String app = consumer.getApp().getCode(); + String subscribeGroup = consumer.getSubscribeGroup(); + List consumers = service.findByApp(app); + if (StringUtils.isNotBlank(subscribeGroup)) { + consumers = consumers.stream().filter(item -> StringUtils.isNotBlank(item.getSubscribeGroup()) + && subscribeGroup.equals(item.getSubscribeGroup())) + .collect(Collectors.toList()); + } else { + consumers = consumers.stream().filter(item -> StringUtils.isBlank(item.getSubscribeGroup())) + .collect(Collectors.toList()); + } + for (Consumer consumerItem: consumers) { + if (consumerItem.getConfig() != null) { + if (StringUtils.isNotBlank(region)) { + consumerItem.getConfig().setRegion(region); + } else { + consumerItem.getConfig().setRegion(null); + } + service.update(consumerItem); + } + } + return Responses.success(); + + } + return Responses.error(500, "consumerId can't be empty"); + } } diff --git a/joyqueue-server/joyqueue-store/joyqueue-store-core/src/main/java/org/joyqueue/store/PartitionGroupStoreManager.java b/joyqueue-server/joyqueue-store/joyqueue-store-core/src/main/java/org/joyqueue/store/PartitionGroupStoreManager.java index 7d8f662f1..c0248346a 100644 --- a/joyqueue-server/joyqueue-store/joyqueue-store-core/src/main/java/org/joyqueue/store/PartitionGroupStoreManager.java +++ b/joyqueue-server/joyqueue-store/joyqueue-store-core/src/main/java/org/joyqueue/store/PartitionGroupStoreManager.java @@ -622,7 +622,7 @@ public ReadResult read(short partition, long index, int count, long maxSize) thr continue; } if (indexItem.getOffset() >= commitPosition()) { - continue; + break; } try { ByteBuffer log; From b10731c3dbced91154240a86ab990c6aa2a03b7d Mon Sep 17 00:00:00 2001 From: iamazy <1448588084@qq.com> Date: Wed, 23 Dec 2020 14:54:23 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E6=9C=BA?= =?UTF-8?q?=E6=88=BF=E5=8D=8F=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/joyqueue/service/ConsumerService.java | 2 ++ .../service/impl/ConsumerServiceImpl.java | 22 +++++++++++++++++++ .../command/monitor/ConsumerCommand.java | 20 +---------------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/ConsumerService.java b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/ConsumerService.java index e46018cc8..ad3df7f4e 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/ConsumerService.java +++ b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/ConsumerService.java @@ -33,4 +33,6 @@ public interface ConsumerService extends NsrService { List findAppsByTopic(String topic) throws Exception; + void updateAllConsumerRegion(String app, String subscribeGroup, String region) throws Exception; + } diff --git a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/ConsumerServiceImpl.java b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/ConsumerServiceImpl.java index 82d327c24..8ea299154 100644 --- a/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/ConsumerServiceImpl.java +++ b/joyqueue-console/joyqueue-data/joyqueue-data-service/src/main/java/org/joyqueue/service/impl/ConsumerServiceImpl.java @@ -217,4 +217,26 @@ protected Consumer fillConsumer(Consumer consumer) { return consumer; } + @Override + public void updateAllConsumerRegion(String app, String subscribeGroup, String region) throws Exception { + List consumers = findByApp(app); + if (StringUtils.isNotBlank(subscribeGroup)) { + consumers = consumers.stream().filter(item -> StringUtils.isNotBlank(item.getSubscribeGroup()) + && subscribeGroup.equals(item.getSubscribeGroup())) + .collect(Collectors.toList()); + } else { + consumers = consumers.stream().filter(item -> StringUtils.isBlank(item.getSubscribeGroup())) + .collect(Collectors.toList()); + } + for (Consumer consumerItem: consumers) { + if (consumerItem.getConfig() != null) { + if (StringUtils.isNotBlank(region)) { + consumerItem.getConfig().setRegion(region); + } else { + consumerItem.getConfig().setRegion(null); + } + this.update(consumerItem); + } + } + } } diff --git a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ConsumerCommand.java b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ConsumerCommand.java index 84674eb14..2a7e4523b 100644 --- a/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ConsumerCommand.java +++ b/joyqueue-console/joyqueue-web/joyqueue-web-handler/src/main/java/org/joyqueue/handler/routing/command/monitor/ConsumerCommand.java @@ -277,25 +277,7 @@ public Response updateRegion(@QueryParam("consumerId") String consumerId, Consumer consumer = service.findById(consumerId); String app = consumer.getApp().getCode(); String subscribeGroup = consumer.getSubscribeGroup(); - List consumers = service.findByApp(app); - if (StringUtils.isNotBlank(subscribeGroup)) { - consumers = consumers.stream().filter(item -> StringUtils.isNotBlank(item.getSubscribeGroup()) - && subscribeGroup.equals(item.getSubscribeGroup())) - .collect(Collectors.toList()); - } else { - consumers = consumers.stream().filter(item -> StringUtils.isBlank(item.getSubscribeGroup())) - .collect(Collectors.toList()); - } - for (Consumer consumerItem: consumers) { - if (consumerItem.getConfig() != null) { - if (StringUtils.isNotBlank(region)) { - consumerItem.getConfig().setRegion(region); - } else { - consumerItem.getConfig().setRegion(null); - } - service.update(consumerItem); - } - } + service.updateAllConsumerRegion(app, subscribeGroup, region); return Responses.success(); }