diff --git a/abtest-sample/src/test/java/com/dianping/abtest/sample/ABTestServerConfigurator.java b/abtest-sample/src/test/java/com/dianping/abtest/sample/ABTestServerConfigurator.java
index 3a534a6fbd995aa1502c0b51a967c38d95385ba4..f608ec5826a0d74302af3c8ad03592d25edc1f96 100644
--- a/abtest-sample/src/test/java/com/dianping/abtest/sample/ABTestServerConfigurator.java
+++ b/abtest-sample/src/test/java/com/dianping/abtest/sample/ABTestServerConfigurator.java
@@ -6,7 +6,10 @@ import java.util.List;
import org.unidal.lookup.configuration.AbstractResourceConfigurator;
import org.unidal.lookup.configuration.Component;
+import com.dianping.cat.abtest.repository.ABTestEntityRepository;
+import com.dianping.cat.abtest.repository.HttpABTestEntityRepository;
import com.dianping.cat.abtest.spi.ABTestGroupStrategy;
+import com.dianping.cat.configuration.ClientConfigManager;
public class ABTestServerConfigurator extends AbstractResourceConfigurator {
@Override
@@ -15,6 +18,10 @@ public class ABTestServerConfigurator extends AbstractResourceConfigurator {
all.add(C(ABTestGroupStrategy.class, IPDistributionStrategy.ID, IPDistributionStrategy.class)
.is(PER_LOOKUP));
+
+ all.add(C(ABTestEntityRepository.class, HttpABTestEntityRepository.class) //
+ .req(ClientConfigManager.class)
+ .config(E("refreshTimeInSeconds").value("6")));
return all;
}
diff --git a/abtest-sample/src/test/resources/com/dianping/abtest/sample/ABTestServer.xml b/abtest-sample/src/test/resources/com/dianping/abtest/sample/ABTestServer.xml
index 6963530ea9a63b6487104eae96afa76dd17a0a87..8bec6cb1017f3056d4c26236185cf080b758426b 100644
--- a/abtest-sample/src/test/resources/com/dianping/abtest/sample/ABTestServer.xml
+++ b/abtest-sample/src/test/resources/com/dianping/abtest/sample/ABTestServer.xml
@@ -6,5 +6,17 @@
com.dianping.abtest.sample.IPDistributionStrategy
per-lookup
+
+ com.dianping.cat.abtest.repository.ABTestEntityRepository
+ com.dianping.cat.abtest.repository.HttpABTestEntityRepository
+
+ 6
+
+
+
+ com.dianping.cat.configuration.ClientConfigManager
+
+
+
diff --git a/cat-core/src/main/java/com/dianping/cat/abtest/ABTestManager.java b/cat-core/src/main/java/com/dianping/cat/abtest/ABTestManager.java
index c013ab3890482f2f75bad0d989b6825910a8074d..f32fd66e5eb5884ca5de32112b14f8b6fffc91a1 100644
--- a/cat-core/src/main/java/com/dianping/cat/abtest/ABTestManager.java
+++ b/cat-core/src/main/java/com/dianping/cat/abtest/ABTestManager.java
@@ -1,6 +1,7 @@
package com.dianping.cat.abtest;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.codehaus.plexus.PlexusContainer;
import org.unidal.helper.Threads;
@@ -43,10 +44,10 @@ public final class ABTestManager {
}
}
- public static void onRequestBegin(HttpServletRequest req) {
+ public static void onRequestBegin(HttpServletRequest request,HttpServletResponse response) {
initialize();
- s_contextManager.onRequestBegin(req);
+ s_contextManager.onRequestBegin(request,response);
}
public static void onRequestEnd() {
diff --git a/cat-core/src/main/java/com/dianping/cat/abtest/spi/ABTestContext.java b/cat-core/src/main/java/com/dianping/cat/abtest/spi/ABTestContext.java
index ebc79ca39d16025b8075fc1cf1f6813f54640f99..dbb025f3b74b8191a2fd90a02a32c828dd08a35f 100644
--- a/cat-core/src/main/java/com/dianping/cat/abtest/spi/ABTestContext.java
+++ b/cat-core/src/main/java/com/dianping/cat/abtest/spi/ABTestContext.java
@@ -1,6 +1,7 @@
package com.dianping.cat.abtest.spi;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
public interface ABTestContext {
public final String DEFAULT_GROUP = "default";
@@ -12,4 +13,6 @@ public interface ABTestContext {
public void setGroupName(String groupName);
public HttpServletRequest getHttpServletRequest();
+
+ public HttpServletResponse getHttpServletResponse();
}
diff --git a/cat-core/src/main/java/com/dianping/cat/abtest/spi/internal/ABTestContextManager.java b/cat-core/src/main/java/com/dianping/cat/abtest/spi/internal/ABTestContextManager.java
index ce6b97ce92e9987fac838a3b342af16fc381c825..2c22b121bc727921cb0cc6279518cb65d827acfb 100644
--- a/cat-core/src/main/java/com/dianping/cat/abtest/spi/internal/ABTestContextManager.java
+++ b/cat-core/src/main/java/com/dianping/cat/abtest/spi/internal/ABTestContextManager.java
@@ -3,6 +3,7 @@ package com.dianping.cat.abtest.spi.internal;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import com.dianping.cat.abtest.ABTestName;
import com.dianping.cat.abtest.spi.ABTestContext;
@@ -12,7 +13,7 @@ public interface ABTestContextManager {
public List getContexts();
- public void onRequestBegin(HttpServletRequest req);
+ public void onRequestBegin(HttpServletRequest request,HttpServletResponse response);
public void onRequestEnd();
}
diff --git a/cat-core/src/main/java/com/dianping/cat/abtest/spi/internal/DefaultABTestContext.java b/cat-core/src/main/java/com/dianping/cat/abtest/spi/internal/DefaultABTestContext.java
index db7616e080a6399d395b520805dadfda32b2d59c..c47690671e1e21bfc173d39e46bee079720ff632 100644
--- a/cat-core/src/main/java/com/dianping/cat/abtest/spi/internal/DefaultABTestContext.java
+++ b/cat-core/src/main/java/com/dianping/cat/abtest/spi/internal/DefaultABTestContext.java
@@ -3,6 +3,7 @@ package com.dianping.cat.abtest.spi.internal;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import com.dianping.cat.Cat;
import com.dianping.cat.abtest.spi.ABTestContext;
@@ -16,7 +17,9 @@ public class DefaultABTestContext implements ABTestContext {
private ABTestEntity m_entity;
- private HttpServletRequest m_req;
+ private HttpServletRequest m_request;
+
+ private HttpServletResponse m_response;
private ABTestGroupStrategy m_groupStrategy;
@@ -61,15 +64,21 @@ public class DefaultABTestContext implements ABTestContext {
m_groupName = groupName;
}
- public void setup(HttpServletRequest req) {
- m_req = req;
+ public void setup(HttpServletRequest request,HttpServletResponse response) {
+ m_request = request;
+ m_response = response;
}
@Override
public HttpServletRequest getHttpServletRequest() {
- return m_req;
+ return m_request;
}
+ @Override
+ public HttpServletResponse getHttpServletResponse() {
+ return m_response;
+ }
+
@Override
public ABTestEntity getEntity() {
return m_entity;
@@ -78,4 +87,6 @@ public class DefaultABTestContext implements ABTestContext {
public void setGroupStrategy(ABTestGroupStrategy groupStrategy) {
m_groupStrategy = groupStrategy;
}
+
+
}
diff --git a/cat-core/src/main/java/com/dianping/cat/abtest/spi/internal/DefaultABTestContextManager.java b/cat-core/src/main/java/com/dianping/cat/abtest/spi/internal/DefaultABTestContextManager.java
index 255420b856c47be8ed041989d0a3c52bdc7dae1a..ac8b890da45a2ddc93873da44d6dc542161c3b15 100644
--- a/cat-core/src/main/java/com/dianping/cat/abtest/spi/internal/DefaultABTestContextManager.java
+++ b/cat-core/src/main/java/com/dianping/cat/abtest/spi/internal/DefaultABTestContextManager.java
@@ -7,6 +7,7 @@ import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.unidal.lookup.ContainerHolder;
import org.unidal.lookup.annotation.Inject;
@@ -37,20 +38,20 @@ public class DefaultABTestContextManager extends ContainerHolder implements ABTe
if (ctx == null) {
ABTestEntity entity = m_entityManager.getEntity(testName);
- ctx = createContext(entity, entry.getHttpServletRequest());
+ ctx = createContext(entity, entry.getHttpServletRequest(),entry.getHttpServletResponse());
map.put(name, ctx);
}
return ctx;
}
- private DefaultABTestContext createContext(ABTestEntity entity, HttpServletRequest req) {
+ private DefaultABTestContext createContext(ABTestEntity entity, HttpServletRequest request,HttpServletResponse response) {
DefaultABTestContext ctx = new DefaultABTestContext(entity);
if (!entity.isDisabled()) {
ABTestGroupStrategy groupStrategy = entity.getGroupStrategy();
- ctx.setup(req);
+ ctx.setup(request,response);
ctx.setGroupStrategy(groupStrategy);
}
@@ -73,7 +74,7 @@ public class DefaultABTestContextManager extends ContainerHolder implements ABTe
DefaultABTestContext ctx = ctxMap.get(name);
if (ctx == null) {
- ctx = createContext(entity, entry.getHttpServletRequest());
+ ctx = createContext(entity, entry.getHttpServletRequest(),entry.getHttpServletResponse());
ctxMap.put(name, ctx);
}
@@ -95,14 +96,14 @@ public class DefaultABTestContextManager extends ContainerHolder implements ABTe
}
@Override
- public void onRequestBegin(HttpServletRequest req) {
+ public void onRequestBegin(HttpServletRequest request,HttpServletResponse response) {
Entry entry = m_threadLocal.get();
- entry.setHttpServletRequest(req);
+ entry.setup(request,response);
Map map = entry.getContextMap();
for (DefaultABTestContext ctx : map.values()) {
- ctx.setup(req);
+ ctx.setup(request,response);
}
}
@@ -111,12 +112,23 @@ public class DefaultABTestContextManager extends ContainerHolder implements ABTe
private List m_list;
- private HttpServletRequest m_req;
+ private HttpServletRequest m_request;
+
+ private HttpServletResponse m_response;
public Map getContextMap() {
return m_map;
}
+ public void setup(HttpServletRequest request, HttpServletResponse response) {
+ m_request = request;
+ m_response = response;
+ }
+
+ public HttpServletResponse getHttpServletResponse() {
+ return m_response;
+ }
+
public void setContextList(List ctxList) {
m_list = ctxList;
}
@@ -126,11 +138,7 @@ public class DefaultABTestContextManager extends ContainerHolder implements ABTe
}
public HttpServletRequest getHttpServletRequest() {
- return m_req;
- }
-
- public void setHttpServletRequest(HttpServletRequest req) {
- m_req = req;
+ return m_request;
}
}
}
diff --git a/cat-core/src/main/java/com/dianping/cat/build/ABTestComponentConfigurator.java b/cat-core/src/main/java/com/dianping/cat/build/ABTestComponentConfigurator.java
index d52c4f64818b6f56522ff870a81f0d6da9f6eca4..ad41b7d3dd4eea29e8fb813cc60c85b01b5ef06f 100644
--- a/cat-core/src/main/java/com/dianping/cat/build/ABTestComponentConfigurator.java
+++ b/cat-core/src/main/java/com/dianping/cat/build/ABTestComponentConfigurator.java
@@ -24,7 +24,7 @@ class ABTestComponentConfigurator extends AbstractResourceConfigurator {
all.add(C(ABTestEntityRepository.class, HttpABTestEntityRepository.class) //
.req(ClientConfigManager.class)
- .config(E("refreshTime").value("6")));
+ .config(E("refreshTimeInSeconds").value("60")));
all.add(C(ABTestEntityManager.class, DefaultABTestEntityManager.class) //
.req(ABTestEntityRepository.class));
diff --git a/cat-core/src/main/java/com/dianping/cat/servlet/CatFilter.java b/cat-core/src/main/java/com/dianping/cat/servlet/CatFilter.java
index 175c851160991b2d70b5f505817905aedc25d300..3ab14012a00eb05ba393a138f392a3321185392c 100644
--- a/cat-core/src/main/java/com/dianping/cat/servlet/CatFilter.java
+++ b/cat-core/src/main/java/com/dianping/cat/servlet/CatFilter.java
@@ -10,6 +10,7 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import com.dianping.cat.Cat;
import com.dianping.cat.CatConstants;
@@ -28,6 +29,7 @@ public class CatFilter implements Filter {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
ServletException {
HttpServletRequest req = (HttpServletRequest) request;
+ HttpServletResponse resp = (HttpServletResponse) response;
boolean isRoot = !Cat.getManager().hasContext();
if (isRoot) {
@@ -41,7 +43,7 @@ public class CatFilter implements Filter {
if (isRoot) {
t = Cat.newTransaction(getTypeName(), getOriginalUrl(request));
logRequestClientInfo(cat, req);
- ABTestManager.onRequestBegin(req);
+ ABTestManager.onRequestBegin(req,resp);
} else {
t = Cat.newTransaction(getTypeName() + ".Forward", getOriginalUrl(request));
}
diff --git a/cat-core/src/main/resources/META-INF/plexus/components.xml b/cat-core/src/main/resources/META-INF/plexus/components.xml
index 5a9cd0b0b81cbc3d08351a088e30b56105d80c93..894d859720fcc79989b5a404ab5addcce500a108 100644
--- a/cat-core/src/main/resources/META-INF/plexus/components.xml
+++ b/cat-core/src/main/resources/META-INF/plexus/components.xml
@@ -315,7 +315,7 @@
com.dianping.cat.abtest.repository.ABTestEntityRepository
com.dianping.cat.abtest.repository.HttpABTestEntityRepository
- 6
+ 60
diff --git a/cat-core/src/test/java/com/dianping/cat/abtest/demo/roundrobin/ABTestServerConfigurator.java b/cat-core/src/test/java/com/dianping/cat/abtest/demo/roundrobin/ABTestServerConfigurator.java
index 074292122c21a4e6a31d0a2e61098fa089f80177..1342af14a7f54c70237e0425386e38cbca6320eb 100644
--- a/cat-core/src/test/java/com/dianping/cat/abtest/demo/roundrobin/ABTestServerConfigurator.java
+++ b/cat-core/src/test/java/com/dianping/cat/abtest/demo/roundrobin/ABTestServerConfigurator.java
@@ -6,17 +6,17 @@ import java.util.List;
import org.unidal.lookup.configuration.AbstractResourceConfigurator;
import org.unidal.lookup.configuration.Component;
-import com.dianping.cat.abtest.spi.ABTestGroupStrategy;
+import com.dianping.cat.abtest.spi.internal.ABTestContextManager;
import com.dianping.cat.abtest.spi.internal.ABTestEntityManager;
-import com.dianping.cat.abtest.spi.internal.DefaultABTestEntityManager;
+import com.dianping.cat.abtest.spi.internal.DefaultABTestContextManager;
public class ABTestServerConfigurator extends AbstractResourceConfigurator {
@Override
public List defineComponents() {
List all = new ArrayList();
- all.add(C(ABTestEntityManager.class, DefaultABTestEntityManager.class));
- all.add(C(ABTestGroupStrategy.class, "roundrobin", RoundRobinGroupStrategy.class));
+ all.add(C(ABTestContextManager.class, DefaultABTestContextManager.class) //
+ .req(ABTestEntityManager.class));
return all;
}
diff --git a/cat-core/src/test/resources/com/dianping/cat/abtest/demo/roundrobin/ABTestServer.xml b/cat-core/src/test/resources/com/dianping/cat/abtest/demo/roundrobin/ABTestServer.xml
index c0bbf6b21e47963018ae215bed178caaea2776e6..181c122c44eef6e2657e5f2c395938851229256c 100644
--- a/cat-core/src/test/resources/com/dianping/cat/abtest/demo/roundrobin/ABTestServer.xml
+++ b/cat-core/src/test/resources/com/dianping/cat/abtest/demo/roundrobin/ABTestServer.xml
@@ -1,13 +1,13 @@
- com.dianping.cat.abtest.spi.ABTestEntityManager
- com.dianping.cat.abtest.spi.internal.DefaultABTestEntityManager
-
-
- com.dianping.cat.abtest.spi.ABTestGroupStrategy
- roundrobin
- com.dianping.cat.abtest.demo.roundrobin.RoundRobinGroupStrategy
+ com.dianping.cat.abtest.spi.internal.ABTestContextManager
+ com.dianping.cat.abtest.spi.internal.DefaultABTestContextManager
+
+
+ com.dianping.cat.abtest.spi.internal.ABTestEntityManager
+
+
diff --git a/cat-home/src/main/resources/META-INF/plexus/components.xml b/cat-home/src/main/resources/META-INF/plexus/components.xml
index e25c48d163a5677576a2373ef39c439ab62bc1b7..c85aa1b9504199ea3d7678c9b7fbd14ded8b87e2 100755
--- a/cat-home/src/main/resources/META-INF/plexus/components.xml
+++ b/cat-home/src/main/resources/META-INF/plexus/components.xml
@@ -1160,9 +1160,9 @@
1000
com.mysql.jdbc.Driver
- jdbc:mysql://192.168.7.43:3306/cat
- binlog
- binlog
+ jdbc:mysql://127.0.0.1:3306/cat
+ root
+
@@ -3156,9 +3156,6 @@
com.dianping.cat.system.page.abtest.Handler
com.dianping.cat.system.page.abtest.Handler
-
- com.dianping.cat.system.page.abtest.JspViewer
-
com.dianping.cat.home.dal.abtest.AbtestDao
@@ -3166,19 +3163,13 @@
com.dianping.cat.home.dal.abtest.AbtestRunDao
- com.dainping.cat.consumer.dal.report.ProjectDao
+ com.dianping.cat.home.dal.abtest.GroupStrategyDao
- com.dianping.cat.home.dal.abtest.GroupStrategyDao
+ com.dainping.cat.consumer.dal.report.ProjectDao
-
-
-
- com.dianping.cat.system.page.abtest.JspViewer
- com.dianping.cat.system.page.abtest.JspViewer
-
- org.unidal.web.mvc.view.model.ModelHandler
+ com.dianping.cat.system.page.abtest.JspViewer
@@ -3209,6 +3200,15 @@
+
+ com.dianping.cat.system.page.abtest.JspViewer
+ com.dianping.cat.system.page.abtest.JspViewer
+
+
+ org.unidal.web.mvc.view.model.ModelHandler
+
+
+
com.dianping.cat.system.alarm.AlarmRuleCreator
com.dianping.cat.system.alarm.AlarmRuleCreator