{"_id":"566ff8f33a32d20d00c45b37","category":{"_id":"55e94ebee5d0c623003ed86c","pages":["55e94ebfe5d0c623003ed86e","55ed7fdadf21af2b009e217d","55ed86db2e66b621009941a6","55ed879428d7c33700de00e1","55ed88392e66b621009941a9","55ed885cec4c3e3900b75611","55ed88ba2e66b621009941ab","55ed8caba872a80d00acff5d","55ed8ce82e66b621009941c3","560d5df697a0a32f006e9de9","566ff8f33a32d20d00c45b37","5670195e81801f0d00802e1c"],"version":"55e94ebee5d0c623003ed86b","__v":12,"project":"55e94ebde5d0c623003ed868","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-09-04T07:56:46.830Z","from_sync":false,"order":9999,"slug":"documentation","title":"Documentation"},"user":"55e84e0f0693802d00bc6952","version":{"_id":"55e94ebee5d0c623003ed86b","project":"55e94ebde5d0c623003ed868","__v":1,"createdAt":"2015-09-04T07:56:46.272Z","releaseDate":"2015-09-04T07:56:46.272Z","categories":["55e94ebee5d0c623003ed86c"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"0.3.0","version":"0.3.0"},"githubsync":"","__v":4,"project":"55e94ebde5d0c623003ed868","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-15T11:26:43.705Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":11,"body":"**CodePools ** are the basic unit for Dynamic code deployment.\nThere are two ways of deploying code to workers:\n- compile your code and put your JARs in the \"extra\" directory of each worker\n- create a CodePool and assign it to your tasks\n\nA CodePool is essentially a bunch of JAR files packaged as a ZIP file which will be put in the classpath of the code which execute the task.\n\nThe best way to create CodePools is to use the TaskSubmitter utilty.\n\nSee this file for a simple example:\nhttps://github.com/majordodo/Majordodo/blob/0.2.0/majordodo-test-clients/src/main/java/majordodo/testclients/TaskSubmissionExample.java\n\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Task Submission\"\n}\n[/block]\nTask submission can happen in these \"modes\":\n- **mode=factory**: the worker will look for a TaskExecutionFactory in the \"extra\" classpath, this in turn will create TaskExecutors\n- **mode=object**: the worker will consider the \"data\" payload of the Task in order to instantiate a TaskExecutor\n\nWith **mode=object** the TaskExecutor will be interpreted in this way:\n- if the data field starts with base64 then the rest of the string will be treated as a base64 encoded stream which contains the JDK serialized TaskExecutor\n- if the data field starts with newinstance: then the rest of the string will be treated as a class name, and the Worker will instantiate a TaskExecutor using Class.forName(...).newInstance\n\nWith **mode=object** the worker will instantiate the TaskExecutor using a classloader choosen in this way:\n- if the task is assigned to a CodePool then the TaskExecutor will be created using the CodePool Classloader (which contains CodePool Jars, the \"extra\" libs and the \"system\" libs)\n- if the task is not assigned to a CodePool then the TaskExecutor will be created using the \"extra\" libs and the \"system\" libs\n\nIt is always advised to put your custom classes in the \"extra\" directory and not in the 'lib' directory in order to handle easy upgrades. In fact upgrade is usually done by replacing the contents of the the \"lib\" directory and leaving untouched the \"extra\" directory.","excerpt":"","slug":"codepools","type":"basic","title":"Code Deployment"}
**CodePools ** are the basic unit for Dynamic code deployment. There are two ways of deploying code to workers: - compile your code and put your JARs in the "extra" directory of each worker - create a CodePool and assign it to your tasks A CodePool is essentially a bunch of JAR files packaged as a ZIP file which will be put in the classpath of the code which execute the task. The best way to create CodePools is to use the TaskSubmitter utilty. See this file for a simple example: https://github.com/majordodo/Majordodo/blob/0.2.0/majordodo-test-clients/src/main/java/majordodo/testclients/TaskSubmissionExample.java [block:api-header] { "type": "basic", "title": "Task Submission" } [/block] Task submission can happen in these "modes": - **mode=factory**: the worker will look for a TaskExecutionFactory in the "extra" classpath, this in turn will create TaskExecutors - **mode=object**: the worker will consider the "data" payload of the Task in order to instantiate a TaskExecutor With **mode=object** the TaskExecutor will be interpreted in this way: - if the data field starts with base64 then the rest of the string will be treated as a base64 encoded stream which contains the JDK serialized TaskExecutor - if the data field starts with newinstance: then the rest of the string will be treated as a class name, and the Worker will instantiate a TaskExecutor using Class.forName(...).newInstance With **mode=object** the worker will instantiate the TaskExecutor using a classloader choosen in this way: - if the task is assigned to a CodePool then the TaskExecutor will be created using the CodePool Classloader (which contains CodePool Jars, the "extra" libs and the "system" libs) - if the task is not assigned to a CodePool then the TaskExecutor will be created using the "extra" libs and the "system" libs It is always advised to put your custom classes in the "extra" directory and not in the 'lib' directory in order to handle easy upgrades. In fact upgrade is usually done by replacing the contents of the the "lib" directory and leaving untouched the "extra" directory.