Merge branch 'github_dev' into traffic-policy

# Conflicts:
#	src/main/java/com/ctrip/zeus/service/build/conf/LocationConf.java
This commit is contained in:
Mengyi Zhou 2017-02-07 18:49:00 +08:00
commit 0759f50638
12 changed files with 316 additions and 133 deletions

View file

@ -31,7 +31,7 @@ public class AccessLogStateMachine implements LogStatsStateMachine {
}
if (ctxt.shouldProceed()) {
ctxt.setState(StateMachineContext.ContextState.FAILURE);
} else {
} else if (!ctxt.getState().equals(StateMachineContext.ContextState.FAILURE)) {
ctxt.setState(StateMachineContext.ContextState.SUCCESS);
}
} catch (Exception ex) {

View file

@ -61,8 +61,13 @@ public class WrappedStringState implements LogStatsState {
c = source[i];
if (c == startSymbol) {
if (!_escaping && matcher[0] == Character.MIN_VALUE) {
if (sb.length() == 0) {
matcher[0] = c;
continue;
} else {
ctxt.setState(StateMachineContext.ContextState.FAILURE);
return;
}
}
}
if (c == endSymbol) {

View file

@ -29,10 +29,10 @@ public abstract class GroupView {
@JsonView(ViewConstraints.Normal.class)
abstract Integer getVersion();
@JsonView(ViewConstraints.Normal.class)
@JsonView(ViewConstraints.Detail.class)
abstract HealthCheck getHealthCheck();
@JsonView(ViewConstraints.Normal.class)
@JsonView(ViewConstraints.Detail.class)
abstract LoadBalancingMethod getLoadBalancingMethod();
@JsonView(ViewConstraints.Normal.class)

View file

@ -123,6 +123,22 @@ public class GroupMemberResource {
return responseHandler.handle(groupServerList, hh.getMediaType());
}
/**
* @api {post} /api/group/addMember: [Write] Add group server
* @apiDescription See [Update group server](#api-Member-UpdateMember) for object description
* @apiName AddMember
* @apiGroup Member
* @apiSuccess (Success 200) {String} message success message
* @apiParam (Parameter) {boolean} [online=false] add group servers to its offline (and online) version
* @apiParam (RequestEntity) {long} group-id the group to be modified
* @apiParam (RequestEntity) {GroupServer[]} group-servers group servers to be added
* @apiParam (GroupServer) {Integer} port server port
* @apiParam (GroupServer) {String} ip server ip
* @apiParam (GroupServer) {String} host-name server host name
* @apiParam (GroupServer) {Integer} [weight] proxying weight
* @apiParam (GroupServer) {Integer} [max-fails=0] exclude server from proxying if max_fails count exceeds the latch for fails_timeout interval, disabled if values 0
* @apiParam (GroupServer) {Integer} [fails-timeout=0] disabled by default
*/
@POST
@Path("/group/addMember")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@ -174,6 +190,41 @@ public class GroupMemberResource {
return responseHandler.handle("Successfully added group servers to group with id " + gsl.getGroupId() + ".", hh.getMediaType());
}
/**
* @api {post} /api/group/updateMember: [Write] Update group server
* @apiDescription UpdateMember only incrementally affects group servers in the list, other members would remain unchanged.
* @apiName UpdateMember
* @apiGroup Member
* @apiSuccess (Success 200) {String} message success message
* @apiParam (Parameter) {boolean} [online=false] add group servers to its offline (and online) version
* @apiParam (RequestEntity) {long} group-id the group to be modified
* @apiParam (RequestEntity) {GroupServer[]} group-servers group servers to be modified
* @apiParam (GroupServer) {Integer} port server port
* @apiParam (GroupServer) {String} ip server ip
* @apiParam (GroupServer) {String} host-name server host name
* @apiParam (GroupServer) {Integer} [weight] proxying weight
* @apiParam (GroupServer) {Integer} [max-fails=0] exclude server from proxying if max_fails count exceeds the latch for fails_timeout interval, disabled if values 0
* @apiParam (GroupServer) {Integer} [fails-timeout=0] disabled by default
* @apiParamExample {json} Sample Request:
* {
* "group-id" : 1,
* "group-servers" : [ {
* "port" : 8080,
* "ip" : "127.0.0.1",
* "host-name" : "PC1",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* }, {
* "port" : 8080,
* "ip" : "127.0.0.2",
* "host-name" : "PC2",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* } ]
* }
*/
@POST
@Path("/group/updateMember")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@ -235,6 +286,15 @@ public class GroupMemberResource {
return responseHandler.handle("Successfully updated group servers to group with id " + gsl.getGroupId() + ".", hh.getMediaType());
}
/**
* @api {get} /api/group/removeMember: [Write] Remove group server
* @apiName RemoveMember
* @apiGroup Member
* @apiSuccess (Success 200) {String} message success message
* @apiParam {boolean} [online=false] add group servers to its offline (and online) version
* @apiParam {long} groupId the group to be modified
* @apiParam {string[]} ip group servers to be removed
*/
@GET
@Path("/group/removeMember")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})

View file

@ -76,23 +76,101 @@ public class GroupResource {
Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* @api {get} /api/groups: Request group information
* @api {get} /api/groups: [Read] Batch fetch group data
* @apiName ListGroups
* @apiGroup Group
* @apiParam {long[]} groupId 1,2,3
* @apiParam {string[]} groupName dev,localhost,test
* @apiParam {string[]} fuzzyName de,local,te
* @apiParam {string[]} appId 1001,1101,1100
* @apiParam {string[]} ip 10.2.1.2,10.2.1.11
* @apiParam {string} mode get {online/offline/redundant} (redundant=online&offline) version
* @apiParam {string} type get groups with {info/normal/detail/extended} information
* @apiParam {string[]} anyTag union search groups by tags e.g. anyTag=group1,group2
* @apiParam {string[]} tags join search groups by tags e.g. tags=group1,group2
* @apiParam {string[]} anyProp union search groups by properties(key:value) e.g. anyProp=dc:oy,dc:jq
* @apiParam {string[]} props join search groups by properties(key:value) e.g. props=department:hotel,dc:jq
* @apiParam {any} vs supported vs property queries, ref /api/vses
* @apiParam {any} slb supported slb property queries, ref /api/slbs
* @apiSuccess {Group[]} groups group list json object
* @apiDescription See [Update group content](#api-Group-FullUpdateGroup) for object description
* @apiSuccess (Success 200) {GroupObject[]} groups group list result after query
* @apiSuccess (Success 200) {Integer[]} total total number of group entities in the group list, it may be useful when `limit` parameter is specified
* @apiParam {long[]} [groupId] 1,2,3
* @apiParam {string[]} [groupName] dev,localhost,test
* @apiParam {string[]} [fuzzyName] de,local,te
* @apiParam {string[]} [appId] 1001,1101,1100
* @apiParam {string[]} [ip] 10.2.1.2,10.2.1.11
* @apiParam {string=online,offline,redundant(online&offline)} [mode] query snapshot versions by mode
* @apiParam {string=info,normal,detail,extended} [type] filter group information by detail level
* @apiParam {int} [limit=unlimited] get limited number of result
* @apiParam {int} [offset=0] get limited number of result since offset
* @apiParam {string=id,name,created-time} [sort] sort by property asc
* @apiParam {string=asc,desc} [order] sort by group property and specified order
* @apiParam {string[]} [anyTag] union search group by tags e.g. anyTag=group1,group2
* @apiParam {string[]} [tags] join search group by tags e.g. tags=group1,group2
* @apiParam {string[]} [anyProp] union search group by properties(key:value) e.g. anyProp=dc:oy,dc:jq
* @apiParam {string[]} [props] join search group by properties(key:value) e.g. props=department:hotel,dc:jq
* @apiParam {any} [vs] supported vs property queries, ref /api/vses
* @apiParam {any} [slb] supported slb property queries, ref /api/slbs
* @apiSuccess (PropertyDetailLevel) {Long} id info/normal/detail/extended
* @apiSuccess (PropertyDetailLevel) {String} name info/normal/detail/extended
* @apiSuccess (PropertyDetailLevel) {Integer} version info/normal/detail/extended
* @apiSuccess (PropertyDetailLevel) {String} created-time normal/detail/extended
* @apiSuccess (PropertyDetailLevel) {Boolean} ssl normal/detail/extended
* @apiSuccess (PropertyDetailLevel) {String} app-id info/normal/detail/extended
* @apiSuccess (PropertyDetailLevel) {GroupVirtualServer[]} group-virtual-servers detail/extended
* @apiSuccess (PropertyDetailLevel) {HealthCheck} health-check detail/extended
* @apiSuccess (PropertyDetailLevel) {Object} load-balancing-method detail/extended
* @apiSuccess (PropertyDetailLevel) {String[]} tags extended
* @apiSuccess (PropertyDetailLevel) {Object[]} properties extended
* @apiSuccess (PropertyDetailLevel) {Object[]} group-servers normal/detail/extended
* @apiSuccessExample {json} JSON format:
* {
* "id" : 1,
* "name" : "sg_soho_dev_localhost_testservice",
* "version" : 1,
* "created-time" : "2016-09-18 10:00:05",
* "ssl" : false,
* "app-id" : "999999",
* "group-virtual-servers" : [ {
* "path" : "~* ^/testservice($|/|\\?)",
* "virtual-server" : {
* "port" : "80",
* "version" : 1,
* "domains" : [ {
* "name" : "localhost"
* } ],
* "ssl" : false,
* "id" : 3,
* "slb-id" : 3,
* "slb-ids" : [ 3 ],
* "name" : "localhost_80"
* },
* "rewrite" : "",
* "priority" : 1000
* } ],
* "health-check" : {
* "timeout" : 2000,
* "uri" : "/slbhealthcheck.html",
* "intervals" : 10000,
* "fails" : 10,
* "passes" : 3
* },
* "load-balancing-method" : {
* "type" : "roundrobin",
* "value" : "default"
* },
* "tags" : [ "my_favorite", "test_group" ],
* "properties" : [ {
* "name" : "status",
* "value" : "activated"
* }, {
* "name" : "Department",
* "value" : "framework"
* } ],
* "group-servers" : [ {
* "port" : 8080,
* "ip" : "127.0.0.1",
* "host-name" : "PC1",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* }, {
* "port" : 8080,
* "ip" : "127.0.0.2",
* "host-name" : "PC2",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* } ]
* }
*/
@GET
@Path("/groups")
@ -165,61 +243,11 @@ public class GroupResource {
}
/**
* @api {get} /api/group: Get group content
* @api {get} /api/group: [Read] Get single group data
* @apiName GetSingleGroup
* @apiGroup Group
* @apiSuccess {Group} group json object
* @apiExample {json} Usage:
* {
* "id" : 1,
* "name" : "sg_soho_dev_localhost_testservice",
* "version" : 1,
* "ssl" : false,
* "app-id" : "999999",
* "group-virtual-servers" : [ {
* "path" : "~* ^/testservice",
* "virtual-server" : {
* "port" : "80",
* "version" : 1,
* "domains" : [ {
* "name" : "localhost"
* } ],
* "ssl" : false,
* "id" : 3,
* "slb-id" : 3,
* "slb-ids" : [ 3 ],
* "name" : "localhost_80"
* },
* "rewrite" : "",
* "priority" : 1000
* } ],
* "health-check" : {
* "timeout" : 2000,
* "uri" : "/slbhealthcheck.html",
* "intervals" : 10000,
* "fails" : 10,
* "passes" : 3
* },
* "load-balancing-method" : {
* "type" : "roundrobin",
* "value" : "default"
* },
* "group-servers" : [ {
* "port" : 8080,
* "ip" : "127.0.0.1",
* "host-name" : "PC1",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* }, {
* "port" : 8080,
* "ip" : "127.0.0.2",
* "host-name" : "PC2",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* } ]
* }
* @apiDescription See [Batch fetch group data](#api-Group-ListGroups) for more information
* @apiSuccess (Success 200) {GroupObject} group group entity
*/
@GET
@Path("/group")
@ -295,6 +323,13 @@ public class GroupResource {
return responseHandler.handleSerializedValue(ObjectJsonWriter.write(listView, type), hh.getMediaType());
}
/**
* @api {post} /api/group/new: [Write] Create new group
* @apiName CreateGroup
* @apiGroup Group
* @apiDescription See [Update group content](#api-Group-FullUpdateGroup) for object description
* @apiSuccess {Group} newly created group object
**/
@POST
@Path("/group/new")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, "*/*"})
@ -378,50 +413,70 @@ public class GroupResource {
}
/**
* @api {post} /api/group/update: Update group content
* @apiName UpdateGroup
* @api {post} /api/group/update: [Write] Update group content
* @apiName FullUpdateGroup
* @apiGroup Group
* @apiSuccess {Group} group json object
* @apiExample {json} Usage:
* @apiSuccess {Group} updated group object
* @apiParam (GroupObject) {Long} id id
* @apiParam (GroupObject) {String} name name
* @apiParam (GroupObject) {Integer} version version
* @apiParam (GroupObject) {Boolean} ssl https group
* @apiParam (GroupObject) {String} app-id app id
* @apiParam (GroupObject) {GroupVirtualServer[]} group-virtual-servers configuration on specified virtual server
* @apiParam (GroupObject) {HealthCheck} [health-check] health check configuration, disabled if null
* @apiParam (GroupObject) {String[]} [tags] add tags to group
* @apiParam (GroupObject) {Object[]} [properties] add/update properties of group
* @apiParam (GroupObject) {Object[]} group-servers group server list
* @apiParam (GroupVirtualServer) {String} path location entry on the specified virtual server
* @apiParam (GroupVirtualServer) {String} [rewrite] rewrite path before proxying
* @apiParam (GroupVirtualServer) {Integer} [priority] recommend to leave null, otherwise force set priority of location entry on the specified virtual server
* @apiParam (GroupVirtualServer) {Object} virtual-server combined virtual server [id only]
* @apiParam (HealthCheck) {Integer} [timeout=2000] timeout for health check page
* @apiParam (HealthCheck) {Integer} uri health check uri
* @apiParam (HealthCheck) {Integer} [interval=5000] health check interval
* @apiParam (HealthCheck) {Integer} [fails=3] mark down after continuous failure count exceeds the latch
* @apiParam (HealthCheck) {Integer} [passes=1] mark up after continuous success count reaches the latch
* @apiParam (GroupServer) {Integer} port server port
* @apiParam (GroupServer) {String} ip server ip
* @apiParam (GroupServer) {String} host-name server host name
* @apiParam (GroupServer) {Integer} [weight] [readonly]
* @apiParam (GroupServer) {Integer} [max-fails=0] exclude server from proxing if max_fails count exceeds the latch for fails_timeout interval, disabled if values 0
* @apiParam (GroupServer) {Integer} [fails-timeout=0] disabled by default
* @apiParamExample {json} Sample Request:
* {
* "id" : 1,
* "name" : "sg_soho_dev_localhost_testservice",
* "version" : 1,
* "created-time" : "2016-09-18 10:00:05",
* "ssl" : false,
* "app-id" : "999999",
* "group-virtual-servers" : [ {
* "path" : "~* ^/testservice",
* "path" : "~* ^/testservice($|/|\\?)",
* "virtual-server" : {
* "id" : 715
* "id" : 3
* },
* "rewrite" : "",
* "priority" : 1000
* } ],
* "health-check" : {
* "timeout" : 2000,
* "uri" : "/slbhealthcheck.html",
* "intervals" : 10000,
* "fails" : 10,
* "passes" : 3
* },
* "load-balancing-method" : {
* "type" : "roundrobin",
* "value" : "default"
* "uri" : "/slbhealthcheck.html"
* },
* "tags" : [ "my_favorite", "test_group" ],
* "properties" : [ {
* "name" : "status",
* "value" : "activated"
* }, {
* "name" : "Department",
* "value" : "framework"
* } ],
* "group-servers" : [ {
* "port" : 8080,
* "ip" : "127.0.0.1",
* "host-name" : "PC1",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* }, {
* "port" : 8080,
* "ip" : "127.0.0.2",
* "host-name" : "PC2",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* } ]
* }
*/
@ -450,6 +505,12 @@ public class GroupResource {
lock.unlock();
}
if (extendedView.getProperties() != null) {
setProperties(g.getId(), extendedView.getProperties());
}
if (extendedView.getTags() != null) {
addTag(g.getId(), extendedView.getTags());
}
try {
if (groupCriteriaQuery.queryByIdAndMode(g.getId(), SelectionMode.ONLINE_EXCLUSIVE).length == 1) {
@ -458,14 +519,6 @@ public class GroupResource {
} catch (Exception ex) {
}
if (extendedView.getProperties() != null) {
setProperties(g.getId(), extendedView.getProperties());
}
if (extendedView.getTags() != null) {
addTag(g.getId(), extendedView.getTags());
}
addHealthProperty(g.getId());
String slbMessageData = MessageUtil.getMessageData(request, new Group[]{g}, null, null, null, true);

View file

@ -84,8 +84,8 @@ public class OperationResource {
private Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* @api {get} /api/op/upServer: Mark up a server
* @apiDescription Mark up server action will take effect on a physical server. It will set server status to 'up' to all nesting SLB groups.
* @api {get} /api/op/upServer: [OPS] Mark up a server
* @apiDescription Mark up server action will take effect on a physical server. It will set `server` status to 'up' to all nesting SLB groups.
* @apiName MarkUpServer
* @apiGroup Operation
* @apiParam {String} ip server ip address
@ -99,8 +99,8 @@ public class OperationResource {
}
/**
* @api {get} /api/op/downServer: Mark down a server
* @apiDescription Mark down server action will take effect on a physical server. It will set server status to 'down' to all nesting SLB groups.
* @api {get} /api/op/downServer: [OPS] Mark down a server
* @apiDescription Mark down server action will take effect on a physical server. It will set `server` status to 'down' to all nesting SLB groups.
* @apiName MarkDownServer
* @apiGroup Operation
* @apiParam {String} ip server ip address
@ -187,13 +187,13 @@ public class OperationResource {
}
/**
* @api {get} /api/op/upMember: Mark up group member(s)
* @apiDescription Mark up group member action will take effect only on a single group. It will set member status to 'up' on the specified group.
* @api {get} /api/op/upMember: [OPS] Mark up member(s)
* @apiDescription Mark up group member action will take effect only on a single group. It will set `member` status to 'up' on the specified group.
* @apiName MarkUpMember
* @apiGroup Operation
* @apiParam {Long} groupId id of the target group whose member needs to be marked up
* @apiParam {String} groupName name of the target group whose member needs to be marked up
* @apiParam {StringList} ip group member ip address(es)
* @apiParam {String[]} ip group member ip address(es)
* @apiParam {Boolean} batch if multiple group members needs to be marked up, batch value must be explicitly set to true
* @apiSuccess {GroupServerStatusList} member statuses by group
*/
@ -219,13 +219,13 @@ public class OperationResource {
}
/**
* @api {get} /api/op/downMember: Mark down group member(s)
* @apiDescription Mark down group member action will take effect only on a single group. It will set member status to 'down' on the specified group.
* @api {get} /api/op/downMember: [OPS] Mark down member(s)
* @apiDescription Mark down group member action will take effect only on a single group. It will set `member` status to 'down' on the specified group.
* @apiName MarkDownMember
* @apiGroup Operation
* @apiParam {Long} groupId id of the target group whose member needs to be marked down
* @apiParam {String} groupName name of the target group whose member needs to be marked down
* @apiParam {StringList} ip group member ip address(es)
* @apiParam {String[]} ip group member ip address(es)
* @apiParam {Boolean} batch if multiple group members needs to be marked down, batch value must be explicitly set to true
* @apiSuccess {GroupServerStatusList} member statuses by group
*/
@ -252,13 +252,13 @@ public class OperationResource {
}
/**
* @api {get} /api/op/pullIn: Pull in group member(s)
* @apiDescription Pull in group member action will take effect only on a single group. It will set pull status to 'up' on the specified group.
* @api {get} /api/op/pullIn: [TARS] Pull in member(s)
* @apiDescription Pull in group member action will take effect only on a single group. It will set `pull` status to 'up' on the specified group.
* @apiName PullInMember
* @apiGroup Operation
* @apiParam {Long} groupId id of the target group whose member needs to be pulled in
* @apiParam {String} groupName name of the target group whose member needs to be pulled in
* @apiParam {StringList} ip group member ip address(es)
* @apiParam {String[]} ip group member ip address(es)
* @apiParam {Boolean} batch if multiple group members needs to be pulled in, batch value must be explicitly set to true
* @apiSuccess {GroupServerStatusList} member statuses by group
*/
@ -283,13 +283,13 @@ public class OperationResource {
}
/**
* @api {get} /api/op/pullOut: Pull out group member(s)
* @apiDescription Pull out group member action will take effect only on a single group. It will set pull status to 'down' on the specified group.
* @api {get} /api/op/pullOut: [TARS] Pull out member(s)
* @apiDescription Pull out group member action will take effect only on a single group. It will set `pull` status to 'down' on the specified group.
* @apiName PullOutMember
* @apiGroup Operation
* @apiParam {Long} groupId id of the target group whose member needs to be pulled out
* @apiParam {String} groupName name of the target group whose member needs to be pulled out
* @apiParam {StringList} ip group member ip address(es)
* @apiParam {String[]} ip group member ip address(es)
* @apiParam {Boolean} batch if multiple group members needs to be pulled out, batch value must be explicitly set to true
* @apiSuccess {GroupServerStatusList} member statuses by group
*/
@ -313,6 +313,17 @@ public class OperationResource {
return memberOps(request, hh, groupId, ips, batch, false, TaskOpsType.PULL_MEMBER_OPS);
}
/**
* @api {get} /api/op/raise: [HC] Raise member(s)
* @apiDescription Raise group member action will take effect only on a single group. It will set `healthy` status to 'up' on the specified group.
* @apiName RaiseMember
* @apiGroup Operation
* @apiParam {Long} groupId id of the target group whose member needs to be pulled out
* @apiParam {String} groupName name of the target group whose member needs to be pulled out
* @apiParam {String[]} ip group member ip address(es)
* @apiParam {Boolean} batch if multiple group members needs to be pulled out, batch value must be explicitly set to true
* @apiSuccess {GroupServerStatusList} member statuses by group
*/
@GET
@Path("/raise")
@Authorize(name = "upDownMember")
@ -342,6 +353,17 @@ public class OperationResource {
}
}
/**
* @api {get} /api/op/fall: [HC] Fall member(s)
* @apiDescription Fall group member action will take effect only on a single group. It will set `healthy` status to 'down' on the specified group.
* @apiName FallMember
* @apiGroup Operation
* @apiParam {Long} groupId id of the target group whose member needs to be pulled out
* @apiParam {String} groupName name of the target group whose member needs to be pulled out
* @apiParam {String[]} ip group member ip address(es)
* @apiParam {Boolean} batch if multiple group members needs to be pulled out, batch value must be explicitly set to true
* @apiSuccess {GroupServerStatusList} member statuses by group
*/
@GET
@Path("/fall")
@Authorize(name = "upDownMember")

View file

@ -130,6 +130,8 @@ public class LocationConf {
confWriter.writeCommand("proxy_read_timeout", readTimeout + "s");
}
writeSlbUrlCheck(confWriter, slbId, vsId, groupId);
// write x-forward-for configuration
if (configHandler.getEnable("location.x-forwarded-for", slbId, vsId, groupId, true)) {
confWriter.writeIfStart("$remote_addr ~* \"" +
@ -162,6 +164,14 @@ public class LocationConf {
confWriter.writeLocationEnd();
}
private void writeSlbUrlCheck(ConfWriter confWriter, Long slbId, Long vsId, Long groupId) throws Exception {
if (configHandler.getEnable("slb.url.check.flag", slbId, vsId, groupId, false)) {
confWriter.writeIfStart("$http_" + configHandler.getStringValue("slb.url.check.header.name", "thisfieldusedforslburlcheck") + " = \"true\"");
confWriter.writeCommand("return", " 200 \"GroupId=" + groupId + "\"");
confWriter.writeIfEnd();
}
}
private void writeSocketIOGroup(ConfWriter confWriter, String path, Group group, String upstreamName) {
confWriter.writeLocationStart(path);
confWriter.writeCommand("proxy_set_header", "Upgrade $http_upgrade");
@ -339,5 +349,12 @@ public class LocationConf {
confWriter.writeLocationEnd();
}
public void writeDefaultRootLocation(ConfWriter confWriter) {
confWriter.writeLocationStart("/");
confWriter.writeCommand("error_page", "404 /404page");
confWriter.writeCommand("return", "404");
confWriter.writeLocationEnd();
}
}

View file

@ -89,6 +89,8 @@ public class ServerConf {
}
}
addDefaultRootLoaction(slbId, vsId, groups, confWriter);
confWriter.writeServerEnd();
return confWriter.getValue();
}
@ -266,4 +268,23 @@ public class ServerConf {
}
return result;
}
private void addDefaultRootLoaction(Long slbId, Long vsId, List<Group> groups, ConfWriter confWriter) throws Exception {
// 0. enable flag
if (!configHandler.getEnable("default.root.location", slbId, vsId, null, false)) {
return;
}
// 1. return while already have root location .
for (Group group : groups) {
for (GroupVirtualServer gvs : group.getGroupVirtualServers()) {
if (gvs.getVirtualServer().getId().equals(vsId)) {
if (gvs.getPath().trim().equals("/") || gvs.getPath().trim().equals("~* ^/")) {
return;
}
}
}
}
// 2. add default location instead while not found root location.
locationConf.writeDefaultRootLocation(confWriter);
}
}

View file

@ -147,8 +147,12 @@ public class QueryEngine {
}
pre.retainAll(orig);
}
if (pre.size() == 0) {
c.addAtIndex(0, "-1");
}else {
c.addAtIndex(0, Joiner.on(",").join(pre));
}
}
// filter by criteria queries
String[] traverseSequence = new String[]{sequenceController[1].getType(),

View file

@ -168,7 +168,7 @@ public class PropertyServiceImpl implements PropertyService {
Set<Long> result = new HashSet<>();
for (PropertyItemDo e : propertyItemDao.findAllByProperties(pids.values().toArray(new Long[0]), PropertyItemEntity.READSET_FULL)) {
if (e.getType().equals(type)) {
if (e.getType().toLowerCase().equals(type.toLowerCase())) {
result.add(e.getItemId());
}
}
@ -198,14 +198,14 @@ public class PropertyServiceImpl implements PropertyService {
}
}
for (Long l : pids.values()) {
if (l == obj) return new HashSet<>();
if (l.equals(obj)) return new HashSet<>();
}
int joinedValue = pids.size();
Map<Long, Counter> marker = new HashMap<>();
for (PropertyItemDo e : propertyItemDao.findAllByProperties(pids.values().toArray(new Long[0]), PropertyItemEntity.READSET_FULL)) {
if (e.getType().equals(type)) {
Counter m = marker.get(e.getPropertyId());
if (e.getType().toLowerCase().equals(type.toLowerCase())) {
Counter m = marker.get(e.getItemId());
if (m == null) {
marker.put(e.getItemId(), new Counter());
} else {

View file

@ -23,7 +23,7 @@ import java.util.concurrent.atomic.AtomicLong;
*/
public class StressTest {
public static void main(String[] args) throws IOException {
final File accessLogFile = new File("D:/opt/logs/nginx/access.log");
final File accessLogFile = new File("D:/opt/logs/nginx/access_1.log");
final AtomicLong errorCount = new AtomicLong();
final AtomicLong succCount = new AtomicLong();
final int analyzerWorkers = 2;
@ -45,6 +45,11 @@ public class StressTest {
.registerLogStatsDelegator(new StatsDelegate<List<KeyValue>>() {
@Override
public void delegate(List<KeyValue> input) {
}
@Override
public void delegate(String raw, List<KeyValue> input) {
if (input != null && input.size() > 0) {
try {
dateFormat.get().parse(input.get(0).getValue());
@ -59,11 +64,6 @@ public class StressTest {
errorCount.incrementAndGet();
}
}
@Override
public void delegate(String raw, List<KeyValue> input) {
}
});
long now = System.nanoTime();

View file

@ -110,6 +110,7 @@ public class StateMachineParsingTest {
List<String> realCases = new ArrayList<>();
realCases.add("--");
realCases.add("[17/Jan/2017:14:02:18 +0800] m.localhost.com svr40315 127.8.110.51 GET /html5/flight/empty.html?allianceID=\\xB2\\x99 \\xE2\\x80 \\xE9\\x86 (16) 80 - 220.202.153.40 - HTTP/1.1 \"Mozilla/5.0\" \"-\" 400 1322 2602 0.008 0.001 : 0.007 10.8.161.147:80 : 10.15.211.2:80 400 : 200 backend_5270");
for (String rc : realCases) {
List<KeyValue> kvs = parser.parse(rc);
Assert.assertTrue(kvs.size() == 0);