Search in sources :

Example 1 with Agent

use of org.openntf.domino.Agent in project org.openntf.domino by OpenNTF.

the class SerializeTest method testAgentNameConflict.

@Test
public void testAgentNameConflict() throws IOException, ClassNotFoundException {
    Session sess = Factory.getSession(SessionType.CURRENT);
    Database db = sess.getDatabase("log.nsf");
    Agent ag = db.getAgent("name1");
    assertNotNull("you need 4 agents for this test in your log.nsf: 'name1|sameAlias','name2|sameAlias', 'sameName|alias1', 'sameName|alias2'", ag);
    Agent ret = test(ag, true);
    assertFalse(ag == ret);
    ag = db.getAgent("name2");
    ret = test(ag, true);
    assertFalse(ag == ret);
    ag = db.getAgent("alias1");
    ret = test(ag, true);
    assertFalse(ag == ret);
    ag = db.getAgent("alias2");
    ret = test(ag, true);
    assertFalse(ag == ret);
}
Also used : Agent(org.openntf.domino.Agent) Database(org.openntf.domino.Database) Session(org.openntf.domino.Session) Test(org.junit.Test)

Example 2 with Agent

use of org.openntf.domino.Agent in project org.openntf.domino by OpenNTF.

the class AgentLog method run.

@SuppressWarnings("unchecked")
@Override
public void run() {
    try {
        Session sess = Factory.getSession(SessionType.NATIVE);
        Database db = sess.getDatabase("PrivateTest.nsf");
        DatabaseDesign dbDesign = db.getDesign();
        StringBuilder sb = new StringBuilder();
        for (Agent agent : db.getAgents()) {
            if (null != agent.getLastRunDate()) {
                DesignAgent agentDesign = dbDesign.getAgent(agent.getActualName());
                sb.append(agentDesign.getRunLog());
                addNewLine(sb);
                List<String> strings = agentDesign.getRunLogAsList();
                sb.append("Lines = " + strings.size());
                addNewLine(sb);
                sb.append("Duration = " + agentDesign.getLastRunDuration() + " seconds");
                addNewLine(sb);
                sb.append("Exceeded timeout? " + agentDesign.isLastRunExceededTimeLimit());
                addNewLine(sb);
            }
        }
        System.out.println(sb.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DesignAgent(org.openntf.domino.design.DesignAgent) Agent(org.openntf.domino.Agent) DatabaseDesign(org.openntf.domino.design.DatabaseDesign) Database(org.openntf.domino.Database) DesignAgent(org.openntf.domino.design.DesignAgent) Session(org.openntf.domino.Session)

Example 3 with Agent

use of org.openntf.domino.Agent in project org.openntf.domino by OpenNTF.

the class AgentSchedule method run.

@SuppressWarnings("unchecked")
@Override
public void run() {
    try {
        Session sess = Factory.getSession(SessionType.NATIVE);
        Database db = sess.getDatabase("PrivateTest.nsf");
        StringBuilder sb = new StringBuilder();
        for (Agent agent : db.getAgents()) {
            sb.append("============");
            addNewLine(sb);
            DesignAgent designAgent = db.getDesign().getAgent(agent.getActualName());
            if (!designAgent.isScheduled()) {
                sb.append("Agent " + agent.getActualName() + " is not scheduled");
            } else {
                sb.append("Outputting schedule for agent " + agent.getActualName());
                addNewLine(sb);
                sb.append("Set to run on: " + designAgent.getRunLocation());
                addNewLine(sb);
                sb.append("Schedule type: " + designAgent.getScheduleType().name());
                addNewLine(sb);
                switch(designAgent.getScheduleType()) {
                    case MORE_THAN_DAILY:
                        sb.append("Set to run every " + designAgent.getIntervalHours() + " hours, every " + designAgent.getIntervalMinutes() + " minutes");
                        addNewLine(sb);
                        sb.append("Starting at " + designAgent.getStartTime() + ", ending at " + designAgent.getEndTime());
                        addNewLine(sb);
                        if (designAgent.getRunOnWeekends()) {
                            sb.append("Agent set to run on weekends");
                        } else {
                            sb.append("Agent not set to run on weekends");
                        }
                        break;
                    case DAILY:
                        sb.append("Run daily at " + designAgent.getStartTime());
                        addNewLine(sb);
                        if (designAgent.getRunOnWeekends()) {
                            sb.append("Agent set to run on weekends");
                        } else {
                            sb.append("Agent not set to run on weekends");
                        }
                        break;
                    case WEEKLY:
                        sb.append("Run every " + designAgent.getDayOfWeek() + " at " + designAgent.getStartTime());
                        break;
                    case MONTHLY:
                        sb.append("Run every month on day " + designAgent.getDayOfMonth() + " at " + designAgent.getStartTime());
                        break;
                    default:
                }
                addNewLine(sb);
                sb.append("Agent scheduled to run from " + designAgent.getStartDate() + " to " + designAgent.getEndDate());
            }
            addNewLine(sb);
            sb.append("============");
            addNewLine(sb);
        }
        System.out.println(sb.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DesignAgent(org.openntf.domino.design.DesignAgent) Agent(org.openntf.domino.Agent) Database(org.openntf.domino.Database) DesignAgent(org.openntf.domino.design.DesignAgent) Session(org.openntf.domino.Session)

Aggregations

Agent (org.openntf.domino.Agent)3 Database (org.openntf.domino.Database)3 Session (org.openntf.domino.Session)3 DesignAgent (org.openntf.domino.design.DesignAgent)2 Test (org.junit.Test)1 DatabaseDesign (org.openntf.domino.design.DatabaseDesign)1