Typed 서킷브레이커 관리화면 추가
This commit is contained in:
@@ -0,0 +1,140 @@
|
|||||||
|
<%@ page language="java" contentType="text/html; charset=utf-8"%>
|
||||||
|
<%@ page import="java.io.*"%>
|
||||||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||||
|
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
|
||||||
|
<%@ include file="/jsp/common/include/localemessage.jsp" %>
|
||||||
|
<%
|
||||||
|
response.setHeader("Pragma", "No-cache");
|
||||||
|
response.setHeader("Cache-Control", "no-cache");
|
||||||
|
response.setHeader("Expires", "0");
|
||||||
|
|
||||||
|
%>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title></title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<jsp:include page="/jsp/common/include/css.jsp"/>
|
||||||
|
<jsp:include page="/jsp/common/include/script.jsp"/>
|
||||||
|
<script language="javascript" >
|
||||||
|
var url ='<c:url value="/onl/admin/circuitbreaker/circuitBreakerInterfaceMan.json" />';
|
||||||
|
var url_view ='<c:url value="/onl/admin/circuitbreaker/circuitBreakerInterfaceMan.view" />';
|
||||||
|
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#grid').jqGrid({
|
||||||
|
datatype:"json",
|
||||||
|
mtype: 'POST',
|
||||||
|
url: url,
|
||||||
|
postData : { cmd : 'LIST', searchName: $('input[name=searchName]').val()},
|
||||||
|
colNames:['API 명',
|
||||||
|
'설명',
|
||||||
|
'실패 비율',
|
||||||
|
'슬라이딩 창 크기',
|
||||||
|
'느린호출 비율',
|
||||||
|
'사용여부'
|
||||||
|
],
|
||||||
|
colModel:[
|
||||||
|
{ name : 'CBREAKERNAME' , align:'left' , width:'100' , sortable:false },
|
||||||
|
{ name : 'CBREAKERDESC' , align:'left' , width:'200'},
|
||||||
|
{ name : 'FAILURERATETHRESHOLD' , align:'right' , width:'60'},
|
||||||
|
{ name : 'SLIDINGWINDOWSIZE' , align:'right' , width:'60'},
|
||||||
|
{ name : 'SLOWCALLRATETHRESHOLD' , align:'center' , width:'80'},
|
||||||
|
{ name : 'USEYN', align:'center' , width:'60' , editoptions:{value:"0:사용안함;1:사용함"}, formatter:"select" }
|
||||||
|
],
|
||||||
|
jsonReader: {
|
||||||
|
repeatitems:false
|
||||||
|
},
|
||||||
|
pager : $('#pager'),
|
||||||
|
page : '${param.page}',
|
||||||
|
rowNum : '${rmsDefaultRowNum}',
|
||||||
|
autoheight: true,
|
||||||
|
height: $("#container").height(),
|
||||||
|
autowidth: true,
|
||||||
|
viewrecords: true,
|
||||||
|
rowList : eval('[${rmsDefaultRowList}]'),
|
||||||
|
ondblClickRow: function(rowId) {
|
||||||
|
var rowData = $(this).getRowData(rowId);
|
||||||
|
var name = rowData['CBREAKERNAME'];
|
||||||
|
var url2 = url_view;
|
||||||
|
url2 += '?cmd=DETAIL';
|
||||||
|
url2 += '&page='+$(this).getGridParam("page");
|
||||||
|
url2 += '&returnUrl='+getReturnUrl();
|
||||||
|
url2 += '&menuId='+'${param.menuId}';
|
||||||
|
//검색값
|
||||||
|
url2 += '&searchName='+$("input[name=searchName]").val();
|
||||||
|
//key값
|
||||||
|
url2 += '&name='+name;
|
||||||
|
goNav(url2);
|
||||||
|
|
||||||
|
},
|
||||||
|
gridComplete:function (d){
|
||||||
|
var colModel = $(this).getGridParam("colModel");
|
||||||
|
for(var i = 0 ; i< colModel.length; i++){
|
||||||
|
$(this).setColProp(colModel[i].name, {sortable : false});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
resizeJqGridWidth('grid','content_middle','1000');
|
||||||
|
|
||||||
|
$("#btn_search").click(function(){
|
||||||
|
$("#grid").setGridParam({ postData: { searchName: $('input[name=searchName]').val()}, page:1 }).trigger("reloadGrid");
|
||||||
|
});
|
||||||
|
$("#btn_new").click(function(){
|
||||||
|
var url2 = url_view;
|
||||||
|
url2 += '?cmd=DETAIL';
|
||||||
|
url2 += '&page='+$("#grid").getGridParam("page");
|
||||||
|
url2 += '&returnUrl='+getReturnUrl();
|
||||||
|
url2 += '&menuId='+'${param.menuId}';
|
||||||
|
//검색값
|
||||||
|
url2 += '&searchName=';
|
||||||
|
|
||||||
|
goNav(url2);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("input[name^=search]").keydown(function(key){
|
||||||
|
if (key.keyCode == 13){
|
||||||
|
$("#btn_search").click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonControl();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="right_box">
|
||||||
|
<div class="content_top">
|
||||||
|
<ul class="path">
|
||||||
|
<li><a href="#">${rmsMenuPath}</a></li>
|
||||||
|
</ul>
|
||||||
|
</div><!-- end content_top -->
|
||||||
|
<div class="content_middle" id="content_middle">
|
||||||
|
<div class="search_wrap">
|
||||||
|
<button type="button" class="cssbtn" id="btn_search" level="R"><i class="material-icons">search</i> <%= localeMessage.getString("button.search") %></button>
|
||||||
|
<!-- img src="<c:url value="/img/btn_new.png" />" alt="" id="btn_new" level="R" /-->
|
||||||
|
<%-- <img src="<c:url value="/img/btn_search.png"/>" alt="" id="btn_search" level="R" /> --%>
|
||||||
|
</div>
|
||||||
|
<div class="title">API 별 서킷브레이커<span class="tooltip">API 별 서킷브레이커</span></div>
|
||||||
|
|
||||||
|
<table class="search_condition" cellspacing=0;>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th style="width:180px;">API 명</th>
|
||||||
|
<td><input type="text" name="searchName" value="${param.searchName}"></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<table id="grid" ></table>
|
||||||
|
<div id="pager"></div>
|
||||||
|
|
||||||
|
</div><!-- end content_middle -->
|
||||||
|
</div><!-- end right_box -->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
<%@ page language="java" contentType="text/html; charset=utf-8"%>
|
||||||
|
<%@ page import="java.io.*"%>
|
||||||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||||
|
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
|
||||||
|
<%@ include file="/jsp/common/include/localemessage.jsp" %>
|
||||||
|
<%
|
||||||
|
response.setHeader("Pragma", "No-cache");
|
||||||
|
response.setHeader("Cache-Control", "no-cache");
|
||||||
|
response.setHeader("Expires", "0");
|
||||||
|
%>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title></title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<jsp:include page="/jsp/common/include/css.jsp"/>
|
||||||
|
<jsp:include page="/jsp/common/include/script.jsp"/>
|
||||||
|
|
||||||
|
<script language="javascript" >
|
||||||
|
var url ='<c:url value="/onl/admin/circuitbreaker/circuitBreakerInterfaceMan.json" />';
|
||||||
|
var url_view ='<c:url value="/onl/admin/circuitbreaker/circuitBreakerInterfaceMan.view" />';
|
||||||
|
var isDetail = false;
|
||||||
|
function init(url,key,callback){
|
||||||
|
$.ajax({
|
||||||
|
type : "POST",
|
||||||
|
url:url,
|
||||||
|
dataType:"json",
|
||||||
|
data:{cmd: 'LIST_INIT_COMBO'},
|
||||||
|
success:function(json){
|
||||||
|
new makeOptions("CODE","NAME").setObj($("select[name=useYn]")).setData(json.useYnRows).setFormat(codeName3OptionFormat).rendering();
|
||||||
|
|
||||||
|
if(typeof callback === 'function') {
|
||||||
|
callback(url,key);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error:function(e){
|
||||||
|
alert(e.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function detail(url,key){
|
||||||
|
if (!isDetail)return;
|
||||||
|
$.ajax({
|
||||||
|
type : "POST",
|
||||||
|
url:url,
|
||||||
|
dataType:"json",
|
||||||
|
data:{cmd: 'DETAIL', name : key},
|
||||||
|
success:function(json){
|
||||||
|
var data = json;
|
||||||
|
$("input[name=cbreakerId]").attr('readonly',true);
|
||||||
|
$("input[name=cbreakerName]").attr('readonly',true);
|
||||||
|
$("input[name=cbreakerDesc]").attr('readonly',true);
|
||||||
|
|
||||||
|
$("#ajaxForm input[type!=radio],#ajaxForm select,#ajaxForm textarea").each(function(){
|
||||||
|
var name = $(this).attr("name");
|
||||||
|
var tag = $(this).prop("tagName").toLowerCase();
|
||||||
|
$(tag+"[name="+name+"]").val(data[name.toUpperCase()]);
|
||||||
|
});
|
||||||
|
|
||||||
|
var cbreakerId = json.CBREAKERID || json.cbreakerId;
|
||||||
|
if (cbreakerId) {
|
||||||
|
$('#idRow').show();
|
||||||
|
} else {
|
||||||
|
$('#btn_delete').hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
error:function(e){
|
||||||
|
alert(e.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$(document).ready(function() {
|
||||||
|
var returnUrl = getReturnUrlForReturn();
|
||||||
|
var key ="${param.name}";
|
||||||
|
if (key != "" && key !="null"){
|
||||||
|
isDetail = true;
|
||||||
|
}
|
||||||
|
init(url,key,detail);
|
||||||
|
|
||||||
|
|
||||||
|
$("#btn_modify").click(function(){
|
||||||
|
var postData = $('#ajaxForm').serializeArray();
|
||||||
|
if (isDetail){
|
||||||
|
postData.push({ name: "cmd" , value:"UPDATE"});
|
||||||
|
}else{
|
||||||
|
postData.push({ name: "cmd" , value:"INSERT"});
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
type : "POST",
|
||||||
|
url:url,
|
||||||
|
data:postData,
|
||||||
|
success:function(args){
|
||||||
|
alert("<%= localeMessage.getString("common.saveMsg") %>");
|
||||||
|
goNav(returnUrl);//LIST로 이동
|
||||||
|
},
|
||||||
|
error:function(e){
|
||||||
|
alert(e.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$("#btn_delete").click(function(){
|
||||||
|
|
||||||
|
if ( confirm( '<%=localeMessage.getString("common.confirmMsg")%>' ) != true ) return;
|
||||||
|
|
||||||
|
var postData = $('#ajaxForm').serializeArray();
|
||||||
|
postData.push({ name: "cmd" , value:"DELETE"});
|
||||||
|
$.ajax({
|
||||||
|
type : "POST",
|
||||||
|
url:url,
|
||||||
|
data:postData,
|
||||||
|
success:function(args){
|
||||||
|
alert("<%= localeMessage.getString("common.deleteMsg") %>");
|
||||||
|
goNav(returnUrl);//LIST로 이동
|
||||||
|
|
||||||
|
},
|
||||||
|
error:function(e){
|
||||||
|
alert(e.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$("#btn_previous").click(function(){
|
||||||
|
goNav(returnUrl);//LIST로 이동
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonControl(isDetail);
|
||||||
|
titleControl(isDetail);
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="right_box">
|
||||||
|
<div class="content_top">
|
||||||
|
<ul class="path">
|
||||||
|
<li><a href="#">${rmsMenuPath}</a></li>
|
||||||
|
</ul>
|
||||||
|
</div><!-- end content_top -->
|
||||||
|
<div class="content_middle">
|
||||||
|
<div class="search_wrap">
|
||||||
|
<button type="button" class="cssbtn" id="btn_delete" level="W" status="DETAIL"><i class="material-icons">delete</i> <%= localeMessage.getString("button.delete") %></button>
|
||||||
|
<button type="button" class="cssbtn" id="btn_modify" level="W" status="DETAIL,NEW"><i class="material-icons">save</i> <%= localeMessage.getString("button.modify") %></button>
|
||||||
|
<button type="button" class="cssbtn" id="btn_previous" level="R" status="DETAIL,NEW"><i class="material-icons">arrow_back</i> <%= localeMessage.getString("button.previous") %></button>
|
||||||
|
<%-- <img src="<c:url value="/img/btn_delete.png"/>" alt="" id="btn_delete" level="W" status="DETAIL"/> --%>
|
||||||
|
<%-- <img src="<c:url value="/img/btn_modify.png"/>" alt="" id="btn_modify" level="W" status="DETAIL,NEW" /> --%>
|
||||||
|
<%-- <img src="<c:url value="/img/btn_previous.png"/>" alt="" id="btn_previous" level="R" status="DETAIL,NEW"/> --%>
|
||||||
|
</div>
|
||||||
|
<div class="title">API 별 서킷브레이커 수정<span class="tooltip" >API 별 서킷브레이커 수정</span></div>
|
||||||
|
|
||||||
|
<table id="grid" ></table>
|
||||||
|
<div id="pager"></div>
|
||||||
|
|
||||||
|
<!-- detail -->
|
||||||
|
<form id="ajaxForm">
|
||||||
|
<table class="table_row" cellspacing="0">
|
||||||
|
<tr id="idRow" style="display:none;">
|
||||||
|
<th style="width:20%;">ID</th>
|
||||||
|
<td><input type="text" name="cbreakerId" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="width:20%;">API 명</th>
|
||||||
|
<td><input type="text" name="cbreakerName" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="width:20%;">설명</th>
|
||||||
|
<td><input type="text" name="cbreakerDesc" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="width:20%;">실패 비율 임계값(%)</th>
|
||||||
|
<td><input type="text" name="failureRateThreshold" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="width:20%;">슬라이딩 창의 크기</th>
|
||||||
|
<td><input type="text" name="slidingWindowSize" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="width:20%;">최소 호출 수</th>
|
||||||
|
<td><input type="text" name="minimumNumberOfCalls" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="width:20%;">OPEN 상태 대기 시간(초)</th>
|
||||||
|
<td><input type="text" name="waitDurationInOpenState" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="width:20%;">HALF_OPEN 상태 허용 호출 수</th>
|
||||||
|
<td><input type="text" name="permittedNumberOfCallsInHalfOpenState" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="width:20%;">느린 호출 비율 임계값(%)</th>
|
||||||
|
<td><input type="text" name="slowCallRateThreshold" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="width:20%;">느린 호출 지속 시간 임계값(ms)</th>
|
||||||
|
<td><input type="text" name="slowCallDurationThreshold" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="width:20%;">사용여부</th>
|
||||||
|
<td>
|
||||||
|
<div class="select-style">
|
||||||
|
<select name="useYn" />
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div><!-- end content_middle -->
|
||||||
|
</div><!-- end right_box -->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
package com.eactive.eai.rms.data.entity.onl.circuitbreaker;
|
||||||
|
|
||||||
|
import com.eactive.eai.data.entity.onl.circuitbreaker.CircuitBreakerConfig;
|
||||||
|
import com.eactive.eai.data.jpa.BaseRepository;
|
||||||
|
|
||||||
|
public interface CircuitBreakerRepository extends BaseRepository<CircuitBreakerConfig, String> {
|
||||||
|
|
||||||
|
}
|
||||||
+94
@@ -0,0 +1,94 @@
|
|||||||
|
package com.eactive.eai.rms.data.entity.onl.circuitbreaker;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.PersistenceContext;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageImpl;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.eactive.eai.data.entity.onl.circuitbreaker.CircuitBreakerConfig;
|
||||||
|
import com.eactive.eai.data.entity.onl.circuitbreaker.QCircuitBreakerConfig;
|
||||||
|
import com.eactive.eai.data.entity.onl.message.QEAIMessageEntity;
|
||||||
|
import com.eactive.eai.data.jpa.AbstractDataService;
|
||||||
|
import com.eactive.eai.rms.onl.manage.circuitbreaker.CircuitBreakerManMapper;
|
||||||
|
import com.querydsl.core.Tuple;
|
||||||
|
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CircuitBreakerService extends AbstractDataService<CircuitBreakerConfig, String, CircuitBreakerRepository> {
|
||||||
|
|
||||||
|
public static final String APIID_TYPE = "01";
|
||||||
|
|
||||||
|
@PersistenceContext
|
||||||
|
EntityManager entityManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CircuitBreakerManMapper mapper;
|
||||||
|
|
||||||
|
public Page<CircuitBreakerServiceDto> findAllForInterface(Pageable pageable, String searchName) {
|
||||||
|
JPAQueryFactory jpaQueryFactory = new JPAQueryFactory(entityManager);
|
||||||
|
QCircuitBreakerConfig qCircuitBreakerConfig = QCircuitBreakerConfig.circuitBreakerConfig;
|
||||||
|
QEAIMessageEntity qEAIMessageEntity = QEAIMessageEntity.eAIMessageEntity;
|
||||||
|
|
||||||
|
List<Tuple> tupleList = jpaQueryFactory
|
||||||
|
.select(qCircuitBreakerConfig, qEAIMessageEntity.eaisvcname, qEAIMessageEntity.eaisvcdesc)
|
||||||
|
.from(qEAIMessageEntity)
|
||||||
|
.leftJoin(qCircuitBreakerConfig)
|
||||||
|
.on(qCircuitBreakerConfig.cbreakerType.eq(APIID_TYPE).and(qCircuitBreakerConfig.cbreakerName.eq(qEAIMessageEntity.eaisvcname)))
|
||||||
|
.where(qEAIMessageEntity.eaisvcname.contains(searchName))
|
||||||
|
.orderBy(qEAIMessageEntity.eaisvcname.asc())
|
||||||
|
.offset(pageable.getOffset())
|
||||||
|
.limit(pageable.getPageSize())
|
||||||
|
.fetch();
|
||||||
|
|
||||||
|
List<CircuitBreakerServiceDto> dtoList = tupleList
|
||||||
|
.stream()
|
||||||
|
.map(tuple -> toDto(qEAIMessageEntity, qCircuitBreakerConfig, tuple))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
long totalCount = jpaQueryFactory
|
||||||
|
.select(qEAIMessageEntity.eaisvcname.count())
|
||||||
|
.from(qEAIMessageEntity)
|
||||||
|
.where(qEAIMessageEntity.eaisvcname.contains(searchName))
|
||||||
|
.fetchOne();
|
||||||
|
return new PageImpl<>(dtoList, pageable, totalCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CircuitBreakerServiceDto toDto(QEAIMessageEntity qEAIMessageEntity, QCircuitBreakerConfig qCircuitBreakerConfig,
|
||||||
|
Tuple tuple) {
|
||||||
|
CircuitBreakerServiceDto dto = null;
|
||||||
|
if (tuple.get(qCircuitBreakerConfig) != null)
|
||||||
|
dto = mapper.toDto(tuple.get(qCircuitBreakerConfig));
|
||||||
|
else {
|
||||||
|
dto = new CircuitBreakerServiceDto();
|
||||||
|
dto.setCbreakerName(tuple.get(qEAIMessageEntity.eaisvcname));
|
||||||
|
dto.setCbreakerType(APIID_TYPE);
|
||||||
|
dto.setUseYn("0");//사용안함
|
||||||
|
}
|
||||||
|
dto.setCbreakerDesc(tuple.get(qEAIMessageEntity.eaisvcdesc));
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CircuitBreakerServiceDto findByIdForInterface(String eaisvcname) {
|
||||||
|
JPAQueryFactory jpaQueryFactory = new JPAQueryFactory(entityManager);
|
||||||
|
QCircuitBreakerConfig qCircuitBreakerConfig = QCircuitBreakerConfig.circuitBreakerConfig;
|
||||||
|
QEAIMessageEntity qEAIMessageEntity = QEAIMessageEntity.eAIMessageEntity;
|
||||||
|
|
||||||
|
Tuple tuple = jpaQueryFactory
|
||||||
|
.select(qCircuitBreakerConfig, qEAIMessageEntity.eaisvcname, qEAIMessageEntity.eaisvcdesc)
|
||||||
|
.from(qEAIMessageEntity)
|
||||||
|
.leftJoin(qCircuitBreakerConfig)
|
||||||
|
.on(qCircuitBreakerConfig.cbreakerType.eq(APIID_TYPE).and(qCircuitBreakerConfig.cbreakerName.eq(qEAIMessageEntity.eaisvcname)))
|
||||||
|
.where(qEAIMessageEntity.eaisvcname.eq(eaisvcname))
|
||||||
|
.fetchOne();
|
||||||
|
|
||||||
|
return toDto(qEAIMessageEntity, qCircuitBreakerConfig, tuple);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package com.eactive.eai.rms.data.entity.onl.circuitbreaker;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CircuitBreakerServiceDto {
|
||||||
|
|
||||||
|
private String cbreakerId;
|
||||||
|
|
||||||
|
String cbreakerType;
|
||||||
|
|
||||||
|
String cbreakerName;
|
||||||
|
|
||||||
|
String cbreakerDesc;
|
||||||
|
|
||||||
|
int failureRateThreshold;
|
||||||
|
|
||||||
|
int slidingWindowSize;
|
||||||
|
|
||||||
|
int minimumNumberOfCalls;
|
||||||
|
|
||||||
|
int waitDurationInOpenState;
|
||||||
|
|
||||||
|
int permittedNumberOfCallsInHalfOpenState;
|
||||||
|
|
||||||
|
int slowCallRateThreshold;
|
||||||
|
|
||||||
|
int slowCallDurationThreshold;
|
||||||
|
|
||||||
|
String useYn;
|
||||||
|
|
||||||
|
}
|
||||||
+95
@@ -0,0 +1,95 @@
|
|||||||
|
package com.eactive.eai.rms.onl.manage.circuitbreaker;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
import com.eactive.eai.agent.command.CommonCommand;
|
||||||
|
import com.eactive.eai.rms.common.base.OnlBaseAnnotationController;
|
||||||
|
import com.eactive.eai.rms.common.combo.ComboService;
|
||||||
|
import com.eactive.eai.rms.common.combo.ComboVo;
|
||||||
|
import com.eactive.eai.rms.common.vo.GridResponse;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class CircuitBreakerInterfaceManController extends OnlBaseAnnotationController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CircuitBreakerManService service;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ComboService comboService;
|
||||||
|
|
||||||
|
@RequestMapping(value = "/onl/admin/circuitbreaker/circuitBreakerInterfaceMan.view")
|
||||||
|
public String viewList() {
|
||||||
|
return "/onl/admin/circuitbreaker/circuitBreakerInterfaceMan";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/onl/admin/circuitbreaker/circuitBreakerInterfaceMan.view", params = "cmd=DETAIL")
|
||||||
|
public String viewDetail() {
|
||||||
|
return "/onl/admin/circuitbreaker/circuitBreakerInterfaceManDetail";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/onl/admin/circuitbreaker/circuitBreakerInterfaceMan.json", params = "cmd=LIST")
|
||||||
|
public ResponseEntity<GridResponse<CircuitBreakerManUI>> selectList(HttpServletRequest request, Pageable pageVo,
|
||||||
|
String searchName) {
|
||||||
|
Page<CircuitBreakerManUI> uiPage = service.selectList(pageVo, searchName);
|
||||||
|
return ResponseEntity.ok(new GridResponse<>(uiPage));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/onl/admin/circuitbreaker/circuitBreakerInterfaceMan.json", params = "cmd=DETAIL")
|
||||||
|
public ResponseEntity<CircuitBreakerManUI> selectDetail(HttpServletRequest request, HttpServletResponse response,
|
||||||
|
String name) {
|
||||||
|
CircuitBreakerManUI ui = service.selectDetail(name);
|
||||||
|
return ResponseEntity.ok(ui);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/onl/admin/circuitbreaker/circuitBreakerInterfaceMan.json", params = "cmd=UPDATE")
|
||||||
|
public String save(HttpServletRequest request, HttpServletResponse response, CircuitBreakerManUI ui)
|
||||||
|
throws Exception {
|
||||||
|
String modifiedBy = getSessionUserId(request);
|
||||||
|
ui.setModifiedBy(modifiedBy);
|
||||||
|
ui.setModifiedAt(LocalDateTime.now());
|
||||||
|
service.merge(ui);
|
||||||
|
CommonCommand command = new CommonCommand("com.eactive.eai.agent.circuitBreaker.type.ReloadTypedCircuitBreakerCommand",
|
||||||
|
ui.getCbreakerId());
|
||||||
|
agentUtilService.broadcast(command);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/onl/admin/circuitbreaker/circuitBreakerInterfaceMan.json", params = "cmd=DELETE")
|
||||||
|
public String delete(HttpServletRequest request, HttpServletResponse response, CircuitBreakerManUI ui) throws Exception {
|
||||||
|
service.delete(ui.getCbreakerId());
|
||||||
|
CommonCommand command = new CommonCommand("com.eactive.eai.agent.circuitBreaker.type.ReloadTypedCircuitBreakerCommand",
|
||||||
|
ui.getCbreakerId());
|
||||||
|
agentUtilService.broadcast(command);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/onl/admin/circuitbreaker/circuitBreakerInterfaceMan.json", params = "cmd=LIST_INIT_COMBO")
|
||||||
|
public ModelAndView initCombo(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
List<ComboVo> useYnRows = comboService.getFromCode("USE_YN");
|
||||||
|
Map<String, List<ComboVo>> resultMap = new HashMap<>();
|
||||||
|
resultMap.put("useYnRows", useYnRows);
|
||||||
|
return new ModelAndView("jsonView", resultMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 세션에서 사용자 ID 조회
|
||||||
|
*/
|
||||||
|
private String getSessionUserId(HttpServletRequest request) {
|
||||||
|
Object userId = request.getSession().getAttribute("userId");
|
||||||
|
return userId != null ? userId.toString() : "SYSTEM";
|
||||||
|
}
|
||||||
|
}
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package com.eactive.eai.rms.onl.manage.circuitbreaker;
|
||||||
|
|
||||||
|
import org.mapstruct.BeanMapping;
|
||||||
|
import org.mapstruct.InheritInverseConfiguration;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.MappingTarget;
|
||||||
|
import org.mapstruct.NullValuePropertyMappingStrategy;
|
||||||
|
import org.mapstruct.ReportingPolicy;
|
||||||
|
|
||||||
|
import com.eactive.eai.data.entity.onl.circuitbreaker.CircuitBreakerConfig;
|
||||||
|
import com.eactive.eai.data.mapper.GenericMapper;
|
||||||
|
import com.eactive.eai.rms.data.entity.onl.circuitbreaker.CircuitBreakerServiceDto;
|
||||||
|
|
||||||
|
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||||
|
public interface CircuitBreakerManMapper extends GenericMapper<CircuitBreakerManUI, CircuitBreakerConfig> {
|
||||||
|
@Override
|
||||||
|
CircuitBreakerManUI toVo(CircuitBreakerConfig entity);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@InheritInverseConfiguration
|
||||||
|
CircuitBreakerConfig toEntity(CircuitBreakerManUI vo);
|
||||||
|
|
||||||
|
@InheritInverseConfiguration
|
||||||
|
@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
|
||||||
|
void updateToEntity(CircuitBreakerManUI vo, @MappingTarget CircuitBreakerConfig entity);
|
||||||
|
|
||||||
|
CircuitBreakerServiceDto toDto(CircuitBreakerConfig entity);
|
||||||
|
|
||||||
|
CircuitBreakerManUI toVo(CircuitBreakerServiceDto serviceDto);
|
||||||
|
|
||||||
|
}
|
||||||
+70
@@ -0,0 +1,70 @@
|
|||||||
|
package com.eactive.eai.rms.onl.manage.circuitbreaker;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import com.eactive.eai.data.entity.onl.circuitbreaker.CircuitBreakerConfig;
|
||||||
|
import com.eactive.eai.rms.common.base.BaseService;
|
||||||
|
import com.eactive.eai.rms.common.combo.ComboService;
|
||||||
|
import com.eactive.eai.rms.data.entity.onl.circuitbreaker.CircuitBreakerService;
|
||||||
|
import com.eactive.eai.rms.data.entity.onl.circuitbreaker.CircuitBreakerServiceDto;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CircuitBreakerManService extends BaseService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("comboService")
|
||||||
|
public ComboService comboService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CircuitBreakerService service;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CircuitBreakerManMapper mapper;
|
||||||
|
|
||||||
|
// 어댑터 유량제어
|
||||||
|
public Page<CircuitBreakerManUI> selectList(Pageable pageable, String searchName) {
|
||||||
|
Page<CircuitBreakerServiceDto> dtoList = service.findAllForInterface(pageable, searchName);
|
||||||
|
return dtoList.map(mapper::toVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CircuitBreakerManUI selectDetail(String id) {
|
||||||
|
CircuitBreakerServiceDto dto = service.findByIdForInterface(id);
|
||||||
|
return mapper.toVo(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void merge(CircuitBreakerManUI ui) {
|
||||||
|
ui.setCbreakerType(CircuitBreakerService.APIID_TYPE);
|
||||||
|
Optional<CircuitBreakerConfig> circuitBreakerConfigOptional;
|
||||||
|
if(StringUtils.isNotEmpty(ui.getCbreakerId()))
|
||||||
|
circuitBreakerConfigOptional = service.findById(ui.getCbreakerId());
|
||||||
|
else
|
||||||
|
circuitBreakerConfigOptional = Optional.empty();
|
||||||
|
|
||||||
|
CircuitBreakerConfig entity = null;
|
||||||
|
if (circuitBreakerConfigOptional.isPresent()) {
|
||||||
|
entity = circuitBreakerConfigOptional.get();
|
||||||
|
mapper.updateToEntity(ui, entity);
|
||||||
|
} else {
|
||||||
|
entity = mapper.toEntity(ui);
|
||||||
|
entity.setCbreakerId(null);
|
||||||
|
}
|
||||||
|
entity = service.save(entity);
|
||||||
|
ui.setCbreakerId(entity.getCbreakerId());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(String id) {
|
||||||
|
service.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.eactive.eai.rms.onl.manage.circuitbreaker;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CircuitBreakerManUI {
|
||||||
|
@JsonProperty("CBREAKERID")
|
||||||
|
private String cbreakerId;
|
||||||
|
|
||||||
|
@JsonProperty("CBREAKERTYPE")
|
||||||
|
String cbreakerType;
|
||||||
|
|
||||||
|
@JsonProperty("CBREAKERNAME")
|
||||||
|
String cbreakerName;
|
||||||
|
|
||||||
|
@JsonProperty("CBREAKERDESC")
|
||||||
|
String cbreakerDesc;
|
||||||
|
|
||||||
|
@JsonProperty("FAILURERATETHRESHOLD")
|
||||||
|
Integer failureRateThreshold;
|
||||||
|
|
||||||
|
@JsonProperty("SLIDINGWINDOWSIZE")
|
||||||
|
Integer slidingWindowSize;
|
||||||
|
|
||||||
|
@JsonProperty("MINIMUMNUMBEROFCALLS")
|
||||||
|
Integer minimumNumberOfCalls;
|
||||||
|
|
||||||
|
@JsonProperty("WAITDURATIONINOPENSTATE")
|
||||||
|
Integer waitDurationInOpenState;
|
||||||
|
|
||||||
|
@JsonProperty("PERMITTEDNUMBEROFCALLSINHALFOPENSTATE")
|
||||||
|
Integer permittedNumberOfCallsInHalfOpenState;
|
||||||
|
|
||||||
|
@JsonProperty("SLOWCALLRATETHRESHOLD")
|
||||||
|
Integer slowCallRateThreshold;
|
||||||
|
|
||||||
|
@JsonProperty("SLOWCALLDURATIONTHRESHOLD")
|
||||||
|
Integer slowCallDurationThreshold;
|
||||||
|
|
||||||
|
@JsonProperty("USEYN")
|
||||||
|
String useYn;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
String modifiedBy;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
LocalDateTime modifiedAt;
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user