提交 8dd84115 编写于 作者: Y yong.you

fix small issure

上级 1820ec5b
......@@ -80,6 +80,8 @@ public class RealtimeConsumer extends ContainerHolder implements MessageConsumer
private long m_networkError;
private static int QUEUE_SIZE = 500000;
@Override
public void consume(MessageTree tree) {
try {
......@@ -212,7 +214,7 @@ public class RealtimeConsumer extends ContainerHolder implements MessageConsumer
for (String name : m_analyzerNames) {
MessageAnalyzer analyzer = m_factory.create(name, startTime, m_duration, m_extraTime);
MessageQueue queue = new DefaultMessageQueue();
MessageQueue queue = new DefaultMessageQueue(QUEUE_SIZE);
PeriodTask task = new PeriodTask(m_factory, analyzer, queue, startTime);
analyzers.put(name, analyzer);
......@@ -359,29 +361,29 @@ public class RealtimeConsumer extends ContainerHolder implements MessageConsumer
startPeriod(startTime);
m_latch.countDown();
try {
while (m_active) {
try {
long now = System.currentTimeMillis();
long value = m_strategy.next(now);
if (value == 0) {
// do nothing here
} else if (value > 0) {
// prepare next period in ahead of 3 minutes
startPeriod(value);
} else {
// last period is over
endPeriod(-value);
}
} catch (Throwable e) {
Cat.logError(e);
while (m_active) {
try {
long now = System.currentTimeMillis();
long value = m_strategy.next(now);
if (value == 0) {
// do nothing here
} else if (value > 0) {
// prepare next period in ahead of 3 minutes
startPeriod(value);
} else {
// last period is over
endPeriod(-value);
}
} catch (Throwable e) {
Cat.logError(e);
}
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
break;
}
} catch (InterruptedException e) {
// ignore it
}
}
......
......@@ -15,18 +15,8 @@ public class DefaultMessageQueue implements MessageQueue {
@Inject
private int m_size;
private static final int SIZE = 500000;
public DefaultMessageQueue() {
this(SIZE);
}
public DefaultMessageQueue(int size) {
if (size > 0) {
m_queue = new LinkedBlockingQueue<MessageTree>(size);
} else {
m_queue = new LinkedBlockingQueue<MessageTree>(SIZE);
}
m_queue = new LinkedBlockingQueue<MessageTree>(size);
}
@Override
......
......@@ -47,7 +47,9 @@ com.dianping.cat.report.page.query.Handler.class,
com.dianping.cat.report.page.top.Handler.class,
com.dianping.cat.report.page.metric.Handler.class
com.dianping.cat.report.page.metric.Handler.class,
com.dianping.cat.report.page.pushError.Handler.class
})
public class ReportModule extends AbstractModule {
......
......@@ -45,7 +45,9 @@ public enum ReportPage implements Page {
TOP("top", "top", "Top", "Top", true),
METRIC("metric", "metric", "Metric", "Metric", true);
METRIC("metric", "metric", "Metric", "Metric", true),
PUSHERROR("pushError", "pushError", "PushError", "PushError", true);
private String m_name;
......
package com.dianping.cat.report.page.pushError;
public enum Action implements org.unidal.web.mvc.Action {
VIEW("view");
private String m_name;
private Action(String name) {
m_name = name;
}
public static Action getByName(String name, Action defaultAction) {
for (Action action : Action.values()) {
if (action.getName().equals(name)) {
return action;
}
}
return defaultAction;
}
@Override
public String getName() {
return m_name;
}
}
package com.dianping.cat.report.page.pushError;
import com.dianping.cat.report.ReportContext;
public class Context extends ReportContext<Payload> {
}
package com.dianping.cat.report.page.pushError;
import java.io.IOException;
import javax.servlet.ServletException;
import com.dianping.cat.report.ReportPage;
import org.unidal.lookup.annotation.Inject;
import org.unidal.web.mvc.PageHandler;
import org.unidal.web.mvc.annotation.InboundActionMeta;
import org.unidal.web.mvc.annotation.OutboundActionMeta;
import org.unidal.web.mvc.annotation.PayloadMeta;
public class Handler implements PageHandler<Context> {
@Inject
private JspViewer m_jspViewer;
@Override
@PayloadMeta(Payload.class)
@InboundActionMeta(name = "pushError")
public void handleInbound(Context ctx) throws ServletException, IOException {
// display only, no action here
}
@Override
@OutboundActionMeta(name = "pushError")
public void handleOutbound(Context ctx) throws ServletException, IOException {
Model model = new Model(ctx);
model.setAction(Action.VIEW);
model.setPage(ReportPage.PUSHERROR);
m_jspViewer.view(ctx, model);
}
}
package com.dianping.cat.report.page.pushError;
public enum JspFile {
VIEW("/jsp/report/pushError.jsp"),
;
private String m_path;
private JspFile(String path) {
m_path = path;
}
public String getPath() {
return m_path;
}
}
package com.dianping.cat.report.page.pushError;
import com.dianping.cat.report.ReportPage;
import org.unidal.web.mvc.view.BaseJspViewer;
public class JspViewer extends BaseJspViewer<ReportPage, Action, Context, Model> {
@Override
protected String getJspFilePath(Context ctx, Model model) {
Action action = model.getAction();
switch (action) {
case VIEW:
return JspFile.VIEW.getPath();
}
throw new RuntimeException("Unknown action: " + action);
}
}
package com.dianping.cat.report.page.pushError;
import com.dianping.cat.report.ReportPage;
import org.unidal.web.mvc.ViewModel;
public class Model extends ViewModel<ReportPage, Action, Context> {
private String m_status;
public String getStatus() {
return m_status;
}
public void setStatus(String status) {
m_status = status;
}
public Model(Context ctx) {
super(ctx);
}
@Override
public Action getDefaultAction() {
return Action.VIEW;
}
}
package com.dianping.cat.report.page.pushError;
import com.dianping.cat.report.ReportPage;
import org.unidal.web.mvc.ActionContext;
import org.unidal.web.mvc.ActionPayload;
import org.unidal.web.mvc.payload.annotation.FieldMeta;
public class Payload implements ActionPayload<ReportPage, Action> {
private ReportPage m_page;
@FieldMeta("op")
private Action m_action;
@FieldMeta("timestamp")
private long m_timestamp;
@FieldMeta("error")
private String m_error;
@FieldMeta("file")
private String m_file;
@FieldMeta("url")
private String m_url;
@FieldMeta("host")
private String m_host;
@FieldMeta("line")
private String m_line;
public void setAction(String action) {
m_action = Action.getByName(action, Action.VIEW);
}
@Override
public Action getAction() {
return m_action;
}
@Override
public ReportPage getPage() {
return m_page;
}
@Override
public void setPage(String page) {
m_page = ReportPage.getByName(page, ReportPage.PUSHERROR);
}
public long getTimestamp() {
return m_timestamp;
}
public void setTimestamp(long timestamp) {
m_timestamp = timestamp;
}
public String getError() {
return m_error;
}
public void setError(String error) {
m_error = error;
}
public String getFile() {
return m_file;
}
public void setFile(String file) {
m_file = file;
}
public String getUrl() {
return m_url;
}
public void setUrl(String url) {
m_url = url;
}
public String getHost() {
return m_host;
}
public void setHost(String host) {
m_host = host;
}
public String getLine() {
return m_line;
}
public void setLine(String line) {
m_line = line;
}
@Override
public void validate(ActionContext<?> ctx) {
if (m_action == null) {
m_action = Action.VIEW;
}
}
}
......@@ -65,6 +65,9 @@
<page name="metric" title="Metric" path="metric">
<description>Metric</description>
</page>
<page name="pushError" title="PushError" path="pushError">
<description>PushError</description>
</page>
</module>
<module name="system" path="s" default="false">
<page name="alarm" title="Alarm" default="true" path="alarm">
......
<%@ page contentType="text/html; charset=utf-8" %>
<jsp:useBean id="ctx" type="com.dianping.cat.report.page.pushError.Context" scope="request"/>
<jsp:useBean id="payload" type="com.dianping.cat.report.page.pushError.Payload" scope="request"/>
<jsp:useBean id="model" type="com.dianping.cat.report.page.pushError.Model" scope="request"/>
View of pushError page under report
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册