提交 a297000b 编写于 作者: Y youyong

modify the cat project info

上级 7b0f3f9a
......@@ -256,7 +256,7 @@ public class CommonAnalyzer extends AbstractMessageAnalyzer<CommonReport> implem
public static final String TUANGOUZHIFU = "支付中心";
public static final String MIDDLDWARE = "基础组";
public static final String MIDDLDWARE = "基础组";
public static final String MOBILEWEB = "手机后台";
......
......@@ -103,7 +103,8 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
.req(MessageCodec.class, PlainTextMessageCodec.ID) //
.req(ChannelBufferManager.class));
all.add(C(MessageBucketManager.class, LocalMessageBucketManager.ID, LocalMessageBucketManager.class) //
.req(ServerConfigManager.class, MessagePathBuilder.class));
.req(ServerConfigManager.class, MessagePathBuilder.class)//
.req(MessageCodec.class, ChannelBufferManager.class));
all.add(C(ChannelBufferManager.class));
all.add(C(Module.class, CatCoreModule.ID, CatCoreModule.class));
......
......@@ -109,25 +109,28 @@ public class LocalMessageBucket implements MessageBucket {
}
}
protected synchronized MessageBlock flushBlock() throws IOException {
protected MessageBlock flushBlock() throws IOException {
boolean b = m_dirty.get();
if (b) {
m_out.close();
byte[] data = m_buf.toByteArray();
try {
m_block.setData(data);
m_blockSize = 0;
m_buf.reset();
m_out = new GZIPOutputStream(m_buf);
m_dirty.set(false);
return m_block;
} finally {
m_block = new MessageBlock(m_dataFile);
synchronized (m_out) {
m_out.close();
byte[] data = m_buf.toByteArray();
try {
m_block.setData(data);
m_blockSize = 0;
m_buf.reset();
m_out = new GZIPOutputStream(m_buf);
m_dirty.set(false);
return m_block;
} finally {
m_block = new MessageBlock(m_dataFile);
}
}
}
return null;
}
......@@ -166,15 +169,19 @@ public class LocalMessageBucket implements MessageBucket {
}
@Override
public synchronized MessageBlock store(final MessageTree tree, final MessageId id) throws IOException {
public MessageBlock store(final MessageTree tree, final MessageId id) throws IOException {
final ChannelBuffer buf = m_bufferManager.allocate();
m_lastAccessTime = System.currentTimeMillis();
m_codec.encode(tree, buf);
return storeMessage(buf, id);
}
synchronized MessageBlock storeMessage(final ChannelBuffer buf, final MessageId id) throws IOException {
int size = buf.readableBytes();
m_dirty.set(true);
m_lastAccessTime = System.currentTimeMillis();
m_blockSize += size;
m_block.addIndex(id.getIndex(), size);
buf.getBytes(0, m_out, size); // write buffer and compress it
......
......@@ -18,6 +18,7 @@ import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.jboss.netty.buffer.ChannelBuffer;
import com.dianping.cat.Cat;
import com.dianping.cat.configuration.NetworkInterfaceManager;
......@@ -26,6 +27,7 @@ import com.dianping.cat.message.Message;
import com.dianping.cat.message.MessageProducer;
import com.dianping.cat.message.Transaction;
import com.dianping.cat.message.internal.MessageId;
import com.dianping.cat.message.spi.MessageCodec;
import com.dianping.cat.message.spi.MessagePathBuilder;
import com.dianping.cat.message.spi.MessageTree;
import com.site.helper.Files;
......@@ -49,6 +51,12 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
@Inject
private ServerConfigManager m_configManager;
@Inject
private MessageCodec m_codec;
@Inject
private ChannelBufferManager m_bufferManager;
private BlockingQueue<EncodeItem> m_encodeItems = new LinkedBlockingQueue<EncodeItem>(10000);
private int m_error;
......@@ -148,6 +156,7 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
Threads.forGroup("Cat").start(new MessageEncode(1));
Threads.forGroup("Cat").start(new MessageEncode(2));
Threads.forGroup("Cat").start(new MessageEncode(3));
Threads.forGroup("Cat").start(new MessageEncode(4));
}
private boolean isFit(String path) {
......@@ -457,7 +466,10 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
MessageId id = item.getId();
try {
MessageBlock bolck = bucket.store(tree, id);
final ChannelBuffer buf = m_bufferManager.allocate();
m_codec.encode(tree, buf);
MessageBlock bolck = bucket.storeMessage(buf, id);
if (bolck != null) {
boolean result = m_messageBlocks.offer(bolck);
......
......@@ -216,6 +216,12 @@
<requirement>
<role>com.dianping.cat.message.spi.MessagePathBuilder</role>
</requirement>
<requirement>
<role>com.dianping.cat.message.spi.MessageCodec</role>
</requirement>
<requirement>
<role>com.dianping.cat.storage.dump.ChannelBufferManager</role>
</requirement>
</requirements>
</component>
<component>
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.dianping.cat</groupId>
<artifactId>parent</artifactId>
<version>0.4.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cat-home</artifactId>
<name>CAT Home</name>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.dianping.dpsf</groupId>
<artifactId>dpsf-net</artifactId>
<version>1.7.3</version>
</dependency>
<dependency>
<groupId>com.dianping.hawk</groupId>
<artifactId>hawk-client</artifactId>
<version>0.6.7</version>
</dependency>
<dependency>
<groupId>com.dianping.lion</groupId>
<artifactId>lion-client</artifactId>
<version>0.2.2</version>
</dependency>
<dependency>
<groupId>com.dianping</groupId>
<artifactId>mail-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.dianping</groupId>
<artifactId>sms-api</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.dianping.lion</groupId>
<artifactId>lion-${env}</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>com.dianping.cat</groupId>
<artifactId>cat-consumer</artifactId>
</dependency>
<dependency>
<groupId>com.dianping.cat</groupId>
<artifactId>cat-job</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>com.site.common</groupId>
<artifactId>web-framework</artifactId>
</dependency>
<dependency>
<groupId>org.unidal.webres</groupId>
<artifactId>WebResServer</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-api-2.1</artifactId>
<version>6.1.14</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1</artifactId>
<version>6.1.14</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.site.common</groupId>
<artifactId>test-framework</artifactId>
<scope>${test-framework.scope}</scope>
</dependency>
<dependency>
<groupId>com.site.dal</groupId>
<artifactId>dal-jdbc</artifactId>
<version>1.1.8</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.9</version>
</dependency>
</dependencies>
<build>
<finalName>cat</finalName>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<targetPath>WEB-INF/classes</targetPath>
</resource>
<resource>
<directory>src/main/webapp</directory>
<filtering>false</filtering>
<includes>
<include>WEB-INF/web.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.unidal.maven.plugins</groupId>
<artifactId>codegen-maven-plugin</artifactId>
<version>1.1.9</version>
<executions>
<execution>
<id>generate plexus component descriptor</id>
<phase>process-classes</phase>
<goals>
<goal>plexus</goal>
</goals>
<configuration>
<className>com.dianping.cat.build.ComponentsConfigurator</className>
<env>dev</env>
</configuration>
</execution>
<execution>
<id>generate report models</id>
<phase>generate-sources</phase>
<goals>
<goal>dal-model</goal>
</goals>
<configuration>
<manifest>${basedir}/src/main/resources/META-INF/dal/model/threshold-template-manifest.xml,</manifest>
</configuration>
</execution>
<execution>
<id>generate dal jdbc model</id>
<phase>generate-sources</phase>
<goals>
<goal>dal-jdbc</goal>
</goals>
<configuration>
<manifest><![CDATA[
${basedir}/src/main/resources/META-INF/dal/jdbc/report-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/jdbc/alarm-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/jdbc/user-manifest.xml,
]]></manifest>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<index>true</index>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.dianping.cat.Server</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<downloadSources>true</downloadSources>
<ajdtVersion>none</ajdtVersion>
<additionalConfig>
<file>
<name>.settings/org.eclipse.jdt.core.prefs</name>
<content><![CDATA[org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.dianping.cat</groupId>
<artifactId>parent</artifactId>
<version>0.4.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cat-home</artifactId>
<name>CAT Home</name>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.dianping.dpsf</groupId>
<artifactId>dpsf-net</artifactId>
<version>1.7.3</version>
</dependency>
<dependency>
<groupId>com.dianping.hawk</groupId>
<artifactId>hawk-client</artifactId>
<version>0.6.7</version>
</dependency>
<dependency>
<groupId>com.dianping.lion</groupId>
<artifactId>lion-client</artifactId>
<version>0.2.2</version>
</dependency>
<dependency>
<groupId>com.dianping</groupId>
<artifactId>mail-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.dianping</groupId>
<artifactId>sms-api</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.dianping.lion</groupId>
<artifactId>lion-${env}</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>com.dianping.cat</groupId>
<artifactId>cat-consumer</artifactId>
</dependency>
<dependency>
<groupId>com.dianping.cat</groupId>
<artifactId>cat-job</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>com.site.common</groupId>
<artifactId>web-framework</artifactId>
</dependency>
<dependency>
<groupId>org.unidal.webres</groupId>
<artifactId>WebResServer</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-api-2.1</artifactId>
<version>6.1.14</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1</artifactId>
<version>6.1.14</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.site.common</groupId>
<artifactId>test-framework</artifactId>
<scope>${test-framework.scope}</scope>
</dependency>
<dependency>
<groupId>com.site.dal</groupId>
<artifactId>dal-jdbc</artifactId>
<version>1.1.8</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.9</version>
</dependency>
</dependencies>
<build>
<finalName>cat</finalName>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<targetPath>WEB-INF/classes</targetPath>
</resource>
<resource>
<directory>src/main/webapp</directory>
<filtering>false</filtering>
<includes>
<include>WEB-INF/web.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.unidal.maven.plugins</groupId>
<artifactId>codegen-maven-plugin</artifactId>
<version>1.1.9</version>
<executions>
<execution>
<id>generate plexus component descriptor</id>
<phase>process-classes</phase>
<goals>
<goal>plexus</goal>
</goals>
<configuration>
<className>com.dianping.cat.build.ComponentsConfigurator</className>
<env>dev</env>
</configuration>
</execution>
<execution>
<id>generate report models</id>
<phase>generate-sources</phase>
<goals>
<goal>dal-model</goal>
</goals>
<configuration>
<manifest>${basedir}/src/main/resources/META-INF/dal/model/threshold-template-manifest.xml,</manifest>
</configuration>
</execution>
<execution>
<id>generate dal jdbc model</id>
<phase>generate-sources</phase>
<goals>
<goal>dal-jdbc</goal>
</goals>
<configuration>
<manifest><![CDATA[${basedir}/src/main/resources/META-INF/dal/jdbc/report-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/jdbc/alarm-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/jdbc/user-manifest.xml,]]></manifest>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<index>true</index>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.dianping.cat.Server</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<downloadSources>true</downloadSources>
<ajdtVersion>none</ajdtVersion>
<additionalConfig>
<file>
<name>.settings/org.eclipse.jdt.core.prefs</name>
<content><![CDATA[org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.compliance=1.6]]><![CDATA[org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.compliance=1.6]]></content>
</file>
</additionalConfig>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<properties>
<packaging>war</packaging>
<env>alpha</env>
<test-framework.scope>test</test-framework.scope>
</properties>
</file>
</additionalConfig>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<properties>
<packaging>war</packaging>
<env>alpha</env>
<test-framework.scope>test</test-framework.scope>
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
</properties>
</project>
......@@ -6,6 +6,7 @@ import java.util.Collection;
import java.util.Date;
import java.util.Map;
import com.dainping.cat.consumer.dal.report.Project;
import com.dianping.cat.report.ReportPage;
import com.dianping.cat.report.view.DomainNavManager;
import com.dianping.cat.report.view.HistoryNav;
......@@ -89,6 +90,30 @@ public abstract class AbstractReportModel<A extends Action, M extends ActionCont
// required by report tag
public abstract Collection<String> getDomains();
public String getDepartment() {
String domain = getDomain();
if (domain != null) {
Project project = DomainNavManager.getProjectByName(domain);
if (project != null) {
return project.getDepartment();
}
}
return "Default";
}
public String getProjectLine() {
String domain = getDomain();
if (domain != null) {
Project project = DomainNavManager.getProjectByName(domain);
if (project != null) {
return project.getProjectLine();
}
}
return "Default";
}
public Map<String, Department> getDomainGroups() {
return DomainNavManager.getDepartment(getDomains());
}
......
......@@ -27,6 +27,10 @@ public class DomainNavManager implements Initializable {
private static Map<String, Project> m_projects = new HashMap<String, Project>();
public static Project getProjectByName(String domain) {
return m_projects.get(domain);
}
public static Map<String, Department> getDepartment(Collection<String> domains) {
Map<String, Department> result = new TreeMap<String, Department>();
......
......@@ -48,6 +48,8 @@ public class NavigationBar {
SystemPage.ALARM,
SystemPage.PROJECT,
SystemPage.LOGIN
};
......
......@@ -9,7 +9,9 @@ import com.site.web.mvc.annotation.ModulePagesMeta;
com.dianping.cat.system.page.alarm.Handler.class,
com.dianping.cat.system.page.login.Handler.class
com.dianping.cat.system.page.login.Handler.class,
com.dianping.cat.system.page.project.Handler.class
})
public class SystemModule extends AbstractModule {
......
......@@ -7,28 +7,20 @@ public enum SystemPage implements Page {
ALARM("alarm", "alarm", "Alarm", "Alarm", true),
LOGIN("login", "login", "Login", "Login", false);
LOGIN("login", "login", "Login", "Login", false),
public static SystemPage getByName(String name, SystemPage defaultPage) {
for (SystemPage action : SystemPage.values()) {
if (action.getName().equals(name)) {
return action;
}
}
return defaultPage;
}
private String m_description;
PROJECT("project", "project", "Project", "Project", true);
private String m_name;
private String m_path;
private boolean m_standalone;
private String m_title;
private String m_description;
private boolean m_standalone;
private SystemPage(String name, String path, String title, String description, boolean standalone) {
m_name = name;
m_path = path;
......@@ -37,6 +29,16 @@ public enum SystemPage implements Page {
m_standalone = standalone;
}
public static SystemPage getByName(String name, SystemPage defaultPage) {
for (SystemPage action : SystemPage.values()) {
if (action.getName().equals(name)) {
return action;
}
}
return defaultPage;
}
public String getDescription() {
return m_description;
}
......@@ -65,11 +67,11 @@ public enum SystemPage implements Page {
return m_title;
}
public SystemPage[] getValues() {
return SystemPage.values();
}
public boolean isStandalone() {
return m_standalone;
}
public SystemPage[] getValues() {
return SystemPage.values();
}
}
......@@ -3,8 +3,6 @@ package com.dianping.cat.system.page.alarm;
public enum Action implements com.site.web.mvc.Action {
ALARM_RECORD_DETAIL("alarmRecordDetail"),
REPORT_RECORD_LIST("reportRecordList"),
ALARM_RECORD_LIST("alarmRecordList"),
ALARM_RULE_ADD("alarmRuleAdd"),
......@@ -33,25 +31,27 @@ public enum Action implements com.site.web.mvc.Action {
EXCEPTION_ALARM_RULE_SUB("exceptionAlarmRuleSub"),
SERVICE_ALARM_RULE_DELETE("serviceAlarmRuleDelete"),
REPORT_RECORD_LIST("reportRecordList"),
SERVICE_ALARM_RULE_LIST("serviceAlarmRules"),
SCHEDULED_REPORT_ADD("scheduledReportAdd"),
SERVICE_ALARM_RULE_SUB("serviceAlarmRuleSub"),
SCHEDULED_REPORT_ADD_SUBMIT("scheduledReportAddSubmit"),
SCHEDULED_REPORT_LIST("scheduledReports"),
SCHEDULED_REPORT_DELETE("scheduledReportDelete"),
SCHEDULED_REPORT_ADD("scheduledReportAdd"),
SCHEDULED_REPORT_LIST("scheduledReports"),
SCHEDULED_REPORT_ADD_SUBMIT("scheduledReportAddSubmit"),
SCHEDULED_REPORT_SUB("scheduledReportSub"),
SCHEDULED_REPORT_UPDATE("scheduledReportUpdate"),
SCHEDULED_REPORT_UPDATE_SUBMIT("scheduledReportUpdateSubmit"),
SCHEDULED_REPORT_DELETE("scheduledReportDelete"),
SERVICE_ALARM_RULE_DELETE("serviceAlarmRuleDelete"),
SERVICE_ALARM_RULE_LIST("serviceAlarmRules"),
SCHEDULED_REPORT_SUB("scheduledReportSub")
SERVICE_ALARM_RULE_SUB("serviceAlarmRuleSub")
;
......
......@@ -28,10 +28,10 @@ public class Handler implements PageHandler<Context> {
private RuleManager m_ruleManager;
@Inject
private TemplateManager m_templateManager;
private ScheduledManager m_scheduledManager;
@Inject
private ScheduledManager m_scheduledManager;
private TemplateManager m_templateManager;
private int getLoginUserId(Context ctx) {
DpAdminLogin member = ctx.getSigninMember();
......
......@@ -31,25 +31,25 @@ public enum JspFile {
EXCEPTION_ALARM_RULE_SUB("/jsp/system/alarmExceptionRules.jsp"),
SERVICE_ALARM_RULE_DELETE("/jsp/system/alarmServiceRules.jsp"),
SCHEDULED_REPORT_ADD("/jsp/system/scheduledReportAdd.jsp"),
SERVICE_ALARM_RULE_LIST("/jsp/system/alarmServiceRules.jsp"),
SCHEDULED_REPORT_ADD_SUBMIT("/jsp/system/alarmOpState.jsp"),
SERVICE_ALARM_RULE_SUB("/jsp/system/alarmServiceRules.jsp"),
SCHEDULED_REPORT_DELETE("/jsp/system/scheduledReports.jsp"),
SCHEDULED_REPORT_LIST("/jsp/system/scheduledReports.jsp"),
SCHEDULED_REPORT_ADD("/jsp/system/scheduledReportAdd.jsp"),
SCHEDULED_REPORT_ADD_SUBMIT("/jsp/system/alarmOpState.jsp"),
SCHEDULED_REPORT_SUB("/jsp/system/scheduledReports.jsp"),
SCHEDULED_REPORT_UPDATE("/jsp/system/scheduledReportUpdate.jsp"),
SCHEDULED_REPORT_UPDATE_SUBMIT("/jsp/system/alarmOpState.jsp"),
SCHEDULED_REPORT_DELETE("/jsp/system/scheduledReports.jsp"),
SERVICE_ALARM_RULE_DELETE("/jsp/system/alarmServiceRules.jsp"),
SERVICE_ALARM_RULE_LIST("/jsp/system/alarmServiceRules.jsp"),
SCHEDULED_REPORT_SUB("/jsp/system/scheduledReports.jsp")
SERVICE_ALARM_RULE_SUB("/jsp/system/alarmServiceRules.jsp")
;
......
......@@ -20,18 +20,18 @@ public class Model extends ViewModel<SystemPage, Action, Context> {
private List<MailRecord> m_mailRecords;
private ScheduledReport m_scheduledReport;
private String m_opState;
private List<ScheduledReport> m_schduledReports;
private String m_opState;
private ScheduledReport m_scheduledReport;
private int m_templateIndex;
private List<UserAlarmSubState> m_userSubStates;
private List<UserReportSubState> m_userReportSubStates;
private List<UserAlarmSubState> m_userSubStates;
public Model(Context ctx) {
super(ctx);
}
......@@ -73,10 +73,22 @@ public class Model extends ViewModel<SystemPage, Action, Context> {
return m_opState;
}
public List<ScheduledReport> getSchduledReports() {
return m_schduledReports;
}
public ScheduledReport getScheduledReport() {
return m_scheduledReport;
}
public int getTemplateIndex() {
return m_templateIndex;
}
public List<UserReportSubState> getUserReportSubStates() {
return m_userReportSubStates;
}
public List<UserAlarmSubState> getUserSubStates() {
return m_userSubStates;
}
......@@ -105,28 +117,16 @@ public class Model extends ViewModel<SystemPage, Action, Context> {
m_opState = opState;
}
public void setTemplateIndex(int templateIndex) {
m_templateIndex = templateIndex;
}
public ScheduledReport getScheduledReport() {
return m_scheduledReport;
public void setSchduledReports(List<ScheduledReport> schduledReports) {
m_schduledReports = schduledReports;
}
public void setScheduledReport(ScheduledReport scheduledReport) {
m_scheduledReport = scheduledReport;
}
public List<ScheduledReport> getSchduledReports() {
return m_schduledReports;
}
public void setSchduledReports(List<ScheduledReport> schduledReports) {
m_schduledReports = schduledReports;
}
public List<UserReportSubState> getUserReportSubStates() {
return m_userReportSubStates;
public void setTemplateIndex(int templateIndex) {
m_templateIndex = templateIndex;
}
public void setUserReportSubStates(List<UserReportSubState> userReportSubStates) {
......
......@@ -15,9 +15,6 @@ public class Payload implements ActionPayload<SystemPage, Action> {
@FieldMeta("alarmRuleId")
private int m_alarmRuleId;
@FieldMeta("scheduledReportId")
private int m_scheduledReportId;
@FieldMeta("alarmTemplateId")
private int m_alarmTemplateId;
......@@ -28,6 +25,9 @@ public class Payload implements ActionPayload<SystemPage, Action> {
private String m_domain;
private SystemPage m_page;
@FieldMeta("scheduledReportId")
private int m_scheduledReportId;
@FieldMeta("templateName")
private String m_templateName;
......@@ -72,6 +72,10 @@ public class Payload implements ActionPayload<SystemPage, Action> {
return "";
}
public int getScheduledReportId() {
return m_scheduledReportId;
}
public String getTemplateName() {
return m_templateName;
}
......@@ -99,11 +103,11 @@ public class Payload implements ActionPayload<SystemPage, Action> {
public void setAlarmTemplateId(int alarmTemplateId) {
m_alarmTemplateId = alarmTemplateId;
}
public void setContent(String content) {
m_content = content;
}
public void setDomain(String domain) {
m_domain = domain;
}
......@@ -113,10 +117,14 @@ public class Payload implements ActionPayload<SystemPage, Action> {
m_page = SystemPage.getByName(page, SystemPage.ALARM);
}
public void setScheduledReportId(int scheduledReportId) {
m_scheduledReportId = scheduledReportId;
}
public void setTemplateName(String templateName) {
m_templateName = templateName;
}
public void setType(String type) {
m_type = type;
}
......@@ -124,14 +132,6 @@ public class Payload implements ActionPayload<SystemPage, Action> {
public void setUserSubState(int userSubState) {
m_userSubState = userSubState;
}
public int getScheduledReportId() {
return m_scheduledReportId;
}
public void setScheduledReportId(int scheduledReportId) {
m_scheduledReportId = scheduledReportId;
}
@Override
public void validate(ActionContext<?> ctx) {
......
......@@ -22,10 +22,10 @@ public class RecordManager {
private AlarmRuleSubscriptionDao m_alarmRuleSubscriptionDao;
@Inject
private ScheduledReportSubscriptionDao m_scheduledReportSubscriptionDao;
private MailRecordDao m_mailRecordDao;
@Inject
private MailRecordDao m_mailRecordDao;
private ScheduledReportSubscriptionDao m_scheduledReportSubscriptionDao;
public void queryAlarmRecordDetail(Payload payload, Model model) {
int id = payload.getAlarmRecordId();
......@@ -38,26 +38,6 @@ public class RecordManager {
}
}
public void queryUserReportRecords(Model model, int userId) {
try {
List<ScheduledReportSubscription> scheduledReportSubscriptions = m_scheduledReportSubscriptionDao
.findByUserId(userId, ScheduledReportSubscriptionEntity.READSET_FULL);
int size = scheduledReportSubscriptions.size();
int ruleIds[] = new int[size];
for (int i = 0; i < size; i++) {
ScheduledReportSubscription scheduledReportSubscription = scheduledReportSubscriptions.get(i);
ruleIds[i] = scheduledReportSubscription.getScheduledReportId();
}
List<MailRecord> mails = m_mailRecordDao.findReportRecordByRuleId(ruleIds, MailRecordEntity.READSET_FULL);
model.setMailRecords(mails);
} catch (DalNotFoundException e) {
} catch (DalException e) {
Cat.logError(e);
}
model.setTemplateIndex(3);
}
public void queryUserAlarmRecords(Model model, int userId) {
try {
List<AlarmRuleSubscription> alarmRuleSubscriptions = m_alarmRuleSubscriptionDao.findByUserId(userId,
......@@ -79,4 +59,24 @@ public class RecordManager {
}
model.setTemplateIndex(2);
}
public void queryUserReportRecords(Model model, int userId) {
try {
List<ScheduledReportSubscription> scheduledReportSubscriptions = m_scheduledReportSubscriptionDao
.findByUserId(userId, ScheduledReportSubscriptionEntity.READSET_FULL);
int size = scheduledReportSubscriptions.size();
int ruleIds[] = new int[size];
for (int i = 0; i < size; i++) {
ScheduledReportSubscription scheduledReportSubscription = scheduledReportSubscriptions.get(i);
ruleIds[i] = scheduledReportSubscription.getScheduledReportId();
}
List<MailRecord> mails = m_mailRecordDao.findReportRecordByRuleId(ruleIds, MailRecordEntity.READSET_FULL);
model.setMailRecords(mails);
} catch (DalNotFoundException e) {
} catch (DalException e) {
Cat.logError(e);
}
model.setTemplateIndex(3);
}
}
......@@ -22,19 +22,13 @@ import com.site.lookup.annotation.Inject;
public class ScheduledManager {
@Inject
private ScheduledReportDao m_scheduledReportDao;
private DpAdminLoginDao m_loginDao;
@Inject
private ScheduledReportSubscriptionDao m_scheduledReportSubscriptionDao;
private ScheduledReportDao m_scheduledReportDao;
@Inject
private DpAdminLoginDao m_loginDao;
public List<ScheduledReport> queryScheduledReports() throws DalException {
List<ScheduledReport> reports = m_scheduledReportDao.findAll(ScheduledReportEntity.READSET_FULL);
return reports;
}
private ScheduledReportSubscriptionDao m_scheduledReportSubscriptionDao;
public List<String> queryEmailsBySchReportId(int scheduledReportId) throws DalException {
List<String> emails = new ArrayList<String>();
......@@ -51,6 +45,12 @@ public class ScheduledManager {
return emails;
}
public List<ScheduledReport> queryScheduledReports() throws DalException {
List<ScheduledReport> reports = m_scheduledReportDao.findAll(ScheduledReportEntity.READSET_FULL);
return reports;
}
public void queryScheduledReports(Model model, int userId) {
List<UserReportSubState> userRules = new ArrayList<UserReportSubState>();
try {
......
......@@ -18,14 +18,14 @@ public class UserReportSubState {
return m_scheduledReport;
}
public void setScheduledReport(ScheduledReport scheduledReport) {
m_scheduledReport = scheduledReport;
}
public int getSubscriberState() {
return m_subscriberState;
}
public void setScheduledReport(ScheduledReport scheduledReport) {
m_scheduledReport = scheduledReport;
}
public void setSubscriberState(int subscriberState) {
m_subscriberState = subscriberState;
}
......
package com.dianping.cat.system.page.project;
public enum Action implements com.site.web.mvc.Action {
ALL("view"),
PROJECT_UPDATE("update"),
PROJECT_UPDATE_SUBMIT("updateSubmit");
public static Action getByName(String name, Action defaultAction) {
for (Action action : Action.values()) {
if (action.getName().equals(name)) {
return action;
}
}
return defaultAction;
}
private String m_name;
private Action(String name) {
m_name = name;
}
@Override
public String getName() {
return m_name;
}
}
package com.dianping.cat.system.page.project;
import com.dianping.cat.system.SystemContext;
public class Context extends SystemContext<Payload> {
}
package com.dianping.cat.system.page.project;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import javax.servlet.ServletException;
import com.dainping.cat.consumer.dal.report.Project;
import com.dainping.cat.consumer.dal.report.ProjectDao;
import com.dainping.cat.consumer.dal.report.ProjectEntity;
import com.dianping.cat.Cat;
import com.dianping.cat.system.SystemPage;
import com.site.dal.jdbc.DalException;
import com.site.lookup.annotation.Inject;
import com.site.web.mvc.PageHandler;
import com.site.web.mvc.annotation.InboundActionMeta;
import com.site.web.mvc.annotation.OutboundActionMeta;
import com.site.web.mvc.annotation.PayloadMeta;
public class Handler implements PageHandler<Context> {
@Inject
private JspViewer m_jspViewer;
@Inject
private ProjectDao m_projectDao;
@Override
@PayloadMeta(Payload.class)
@InboundActionMeta(name = "project")
public void handleInbound(Context ctx) throws ServletException, IOException {
// display only, no action here
}
@Override
@OutboundActionMeta(name = "project")
public void handleOutbound(Context ctx) throws ServletException, IOException {
Model model = new Model(ctx);
Payload payload = ctx.getPayload();
model.setPage(SystemPage.PROJECT);
Action action = payload.getAction();
model.setAction(action);
switch (action) {
case ALL:
model.setProjects(queryAllProjects());
break;
case PROJECT_UPDATE:
model.setProject(queryProjectById(payload.getProjectId()));
break;
case PROJECT_UPDATE_SUBMIT:
updateProject(payload);
model.setProjects(queryAllProjects());
break;
}
m_jspViewer.view(ctx, model);
}
private void updateProject(Payload payload) {
int projectId = payload.getProjectId();
String department = payload.getDepartment();
String email = payload.getEmail();
String owner = payload.getOwner();
String projectLine = payload.getProjectLine();
String domain = payload.getDomain();
Project project = m_projectDao.createLocal();
project.setId(projectId);
project.setKeyId(projectId);
project.setDepartment(department);
project.setEmail(email);
project.setDomain(domain);
project.setOwner(owner);
project.setProjectLine(projectLine);
try {
m_projectDao.updateByPK(project, ProjectEntity.UPDATESET_FULL);
} catch (DalException e) {
Cat.logError(e);
}
}
private List<Project> queryAllProjects() {
List<Project> projects = new ArrayList<Project>();
try {
projects = m_projectDao.findAll(ProjectEntity.READSET_FULL);
} catch (Exception e) {
Cat.logError(e);
}
Collections.sort(projects, new ProjectCompartor());
return projects;
}
private Project queryProjectById(int projectId) {
Project project = null;
try {
project = m_projectDao.findByPK(projectId, ProjectEntity.READSET_FULL);
} catch (Exception e) {
Cat.logError(e);
}
return project;
}
class ProjectCompartor implements Comparator<Project> {
@Override
public int compare(Project o1, Project o2) {
String department1 = o1.getDepartment();
String department2 = o2.getDepartment();
String productLine1 = o1.getProjectLine();
String productLine2 = o2.getProjectLine();
if (department1.equalsIgnoreCase(department2)) {
if (productLine1.equalsIgnoreCase(productLine2)) {
return o1.getDomain().compareTo(o2.getDomain());
} else {
return productLine1.compareTo(productLine2);
}
} else {
return department1.compareTo(productLine2);
}
}
}
}
package com.dianping.cat.system.page.project;
public enum JspFile {
ALL("/jsp/system/project.jsp"),
UPATE("/jsp/system/projectUpdate.jsp"), ;
private String m_path;
private JspFile(String path) {
m_path = path;
}
public String getPath() {
return m_path;
}
}
package com.dianping.cat.system.page.project;
import com.dianping.cat.system.SystemPage;
import com.site.web.mvc.view.BaseJspViewer;
public class JspViewer extends BaseJspViewer<SystemPage, Action, Context, Model> {
@Override
protected String getJspFilePath(Context ctx, Model model) {
Action action = model.getAction();
switch (action) {
case ALL:
return JspFile.ALL.getPath();
case PROJECT_UPDATE:
return JspFile.UPATE.getPath();
case PROJECT_UPDATE_SUBMIT:
return JspFile.ALL.getPath();
default:
}
throw new RuntimeException("Unknown action: " + action);
}
}
package com.dianping.cat.system.page.project;
import java.util.Collections;
import java.util.List;
import com.dainping.cat.consumer.dal.report.Project;
import com.dianping.cat.system.SystemPage;
import com.site.web.mvc.ViewModel;
public class Model extends ViewModel<SystemPage, Action, Context> {
private Project m_project;
private List<Project> m_projects;
public Model(Context ctx) {
super(ctx);
}
public String getDate() {
return "";
}
@Override
public Action getDefaultAction() {
return Action.ALL;
}
public String getDomain() {
return "";
}
public List<String> getDomains() {
return Collections.emptyList();
}
public Project getProject() {
return m_project;
}
public List<Project> getProjects() {
return m_projects;
}
public void setProject(Project project) {
m_project = project;
}
public void setProjects(List<Project> projects) {
m_projects = projects;
}
}
package com.dianping.cat.system.page.project;
import com.dianping.cat.system.SystemPage;
import com.site.web.mvc.ActionContext;
import com.site.web.mvc.ActionPayload;
import com.site.web.mvc.payload.annotation.FieldMeta;
public class Payload implements ActionPayload<SystemPage, Action> {
@FieldMeta("op")
private Action m_action;
@FieldMeta("department")
private String m_department;
@FieldMeta("email")
private String m_email;
@FieldMeta("owner")
private String m_owner;
private SystemPage m_page;
@FieldMeta("projectId")
private int m_projectId;
@FieldMeta("projectLine")
private String m_projectLine;
@FieldMeta("domain")
private String m_domain;
@Override
public Action getAction() {
if (m_action == null) {
m_action = Action.ALL;
}
return m_action;
}
public String getDepartment() {
return m_department;
}
public String getEmail() {
return m_email;
}
public String getOwner() {
return m_owner;
}
@Override
public SystemPage getPage() {
return m_page;
}
public int getProjectId() {
return m_projectId;
}
public String getProjectLine() {
return m_projectLine;
}
public String getReportType() {
return "";
}
public void setAction(String action) {
m_action =Action.getByName(action, Action.ALL);
}
public void setDepartment(String department) {
m_department = department;
}
public void setEmail(String email) {
m_email = email;
}
public void setOwner(String owner) {
m_owner = owner;
}
@Override
public void setPage(String page) {
m_page = SystemPage.getByName(page, SystemPage.PROJECT);
}
public void setProjectId(int projectId) {
m_projectId = projectId;
}
public String getDomain() {
return m_domain;
}
public void setDomain(String domain) {
m_domain = domain;
}
public void setProjectLine(String projectLine) {
m_projectLine = projectLine;
}
@Override
public void validate(ActionContext<?> ctx) {
}
}
......@@ -2306,10 +2306,10 @@
<role>com.dianping.cat.system.page.alarm.RuleManager</role>
</requirement>
<requirement>
<role>com.dianping.cat.system.page.alarm.TemplateManager</role>
<role>com.dianping.cat.system.page.alarm.ScheduledManager</role>
</requirement>
<requirement>
<role>com.dianping.cat.system.page.alarm.ScheduledManager</role>
<role>com.dianping.cat.system.page.alarm.TemplateManager</role>
</requirement>
</requirements>
</component>
......@@ -2325,10 +2325,10 @@
<role>com.dianping.cat.home.dal.alarm.AlarmRuleSubscriptionDao</role>
</requirement>
<requirement>
<role>com.dianping.cat.home.dal.alarm.ScheduledReportSubscriptionDao</role>
<role>com.dianping.cat.home.dal.alarm.MailRecordDao</role>
</requirement>
<requirement>
<role>com.dianping.cat.home.dal.alarm.MailRecordDao</role>
<role>com.dianping.cat.home.dal.alarm.ScheduledReportSubscriptionDao</role>
</requirement>
</requirements>
</component>
......@@ -2342,8 +2342,8 @@
</requirements>
</component>
<component>
<role>com.dianping.cat.home.dal.alarm.ScheduledReportSubscriptionDao</role>
<implementation>com.dianping.cat.home.dal.alarm.ScheduledReportSubscriptionDao</implementation>
<role>com.dianping.cat.home.dal.alarm.MailRecordDao</role>
<implementation>com.dianping.cat.home.dal.alarm.MailRecordDao</implementation>
<requirements>
<requirement>
<role>com.site.dal.jdbc.QueryEngine</role>
......@@ -2351,8 +2351,8 @@
</requirements>
</component>
<component>
<role>com.dianping.cat.home.dal.alarm.MailRecordDao</role>
<implementation>com.dianping.cat.home.dal.alarm.MailRecordDao</implementation>
<role>com.dianping.cat.home.dal.alarm.ScheduledReportSubscriptionDao</role>
<implementation>com.dianping.cat.home.dal.alarm.ScheduledReportSubscriptionDao</implementation>
<requirements>
<requirement>
<role>com.site.dal.jdbc.QueryEngine</role>
......@@ -2404,27 +2404,18 @@
</requirement>
</requirements>
</component>
<component>
<role>com.dianping.cat.system.page.alarm.TemplateManager</role>
<implementation>com.dianping.cat.system.page.alarm.TemplateManager</implementation>
<requirements>
<requirement>
<role>com.dianping.cat.home.dal.alarm.AlarmTemplateDao</role>
</requirement>
</requirements>
</component>
<component>
<role>com.dianping.cat.system.page.alarm.ScheduledManager</role>
<implementation>com.dianping.cat.system.page.alarm.ScheduledManager</implementation>
<requirements>
<requirement>
<role>com.dianping.cat.home.dal.alarm.ScheduledReportDao</role>
<role>com.dainping.cat.home.dal.user.DpAdminLoginDao</role>
</requirement>
<requirement>
<role>com.dianping.cat.home.dal.alarm.ScheduledReportSubscriptionDao</role>
<role>com.dianping.cat.home.dal.alarm.ScheduledReportDao</role>
</requirement>
<requirement>
<role>com.dainping.cat.home.dal.user.DpAdminLoginDao</role>
<role>com.dianping.cat.home.dal.alarm.ScheduledReportSubscriptionDao</role>
</requirement>
</requirements>
</component>
......@@ -2437,6 +2428,15 @@
</requirement>
</requirements>
</component>
<component>
<role>com.dianping.cat.system.page.alarm.TemplateManager</role>
<implementation>com.dianping.cat.system.page.alarm.TemplateManager</implementation>
<requirements>
<requirement>
<role>com.dianping.cat.home.dal.alarm.AlarmTemplateDao</role>
</requirement>
</requirements>
</component>
<component>
<role>com.dianping.cat.system.page.login.Handler</role>
<implementation>com.dianping.cat.system.page.login.Handler</implementation>
......@@ -2494,6 +2494,31 @@
</requirement>
</requirements>
</component>
<component>
<role>com.dianping.cat.system.page.project.Handler</role>
<implementation>com.dianping.cat.system.page.project.Handler</implementation>
<requirements>
<requirement>
<role>com.dianping.cat.system.page.project.JspViewer</role>
</requirement>
<requirement>
<role>com.dainping.cat.consumer.dal.report.ProjectDao</role>
</requirement>
</requirements>
</component>
<component>
<role>com.dianping.cat.system.page.project.JspViewer</role>
<implementation>com.dianping.cat.system.page.project.JspViewer</implementation>
</component>
<component>
<role>com.dainping.cat.consumer.dal.report.ProjectDao</role>
<implementation>com.dainping.cat.consumer.dal.report.ProjectDao</implementation>
<requirements>
<requirement>
<role>com.site.dal.jdbc.QueryEngine</role>
</requirement>
</requirements>
</component>
<component>
<role>com.dianping.cat.system.alarm.AlarmRuleCreator</role>
<implementation>com.dianping.cat.system.alarm.AlarmRuleCreator</implementation>
......
<wizard package="com.dianping.cat">
<webapp package="com.dianping.cat" webres="true">
<webapp package="com.dianping.cat" webres="true" plugin-management="true">
<module name="report" path="r">
<page name="home" title="Home" default="true">
<description>Home Page</description>
......@@ -63,6 +63,9 @@
<page name="login" title="Login" default="true" path="login" standalone="false">
<description>Login</description>
</page>
<page name="project" title="Project" path="project">
<description>Project</description>
</page>
</module>
</webapp>
</wizard>
......@@ -11,6 +11,7 @@
<a:body>
<res:useCss value='${res.css.local.report_css}' target="head-css" />
<res:useJs value="${res.js.local['jquery-1.7.1.js']}" target="head-js"/>
<div class="report">
<table class="header">
......@@ -36,25 +37,23 @@
</td>
</tr>
</table>
<%-- <table class="navbar">
<tr>
<td class="domain" rowspan="2" style="vertical-align:top;">
<div class="domain">
<c:forEach var="domain" items="${model.domains}">
&nbsp;<c:choose>
<c:when test="${model.domain eq domain}">
<a href="?op=history&domain=${domain}&date=${model.date}&reportType=${model.reportType}" class="current">[&nbsp;${domain}&nbsp;]</a>
</c:when>
<c:otherwise>
<a href="?op=history&domain=${domain}&date=${model.date}&reportType=${model.reportType}">[&nbsp;${domain}&nbsp;]</a>
</c:otherwise>
</c:choose>&nbsp;
</c:forEach>
</div>
</td>
</tr>
</table> --%>
<div class="navbar">
<div class="position">Current Domain:&nbsp;&nbsp;${model.department} &nbsp;&nbsp;>&nbsp;&nbsp;${model.projectLine} &nbsp;&nbsp;
>&nbsp;&nbsp;${model.domain}&nbsp;&nbsp;
&nbsp;&nbsp;[&nbsp;&nbsp;<a href="javascript:showDomain()" id="switch">ShowDomain</a>&nbsp;&nbsp;]&nbsp;&nbsp;
<script>
function showDomain() {
var b = $('#switch').html();
if (b == 'ShowDomain') {
$('.navbar').slideDown();
$('#switch').html("HiddenDomain");
} else {
$('.navbar').slideUp();
$('#switch').html("ShowDomain");
}
}
</script>
</div>
<div class="navbar" style="display:none">
<table border="1" rules="all">
<c:forEach var="item" items="${model.domainGroups}">
<tr>
......
......@@ -11,6 +11,7 @@
<a:body>
<res:useCss value='${res.css.local.report_css}' target="head-css" />
<res:useJs value="${res.js.local['jquery-1.7.1.js']}" target="head-js"/>
<div class="report">
<table class="header">
......@@ -26,26 +27,23 @@
</td>
</tr>
</table>
<%-- <table class="navbar">
<tr>
<td class="domain">
<div class="domain">
<c:forEach var="domain" items="${model.domains}">
&nbsp;<c:choose>
<c:when test="${model.domain eq domain}">
<a href="${model.baseUri}?domain=${domain}&date=${model.date}" class="current">[&nbsp;${domain}&nbsp;]</a>
</c:when>
<c:otherwise>
<a href="${model.baseUri}?domain=${domain}&date=${model.date}">[&nbsp;${domain}&nbsp;]</a>
</c:otherwise>
</c:choose>&nbsp;
</c:forEach>
</div>
</td>
</tr>
</table> --%>
<div class="navbar">
<div class="position"> Current Domain:&nbsp;&nbsp;${model.department} &nbsp;&nbsp;>&nbsp;&nbsp;${model.projectLine} &nbsp;&nbsp;
>&nbsp;&nbsp;${model.domain}&nbsp;&nbsp;
&nbsp;&nbsp;[&nbsp;&nbsp;<a href="javascript:showDomain()" id="switch">ShowDomain</a>&nbsp;&nbsp;]&nbsp;&nbsp;
<script>
function showDomain() {
var b = $('#switch').html();
if (b == 'ShowDomain') {
$('.navbar').slideDown();
$('#switch').html("HiddenDomain");
} else {
$('.navbar').slideUp();
$('#switch').html("ShowDomain");
}
}
</script>
</div>
<div class="navbar" style="display:none">
<table border="1" rules="all">
<c:forEach var="item" items="${model.domainGroups}">
<tr>
......
......@@ -77,4 +77,12 @@
border-bottom: solid black 1px;
width: 100%;
text-align: center;
}
.report .position{
padding:4px;
padding-left:8px;
font-weight: bold;
font-size: 14px;
background: lightBlue;
}
\ No newline at end of file
......@@ -43,6 +43,7 @@ Welcome to <b>Central Application Tracking (CAT)</b>.
<tr class="even"><td>2</td><td>集成了CAT,但是在测试环境看不到信息</td><td>请check相关步骤<a href="http://wiki.dianpingoa.com/bin/view/SOA%E6%9E%B6%E6%9E%84/CAT%E9%9B%86%E6%88%90%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3" target="_blank">CAT集成帮助文档</a></td></tr>
<tr class="odd"><td>3</td><td>Transaction、Event报表区间</<td><td>Transaction、Event历史报表,图表X轴以5分钟为刻度,Y轴表示每5分钟的值</td></tr>
<tr class="even"><td>4</td><td>Problem、Hearbeat报表区间</<td><td>Problem、Heartbeat历史报表,图表X轴以1分钟为刻度,Y轴表示每1分钟的值</td></tr>
<tr class="odd"><td>5</td><td>项目信息修改</<td><td style="color:red;">请到Project标签下,修改项目所在分组的基本信息</td></tr>
</table>
<br>
<br>
......
<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="a" uri="/WEB-INF/app.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="res" uri="http://www.unidal.org/webres"%>
<%@ taglib prefix="w" uri="http://www.unidal.org/web/core"%>
<jsp:useBean id="ctx" type="com.dianping.cat.system.page.project.Context" scope="request"/>
<jsp:useBean id="payload" type="com.dianping.cat.system.page.project.Payload" scope="request"/>
<jsp:useBean id="model" type="com.dianping.cat.system.page.project.Model" scope="request"/>
<a:body>
<res:useCss value='${res.css.local.alarm_css}' target="head-css" />
<res:useJs value="${res.js.local['alarm_js']}" target="head-js" />
<div>
</br>
<table class="project" width="60%">
<tr class="odd">
<td width="15%">项目名称</td>
<td width="10%">所属部门</td>
<td width="10%">产品线</td>
<td width="15%">组邮件</td>
<td width="8%">负责人</td>
<td width="5%">操作</td>
</tr>
<c:forEach var="item" items="${model.projects}"
varStatus="status">
<tr class="${status.index mod 2 != 0 ? 'odd' : 'even'}">
<td>${item.domain}</td>
<td>${item.department}</td>
<td>${item.projectLine}</td>
<td>${item.email}</td>
<td>${item.owner}</td>
<td><a href="?op=update&projectId=${item.id}">编辑</a></td>
</tr>
</c:forEach>
</table>
</div>
</a:body>
\ No newline at end of file
<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="a" uri="/WEB-INF/app.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="res" uri="http://www.unidal.org/webres"%>
<%@ taglib prefix="w" uri="http://www.unidal.org/web/core"%>
<jsp:useBean id="ctx" type="com.dianping.cat.system.page.project.Context" scope="request"/>
<jsp:useBean id="payload" type="com.dianping.cat.system.page.project.Payload" scope="request"/>
<jsp:useBean id="model" type="com.dianping.cat.system.page.project.Model" scope="request"/>
<a:body>
<res:useCss value='${res.css.local.alarm_css}' target="head-css" />
<res:useJs value="${res.js.local['alarm_js']}" target="head-js" />
<form name="projectUpdate" method="post" action="${model.pageUri}?op=updateSubmit">
<table border="0">
<input type="hidden" name="projectId" value="${model.project.id}" />
<input type="hidden" name="domain" value="${model.project.domain}" />
<tr>
<td>项目名称</td>
<td>${model.project.domain}</td>
</tr>
<tr>
<td>所属部门</td>
<td><input type="name" name="department" value="${model.project.department}"/></td>
</tr>
<tr>
<td>产品线</td>
<td><input type="name" name="projectLine" value="${model.project.projectLine}"/></td>
</tr>
<tr>
<td>项目组邮件(多个,逗号分割)</td>
<td><input type="name" name="email" value="${model.project.email}"/></td>
</tr>
<tr>
<td>负责人</td>
<td><input type="name" name="owner" value="${model.project.owner}"/></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="submit" value="submit" /></td>
</tr>
</table>
</form>
</a:body>
\ No newline at end of file
package com.dianping.cat.demo;
import org.junit.Test;
import com.dianping.cat.Cat;
import com.dianping.cat.message.Message;
import com.dianping.cat.message.Transaction;
public class TestMaxMessage {
@Test
public void testSend() throws Exception {
for (int i = 0; i < 100; i++) {
Transaction t = Cat.getProducer().newTransaction("CatTest", "CatTest" + i % 10);
t.setStatus(Message.SUCCESS);
Cat.getProducer().newEvent("Cache.kvdb", "Method" + i % 10 + ":missed");
t.addData("key and value");
t.complete();
}
Thread.sleep(10 * 100);
}
@Test
public void sendMaxMessage() throws Exception {
long time = System.currentTimeMillis();
int i = 10;
while (i > 0) {
i++;
Transaction total = Cat.newTransaction("Test", "Test");
Transaction t = Cat.getProducer().newTransaction("Cache.kvdb", "Method" + i % 10);
t.setStatus(Message.SUCCESS);
Cat.getProducer().newEvent("Cache.kvdb", "Method" + i % 10 + ":missed");
t.addData("key and value");
Transaction t2 = Cat.getProducer().newTransaction("Cache.web", "Method" + i % 10);
Cat.getProducer().newEvent("Cache.web", "Method" + i % 10 + ":missed");
t2.addData("key and value");
t2.setStatus(Message.SUCCESS);
t2.complete();
Transaction t3 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
t3.addData("key and value");
t3.setStatus(Message.SUCCESS);
t3.complete();
Transaction t4 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
t4.addData("key and value");
t4.setStatus(Message.SUCCESS);
t4.complete();
Transaction t5 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
Transaction t6 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
t6.addData("key and value");
t6.setStatus(Message.SUCCESS);
t6.complete();
Transaction t9 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
Transaction t7 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
t7.addData("key and value");
t7.setStatus(Message.SUCCESS);
t7.complete();
Transaction t8 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
t8.addData("key and value");
t8.setStatus(Message.SUCCESS);
t8.complete();
t9.addData("key and value");
t9.setStatus(Message.SUCCESS);
t9.complete();
t5.addData("key and value");
t5.setStatus(Message.SUCCESS);
t5.complete();
t.complete();
total.setStatus(Transaction.SUCCESS);
total.complete();
if (i % 10000 == 0) {
long duration = System.currentTimeMillis() - time;
System.out.println("[" + duration + "ms]" + "[total]" + i + "[每秒" + i / duration * 1000 + "]");
}
}
Thread.sleep(10 * 1000);
}
}
\ No newline at end of file
......@@ -251,9 +251,10 @@ public class TestSendMessage {
public void sendMaxMessage() throws Exception {
long time = System.currentTimeMillis();
int i = 10;
while (i > 0) {
i = 10 * 1000000 - (int) (System.currentTimeMillis() - time);
while (i > 0) {
i++;
Transaction total = Cat.newTransaction("Cat", "Test");
Transaction t = Cat.getProducer().newTransaction("Cache.kvdb", "Method" + i % 10);
t.setStatus(Message.SUCCESS);
Cat.getProducer().newEvent("Cache.kvdb", "Method" + i % 10 + ":missed");
......@@ -300,6 +301,14 @@ public class TestSendMessage {
t9.setStatus(Message.SUCCESS);
t9.complete();
t.complete();
total.setStatus(Transaction.SUCCESS);
t.complete();
if (i % 10000 == 0) {
long duration = System.currentTimeMillis() - time;
System.out.println("[" + duration + "ms]" + "[total]" + i + "[每秒" + i / duration * 1000 + "]");
}
}
Thread.sleep(10 * 1000);
}
......
......@@ -69,42 +69,40 @@ public class ArchMonthAnalyzer extends ComponentTestCase {
Set<String> domains = queryAllDomain(start, end);
for (int i = 0; i < 31; i++) {
long t = start.getTime() + i * TimeUtil.ONE_DAY;
Date date = new Date(t);
System.out.println("Process " + date);
for (String domain : domains) {
try {
Dailyreport report = m_dailyreportDao.findByNameDomainPeriod(date, domain, "transaction",
DailyreportEntity.READSET_FULL);
TransactionReport transactionReport = DefaultSaxParser.parse(report.getContent());
Machine machine = transactionReport.findOrCreateMachine(CatString.ALL_IP);
Indicator indicator = indicators.get(date.getTime());
if (indicator == null) {
indicator = new Indicator();
indicators.put(t, indicator);
}
indicator.accept(machine);
} catch (DalNotFoundException e) {
} catch (Exception e) {
e.printStackTrace();
}
}
Date date = new Date(start.getTime() + i * TimeUtil.ONE_DAY);
System.out.println("process day " + date);
processOneDay(date, domains);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (Entry<Long, Indicator> entry : indicators.entrySet()) {
Date time = new Date(entry.getKey());
Indicator indicator = entry.getValue();
System.out.println(sdf.format(time) + "\t" + indicator);
}
}
private void processOneDay(Date date, Set<String> domains) {
for (String domain : domains) {
try {
Dailyreport report = m_dailyreportDao.findByNameDomainPeriod(date, domain, "transaction",
DailyreportEntity.READSET_FULL);
String timestamp = new SimpleDateFormat("MM-dd HH:mm:ss.SSS").format(new Date());
TransactionReport transactionReport = DefaultSaxParser.parse(report.getContent());
Machine machine = transactionReport.findOrCreateMachine(CatString.ALL_IP);
System.out.println(String.format("[%s] [INFO] Press any key to stop ... ", timestamp));
System.in.read();
Indicator indicator = indicators.get(date.getTime());
if (indicator == null) {
indicator = new Indicator();
indicators.put(date.getTime(), indicator);
}
indicator.accept(machine, transactionReport);
} catch (DalNotFoundException e) {
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static class Indicator {
......@@ -122,7 +120,7 @@ public class ArchMonthAnalyzer extends ComponentTestCase {
private Item m_webCache = new Item();
public void accept(Machine machine) {
public void accept(Machine machine, TransactionReport report) {
Collection<TransactionType> types = machine.getTypes().values();
for (TransactionType type : types) {
String name = type.getId();
......@@ -130,8 +128,17 @@ public class ArchMonthAnalyzer extends ComponentTestCase {
long error = type.getFailCount();
double sum = type.getSum();
if (name.equalsIgnoreCase("url")) {
m_url.add(count, error, sum);
m_url.add(count, error, sum);double avg = type.getAvg();
if (avg > 90) {
System.out.println(report.getDomain());
System.out.println(count + " " + avg);
}
} else if (name.equalsIgnoreCase("service") || name.equalsIgnoreCase("pigeonService")) {
double avg = type.getAvg();
if (avg > 10) {
System.out.println(report.getDomain());
System.out.println(count + " " + avg);
}
m_service.add(count, error, sum);
} else if (name.equalsIgnoreCase("call") || name.equalsIgnoreCase("pigeonCall")) {
m_call.add(count, error, sum);
......@@ -141,9 +148,12 @@ public class ArchMonthAnalyzer extends ComponentTestCase {
m_kvdbCache.add(count, error, sum);
} else if (name.startsWith("Cache.memcached")) {
m_memCache.add(count, error, sum);
if (error > 1000) {
System.out.println(report.getDomain());
System.out.println(machine.getIp());
}
} else if (name.equalsIgnoreCase("Cache.web")) {
m_webCache.add(count, error, sum);
} else {
}
}
}
......
package com.dianping.cat.report.analyzer;
import java.io.IOException;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import com.dianping.cat.Cat;
import com.dianping.cat.consumer.health.model.entity.HealthReport;
import com.dianping.cat.consumer.health.model.entity.MachineInfo;
import com.dianping.cat.consumer.health.model.transform.DefaultSaxParser;
import com.dianping.cat.helper.TimeUtil;
import com.dianping.cat.home.dal.report.Dailyreport;
import com.dianping.cat.home.dal.report.DailyreportDao;
import com.dianping.cat.home.dal.report.DailyreportEntity;
import com.dianping.cat.report.view.StringSortHelper;
import com.site.dal.jdbc.DalException;
import com.site.dal.jdbc.DalNotFoundException;
import com.site.lookup.ComponentTestCase;
import com.site.lookup.annotation.Inject;
@RunWith(JUnit4.class)
public class MachineMonthAnalyzer extends ComponentTestCase {
private Map<String, MonthDomain> m_indicators = new LinkedHashMap<String, MonthDomain>();
@Inject
private DailyreportDao m_dailyreportDao;
@Before
public void setUp() throws Exception {
super.setUp();
m_dailyreportDao = lookup(DailyreportDao.class);
}
private List<String> queryAllDomain(Date start, Date end) {
Set<String> domains = new LinkedHashSet<String>();
try {
List<Dailyreport> reports = m_dailyreportDao.findAllDomainsByNameDuration(start, end, "health",
DailyreportEntity.READSET_DOMAIN_NAME);
for (Dailyreport report : reports) {
domains.add(report.getDomain());
}
} catch (DalException e) {
Cat.logError(e);
}
return StringSortHelper.sort(domains);
}
@Test
public void builderData() throws IOException {
Date start = TimeUtil.getLastMonth();
Date end = TimeUtil.getCurrentMonth();
List<String> domains = queryAllDomain(start, end);
int day = 31;
for (int i = 0; i < day; i++) {
Date date = new Date(start.getTime() + i * TimeUtil.ONE_DAY);
System.out.println("process day " + date);
processOneDay(date, domains);
}
System.out.print("项目名称" + "\t");
System.out.print("部署机器" + "\t");
System.out.print("平均负载" + "\t");
System.out.println("最大负载" + "\t");
for (Entry<String, MonthDomain> entry : m_indicators.entrySet()) {
MonthDomain monthInfo = entry.getValue();
System.out.println(entry.getKey() + "\t" + monthInfo);
}
}
private void processOneDay(Date date, List<String> domains) {
for (String domain : domains) {
try {
Dailyreport report = m_dailyreportDao.findByNameDomainPeriod(date, domain, "health",
DailyreportEntity.READSET_FULL);
HealthReport healthReport = DefaultSaxParser.parse(report.getContent());
MachineInfo machine = healthReport.getMachineInfo();
MonthDomain indicator = m_indicators.get(domain);
if (indicator == null) {
indicator = new MonthDomain();
m_indicators.put(domain, indicator);
}
DomainInfo t = indicator.findOrCreatDomain(date);
t.add(machine.getNumbers(), machine.getAvgMaxLoad(), machine.getAvgLoad());
} catch (DalNotFoundException e) {
} catch (Exception e) {
e.printStackTrace();
}
}
}
public class MonthDomain {
private Map<Long, DomainInfo> m_infos = new LinkedHashMap<Long, DomainInfo>();
public DomainInfo find(Date date) {
return m_infos.get(date.getTime());
}
public DomainInfo findOrCreatDomain(Date date) {
DomainInfo info = m_infos.get(date);
if (info == null) {
info = new DomainInfo();
m_infos.put(date.getTime(), info);
}
return info;
}
public String toString() {
StringBuilder sb = new StringBuilder();
DomainInfo info = new DomainInfo();
for (DomainInfo temp : m_infos.values()) {
info.merger(temp);
}
sb.append(info);
return sb.toString();
}
}
public class DomainInfo {
private int m_machine;
private double m_loadSum;
private double m_loadAvg;
private double m_maxLoad;
private double m_maxLoadSum;
private int m_days;
public DomainInfo merger(DomainInfo info) {
m_machine = info.getMachine();
m_loadSum += info.getLoadSum();
m_days++;
if (info.getMaxLoad() > m_maxLoad) {
m_maxLoad = info.getMaxLoad();
}
m_maxLoadSum += info.getMaxLoadSum();
return this;
}
public double getMaxLoadSum() {
return m_maxLoadSum;
}
public void add(int machine, double maxLoad, double loadAvg) {
m_machine = machine;
m_loadSum += loadAvg;
m_loadAvg = loadAvg;
m_maxLoad = maxLoad;
m_maxLoadSum = maxLoad;
m_days = 1;
}
public int getMachine() {
return m_machine;
}
public void setMachine(int machine) {
m_machine = machine;
}
public double getLoadSum() {
return m_loadSum;
}
public void setLoadSum(double loadSum) {
m_loadSum = loadSum;
}
public double getMaxLoad() {
return m_maxLoad;
}
public void setMaxLoad(double maxLoad) {
m_maxLoad = maxLoad;
}
public double getLoadAvg() {
return m_loadAvg;
}
public void setLoadAvg(double loadAvg) {
m_loadAvg = loadAvg;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(m_machine).append("\t").append(m_loadSum / m_days).append("\t").append(m_maxLoadSum / m_days)
.append("\t");
return sb.toString();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册