From 55fb6a36b4eaf0147300331370dfafc7e565ab87 Mon Sep 17 00:00:00 2001 From: iamazy <1448588084@qq.com> Date: Wed, 9 Dec 2020 11:37:41 +0800 Subject: [PATCH] =?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=20(#319)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Command类overwrite父类的add,update,delete方法 * 请求url转义 --- .../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 +- .../joyqueue-portal/src/mixins/crud.js | 2 +- .../src/views/monitor/consumerBase.vue | 2 +- .../src/views/monitor/consumerConfigForm.vue | 4 +- .../src/views/monitor/producerBase.vue | 2 +- .../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 | 22 +-- .../routing/command/broker/BrokerCommand.java | 19 ++- .../command/broker/BrokerGroupCommand.java | 23 ++- .../routing/command/chart/MetricCommand.java | 10 +- .../routing/command/config/ConfigCommand.java | 18 ++- .../command/config/DataCenterCommand.java | 16 +- .../command/monitor/ConsumerCommand.java | 8 +- .../command/monitor/ProducerCommand.java | 30 +++- .../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 +- 31 files changed, 260 insertions(+), 273 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/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/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/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: '取消订阅失败' 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..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 @@ -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; @@ -27,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; /** * 同步应用 @@ -47,21 +42,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 +58,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..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; @@ -32,6 +31,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 +48,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 +59,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 +83,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..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; @@ -37,6 +36,8 @@ import java.util.stream.Collectors; +import static org.joyqueue.handler.Constants.ID; + /** * 分组 处理器 @@ -52,7 +53,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 +91,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..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; @@ -30,6 +29,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 +50,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 +68,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..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 @@ -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; @@ -22,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; @@ -34,6 +34,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 +78,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 +88,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..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; @@ -37,6 +36,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 +73,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 +88,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..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 @@ -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; @@ -25,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; @@ -45,6 +45,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 +135,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 +145,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 +182,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 +194,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();