mirror of
https://github.com/ctripcorp/zeus.git
synced 2024-11-10 17:13:46 +08:00
introduce traffic policy model
This commit is contained in:
parent
13f4faa833
commit
ad6660cb26
10 changed files with 600 additions and 6 deletions
|
@ -0,0 +1,25 @@
|
|||
package com.ctrip.zeus.service.model;
|
||||
|
||||
import com.ctrip.zeus.model.entity.TrafficPolicy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by zhoumy on 2017/1/11.
|
||||
*/
|
||||
public interface TrafficPolicyRepository {
|
||||
|
||||
List<TrafficPolicy> list() throws Exception;
|
||||
|
||||
List<TrafficPolicy> list(IdVersion[] key) throws Exception;
|
||||
|
||||
TrafficPolicy getById(Long id) throws Exception;
|
||||
|
||||
TrafficPolicy getByKey(IdVersion key) throws Exception;
|
||||
|
||||
TrafficPolicy add(TrafficPolicy trafficPolicy) throws Exception;
|
||||
|
||||
TrafficPolicy update(TrafficPolicy trafficPolicy) throws Exception;
|
||||
|
||||
void delete(Long id) throws Exception;
|
||||
}
|
|
@ -4,7 +4,7 @@ package com.ctrip.zeus.service.model.common;
|
|||
* Created by zhoumy on 2017/1/9.
|
||||
*/
|
||||
public enum MetaType {
|
||||
GROUP(1), VS(2), SLB(3);
|
||||
GROUP(1), VS(2), SLB(3), MEMBER(4), TRAFFIC_POLICY(5);
|
||||
|
||||
int id;
|
||||
|
||||
|
@ -24,6 +24,10 @@ public enum MetaType {
|
|||
return VS;
|
||||
case 3:
|
||||
return SLB;
|
||||
case 4:
|
||||
return MEMBER;
|
||||
case 5:
|
||||
return TRAFFIC_POLICY;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
package com.ctrip.zeus.service.model.impl;
|
||||
|
||||
import com.ctrip.zeus.dal.core.*;
|
||||
import com.ctrip.zeus.exceptions.ValidationException;
|
||||
import com.ctrip.zeus.model.entity.*;
|
||||
import com.ctrip.zeus.service.model.IdVersion;
|
||||
import com.ctrip.zeus.service.model.TrafficPolicyRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.unidal.dal.jdbc.DalException;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by zhoumy on 2017/1/11.
|
||||
*/
|
||||
@Repository("trafficPolicyRepository")
|
||||
public class TrafficPolicyRepositoryImpl implements TrafficPolicyRepository {
|
||||
@Resource
|
||||
private TrafficPolicyDao trafficPolicyDao;
|
||||
@Resource
|
||||
private RTrafficPolicyGroupDao rTrafficPolicyGroupDao;
|
||||
@Resource
|
||||
private RTrafficPolicyVsDao rTrafficPolicyVsDao;
|
||||
|
||||
@Override
|
||||
public List<TrafficPolicy> list() throws Exception {
|
||||
List<TrafficPolicyDo> list = trafficPolicyDao.findAll(TrafficPolicyEntity.READSET_FULL);
|
||||
IdVersion[] currentVersion = new IdVersion[list.size()];
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
currentVersion[i] = new IdVersion(list.get(i).getId(), list.get(i).getVersion());
|
||||
}
|
||||
return list(currentVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TrafficPolicy> list(IdVersion[] key) throws Exception {
|
||||
Map<Long, TrafficPolicy> policyById = new HashMap<>();
|
||||
for (IdVersion e : key) {
|
||||
policyById.put(e.getId(), new TrafficPolicy().setId(e.getId()).setVersion(e.getVersion()));
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
Integer[] hashes = new Integer[policyById.size()];
|
||||
for (TrafficPolicy e : policyById.values()) {
|
||||
hashes[i] = getHashCode(e.getId(), e.getVersion());
|
||||
i++;
|
||||
}
|
||||
|
||||
for (RTrafficPolicyGroupDo e : rTrafficPolicyGroupDao.findAllByHash(hashes, RTrafficPolicyGroupEntity.READSET_FULL)) {
|
||||
TrafficPolicy tp = policyById.get(e.getPolicyId());
|
||||
if (tp != null && tp.getVersion().equals(e.getPolicyVersion())) {
|
||||
tp.getControls().add(new TrafficControl().setGroup(new Group().setId(e.getGroupId())).setWeight(e.getWeight()));
|
||||
}
|
||||
}
|
||||
for (RTrafficPolicyVsDo e : rTrafficPolicyVsDao.findAllByHash(hashes, RTrafficPolicyVsEntity.READSET_FULL)) {
|
||||
TrafficPolicy tp = policyById.get(e.getPolicyId());
|
||||
if (tp != null && tp.getVersion().equals(e.getPolicyVersion())) {
|
||||
tp.getPolicyVirtualServers().add(new PolicyVirtualServer().setPath(e.getPath()).setPriority(e.getPriority()).setVirtualServer(new VirtualServer().setId(e.getVsId())));
|
||||
}
|
||||
}
|
||||
return new ArrayList<>(policyById.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrafficPolicy getById(Long id) throws Exception {
|
||||
TrafficPolicyDo d = trafficPolicyDao.findById(id, TrafficPolicyEntity.READSET_FULL);
|
||||
return d == null ? null : getByKey(new IdVersion(d.getId(), d.getVersion()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrafficPolicy getByKey(IdVersion key) throws Exception {
|
||||
TrafficPolicy tp = new TrafficPolicy().setId(key.getId()).setVersion(key.getVersion());
|
||||
for (RTrafficPolicyGroupDo e : rTrafficPolicyGroupDao.findByPolicy(key.getId(), key.getVersion(), RTrafficPolicyGroupEntity.READSET_FULL)) {
|
||||
if (tp != null && tp.getVersion().equals(e.getPolicyVersion())) {
|
||||
tp.getControls().add(new TrafficControl().setGroup(new Group().setId(e.getGroupId())).setWeight(e.getWeight()));
|
||||
}
|
||||
}
|
||||
for (RTrafficPolicyVsDo e : rTrafficPolicyVsDao.findByPolicy(key.getId(), key.getVersion(), RTrafficPolicyVsEntity.READSET_FULL)) {
|
||||
if (tp != null && tp.getVersion().equals(e.getPolicyVersion())) {
|
||||
tp.getPolicyVirtualServers().add(new PolicyVirtualServer().setPath(e.getPath()).setPriority(e.getPriority()).setVirtualServer(new VirtualServer().setId(e.getVsId())));
|
||||
}
|
||||
}
|
||||
return tp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrafficPolicy add(TrafficPolicy trafficPolicy) throws Exception {
|
||||
TrafficPolicyDo tpd = new TrafficPolicyDo().setVersion(1).setActiveVersion(-1).setNxActiveVersion(1);
|
||||
trafficPolicyDao.insert(tpd);
|
||||
trafficPolicy.setId(tpd.getId()).setVersion(tpd.getVersion());
|
||||
|
||||
maintainRelations(trafficPolicy, tpd);
|
||||
|
||||
return trafficPolicy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrafficPolicy update(TrafficPolicy trafficPolicy) throws Exception {
|
||||
TrafficPolicyDo tpd = trafficPolicyDao.findById(trafficPolicy.getId(), TrafficPolicyEntity.READSET_FULL);
|
||||
if (tpd == null) {
|
||||
throw new ValidationException("Traffic policy " + trafficPolicy.getId() + " that you tried to update does not exists.");
|
||||
}
|
||||
|
||||
tpd.setVersion(tpd.getVersion() + 1).setActiveVersion(tpd.getActiveVersion()).setNxActiveVersion(tpd.getVersion() + 1);
|
||||
trafficPolicyDao.updateById(tpd, TrafficPolicyEntity.UPDATESET_FULL);
|
||||
trafficPolicy.setId(tpd.getId()).setVersion(tpd.getVersion());
|
||||
|
||||
maintainRelations(trafficPolicy, tpd);
|
||||
|
||||
return trafficPolicy;
|
||||
}
|
||||
|
||||
private void maintainRelations(TrafficPolicy trafficPolicy, TrafficPolicyDo tpd) throws DalException {
|
||||
int hashCode = getHashCode(tpd.getId(), tpd.getVersion());
|
||||
RTrafficPolicyGroupDo[] tpgd = new RTrafficPolicyGroupDo[trafficPolicy.getControls().size()];
|
||||
for (int i = 0; i < trafficPolicy.getControls().size(); i++) {
|
||||
TrafficControl c = trafficPolicy.getControls().get(i);
|
||||
tpgd[i] = new RTrafficPolicyGroupDo().setPolicyId(tpd.getId()).setPolicyVersion(tpd.getVersion()).setHash(hashCode)
|
||||
.setGroupId(c.getGroup().getId()).setWeight(c.getWeight());
|
||||
}
|
||||
rTrafficPolicyGroupDao.insert(tpgd);
|
||||
|
||||
RTrafficPolicyVsDo[] tpvd = new RTrafficPolicyVsDo[trafficPolicy.getPolicyVirtualServers().size()];
|
||||
for (int i = 0; i < trafficPolicy.getPolicyVirtualServers().size(); i++) {
|
||||
PolicyVirtualServer pvs = trafficPolicy.getPolicyVirtualServers().get(i);
|
||||
tpvd[i] = new RTrafficPolicyVsDo().setPolicyId(tpd.getId()).setPolicyVersion(tpd.getVersion()).setPolicyVersion(hashCode)
|
||||
.setVsId(pvs.getVirtualServer().getId()).setPath(pvs.getPath()).setPriority(pvs.getPriority());
|
||||
}
|
||||
rTrafficPolicyVsDao.insert(tpvd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) throws Exception {
|
||||
trafficPolicyDao.deleteById(new TrafficPolicyDo().setId(id));
|
||||
rTrafficPolicyGroupDao.deleteByPolicy(new RTrafficPolicyGroupDo().setPolicyId(id));
|
||||
rTrafficPolicyVsDao.deleteByPolicy(new RTrafficPolicyVsDo().setPolicyId(id));
|
||||
|
||||
}
|
||||
|
||||
private static int getHashCode(Long id, int version) {
|
||||
return id.hashCode() * 31 + version;
|
||||
}
|
||||
}
|
|
@ -2001,6 +2001,95 @@
|
|||
</query>
|
||||
</query-defs>
|
||||
</entity>
|
||||
<entity name="r-traffic-policy-group" table="r_traffic_policy_group" alias="rtpg">
|
||||
<member name="id" field="id" value-type="long" length="19" nullable="false" key="true" auto-increment="true" />
|
||||
<member name="group-id" field="group_id" value-type="long" length="19" nullable="false" />
|
||||
<member name="policy-id" field="policy_id" value-type="long" length="19" nullable="false" />
|
||||
<member name="policy-version" field="policy_version" value-type="int" length="10" nullable="false" />
|
||||
<member name="weight" field="weight" value-type="int" length="10" nullable="false" />
|
||||
<member name="hash" field="hash" value-type="int" length="10" nullable="false" />
|
||||
<member name="data-change-last-time" field="DataChange_LastTime" value-type="Date" nullable="false" />
|
||||
<var name="key-id" value-type="long" key-member="id" />
|
||||
<primary-key name="PRIMARY" members="id" />
|
||||
<index name="DataChange_LastTime" members="DataChange_LastTime ASC" />
|
||||
<index name="policy_id_policy_version" members="policy_id ASC, policy_version ASC" />
|
||||
<index name="group_id" members="group_id ASC" />
|
||||
<index name="hash" members="hash ASC" />
|
||||
<readsets>
|
||||
<readset name="FULL" all="true" />
|
||||
</readsets>
|
||||
<updatesets>
|
||||
<updateset name="FULL" all="true" />
|
||||
</updatesets>
|
||||
<query-defs>
|
||||
<query name="find-by-PK" type="SELECT">
|
||||
<param name="key-id" />
|
||||
<statement><![CDATA[SELECT <FIELDS/>
|
||||
FROM <TABLE/>
|
||||
WHERE <FIELD name='id'/> = ${key-id}]]></statement>
|
||||
</query>
|
||||
<query name="insert" type="INSERT">
|
||||
<statement><![CDATA[INSERT INTO <TABLE/>(<FIELDS/>)
|
||||
VALUES(<VALUES/>)]]></statement>
|
||||
</query>
|
||||
<query name="update-by-PK" type="UPDATE">
|
||||
<param name="key-id" />
|
||||
<statement><![CDATA[UPDATE <TABLE/>
|
||||
SET <FIELDS/>
|
||||
WHERE <FIELD name='id'/> = ${key-id}]]></statement>
|
||||
</query>
|
||||
<query name="delete-by-PK" type="DELETE">
|
||||
<param name="key-id" />
|
||||
<statement><![CDATA[DELETE FROM <TABLE/>
|
||||
WHERE <FIELD name='id'/> = ${key-id}]]></statement>
|
||||
</query>
|
||||
</query-defs>
|
||||
</entity>
|
||||
<entity name="r-traffic-policy-vs" table="r_traffic_policy_vs" alias="rtpv">
|
||||
<member name="id" field="id" value-type="long" length="19" nullable="false" key="true" auto-increment="true" />
|
||||
<member name="vs-id" field="vs_id" value-type="long" length="19" nullable="false" />
|
||||
<member name="policy-id" field="policy_id" value-type="long" length="19" nullable="false" />
|
||||
<member name="policy-version" field="policy_version" value-type="int" length="10" nullable="false" />
|
||||
<member name="path" field="path" value-type="String" length="4096" nullable="false" />
|
||||
<member name="priority" field="priority" value-type="int" length="10" nullable="false" />
|
||||
<member name="hash" field="hash" value-type="int" length="10" nullable="false" />
|
||||
<member name="data-change-last-time" field="DataChange_LastTime" value-type="Date" nullable="false" />
|
||||
<var name="key-id" value-type="long" key-member="id" />
|
||||
<primary-key name="PRIMARY" members="id" />
|
||||
<index name="vs_id" members="vs_id ASC" />
|
||||
<index name="DataChange_LastTime" members="DataChange_LastTime ASC" />
|
||||
<index name="policy_id_policy_version" members="policy_id ASC, policy_version ASC" />
|
||||
<index name="hash" members="hash ASC" />
|
||||
<readsets>
|
||||
<readset name="FULL" all="true" />
|
||||
</readsets>
|
||||
<updatesets>
|
||||
<updateset name="FULL" all="true" />
|
||||
</updatesets>
|
||||
<query-defs>
|
||||
<query name="find-by-PK" type="SELECT">
|
||||
<param name="key-id" />
|
||||
<statement><![CDATA[SELECT <FIELDS/>
|
||||
FROM <TABLE/>
|
||||
WHERE <FIELD name='id'/> = ${key-id}]]></statement>
|
||||
</query>
|
||||
<query name="insert" type="INSERT">
|
||||
<statement><![CDATA[INSERT INTO <TABLE/>(<FIELDS/>)
|
||||
VALUES(<VALUES/>)]]></statement>
|
||||
</query>
|
||||
<query name="update-by-PK" type="UPDATE">
|
||||
<param name="key-id" />
|
||||
<statement><![CDATA[UPDATE <TABLE/>
|
||||
SET <FIELDS/>
|
||||
WHERE <FIELD name='id'/> = ${key-id}]]></statement>
|
||||
</query>
|
||||
<query name="delete-by-PK" type="DELETE">
|
||||
<param name="key-id" />
|
||||
<statement><![CDATA[DELETE FROM <TABLE/>
|
||||
WHERE <FIELD name='id'/> = ${key-id}]]></statement>
|
||||
</query>
|
||||
</query-defs>
|
||||
</entity>
|
||||
<entity name="r-vs-domain" table="r_vs_domain" alias="rvd">
|
||||
<member name="id" field="id" value-type="long" length="19" nullable="false" key="true" auto-increment="true" />
|
||||
<member name="vs-id" field="vs_id" value-type="long" length="19" nullable="false" />
|
||||
|
@ -2855,6 +2944,49 @@
|
|||
<primary-key name="PRIMARY" members="id" />
|
||||
<index name="DataChange_LastTime" members="DataChange_LastTime ASC" />
|
||||
<index name="idx_create_time" members="create_time ASC" />
|
||||
<index name="status_target_slb_id" members="status ASC, target_slb_id ASC" />
|
||||
<readsets>
|
||||
<readset name="FULL" all="true" />
|
||||
</readsets>
|
||||
<updatesets>
|
||||
<updateset name="FULL" all="true" />
|
||||
</updatesets>
|
||||
<query-defs>
|
||||
<query name="find-by-PK" type="SELECT">
|
||||
<param name="key-id" />
|
||||
<statement><![CDATA[SELECT <FIELDS/>
|
||||
FROM <TABLE/>
|
||||
WHERE <FIELD name='id'/> = ${key-id}]]></statement>
|
||||
</query>
|
||||
<query name="insert" type="INSERT">
|
||||
<statement><![CDATA[INSERT INTO <TABLE/>(<FIELDS/>)
|
||||
VALUES(<VALUES/>)]]></statement>
|
||||
</query>
|
||||
<query name="update-by-PK" type="UPDATE">
|
||||
<param name="key-id" />
|
||||
<statement><![CDATA[UPDATE <TABLE/>
|
||||
SET <FIELDS/>
|
||||
WHERE <FIELD name='id'/> = ${key-id}]]></statement>
|
||||
</query>
|
||||
<query name="delete-by-PK" type="DELETE">
|
||||
<param name="key-id" />
|
||||
<statement><![CDATA[DELETE FROM <TABLE/>
|
||||
WHERE <FIELD name='id'/> = ${key-id}]]></statement>
|
||||
</query>
|
||||
</query-defs>
|
||||
</entity>
|
||||
<entity name="traffic-policy" table="traffic_policy" alias="tp">
|
||||
<member name="id" field="id" value-type="long" length="19" nullable="false" key="true" auto-increment="true" />
|
||||
<member name="version" field="version" value-type="int" length="10" nullable="false" />
|
||||
<member name="nx-active-version" field="nx_active_version" value-type="int" length="10" nullable="false" />
|
||||
<member name="active-version" field="active_version" value-type="int" length="10" nullable="false" />
|
||||
<member name="data-change-last-time" field="DataChange_LastTime" value-type="Date" nullable="false" />
|
||||
<var name="key-id" value-type="long" key-member="id" />
|
||||
<primary-key name="PRIMARY" members="id" />
|
||||
<index name="DataChange_LastTime" members="DataChange_LastTime ASC" />
|
||||
<index name="version" members="version ASC" />
|
||||
<index name="nx_active_version" members="nx_active_version ASC" />
|
||||
<index name="active_version" members="active_version ASC" />
|
||||
<readsets>
|
||||
<readset name="FULL" all="true" />
|
||||
</readsets>
|
||||
|
|
|
@ -1,5 +1,185 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<entities do-package="com.ctrip.zeus.dal.core" gen="true" do-class-suffix="Do">
|
||||
<entity name="r-traffic-policy-group" table="r_traffic_policy_group" alias="rtpg">
|
||||
<var name="hashes" value-type="Integer[]"/>
|
||||
<query-defs>
|
||||
<query name="find-all-by-hash" type="SELECT" multiple="true">
|
||||
<param name="hashes"/>
|
||||
<statement>
|
||||
<![CDATA[
|
||||
SELECT <FIELDS/>
|
||||
FROM <TABLE/>
|
||||
WHERE <FIELD name='hash'/> IN <IN>${hashes}</IN>
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
<query name="find-by-policy" type="SELECT" multiple="true">
|
||||
<param name="policy-id"/>
|
||||
<param name="policy-version"/>
|
||||
<statement>
|
||||
<![CDATA[
|
||||
SELECT <FIELDS/>
|
||||
FROM <TABLE/>
|
||||
WHERE <FIELD name='policy-id'/> = ${policy-id}
|
||||
AND <FIELD name='policy-version'/> = ${policy-version}
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
<query name="find-by-group" type="SELECT" multiple="true">
|
||||
<param name="group-id"/>
|
||||
<statement>
|
||||
<![CDATA[
|
||||
SELECT <FIELDS/>
|
||||
FROM <TABLE/>
|
||||
WHERE <FIELD name='group-id'/> = ${group-id}
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
<query name="insert" type="INSERT" batch="true">
|
||||
<statement>
|
||||
<![CDATA[
|
||||
INSERT INTO <TABLE/>(<FIELDS/>)
|
||||
VALUES(<VALUES/>)
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
<query name="delete-by-policy" type="DELETE">
|
||||
<param name="policy-id"/>
|
||||
<statement>
|
||||
<![CDATA[
|
||||
DELETE FROM <TABLE/>
|
||||
WHERE <FIELD name='policy-id'/> = ${policy-id}
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
<query name="delete-by-group" type="DELETE">
|
||||
<param name="group-id"/>
|
||||
<statement>
|
||||
<![CDATA[
|
||||
DELETE FROM <TABLE/>
|
||||
WHERE <FIELD name='group-id'/> = ${group-id}
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
</query-defs>
|
||||
</entity>
|
||||
<entity name="r-traffic-policy-vs" table="r_traffic_policy_vs" alias="rtpv">
|
||||
<var name="ids" value-type="Long[]"/>
|
||||
<var name="hashes" value-type="Integer[]"/>
|
||||
<query-defs>
|
||||
<query name="find-all-by-hash" type="SELECT" multiple="true">
|
||||
<param name="hashes"/>
|
||||
<statement>
|
||||
<![CDATA[
|
||||
SELECT <FIELDS/>
|
||||
FROM <TABLE/>
|
||||
WHERE <FIELD name='hash'/> IN <IN>${hashes}</IN>
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
<query name="find-by-policy" type="SELECT" multiple="true">
|
||||
<param name="policy-id"/>
|
||||
<param name="policy-version"/>
|
||||
<statement>
|
||||
<![CDATA[
|
||||
SELECT <FIELDS/>
|
||||
FROM <TABLE/>
|
||||
WHERE <FIELD name='policy-id'/> = ${policy-id}
|
||||
AND <FIELD name='policy-version'/> = ${policy-version}
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
<query name="find-by-vs" type="SELECT" multiple="true">
|
||||
<param name="vs-id"/>
|
||||
<statement>
|
||||
<![CDATA[
|
||||
SELECT <FIELDS/>
|
||||
FROM <TABLE/>
|
||||
WHERE <FIELD name='vs-id'/> = ${vs-id}
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
<query name="find-by-vses" type="SELECT" multiple="true">
|
||||
<param name="ids"/>
|
||||
<statement>
|
||||
<![CDATA[
|
||||
SELECT <FIELDS/>
|
||||
FROM <TABLE/>
|
||||
WHERE <FIELD name='vs-id'/> IN <IN>${ids}</IN>
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
<query name="insert" type="INSERT" batch="true">
|
||||
<statement>
|
||||
<![CDATA[
|
||||
INSERT INTO <TABLE/>(<FIELDS/>)
|
||||
VALUES(<VALUES/>)
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
<query name="delete-by-policy" type="DELETE">
|
||||
<param name="policy-id"/>
|
||||
<statement>
|
||||
<![CDATA[
|
||||
DELETE FROM <TABLE/>
|
||||
WHERE <FIELD name='policy-id'/> = ${policy-id}
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
<query name="delete-by-vs" type="DELETE">
|
||||
<param name="vs-id"/>
|
||||
<statement>
|
||||
<![CDATA[
|
||||
DELETE FROM <TABLE/>
|
||||
WHERE <FIELD name='vs-id'/> = ${vs-id}
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
</query-defs>
|
||||
</entity>
|
||||
<entity name="traffic-policy" table="traffic_policy" alias="tp">
|
||||
<query-defs>
|
||||
<query name="find-all" type="SELECT" multiple="true">
|
||||
<statement>
|
||||
<![CDATA[
|
||||
SELECT <FIELDS/>
|
||||
FROM <TABLE/>
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
<query name="find-by-id" type="SELECT">
|
||||
<param name="id"/>
|
||||
<statement>
|
||||
<![CDATA[
|
||||
SELECT <FIELDS/>
|
||||
FROM <TABLE/>
|
||||
WHERE <FIELD name='id'/> = ${id}
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
<query name="update-by-id" type="UPDATE" batch="true">
|
||||
<param name="id"/>
|
||||
<statement>
|
||||
<![CDATA[
|
||||
UPDATE <TABLE/>
|
||||
SET <FIELD name='version'/> = ${version},
|
||||
<FIELD name='active-version'/> = ${active-version},
|
||||
<FIELD name='nx-active-version'/> = ${nx-active-version}
|
||||
WHERE <FIELD name='id'/> = ${id}
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
<query name="delete-by-id" type="DELETE">
|
||||
<param name="id"/>
|
||||
<statement>
|
||||
<![CDATA[
|
||||
DELETE FROM <TABLE/>
|
||||
WHERE <FIELD name='id'/> = ${id}
|
||||
]]>
|
||||
</statement>
|
||||
</query>
|
||||
</query-defs>
|
||||
</entity>
|
||||
<entity name="rule" table="rule" alias="r2" do-class="RuleDo">
|
||||
<var name="ids" value-type="Long[]"/>
|
||||
<query-defs>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<entity-ref name="virtual-server" />
|
||||
<entity-ref name="slb" />
|
||||
<entity-ref name="rule" />
|
||||
<entity-ref name="policy-virtual-server" />
|
||||
<entity-ref name="traffic-policy" />
|
||||
<entity-ref name="traffic-control" />
|
||||
<entity-ref name="group-list" />
|
||||
|
@ -112,10 +113,17 @@
|
|||
<attribute name="ip" value-type="String" />
|
||||
<attribute name="host-name" value-type="String" />
|
||||
</entity>
|
||||
<entity name="traffic-policy">
|
||||
<element name="id" value-type="long" />
|
||||
<entity name="policy-virtual-server">
|
||||
<element name="path" value-type="String" />
|
||||
<element name="priority" value-type="int" />
|
||||
<entity-ref name="virtual-server" />
|
||||
</entity>
|
||||
<entity name="traffic-policy">
|
||||
<attribute name="id" value-type="long" />
|
||||
<attribute name="version" value-type="int" />
|
||||
<entity-ref name="policy-virtual-server" type="list" names="policy-virtual-servers" xml-indent="true" />
|
||||
<entity-ref name="traffic-control" type="list" names="controls" xml-indent="true" />
|
||||
<entity-ref name="rule" type="list" names="rule-set" xml-indent="true" />
|
||||
</entity>
|
||||
<entity name="traffic-control">
|
||||
<element name="weight" value-type="int" />
|
||||
|
|
|
@ -440,6 +440,24 @@
|
|||
<data-source-name>zeus</data-source-name>
|
||||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.unidal.dal.jdbc.mapping.TableProvider</role>
|
||||
<role-hint>r-traffic-policy-group</role-hint>
|
||||
<implementation>org.unidal.dal.jdbc.mapping.SimpleTableProvider</implementation>
|
||||
<configuration>
|
||||
<physical-table-name>r_traffic_policy_group</physical-table-name>
|
||||
<data-source-name>zeus</data-source-name>
|
||||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.unidal.dal.jdbc.mapping.TableProvider</role>
|
||||
<role-hint>r-traffic-policy-vs</role-hint>
|
||||
<implementation>org.unidal.dal.jdbc.mapping.SimpleTableProvider</implementation>
|
||||
<configuration>
|
||||
<physical-table-name>r_traffic_policy_vs</physical-table-name>
|
||||
<data-source-name>zeus</data-source-name>
|
||||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.unidal.dal.jdbc.mapping.TableProvider</role>
|
||||
<role-hint>r-vs-domain</role-hint>
|
||||
|
@ -485,6 +503,15 @@
|
|||
<data-source-name>zeus</data-source-name>
|
||||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.unidal.dal.jdbc.mapping.TableProvider</role>
|
||||
<role-hint>rule</role-hint>
|
||||
<implementation>org.unidal.dal.jdbc.mapping.SimpleTableProvider</implementation>
|
||||
<configuration>
|
||||
<physical-table-name>rule</physical-table-name>
|
||||
<data-source-name>zeus</data-source-name>
|
||||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.unidal.dal.jdbc.mapping.TableProvider</role>
|
||||
<role-hint>server</role-hint>
|
||||
|
@ -620,6 +647,15 @@
|
|||
<data-source-name>zeus</data-source-name>
|
||||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.unidal.dal.jdbc.mapping.TableProvider</role>
|
||||
<role-hint>traffic-policy</role-hint>
|
||||
<implementation>org.unidal.dal.jdbc.mapping.SimpleTableProvider</implementation>
|
||||
<configuration>
|
||||
<physical-table-name>traffic_policy</physical-table-name>
|
||||
<data-source-name>zeus</data-source-name>
|
||||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>com.ctrip.zeus.dal.core.AppInfoDao</role>
|
||||
<implementation>com.ctrip.zeus.dal.core.AppInfoDao</implementation>
|
||||
|
@ -1052,6 +1088,24 @@
|
|||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
<component>
|
||||
<role>com.ctrip.zeus.dal.core.RTrafficPolicyGroupDao</role>
|
||||
<implementation>com.ctrip.zeus.dal.core.RTrafficPolicyGroupDao</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.unidal.dal.jdbc.QueryEngine</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
<component>
|
||||
<role>com.ctrip.zeus.dal.core.RTrafficPolicyVsDao</role>
|
||||
<implementation>com.ctrip.zeus.dal.core.RTrafficPolicyVsDao</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.unidal.dal.jdbc.QueryEngine</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
<component>
|
||||
<role>com.ctrip.zeus.dal.core.RVsDomainDao</role>
|
||||
<implementation>com.ctrip.zeus.dal.core.RVsDomainDao</implementation>
|
||||
|
@ -1097,6 +1151,15 @@
|
|||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
<component>
|
||||
<role>com.ctrip.zeus.dal.core.RuleDao</role>
|
||||
<implementation>com.ctrip.zeus.dal.core.RuleDao</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.unidal.dal.jdbc.QueryEngine</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
<component>
|
||||
<role>com.ctrip.zeus.dal.core.ServerDao</role>
|
||||
<implementation>com.ctrip.zeus.dal.core.ServerDao</implementation>
|
||||
|
@ -1232,5 +1295,14 @@
|
|||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
<component>
|
||||
<role>com.ctrip.zeus.dal.core.TrafficPolicyDao</role>
|
||||
<implementation>com.ctrip.zeus.dal.core.TrafficPolicyDao</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.unidal.dal.jdbc.QueryEngine</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
</components>
|
||||
</plexus>
|
||||
|
|
|
@ -78,6 +78,9 @@
|
|||
<table name="stats_group_slb"/>
|
||||
<table name="archive_commit"/>
|
||||
<table name="rule"/>
|
||||
<table name="traffic_policy"/>
|
||||
<table name="r_traffic_policy_vs"/>
|
||||
<table name="r_traffic_policy_group"/>
|
||||
</group>
|
||||
</jdbc>
|
||||
</wizard>
|
||||
|
|
|
@ -208,6 +208,14 @@
|
|||
<constructor-arg type="java.lang.Class" value="com.ctrip.zeus.dal.core.RSlbStatusDao"/>
|
||||
</bean>
|
||||
|
||||
<bean id="rTrafficPolicyGroupDao" factory-bean="daoFactory" factory-method="getDao">
|
||||
<constructor-arg type="java.lang.Class" value="com.ctrip.zeus.dal.core.RTrafficPolicyGroupDao"/>
|
||||
</bean>
|
||||
|
||||
<bean id="rTrafficPolicyVsDao" factory-bean="daoFactory" factory-method="getDao">
|
||||
<constructor-arg type="java.lang.Class" value="com.ctrip.zeus.dal.core.RTrafficPolicyVsDao"/>
|
||||
</bean>
|
||||
|
||||
<bean id="ruleDao" factory-bean="daoFactory" factory-method="getDao">
|
||||
<constructor-arg type="java.lang.Class" value="com.ctrip.zeus.dal.core.RuleDao"/>
|
||||
</bean>
|
||||
|
@ -284,4 +292,8 @@
|
|||
<constructor-arg type="java.lang.Class" value="com.ctrip.zeus.dal.core.TaskDao"/>
|
||||
</bean>
|
||||
|
||||
<bean id="trafficPolicyDao" factory-bean="daoFactory" factory-method="getDao">
|
||||
<constructor-arg type="java.lang.Class" value="com.ctrip.zeus.dal.core.TrafficPolicyDao"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -80,13 +80,24 @@
|
|||
<data>abcde</data>
|
||||
<phase>before_abc</phase>
|
||||
</rule>
|
||||
<traffic-policy>
|
||||
<id>123456789012</id>
|
||||
<path>/hotel</path>
|
||||
<policy-virtual-server>
|
||||
<path>/abc</path>
|
||||
<priority>1</priority>
|
||||
<virtual-server/>
|
||||
</policy-virtual-server>
|
||||
<traffic-policy id="123456789012" version="1">
|
||||
<policy-virtual-servers>
|
||||
<policy-virtual-server/>
|
||||
<policy-virtual-server/>
|
||||
</policy-virtual-servers>
|
||||
<controls>
|
||||
<traffic-control/>
|
||||
<traffic-control/>
|
||||
</controls>
|
||||
<rule-set>
|
||||
<rule/>
|
||||
<rule/>
|
||||
</rule-set>
|
||||
</traffic-policy>
|
||||
<traffic-control>
|
||||
<group/>
|
||||
|
|
Loading…
Reference in a new issue