Search in sources :

Example 1 with SystemTimerWorkMgr

use of com.creditease.agent.workqueue.SystemTimerWorkMgr in project uavstack by uavorg.

the class DoTestTaildirSource method setUp.

@Before
public void setUp() throws IOException {
    SystemLogger.init("DEBUG", true, 5);
    source = new LogAgent("Logagent", "Logagent");
    String os = System.getProperty("os.name");
    if (os.indexOf("Windows") != -1)
        tmpDir = new File("F:/temp");
    else
        tmpDir = new File("/Users/fathead/temp");
    posFilePath = tmpDir.getAbsolutePath() + "/taildir_position_test.json";
    // 1) Create 1st file
    File f1 = new File(tmpDir, "file1");
    // normal sep:\t
    String line1 = "[CE]file1line1chapter1\tfile1line1chapter2\tfile1line1chapter3\n";
    // test [CE]
    String line2 = "[C]file1line2hiddenchapter1\tfile1line2hiddenchapter2\tfile1line2hiddenchapter3\n";
    // filter
    // test
    String line3 = "[CE]file1line3chapter1\tfile1line3chapter2\tfile1line3chapter3\tfile1line3undisplaychapter4\n";
    // plus
    // chapter
    // process
    Files.write(line1 + line2 + line3, f1, Charsets.UTF_8);
    try {
        // wait before creating a new file
        Thread.sleep(1000);
    } catch (InterruptedException e) {
    }
    // 1) Create 2nd file
    // normal sep:|
    String line1b = "<CE>file2line1chapter1|file2line1chapter2|file2line1chapter3\n";
    // test default chapter process
    String line2b = "<CE>file2line2chapter1|file2line2chapter2\n";
    // test plus "" chapter
    String line3b = "<CE>file2line3chapter1|file2line3chapter2\tfile2line3chapter3|\n";
    // process
    File f2 = new File(tmpDir, "file2");
    Files.write(line1b + line2b + line3b, f2, Charsets.UTF_8);
    try {
        // wait before creating next file
        Thread.sleep(1000);
    } catch (InterruptedException e) {
    }
    // 3) Create 3rd file
    // test
    String line1c = "[CE]file3line1hiddenchapter1|file3line1hiddenchapter2|file3line1hiddenchapter3\n";
    // un[CE]
    // filter
    String line2c = "<CE>|file3line2chapter1|\n";
    // test multi- process
    String line3c = "<CE>|file3line3chapter1\n";
    File f3 = new File(tmpDir, "file3");
    Files.write(line1c + line2c + line3c, f3, Charsets.UTF_8);
    // 5) Now update the 3rd file so that its the latest file and gets
    // consumed last
    f3.setLastModified(System.currentTimeMillis());
    // 4) Consume the files
    Map<String, String> logfile = Maps.newHashMap();
    logfile.put("ser1--app1--" + f1.getName(), f1.getPath());
    logfile.put("ser1--app2--" + f2.getName(), f2.getPath());
    logfile.put("ser1--app2--" + f3.getName(), f3.getPath());
    ITimerWorkManager itwm = new SystemTimerWorkMgr();
    ConfigurationManager.getInstance().registerComponent("Global", "ITimerWorkManager", itwm);
    // source.configure(posFilePath, logfile);
    /**
     * constructor filter rule {\"separator\":\"\t\", \"assignfields\":{\"content\":1}, \"timestamp\": 0}
     */
    RuleFilterFactory.getInstance().newBuilder().serverId("ser1").appId("app1").logId(f1.getName()).filterRegex("\\[CE\\].*?").ruleRegex("{\"separator\":\"\t\", \"assignfields\":{\"content1\":1, \"content2\":2,\"content3\":3}, \"timestamp\": 0}").build();
    RuleFilterFactory.getInstance().newBuilder().serverId("ser1").appId("app2").logId(f2.getName()).filterRegex("<CE>.*?").ruleRegex("{\"separator\":\"|\", \"assignfields\":{\"content1\":1, \"content2\":2,\"content3\":3}, \"timestamp\": 0}").build();
    RuleFilterFactory.getInstance().newBuilder().serverId("ser1").appId("app2").logId(f3.getName()).filterRegex("<CE>.*?").ruleRegex("{\"separator\":\"|\", \"assignfields\":{\"content1\":1, \"content2\":2,\"content3\":3}, \"timestamp\": 0}").build();
    source.start();
}
Also used : ITimerWorkManager(com.creditease.agent.spi.ITimerWorkManager) LogAgent(com.creditease.agent.feature.LogAgent) SystemTimerWorkMgr(com.creditease.agent.workqueue.SystemTimerWorkMgr) File(java.io.File) Before(org.junit.Before)

Example 2 with SystemTimerWorkMgr

use of com.creditease.agent.workqueue.SystemTimerWorkMgr in project uavstack by uavorg.

the class SystemStarter method createTimerWorkManager.

private ITimerWorkManager createTimerWorkManager() {
    ITimerWorkManager itwm = new SystemTimerWorkMgr();
    this.configMgr.registerComponent("Global", "ITimerWorkManager", itwm);
    log.info(this, "System Timer Manager created");
    return itwm;
}
Also used : ITimerWorkManager(com.creditease.agent.spi.ITimerWorkManager) SystemTimerWorkMgr(com.creditease.agent.workqueue.SystemTimerWorkMgr)

Aggregations

ITimerWorkManager (com.creditease.agent.spi.ITimerWorkManager)2 SystemTimerWorkMgr (com.creditease.agent.workqueue.SystemTimerWorkMgr)2 LogAgent (com.creditease.agent.feature.LogAgent)1 File (java.io.File)1 Before (org.junit.Before)1