Skip to content

Commit

Permalink
Merge 7272eaa into 83d0a5e
Browse files Browse the repository at this point in the history
  • Loading branch information
iamazy committed Nov 26, 2020
2 parents 83d0a5e + 7272eaa commit 11d67f2
Show file tree
Hide file tree
Showing 27 changed files with 232 additions and 253 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public Topic createTopic(Topic topic, List<Broker> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.joyqueue.nsr;

import org.joyqueue.domain.Replica;
import org.joyqueue.model.domain.TopicPartitionGroup;

import java.util.List;
Expand All @@ -27,4 +28,6 @@ public interface PartitionGroupServerService extends NsrService<TopicPartitionGr
List<TopicPartitionGroup> findByTopic(String topic,String namespace);

TopicPartitionGroup findByTopicAndGroup(String namespace, String topic, Integer groupNo);

List<Replica> getByBrokerId(Integer brokerId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -91,4 +95,13 @@ public List<TopicPartitionGroup> findByTopic(String topic, String namespace) {
List<PartitionGroup> partitionGroups = JSON.parseArray(result, PartitionGroup.class);
return partitionGroups.stream().map(partitionGroup -> nsrPartitionGroupConverter.revert(partitionGroup)).collect(Collectors.toList());
}

@Override
public List<Replica> getByBrokerId(Integer brokerId) {
ReplicaQuery replicaQuery = new ReplicaQuery();
replicaQuery.setBrokerId(brokerId);
String result = post(POSTBY_REPLICA_BROKER, replicaQuery);
List<Replica> replicas = JSON.parseArray(result, Replica.class);
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -38,11 +35,8 @@ public interface TopicService extends NsrService<Topic ,String> {
/**
* 保存:带分组和Broker信息
* @param topic
* @param brokerGroup
* @param brokers
* @param operator 操作人
*/
void addWithBrokerGroup(Topic topic, BrokerGroup brokerGroup, List<Broker> brokers, Identity operator);
void addWithBrokerGroup(Topic topic);

/**
* 查询未订阅的topics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,13 +72,16 @@ public class TopicServiceImpl implements TopicService {

@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public void addWithBrokerGroup(Topic topic, BrokerGroup brokerGroup, List<Broker> 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<Broker> brokers = topic.getBrokers();
if (brokers == null) {
brokers = new ArrayList<>();
}
if (EnvironmentUtil.isTest()) {
topic.setElectType(TopicPartitionGroup.ElectType.fix.type());
brokers = Lists.newArrayList(brokers.get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
18 changes: 11 additions & 7 deletions joyqueue-console/joyqueue-portal/src/views/topic/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@

<!-- producerConfig -->
<route inherit="post"
path="/v1/producer/config/addOrUpdate" handlers="addOrUpdateProducerConfig render"
path="/v1/producer/config/addOrUpdate" handlers="producer#configAddOrUpdate render"
errors="error"/>

<!-- consumer post-id -->
Expand Down Expand Up @@ -487,7 +487,7 @@
errors="error"/>
<!--同步操作 -->
<route inherit="post"
path="/v1/sync/application" handlers="syncApp render"
path="/v1/sync/application" handlers="syncApplication#syncApp render"
errors="error"/>
<route inherit="post"
path="/v1/sync/user" handlers="syncUser render"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -38,6 +39,8 @@

import javax.validation.constraints.NotNull;

import static org.joyqueue.handler.Constants.ID;

/**
* Created by wangxiaofei1 on 2018/10/19.
*/
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

import java.util.Date;

import static org.joyqueue.handler.Constants.ID;


/**
* Created by wangxiaofei1 on 2018/10/23.
Expand Down Expand Up @@ -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 {
// 权限约束:普通用户只有该应用下用户才能添加用户
Expand Down
Loading

0 comments on commit 11d67f2

Please sign in to comment.