提交 71665195 编写于 作者: Y youyong

modify the cat log issue and DalException

上级 c15245d6
......@@ -115,9 +115,9 @@ public class DumpAnalyzer extends AbstractMessageAnalyzer<Object> implements Ini
if (duration == 0 || duration == HOUR || duration == -HOUR) {
m_bucketManager.storeMessage(tree, id);
} else {
m_logger.error("error timestamp,meesageId:" + tree.getMessageId() + ",id parse time "
+ m_sdf.format(new Date(idTime)) + " " + id.getIpAddress() + " ,message tree timestamp:"
+ m_sdf.format(new Date(time)) + " " + tree.getIpAddress() + " duration hours:" + duration);
m_logger.error("timestamp:" + tree.getMessageId() + ",id timestamp " + m_sdf.format(new Date(idTime))
+ " " + id.getIpAddress() + " ,tree timestamp:" + m_sdf.format(new Date(time)) + " "
+ tree.getIpAddress() + " duration:" + duration);
}
} catch (IOException e) {
m_logger.error("Error when dumping to local file system, version 2!", e);
......
......@@ -13,7 +13,7 @@
<dependency>
<groupId>org.unidal.framework</groupId>
<artifactId>foundation-service</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.jboss.netty</groupId>
......
......@@ -6,6 +6,12 @@ import java.util.concurrent.locks.LockSupport;
import org.jboss.netty.util.ThreadNameDeterminer;
import org.jboss.netty.util.ThreadRenamingRunnable;
import org.unidal.helper.Threads;
import org.unidal.helper.Threads.AbstractThreadListener;
import org.unidal.initialization.AbstractModule;
import org.unidal.initialization.DefaultModuleContext;
import org.unidal.initialization.Module;
import org.unidal.initialization.ModuleContext;
import com.dianping.cat.configuration.ClientConfigManager;
import com.dianping.cat.configuration.ClientConfigReloader;
......@@ -13,12 +19,6 @@ import com.dianping.cat.configuration.client.entity.ClientConfig;
import com.dianping.cat.message.internal.MilliSecondTimer;
import com.dianping.cat.message.io.TransportManager;
import com.dianping.cat.status.StatusUpdateTask;
import org.unidal.helper.Threads;
import org.unidal.helper.Threads.DefaultThreadListener;
import org.unidal.initialization.AbstractModule;
import org.unidal.initialization.DefaultModuleContext;
import org.unidal.initialization.Module;
import org.unidal.initialization.ModuleContext;
public class CatCoreModule extends AbstractModule {
public static final String ID = "cat-core";
......@@ -67,7 +67,7 @@ public class CatCoreModule extends AbstractModule {
return null; // no dependencies
}
public final class CatThreadListener extends DefaultThreadListener {
public final class CatThreadListener extends AbstractThreadListener {
private final ModuleContext m_ctx;
private CatThreadListener(ModuleContext ctx) {
......
......@@ -5,16 +5,17 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import org.codehaus.plexus.logging.Logger;
import org.unidal.helper.Files;
import org.unidal.helper.Threads.Task;
import org.unidal.lookup.logger.LoggerFactory;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import com.dianping.cat.Cat;
import com.dianping.cat.configuration.client.entity.ClientConfig;
import com.dianping.cat.configuration.client.entity.Domain;
import com.dianping.cat.configuration.client.transform.DefaultDomParser;
import com.dianping.cat.message.Message;
import org.unidal.helper.Files;
import org.unidal.helper.Threads.Task;
public class ClientConfigReloader implements Task {
private static final String CAT_CLIENT_XML = "/META-INF/cat/client.xml";
......@@ -29,6 +30,8 @@ public class ClientConfigReloader implements Task {
private volatile boolean m_active = true;
private Logger m_logger = LoggerFactory.getLogger(ClientConfigReloader.class);
public ClientConfigReloader(String fileName, ClientConfig config) {
m_config = config;
m_parser = new DefaultDomParser();
......@@ -101,14 +104,8 @@ public class ClientConfigReloader implements Task {
}
}
}
} catch (IOException e) {
Cat.getProducer().logEvent("System", "ReloadIOException", "IOException", null);
} catch (SAXParseException e) {
Cat.getProducer().logEvent("System", "ReloadSAXException", "SAXException", null);
} catch (RuntimeException e) {
Cat.getProducer().logEvent("System", "ReloadException", "RuntimeException", null);
} catch (Exception e) {
Cat.logError(e);
m_logger.error("Error when reloading client xml!", e);
}
Thread.sleep(2000L);
} catch (InterruptedException e) {
......
......@@ -262,7 +262,7 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
for (String path : paths) {
File file = new File(m_baseDir, path);
String loginfo = "path:" + m_baseDir + path + ",file size: " + file.length();
String loginfo = "path:" + m_baseDir + "/" + path + ",file size: " + file.length();
LocalMessageBucket bucket = m_buckets.get(path);
if (bucket != null) {
......@@ -291,6 +291,12 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
m_logger.error(e.getMessage(), e);
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
break;
}
}
t.complete();
}
......@@ -385,7 +391,11 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
if (message instanceof Transaction) {
long delay = System.currentTimeMillis() - tree.getMessage().getTimestamp()
- ((Transaction) message).getDurationInMillis();
m_serverStateManager.addProcessDelay(delay);
int fiveMinute = 1000 * 60 * 5;
if (delay < fiveMinute && delay > -fiveMinute) {
m_serverStateManager.addProcessDelay(delay);
}
}
if (m_total % (CatConstants.SUCCESS_COUNT * 1000) == 0) {
m_logger.info("dump message number: " + m_total + " size:" + m_totalSize * 1.0 / 1024 / 1024 / 1024 + "GB");
......
......@@ -14,6 +14,8 @@ import com.dianping.cat.home.dal.report.GraphEntity;
import com.dianping.cat.report.page.HistoryGraphItem;
import com.dianping.cat.report.page.event.Handler.DetailOrder;
import com.dianping.cat.report.page.event.Handler.SummaryOrder;
import org.unidal.dal.jdbc.DalNotFoundException;
import org.unidal.lookup.annotation.Inject;
import org.unidal.lookup.util.StringUtils;
......@@ -116,16 +118,11 @@ public class HistoryGraphs {
Graph graph = m_graphDao.findSingalByDomainNameIpDuration(new Date(startLong), queryIP, domain, "event",
GraphEntity.READSET_FULL);
events.add(graph);
} catch (DalNotFoundException e) {
} catch (Exception e) {
Cat.logError(e);
}
}
// try {
// events = this.m_graphDao.findByDomainNameIpDuration(start, end, queryIP, domain, "event",
// GraphEntity.READSET_FULL);
// } catch (Exception e) {
// Cat.logError(e);
// }
Map<String, double[]> result = buildGraphDatas(start, end, type, name, events);
return result;
}
......
......@@ -18,8 +18,9 @@ public class HistoryGraphs {
public HistoryGraphItem buildHistoryGraph(String domain, Date start, Date end, String reportType, String key) {
if (reportType.equalsIgnoreCase("day")) {
return getDateFromHourlyReport(domain, start, end, key);
} else {
return getDateFromDailyReport(domain, start, end, key);
}
return getDateFromDailyReport(domain, start, end, key);
}
private HistoryGraphItem getDateFromDailyReport(String domain, Date start, Date end, String key) {
......
......@@ -6,6 +6,7 @@ import java.util.Date;
import javax.servlet.ServletException;
import com.dianping.cat.Cat;
import com.dianping.cat.message.Event;
import com.dianping.cat.message.internal.MessageId;
import com.dianping.cat.message.spi.MessagePathBuilder;
import com.dianping.cat.report.ReportPage;
......@@ -86,6 +87,12 @@ public class Handler implements PageHandler<Context> {
String messageId = getMessageId(payload);
String logView = getLogView(messageId, payload.isWaterfall());
if (logView == null || logView.length() == 0) {
Cat.getProducer().logEvent("Logview", "Success", Event.SUCCESS, null);
} else {
Cat.getProducer().logEvent("Logview", "Fail", Event.SUCCESS, null);
}
switch (payload.getAction()) {
case VIEW:
model.setTable(logView);
......@@ -109,7 +116,7 @@ public class Handler implements PageHandler<Context> {
sb.append('/').append(path);
final String key = id.getDomain() + '-' + id.getIpAddress();
return path+key;
}
return path + key;
}
}
......@@ -14,6 +14,8 @@ import com.dianping.cat.home.dal.report.GraphEntity;
import com.dianping.cat.report.page.HistoryGraphItem;
import com.dianping.cat.report.page.problem.Handler.DetailOrder;
import com.dianping.cat.report.page.problem.Handler.SummaryOrder;
import org.unidal.dal.jdbc.DalNotFoundException;
import org.unidal.lookup.annotation.Inject;
import org.unidal.lookup.util.StringUtils;
......@@ -111,16 +113,11 @@ public class HistoryGraphs {
Graph graph = m_graphDao.findSingalByDomainNameIpDuration(new Date(startLong), queryIP, domain, "problem",
GraphEntity.READSET_FULL);
graphs.add(graph);
} catch (DalNotFoundException e) {
} catch (Exception e) {
Cat.logError(e);
}
}
// try {
// graphs = m_graphDao.findByDomainNameIpDuration(start, end, queryIP, domain, "problem",
// GraphEntity.READSET_FULL);
// } catch (DalException e) {
// Cat.logError(e);
// }
Map<String, double[]> result = buildGraphDatas(start, end, type, status, graphs);
return result;
}
......
......@@ -14,6 +14,8 @@ import com.dianping.cat.home.dal.report.GraphEntity;
import com.dianping.cat.report.page.HistoryGraphItem;
import com.dianping.cat.report.page.transaction.Handler.DetailOrder;
import com.dianping.cat.report.page.transaction.Handler.SummaryOrder;
import org.unidal.dal.jdbc.DalNotFoundException;
import org.unidal.lookup.annotation.Inject;
import org.unidal.lookup.util.StringUtils;
......@@ -138,6 +140,7 @@ public class HistoryGraphs {
Graph graph = m_graphDao.findSingalByDomainNameIpDuration(new Date(startLong), queryIp, domain,
"transaction", GraphEntity.READSET_FULL);
graphs.add(graph);
} catch (DalNotFoundException e) {
} catch (Exception e) {
Cat.logError(e);
}
......
......@@ -104,9 +104,9 @@ public class ReportFacade implements LogEnabled, Initializable {
}
}
} catch (Exception e) {
System.out.println("hack for log");
System.err.println("Flowing is error stack trace:");
e.printStackTrace();
m_logger.error(e.getMessage(), e);
m_logger.error("Error when building report," + e.getMessage(), e);
Cat.logError(e);
return false;
}
......@@ -160,7 +160,9 @@ public class ReportFacade implements LogEnabled, Initializable {
}
return update;
} catch (Exception e) {
m_logger.error(e.getMessage(), e);
System.err.println("Flowing is error stack trace in redo:");
e.printStackTrace();
m_logger.error("Error when redo task " + taskID + " " + e.getMessage(), e);
Cat.logError(e);
return false;
}
......
......@@ -113,7 +113,7 @@ public class TransactionGraphCreator implements GraphCreator<TransactionReport>
graph.setPeriod(reportPeriod);
graph.setType(3);
graph.setCreationDate(creationDate);
Machine machine = report.getMachines().get(ip);
Machine machine = report.findOrCreateMachine(ip);
Map<String, TransactionType> types = machine.getTypes();
StringBuilder detailBuilder = new StringBuilder();
StringBuilder summaryBuilder = new StringBuilder();
......
......@@ -162,7 +162,6 @@ public class AlarmRuleCreator implements Task {
}
t.complete();
}
} catch (Exception e) {
Cat.logError(e);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册