本文整理汇总了Java中scouter.util.DateUtil.getDateUnit方法的典型用法代码示例。如果您正苦于以下问题:Java DateUtil.getDateUnit方法的具体用法?Java DateUtil.getDateUnit怎么用?Java DateUtil.getDateUnit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scouter.util.DateUtil
的用法示例。
在下文中一共展示了DateUtil.getDateUnit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import scouter.util.DateUtil; //导入方法依赖的package包/类
public void run() {
long last = System.currentTimeMillis();
while (true) {
long now = System.currentTimeMillis();
if (now > last + DateUtil.MILLIS_PER_HOUR) {
last = now;
clearOldLog();
}
if (lastDataUnit != DateUtil.getDateUnit()) {
pw = (PrintWriter) FileUtil.close(pw);
lastDataUnit = DateUtil.getDateUnit();
}
ThreadUtil.sleep(5000);
}
}
示例2: openFile
import scouter.util.DateUtil; //导入方法依赖的package包/类
private static synchronized void openFile() throws IOException {
if (pw == null) {
lastDataUnit = DateUtil.getDateUnit();
lastDir = conf.log_dir;
lastFileRotation = conf.log_rotation_enalbed;
new File(lastDir).mkdirs();
if (conf.log_rotation_enalbed) {
FileWriter fw = new FileWriter(new File(conf.log_dir, "agent-" + DateUtil.yyyymmdd() + ".log"), true);
pw = new PrintWriter(fw);
} else {
pw = new PrintWriter(new File(conf.log_dir, "agent.log"));
}
lastDataUnit = DateUtil.getDateUnit();
}
}
示例3: getFile
import scouter.util.DateUtil; //导入方法依赖的package包/类
private File getFile() {
if (outFile == null || dateUnit != DateUtil.getDateUnit()) {
String filename = FILE_PREFIX + "-" + DateUtil.yyyymmdd()+ ".log";
outFile = new File(DIRECTORY, filename);
File parentDir = new File(DIRECTORY);
if (parentDir.exists() == false) {
parentDir.mkdirs();
}
}
return outFile;
}
示例4: run
import scouter.util.DateUtil; //导入方法依赖的package包/类
public void run() {
Logger.println("Version " + Version.getAgentFullVersion());
long dateUnit = DateUtil.getDateUnit();
while (running) {
reload(false);
// Text Data Reset..
long nowUnit = DateUtil.getDateUnit();
if (dateUnit != nowUnit) {
dateUnit = nowUnit;
DataProxy.reset();
}
ThreadUtil.sleep(3000);
}
}
示例5: run
import scouter.util.DateUtil; //导入方法依赖的package包/类
public void run() {
Logger.println("Version " + Version.getAgentFullVersion());
long dateUnit = DateUtil.getDateUnit();
while (running) {
reload(false);
// Text Data Reset..
long nowUnit = DateUtil.getDateUnit();
if (dateUnit != nowUnit) {
dateUnit = nowUnit;
DataProxy.reset();
}
ThreadUtil.sleep(3000);
}
}
示例6: clearOldLog
import scouter.util.DateUtil; //导入方法依赖的package包/类
protected static void clearOldLog() {
if (conf.log_rotation_enalbed == false)
return;
if (conf.log_keep_days <= 0)
return;
long nowUnit = DateUtil.getDateUnit();
File dir = new File(conf.log_dir);
File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory())
continue;
String name = files[i].getName();
if (name.startsWith("agent-") == false)
continue;
int x = name.lastIndexOf('.');
if (x < 0)
continue;
String date = name.substring("agent-".length(), x);
if (date.length() != 8)
continue;
try {
long d = DateUtil.yyyymmdd(date);
long fileUnit = DateUtil.getDateUnit(d);
if (nowUnit - fileUnit > DateUtil.MILLIS_PER_DAY * conf.log_keep_days) {
files[i].delete();
}
} catch (Exception e) {
}
}
}