Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(1) Add some logging about when Azkaban tries to send an email. (2) A…
…dd a new job-runner servlet that will run a job based on a curl statement or something. (3) Try to set up tar extraction, but found out it's harder than it really should be in java. Leaving skeleton of code that will allow for it for now.
- Loading branch information
Showing
6 changed files
with
140 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package azkaban.web; | ||
|
||
import azkaban.app.PropsUtils; | ||
import azkaban.common.utils.Props; | ||
import azkaban.flow.ExecutableFlow; | ||
import azkaban.flow.Flow; | ||
import azkaban.flow.FlowExecutionHolder; | ||
import azkaban.flow.FlowManager; | ||
import azkaban.util.JSONToJava; | ||
import org.apache.commons.io.IOUtils; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
/** | ||
*/ | ||
public class JobRunnerServlet extends AbstractAzkabanServlet | ||
{ | ||
private static final JSONToJava jsonConverter = new JSONToJava(); | ||
|
||
@Override | ||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { | ||
String jobName = req.getPathInfo(); | ||
|
||
if (jobName == null || jobName.length() < 2) { | ||
resp.sendError(400, "Path must end with job name to run."); | ||
return; | ||
} | ||
|
||
jobName = jobName.substring(1); // Remove the "/" prefix | ||
|
||
final FlowManager flowManager = getApplication().getAllFlows(); | ||
ExecutableFlow flowToRun = flowManager.createNewExecutableFlow(jobName); | ||
|
||
if (flowToRun == null) { | ||
resp.sendError(404, String.format("Unknown job[%s]", jobName)); | ||
return; | ||
} | ||
|
||
Props parentProps = PropsUtils.produceParentProperties(flowToRun); | ||
final String contentType = req.getContentType(); | ||
if (contentType != null) { | ||
if (contentType.startsWith("application/json")) { | ||
JSONObject obj = null; | ||
try { | ||
obj = new JSONObject(IOUtils.toString(req.getInputStream())); | ||
} catch (JSONException e) { | ||
resp.sendError(400, String.format("Bad JSON object.")); | ||
} | ||
|
||
Map propertyMap = jsonConverter.apply(obj); | ||
parentProps = new Props(parentProps, propertyMap); | ||
} | ||
else { | ||
resp.sendError(400, String.format("Cannot handle content type[%s]", contentType)); | ||
return; | ||
} | ||
} | ||
|
||
getApplication().getScheduler().scheduleNow( | ||
new FlowExecutionHolder( | ||
flowToRun, | ||
parentProps | ||
) | ||
); | ||
|
||
resp.setStatus(200); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters