调大超时警告
This commit is contained in:
+10
-7
@@ -23,7 +23,6 @@ import com.mongodb.DBObject
|
|||||||
*/
|
*/
|
||||||
@BatchOwner(Watcher.Hubingliang)
|
@BatchOwner(Watcher.Hubingliang)
|
||||||
class ApiInvokeStatistics extends BaseBatch{
|
class ApiInvokeStatistics extends BaseBatch{
|
||||||
final static def mongoDomain = "mongo.db.fangjia.com"
|
|
||||||
public static final DBCollection OPEN_URI_LOG = com.fangjia.core.util.MongoUtils.getDbCollection(Constants.SEAWATER_MONGO_URI,"business", "open_uri_log")
|
public static final DBCollection OPEN_URI_LOG = com.fangjia.core.util.MongoUtils.getDbCollection(Constants.SEAWATER_MONGO_URI,"business", "open_uri_log")
|
||||||
public static final DBCollection OPEN_URI_LOG_COUNT = MongoUtils.getCollectionByName("business", "api_invoke_statistical", "mongo.db.fangjia.com", 28017)
|
public static final DBCollection OPEN_URI_LOG_COUNT = MongoUtils.getCollectionByName("business", "api_invoke_statistical", "mongo.db.fangjia.com", 28017)
|
||||||
static final dbFangjia = Sql.newInstance("jdbc:mysql://mysql.db.fangjia.com:4306/fangjia?autoReconnect=true&characterEncoding=utf-8&autoReconnect=true", "sa", "G00jia", "com.mysql.jdbc.Driver");
|
static final dbFangjia = Sql.newInstance("jdbc:mysql://mysql.db.fangjia.com:4306/fangjia?autoReconnect=true&characterEncoding=utf-8&autoReconnect=true", "sa", "G00jia", "com.mysql.jdbc.Driver");
|
||||||
@@ -36,18 +35,22 @@ class ApiInvokeStatistics extends BaseBatch{
|
|||||||
public void process(Object args) {
|
public void process(Object args) {
|
||||||
ApiInvokeStatistics aiks = new ApiInvokeStatistics();
|
ApiInvokeStatistics aiks = new ApiInvokeStatistics();
|
||||||
Date date = DateUtil.truncateDay(new Date())
|
Date date = DateUtil.truncateDay(new Date())
|
||||||
aiks.getYestodayLog(date, date - 1);
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(date);
|
||||||
|
def countDays = 10;
|
||||||
|
for(int i = 0; i < countDays; i++) {
|
||||||
|
Date today = calendar.getTime()
|
||||||
|
Date yesterday = DateUtil.add(today, -1)
|
||||||
|
aiks.getYestodayLog(today, yesterday);
|
||||||
|
calendar.add(Calendar.DAY_OF_MONTH, -1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def getYestodayLog(Date today,Date yestoday){
|
def getYestodayLog(Date today,Date yestoday){
|
||||||
//Date today = getToday();
|
|
||||||
//Date yestoday = getNextDay(today)
|
|
||||||
def deleteQuery = new BasicDBObject("statistical_date", yestoday)
|
def deleteQuery = new BasicDBObject("statistical_date", yestoday)
|
||||||
OPEN_URI_LOG_COUNT.remove(deleteQuery)
|
OPEN_URI_LOG_COUNT.remove(deleteQuery)
|
||||||
println "已删除 ${yestoday.format('yyyy-MM-dd')} 的旧统计数据"
|
|
||||||
BasicDBObject query= new BasicDBObject("c_date", new BasicDBObject('$gte',yestoday).append('$lt', today))
|
BasicDBObject query= new BasicDBObject("c_date", new BasicDBObject('$gte',yestoday).append('$lt', today))
|
||||||
// DBCursor dbc=OPEN_URI_LOG.find(query).batchSize(10000).addOption(Bytes.QUERYOPTION_NOTIMEOUT)
|
println "已删除 ${yestoday.format('yyyy-MM-dd')} 的旧统计数据, 新查询条数: ${query}"
|
||||||
DBCursor dbc = OPEN_URI_LOG.find(query, new BasicDBObject("res_map", 0)).batchSize(10000).addOption(Bytes.QUERYOPTION_NOTIMEOUT)
|
DBCursor dbc = OPEN_URI_LOG.find(query, new BasicDBObject("res_map", 0)).batchSize(10000).addOption(Bytes.QUERYOPTION_NOTIMEOUT)
|
||||||
|
|
||||||
def results = [:]
|
def results = [:]
|
||||||
|
|||||||
-1
@@ -80,7 +80,6 @@ class OpenApiLogAnalyBatch extends BaseBatch{
|
|||||||
index++;
|
index++;
|
||||||
println "[${index}]"+apiUser.id + " "+logs.count()
|
println "[${index}]"+apiUser.id + " "+logs.count()
|
||||||
if(logs){
|
if(logs){
|
||||||
|
|
||||||
def urlCountMap = analyLogsByUrl(logs);
|
def urlCountMap = analyLogsByUrl(logs);
|
||||||
saveAnalyLogs(apiUser, startDate, urlCountMap);
|
saveAnalyLogs(apiUser, startDate, urlCountMap);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user