Skip to content

Commit

Permalink
添加修改归档tps的接口
Browse files Browse the repository at this point in the history
  • Loading branch information
iamazy committed Jan 15, 2021
1 parent 28aba4f commit 6df84ff
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public String toString() {
public static class TopicPolicy implements Serializable {
private Long storeMaxTime;
private Boolean storeCleanKeepUnconsumed;
private Integer produceArchiveTps = -1;
private Integer consumeArchiveTps = -1;
private Map<String, String> params;

public Long getStoreMaxTime() {
Expand All @@ -139,6 +141,22 @@ public Boolean getStoreCleanKeepUnconsumed() {
return storeCleanKeepUnconsumed;
}

public Integer getProduceArchiveTps() {
return produceArchiveTps;
}

public void setProduceArchiveTps(Integer produceArchiveTps) {
this.produceArchiveTps = produceArchiveTps;
}

public Integer getConsumeArchiveTps() {
return consumeArchiveTps;
}

public void setConsumeArchiveTps(Integer consumeArchiveTps) {
this.consumeArchiveTps = consumeArchiveTps;
}

public void setParams(Map<String, String> params) {
this.params = params;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@
<route inherit="put"
path="/v1/topic/update/:id" handlers="validateAdmin topic#update render"
errors="error"/>
<route inherit="put"
path="/v1/topic/updateTopicTps/:topic/:type/:tps" handlers="validateAdmin topic#updateTopicTps render"
errors="error"/>
<route inherit="post"
path="/v1/topic/delete" handlers="validateAdmin topic#delete render"
errors="error"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.jd.laf.web.vertx.response.Response;
import com.jd.laf.web.vertx.response.Responses;
import org.apache.commons.collections.CollectionUtils;
import org.joyqueue.domain.TopicName;
import org.joyqueue.handler.annotation.PageQuery;
import org.joyqueue.handler.error.ConfigException;
import org.joyqueue.handler.error.ErrorCode;
Expand Down Expand Up @@ -144,4 +145,26 @@ public Response update(@QueryParam(ID)String id, @Body Topic model) throws Excep
return super.update(id, model);
}

@Path("updateTopicTps")
public Response updateTopicTps(@QueryParam("topic")String topicCode, @QueryParam("type") String type, @QueryParam("tps") int tps) throws Exception {
TopicName topicName = TopicName.parse(topicCode);
Topic topic = service.findByCode(topicName.getNamespace(), topicName.getCode());
if (topic.getPolicy() != null) {
if (type.equalsIgnoreCase("producer")) {
topic.getPolicy().setProduceArchiveTps(tps);
} else if (type.equalsIgnoreCase("consumer")) {
topic.getPolicy().setConsumeArchiveTps(tps);
}
} else {
org.joyqueue.domain.Topic.TopicPolicy topicPolicy = new org.joyqueue.domain.Topic.TopicPolicy();
if (type.equalsIgnoreCase("producer")) {
topicPolicy.setProduceArchiveTps(tps);
} else if (type.equalsIgnoreCase("consumer")) {
topicPolicy.setConsumeArchiveTps(tps);
}
topic.setPolicy(topicPolicy);
}
return super.update(topic.getId(), topic);
}

}

0 comments on commit 6df84ff

Please sign in to comment.