Changeset 3992
- Timestamp:
- Nov 22, 2007, 2:19:37 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/config/dist/log4j.properties
r3532 r3992 16 16 log4j.appender.migfile.layout=org.apache.log4j.PatternLayout 17 17 log4j.appender.migfile.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n 18 19 ### Job agent log is written to jobagent.log in working directory ### 20 log4j.appender.jobagent=org.apache.log4j.FileAppender 21 log4j.appender.jobagent.File=jobagent.log 22 log4j.appender.jobagent.layout=org.apache.log4j.PatternLayout 23 log4j.appender.jobagent.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n 18 24 19 25 ### set log levels - for more verbose logging change 'info' to 'debug' ### … … 57 63 # Job agent loggers 58 64 # ----------------- 59 log4j.logger.net.sf.basedb.clients.jobagent=warn 65 log4j.logger.net.sf.basedb.clients.jobagent=warn, jobagent 60 66 61 67 # ----------------- -
trunk/doc/src/docbook/admindoc/installation_upgrade.xml
r3917 r3992 378 378 agents to log on to BASE. The account is disabled by 379 379 default and must be enabled. Enable the account and 380 set a password. This password is set in the 380 set a password using the BASE web interface. 381 The same password must also be set in the 381 382 <filename>jobagent.properties</filename> file, see 382 383 item … … 475 476 <listitem> 476 477 <para> 477 <command>userfile </command>: The path to the478 <command>userfiles</command>: The path to the 478 479 directory where user files are located. This 479 480 directory must be accessible from all job -
trunk/doc/src/docbook/appendix/jobagent.sh.xml
r3679 r3992 65 65 66 66 The default value is <filename>jobagent.properties</filename>. 67 The classpath is not searched which means that it doesn't find 68 the configuration file in <filename><base-dir>/www/WEB-INF/classes/</filename> 69 unless you specify the path to it. 67 70 See <xref linkend="appendix.jobagent.properties" /> 68 71 for more information about job agent configuration files. … … 150 153 </listitem> 151 154 </varlistentry> 155 156 <varlistentry> 157 <term><command>status</command></term> 158 <listitem> 159 <para> 160 Similar to the <command>info</command> command but with less output. 161 The output is either <computeroutput>Running, Pauses or Stopped</computeroutput>. 162 In case of an unexpected error, an error message may be displayed instead. 163 </para> 164 </listitem> 165 </varlistentry> 152 166 153 167 <varlistentry> -
trunk/src/clients/jobagent/net/sf/basedb/clients/jobagent/Agent.java
r3675 r3992 210 210 public static final int DEFAULT_CHECK_INTERVAL = 30; 211 211 212 static 213 { 214 org.apache.log4j.LogManager.getLogger("net.sf.basedb.clients.jobagent").setAdditivity(false); 215 } 216 212 217 /** 213 218 Log job agent events. … … 548 553 if (!isRunning) 549 554 { 550 isRunning = true; 555 // Start BASE application and login 556 SessionControl sc = getSessionControl();; 557 // Create executor and job queue checker 551 558 jobExecutor = createJobExecutor(); 552 559 jobQueueChecker = createJobQueueChecker(); 553 554 // Start the BASE application in a new thread so we can return quickly 555 Thread t = new Thread( 556 new Runnable() 557 { 558 public void run() 559 { 560 SessionControl sc = null; 561 try 562 { 563 sc = getSessionControl(); 564 } 565 catch (Throwable t) 566 {} 567 if (sc == null || !sc.isLoggedIn()) 568 { 569 stop(); 570 } 571 } 572 } 573 ); 574 t.start(); 560 isRunning = true; 575 561 } 576 562 } … … 703 689 public SessionControl getSessionControl() 704 690 { 705 try 706 { 707 if (sc == null) 708 { 709 log.info("Starting BASE application"); 710 Application.start(false); 711 sc = Application.newSessionControl("net.sf.basedb.clients.jobagent", 712 SocketUtil.getLocalHost().toString(), null); 713 } 714 if (!sc.isLoggedIn()) 715 { 716 log.info("Logging in as user: " + login); 717 sc.login(login, password, "Job agent running on host " + getServerName(), false); 718 } 719 } 720 catch (Throwable t) 721 { 722 log.error(t.getMessage(), t); 691 if (sc == null) 692 { 693 log.info("Starting BASE application"); 694 Application.start(false); 695 sc = Application.newSessionControl("net.sf.basedb.clients.jobagent", 696 SocketUtil.getLocalHost().toString(), null); 697 } 698 if (!sc.isLoggedIn()) 699 { 700 log.info("Logging in as user: " + login); 701 sc.login(login, password, "Job agent running on host " + getServerName(), false); 723 702 } 724 703 return sc; … … 905 884 executor.init(this); 906 885 } 907 catch ( Throwablet)886 catch (RuntimeException t) 908 887 { 909 888 log.error("Could not create job executor instance: " + executorClass.getName(), t); 910 889 executor = null; 890 throw t; 891 } 892 catch (Exception e) 893 { 894 log.error("Could not create job executor instance: " + executorClass.getName(), e); 895 executor = null; 896 throw new RuntimeException(e); 911 897 } 912 898 return executor; -
trunk/src/clients/jobagent/net/sf/basedb/clients/jobagent/AgentController.java
r3675 r3992 51 51 public class AgentController 52 52 { 53 53 static 54 { 55 org.apache.log4j.LogManager.getLogger("net.sf.basedb.clients.jobagent").setAdditivity(false); 56 } 57 54 58 /** 55 59 Log job agent events. … … 60 64 public static void main(String[] args) 61 65 { 66 int exitCode = 0; 62 67 CmdLine cmdLine = new CmdLine(args); 63 68 String cmd = cmdLine.getCmd(); … … 82 87 printUsage(); 83 88 log.debug(message, t); 84 return;89 System.exit(1); 85 90 } 86 91 … … 92 97 System.out.println("Starting job agent..."); 93 98 ac.startAgent(); 99 exitCode = -1; // Do not exit 94 100 System.out.println("Job agent is up and running."); 95 101 } … … 106 112 System.out.println(info.toString()); 107 113 } 114 else if ("status".equals(cmd)) 115 { 116 String msg = ""; 117 try 118 { 119 JobAgentInfo info = ac.getStatus(); 120 msg += info.isPaused() ? "Paused" : "Running"; 121 } 122 catch (ConnectException ex) 123 { 124 // ConnectException is expected if the agent is not running 125 msg += "Stopped"; 126 log.debug(ex.getMessage(), ex); 127 } 128 catch (Throwable t) 129 { 130 msg += "Error (" + t.getMessage() + ")"; 131 log.error(msg, t); 132 exitCode = 1; 133 } 134 System.out.println(msg); 135 } 108 136 else if ("register".equals(cmd)) 109 137 { … … 133 161 catch (Throwable t) 134 162 { 163 exitCode = 1; 135 164 String message = "Exception when executing command " + cmd; 136 165 System.out.println(message + ": " + t.getMessage()); … … 138 167 } 139 168 } 169 if (exitCode >= 0) System.exit(exitCode); 140 170 } 141 171 … … 144 174 System.out.println("Usage : jobagent.sh [options] cmd"); 145 175 System.out.println(" options : -c <configuration file>"); 146 System.out.println(" cmd : start | stop | pause | info | register | unregister | help");176 System.out.println(" cmd : start | stop | pause | info | status | register | unregister | help"); 147 177 } 148 178 … … 155 185 System.out.println("pause : Pauses the job agent"); 156 186 System.out.println("info : Get info about the job agent"); 187 System.out.println("status : Get status information about the job agent"); 157 188 System.out.println("register : Registers this job agent with the BASE server"); 158 189 System.out.println("unregister: Unregisters this job agent from the BASE server"); … … 318 349 } 319 350 351 /** 352 Get status info about running job agent by sending an info request to the agents r 353 emote control service. The agent may be running in this or in another virtual machine. 354 @throws IOException If there is an error 355 @return A <code>JobAgentInfo</code> object 356 @see JobAgentConnection#getInfo(boolean) 357 @since 2.5 358 */ 359 public JobAgentInfo getStatus() 360 throws IOException 361 { 362 log.info("Getting status from agent on port " + port); 363 JobAgentConnection conn = new JobAgentConnection(port, timeout); 364 JobAgentInfo info = null; 365 try 366 { 367 log.info("Sending status command to job agent on port " + port); 368 info = conn.getInfo(true); 369 } 370 finally 371 { 372 conn.close(); 373 } 374 return info; 375 } 376 320 377 public void registerAgent() 321 378 { -
trunk/src/clients/jobagent/net/sf/basedb/clients/jobagent/JobQueueChecker.java
r3675 r3992 73 73 { 74 74 this.agent = agent; 75 76 // Verify that jobagent is registered 77 DbControl dc = null; 78 try 79 { 80 SessionControl sc = agent.getSessionControl(); 81 dc = sc.newDbControl(); 82 JobAgent jobAgent = agent.getJobAgent(dc); 83 } 84 finally 85 { 86 if (dc != null) dc.close(); 87 } 75 88 } 76 89 -
trunk/src/core/net/sf/basedb/util/jobagent/JobAgentServerConnection.java
r3675 r3992 206 206 catch (Throwable t) 207 207 { 208 answer = "FAILED " + t.getClass().getName() + ": " + t.getMessage();208 answer = t.getMessage() + " [" + t.getClass().getName() + "]"; 209 209 if (logger != null) logger.error("Eception in request handler "+ requestHandler + 210 210 ": " + t.getMessage(), t);
Note: See TracChangeset
for help on using the changeset viewer.