code
stringlengths
23
201k
docstring
stringlengths
17
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
72
path
stringlengths
11
317
url
stringlengths
57
377
license
stringclasses
7 values
@VisibleForTesting String getPid() { final File libDir = PACKAGE_JAR.getParentFile(); final File installDir = libDir.getParentFile(); final File pidFile = new File(installDir, this.pidFilename); try { return Files.readFirstLine(pidFile, StandardCharsets.UTF_8).trim(); } catch (final IOException e) { log.error("Unable to obtain PID", e); return "unknown"; } }
This returns implementation instance for Status containing cluster status information for Azkaban containerization. It includes information pertaining to web server, memory and containerization information such as image types and version for each image types selected based on either random rampup or latest active image version. @return Status
getPid
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/StatusService.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/StatusService.java
Apache-2.0
private Map<Integer, Executor> getActiveExecutors() { final Map<Integer, Executor> executorMap = new HashMap<>(); try { final List<Executor> executors = this.executorLoader.fetchActiveExecutors(); for (final Executor executor : executors) { executorMap.put(executor.getId(), executor); } } catch (final ExecutorManagerException e) { log.error("Fetching executors failed!", e); } return executorMap; }
This returns implementation instance for Status containing cluster status information for Azkaban containerization. It includes information pertaining to web server, memory and containerization information such as image types and version for each image types selected based on either random rampup or latest active image version. @return Status
getActiveExecutors
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/StatusService.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/StatusService.java
Apache-2.0
private boolean getDbStatus() { try { return this.dbOperator.query("SELECT 1", rs -> true); } catch (final SQLException e) { log.error("DB Error", e); } return false; }
This returns implementation instance for Status containing cluster status information for Azkaban containerization. It includes information pertaining to web server, memory and containerization information such as image types and version for each image types selected based on either random rampup or latest active image version. @return Status
getDbStatus
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/StatusService.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/StatusService.java
Apache-2.0
private boolean isContainerizedDispatchMethodEnabled() { return DispatchMethod.isContainerizedMethodEnabled(props .getString(Constants.ConfigurationKeys.AZKABAN_EXECUTION_DISPATCH_METHOD, DispatchMethod.PUSH.name())); }
This returns implementation instance for Status containing cluster status information for Azkaban containerization. It includes information pertaining to web server, memory and containerization information such as image types and version for each image types selected based on either random rampup or latest active image version. @return Status
isContainerizedDispatchMethodEnabled
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/StatusService.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/StatusService.java
Apache-2.0
@Override public void setUp(final DataProvider dataProvider) { logger.info("No metrics set up for Web server."); }
No-op implementation of {@link WebMetrics} used when metrics are disabled or for unit tests.
setUp
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
Apache-2.0
@Override public void startReporting(final Props props) { }
No-op implementation of {@link WebMetrics} used when metrics are disabled or for unit tests.
startReporting
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
Apache-2.0
@Override public void markWebGetCall() { }
No-op implementation of {@link WebMetrics} used when metrics are disabled or for unit tests.
markWebGetCall
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
Apache-2.0
@Override public void markWebPostCall() { }
No-op implementation of {@link WebMetrics} used when metrics are disabled or for unit tests.
markWebPostCall
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
Apache-2.0
@Override public AzkabanAPIMetrics setUpAzkabanAPIMetrics(final String endpointUri) { return new AzkabanAPIMetrics(null, null, null, null, null) { @Override public void incrementAppGetRequests() { } @Override public void incrementAppPostRequests() { } @Override public void incrementNonAppGetRequests() { } @Override public void incrementNonAppPostRequests() { } @Override public void addResponseTime(final long time) { } }; }
No-op implementation of {@link WebMetrics} used when metrics are disabled or for unit tests.
setUpAzkabanAPIMetrics
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
Apache-2.0
@Override public void incrementAppGetRequests() { }
No-op implementation of {@link WebMetrics} used when metrics are disabled or for unit tests.
incrementAppGetRequests
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
Apache-2.0
@Override public void incrementAppPostRequests() { }
No-op implementation of {@link WebMetrics} used when metrics are disabled or for unit tests.
incrementAppPostRequests
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
Apache-2.0
@Override public void incrementNonAppGetRequests() { }
No-op implementation of {@link WebMetrics} used when metrics are disabled or for unit tests.
incrementNonAppGetRequests
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
Apache-2.0
@Override public void incrementNonAppPostRequests() { }
No-op implementation of {@link WebMetrics} used when metrics are disabled or for unit tests.
incrementNonAppPostRequests
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
Apache-2.0
@Override public void addResponseTime(final long time) { }
No-op implementation of {@link WebMetrics} used when metrics are disabled or for unit tests.
addResponseTime
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/metrics/DummyWebMetricsImpl.java
Apache-2.0
@Override public void setUp(final DataProvider dataProvider) { logger.info("Setting up Web Server metrics."); this.webGetCall = this.metricsManager.addMeter("Web-Get-Call-Meter"); this.webPostCall = this.metricsManager.addMeter("Web-Post-Call-Meter"); this.metricsManager .addGauge("JETTY-NumIdleThreads", dataProvider::getNumberOfIdleServerThreads); this.metricsManager.addGauge("JETTY-NumTotalThreads", dataProvider::getNumberOfServerThreads); this.metricsManager.addGauge("JETTY-NumQueueSize", dataProvider::getServerJobsQueueSize); this.metricsManager.addGauge("WEB-NumQueuedFlows", dataProvider::getNumberOfQueuedFlows); this.metricsManager.addGauge("WEB-NumAgedQueuedFlows", dataProvider::getNumberOfAgedQueuedFlows); this.metricsManager.addGauge("WEB-NumRunningFlows", dataProvider::getNumberOfRunningFlows); this.metricsManager.addGauge("session-count", dataProvider::getNumberOfCurrentSessions); }
Class in charge of collecting metrics of the azkaban-web-server module.
setUp
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/metrics/WebMetricsImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/metrics/WebMetricsImpl.java
Apache-2.0
@Override public void startReporting(final Props props) { logger.info("Start reporting Web Server metrics."); this.metricsManager.startReporting(props); }
Class in charge of collecting metrics of the azkaban-web-server module.
startReporting
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/metrics/WebMetricsImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/metrics/WebMetricsImpl.java
Apache-2.0
@Override public void markWebGetCall() { this.webGetCall.mark(); }
Mark the occurrence of a GET call This method should be Thread Safe. Two reasons that we don't make this function call synchronized: 1). drop wizard metrics deals with concurrency internally; 2). mark is basically a math addition operation, which should not cause race condition issue.
markWebGetCall
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/metrics/WebMetricsImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/metrics/WebMetricsImpl.java
Apache-2.0
@Override public void markWebPostCall() { this.webPostCall.mark(); }
Mark the occurrence of a GET call This method should be Thread Safe. Two reasons that we don't make this function call synchronized: 1). drop wizard metrics deals with concurrency internally; 2). mark is basically a math addition operation, which should not cause race condition issue.
markWebPostCall
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/metrics/WebMetricsImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/metrics/WebMetricsImpl.java
Apache-2.0
@Override public AzkabanAPIMetrics setUpAzkabanAPIMetrics(final String endpointUri) { final String metricName = "uri-" + endpointUri; final CounterGauge appGetRequestCount = this.metricsManager.addCounterGauge(metricName + "--num-app-get-req"); final CounterGauge appPostRequestCount = this.metricsManager.addCounterGauge(metricName + "--num-app-post-req"); final CounterGauge nonAppGetRequestCount = this.metricsManager.addCounterGauge(metricName + "--num-nonApp-get-req"); final CounterGauge nonAppPostRequestCount = this.metricsManager.addCounterGauge(metricName + "--num-nonApp-post-req"); final Histogram responseTimeHistogram = this.metricsManager.addHistogram(metricName + "--resp-time-histogram"); return new AzkabanAPIMetrics(appGetRequestCount, appPostRequestCount, nonAppGetRequestCount, nonAppPostRequestCount, responseTimeHistogram); }
Mark the occurrence of a GET call This method should be Thread Safe. Two reasons that we don't make this function call synchronized: 1). drop wizard metrics deals with concurrency internally; 2). mark is basically a math addition operation, which should not cause race condition issue.
setUpAzkabanAPIMetrics
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/metrics/WebMetricsImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/metrics/WebMetricsImpl.java
Apache-2.0
public AzkabanWebServer getApplication() { return this.application; }
To retrieve the application for the servlet
getApplication
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
public WebMetrics getWebMetrics() { return this.application.getWebMetrics(); }
To retrieve the application for the servlet
getWebMetrics
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
@Override public void init(final ServletConfig config) throws ServletException { this.application = SERVICE_PROVIDER.getInstance(AzkabanWebServer.class); if (this.application == null) { throw new IllegalStateException("No batch application is defined in the servlet context!"); } final Props props = this.application.getServerProps(); this.name = props.getString("azkaban.name", ""); this.label = props.getString("azkaban.label", ""); this.color = props.getString("azkaban.color", "#FF0000"); this.depth = props.getString("azkaban.depth", "2"); this.passwordPlaceholder = props.getString("azkaban.password.placeholder", "Password"); this.displayExecutionPageSize = props.getInt(ConfigurationKeys.DISPLAY_EXECUTION_PAGE_SIZE, 16); this.viewerPlugins = PluginRegistry.getRegistry().getViewerPlugins(); this.triggerPlugins = new ArrayList<>(this.application.getTriggerPlugins().values()); }
To retrieve the application for the servlet
init
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
public boolean hasParam(final HttpServletRequest request, final String param) { return HttpRequestUtils.hasParam(request, param); }
Checks for the existance of the parameter in the request
hasParam
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
public String getParam(final HttpServletRequest request, final String name) throws ServletException { return HttpRequestUtils.getParam(request, name); }
Retrieves the param from the http servlet request. Will throw an exception if not found
getParam
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
public String getParam(final HttpServletRequest request, final String name, final String defaultVal) { return HttpRequestUtils.getParam(request, name, defaultVal); }
Retrieves the param from the http servlet request.
getParam
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
public int getIntParam(final HttpServletRequest request, final String name) throws ServletException { return HttpRequestUtils.getIntParam(request, name); }
Returns the param and parses it into an int. Will throw an exception if not found, or a parse error if the type is incorrect.
getIntParam
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
public int getIntParam(final HttpServletRequest request, final String name, final int defaultVal) { return HttpRequestUtils.getIntParam(request, name, defaultVal); }
Returns the param and parses it into an int. Will throw an exception if not found, or a parse error if the type is incorrect.
getIntParam
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
public long getLongParam(final HttpServletRequest request, final String name) throws ServletException { return HttpRequestUtils.getLongParam(request, name); }
Returns the param and parses it into an int. Will throw an exception if not found, or a parse error if the type is incorrect.
getLongParam
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
public long getLongParam(final HttpServletRequest request, final String name, final long defaultVal) { return HttpRequestUtils.getLongParam(request, name, defaultVal); }
Returns the param and parses it into an int. Will throw an exception if not found, or a parse error if the type is incorrect.
getLongParam
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
public boolean getBooleanParam(final HttpServletRequest request, final String name, final boolean defaultVal) { return HttpRequestUtils.getBooleanParam(request, name, defaultVal); }
Returns the param and parses it into an int. Will throw an exception if not found, or a parse error if the type is incorrect.
getBooleanParam
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
public Map<String, String> getParamGroup(final HttpServletRequest request, final String groupName) throws ServletException { return HttpRequestUtils.getParamGroup(request, groupName); }
Returns the param and parses it into an int. Will throw an exception if not found, or a parse error if the type is incorrect.
getParamGroup
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected void setSessionValue(final HttpServletRequest request, final String key, final Object value) { request.getSession(true).setAttribute(key, value); }
Returns the session value of the request.
setSessionValue
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected void addSessionValue(final HttpServletRequest request, final String key, final Object value) { List l = (List) request.getSession(true).getAttribute(key); if (l == null) { l = new ArrayList(); } l.add(value); request.getSession(true).setAttribute(key, l); }
Adds a session value to the request
addSessionValue
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected void setErrorMessageInCookie(final HttpServletResponse response, final String errorMsg) { final Cookie cookie = new Cookie(AZKABAN_FAILURE_MESSAGE, errorMsg); cookie.setPath("/"); response.addCookie(cookie); }
Sets an error message in azkaban.failure.message in the cookie. This will be used by the web client javascript to somehow display the message
setErrorMessageInCookie
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected void setWarnMessageInCookie(final HttpServletResponse response, final String errorMsg) { final Cookie cookie = new Cookie(AZKABAN_WARN_MESSAGE, errorMsg); cookie.setPath("/"); response.addCookie(cookie); }
Sets a warning message in azkaban.warn.message in the cookie. This will be used by the web client javascript to somehow display the message
setWarnMessageInCookie
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected void setSuccessMessageInCookie(final HttpServletResponse response, final String message) { final Cookie cookie = new Cookie(AZKABAN_SUCCESS_MESSAGE, message); cookie.setPath("/"); response.addCookie(cookie); }
Sets a message in azkaban.success.message in the cookie. This will be used by the web client javascript to somehow display the message
setSuccessMessageInCookie
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected String getSuccessMessageFromCookie(final HttpServletRequest request) { final Cookie cookie = getCookieByName(request, AZKABAN_SUCCESS_MESSAGE); if (cookie == null) { return null; } return cookie.getValue(); }
Retrieves a success message from a cookie. azkaban.success.message
getSuccessMessageFromCookie
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected String getWarnMessageFromCookie(final HttpServletRequest request) { final Cookie cookie = getCookieByName(request, AZKABAN_WARN_MESSAGE); if (cookie == null) { return null; } return cookie.getValue(); }
Retrieves a warn message from a cookie. azkaban.warn.message
getWarnMessageFromCookie
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected String getErrorMessageFromCookie(final HttpServletRequest request) { final Cookie cookie = getCookieByName(request, AZKABAN_FAILURE_MESSAGE); if (cookie == null) { return null; } return cookie.getValue(); }
Retrieves a success message from a cookie. azkaban.failure.message
getErrorMessageFromCookie
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected Cookie getCookieByName(final HttpServletRequest request, final String name) { final Cookie[] cookies = request.getCookies(); if (cookies != null) { for (final Cookie cookie : cookies) { if (name.equals(cookie.getName())) { return cookie; } } } return null; }
Retrieves a cookie by name. Potential issue in performance if a lot of cookie variables are used.
getCookieByName
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected Page newPage(final HttpServletRequest req, final HttpServletResponse resp, final Session session, final String template) { final Page page = new Page(req, resp, getApplication().getVelocityEngine(), template); page.add("version", jarVersion); page.add("azkaban_name", this.name); page.add("azkaban_label", this.label); page.add("azkaban_color", this.color); page.add("azkaban_depth", this.depth); page.add("note_type", NoteServlet.type); page.add("note_message", NoteServlet.message); page.add("note_url", NoteServlet.url); page.add("timezone", TimeZone.getDefault().getID()); page.add("currentTime", (new DateTime()).getMillis()); page.add("size", getDisplayExecutionPageSize()); page.add("System", System.class); page.add("TimeUtils", TimeUtils.class); page.add("WebUtils", WebUtils.class); page.add("HTMLFormElementType_TEXTAREA", HTMLFormElementType.TEXTAREA); if (session != null && session.getUser() != null) { page.add("user_id", session.getUser().getUserId()); } final String errorMsg = getErrorMessageFromCookie(req); page.add("error_message", errorMsg == null || errorMsg.isEmpty() ? "null" : errorMsg); setErrorMessageInCookie(resp, null); final String warnMsg = getWarnMessageFromCookie(req); page.add("warn_message", warnMsg == null || warnMsg.isEmpty() ? "null" : warnMsg); setWarnMessageInCookie(resp, null); final String successMsg = getSuccessMessageFromCookie(req); page.add("success_message", successMsg == null || successMsg.isEmpty() ? "null" : successMsg); setSuccessMessageInCookie(resp, null); // @TODO, allow more than one type of viewer. For time sake, I only install // the first one if (this.viewerPlugins != null && !this.viewerPlugins.isEmpty()) { page.add("viewers", this.viewerPlugins); } if (this.triggerPlugins != null && !this.triggerPlugins.isEmpty()) { page.add("triggerPlugins", this.triggerPlugins); } return page; }
Creates a new velocity page to use. With session.
newPage
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected Page newPage(final HttpServletRequest req, final HttpServletResponse resp, final String template) { final Page page = new Page(req, resp, getApplication().getVelocityEngine(), template); page.add("version", jarVersion); page.add("azkaban_name", this.name); page.add("azkaban_label", this.label); page.add("azkaban_color", this.color); page.add("azkaban_depth", this.depth); page.add("note_type", NoteServlet.type); page.add("note_message", NoteServlet.message); page.add("note_url", NoteServlet.url); page.add("timezone", TimeZone.getDefault().getID()); page.add("currentTime", (new DateTime()).getMillis()); page.add("size", getDisplayExecutionPageSize()); // @TODO, allow more than one type of viewer. For time sake, I only install // the first one if (this.viewerPlugins != null && !this.viewerPlugins.isEmpty()) { page.add("viewers", this.viewerPlugins); final ViewerPlugin plugin = this.viewerPlugins.get(0); page.add("viewerName", plugin.getPluginName()); page.add("viewerPath", plugin.getPluginPath()); } if (this.triggerPlugins != null && !this.triggerPlugins.isEmpty()) { page.add("triggers", this.triggerPlugins); } return page; }
Creates a new velocity page to use.
newPage
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected void writeJSON(final HttpServletResponse resp, final Object obj) throws IOException { writeJSON(resp, obj, false); }
Writes json out to the stream.
writeJSON
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected void writeJSON(final HttpServletResponse resp, final Object obj, final boolean pretty) throws IOException { resp.setContentType(JSON_MIME_TYPE); JSONUtils.toJSON(obj, resp.getOutputStream(), true); }
Writes json out to the stream.
writeJSON
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected int getDisplayExecutionPageSize() { return this.displayExecutionPageSize; }
Writes json out to the stream.
getDisplayExecutionPageSize
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
public static String createJsonResponse(final String status, final String message, final String action, final Map<String, Object> params) { final HashMap<String, Object> response = new HashMap<>(); response.put("status", status); if (message != null) { response.put("message", message); } if (action != null) { response.put("action", action); } if (params != null) { response.putAll(params); } return JSONUtils.toJSON(response); }
Writes json out to the stream.
createJsonResponse
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
public Optional<AzkabanAPI> getAzkabanAPI(final HttpServletRequest request) { // Inspect parameters contained in the query string or posted form data for (final AzkabanAPI api : getApiEndpoints()) { final String paramName = api.getRequestParameter(); final String paramValue = api.getParameterValue(); if (request.getParameter(paramName) != null && (paramValue.isEmpty() || paramValue.equals( request.getParameter(paramName)))) { return Optional.of(api); } } // Handle multipart/form-data requests if (ServletFileUpload.isMultipartContent(request)) { // At the time this code was added servlet 2.5 was used which doesn't support // multipart/form-data requests natively. To parse parameters of such requests Apache // Commons was the way to go but it can only be called once. As this is done already in // LoginAbstracAzkabanServlet.java (this.multipartParser.parseMultipart(req)) and Azkaban only // has one API endpoint with multipart/form-data content type, opting for a more hardcoded // approach to determine the Azkaban API being used. final String reqOrigin = request.getHeader(HTTP_HEADER_AZKABAN_TRACE_ORIGIN); final boolean isReqFromWebApp = HTTP_HEADER_VALUE_AZKABAN_TRACE_ORIGIN.equals(reqOrigin); final String paramName = isReqFromWebApp ? "action" : "ajax"; return this.apiEndpoints.stream() .filter(a -> a.getRequestParameter().equals(paramName) && a.getParameterValue() .equals(ProjectManagerServlet.API_UPLOAD)) .findAny(); } return Optional.empty(); }
Writes json out to the stream.
getAzkabanAPI
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected void sendErrorResponse(final HttpServletResponse httpServletResponse, final int status, final String errorMessage) throws IOException { final Map<String, Object> responseObj = new HashMap<>(); responseObj.put("error", status); responseObj.put("message", errorMessage); httpServletResponse.setStatus(status); writeJSON(httpServletResponse, responseObj, true); }
Writes json out to the stream.
sendErrorResponse
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected void sendResponse(final HttpServletResponse httpServletResponse, final int status, final Object responseObj) throws IOException { httpServletResponse.setStatus(status); writeJSON(httpServletResponse, responseObj, true); }
Writes json out to the stream.
sendResponse
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
protected void sendResponse(final HttpServletResponse httpServletResponse, final int status, final String errorMessage, final Object response) throws IOException { final Map<String, Object> responseObj = new LinkedHashMap<>(); responseObj.put("error", status); responseObj.put("message", errorMessage); responseObj.put("response", response); httpServletResponse.setStatus(status); writeJSON(httpServletResponse, responseObj, true); }
Writes json out to the stream.
sendResponse
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
Apache-2.0
private void ajaxUpdateQueueProcessor(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> returnMap, final User user, final boolean enableQueue) { boolean wasSuccess = false; if (HttpRequestUtils.hasPermission(this.userManager, user, Type.ADMIN)) { try { if (enableQueue) { this.executorManagerAdapter.enableQueueProcessorThread(); } else { this.executorManagerAdapter.disableQueueProcessorThread(); } returnMap.put(ConnectorParams.STATUS_PARAM, ConnectorParams.RESPONSE_SUCCESS); wasSuccess = true; } catch (final ExecutorManagerException e) { returnMap.put(ConnectorParams.RESPONSE_ERROR, e.getMessage()); } } else { returnMap.put(ConnectorParams.RESPONSE_ERROR, "Only Admins are allowed to update queue processor"); } if (!wasSuccess) { returnMap.put(ConnectorParams.STATUS_PARAM, ConnectorParams.RESPONSE_ERROR); } }
<pre> Enables queueProcessor if @param status is true disables queueProcessor if @param status is false. </pre>
ajaxUpdateQueueProcessor
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxFetchScheduledFlowGraph(final String projectName, final String flowName, final HashMap<String, Object> ret, final User user) throws ServletException { final Project project = getProjectAjaxByPermission(ret, projectName, user, Type.EXECUTE); if (project == null) { ret.put("error", "Project '" + projectName + "' doesn't exist."); return; } try { final Schedule schedule = this.scheduleManager.getSchedule(project.getId(), flowName); final ExecutionOptions executionOptions = schedule != null ? schedule.getExecutionOptions() : new ExecutionOptions(); final Flow flow = project.getFlow(flowName); if (flow == null) { ret.put("error", "Flow '" + flowName + "' cannot be found in project " + project); return; } final ExecutableFlow exFlow = new ExecutableFlow(project, flow); exFlow.setExecutionOptions(executionOptions); ret.put("submitTime", exFlow.getSubmitTime()); ret.put("submitUser", exFlow.getSubmitUser()); ret.put("execid", exFlow.getExecutionId()); ret.put("projectId", exFlow.getProjectId()); ret.put("project", project.getName()); FlowUtils.applyDisabledJobs(executionOptions.getDisabledJobs(), exFlow); final Map<String, Object> flowObj = getExecutableNodeInfo(exFlow); ret.putAll(flowObj); } catch (final ScheduleManagerException ex) { throw new ServletException(ex); } }
<pre> Enables queueProcessor if @param status is true disables queueProcessor if @param status is false. </pre>
ajaxFetchScheduledFlowGraph
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxReloadExecutors(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> returnMap, final User user) { boolean wasSuccess = false; if (HttpRequestUtils.hasPermission(this.userManager, user, Type.ADMIN)) { try { this.executorManagerAdapter.setupExecutors(); returnMap.put(ConnectorParams.STATUS_PARAM, ConnectorParams.RESPONSE_SUCCESS); wasSuccess = true; } catch (final ExecutorManagerException e) { returnMap.put(ConnectorParams.RESPONSE_ERROR, "Failed to refresh the executors " + e.getMessage()); } } else { returnMap.put(ConnectorParams.RESPONSE_ERROR, "Only Admins are allowed to refresh the executors"); } if (!wasSuccess) { returnMap.put(ConnectorParams.STATUS_PARAM, ConnectorParams.RESPONSE_ERROR); } }
<pre> Enables queueProcessor if @param status is true disables queueProcessor if @param status is false. </pre>
ajaxReloadExecutors
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
@Override protected void handlePost(final HttpServletRequest req, final HttpServletResponse resp, final Session session) throws ServletException, IOException { if (hasParam(req, "ajax")) { handleAJAXAction(req, resp, session); } }
<pre> Enables queueProcessor if @param status is true disables queueProcessor if @param status is false. </pre>
handlePost
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void handleExecutionJobDetailsPage(final HttpServletRequest req, final HttpServletResponse resp, final Session session) throws ServletException, IOException { final Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/jobdetailspage.vm"); final User user = session.getUser(); final int execId = getIntParam(req, "execid"); final String jobId = getParam(req, "job"); final int attempt = getIntParam(req, "attempt", 0); page.add("execid", execId); page.add("jobid", jobId); page.add("attempt", attempt); ExecutableFlow flow = null; ExecutableNode node = null; try { flow = this.executorManagerAdapter.getExecutableFlow(execId); if (flow == null) { page.add("errorMsg", "Error loading executing flow " + execId + ": not found."); page.render(); return; } node = flow.getExecutableNodePath(jobId); if (node == null) { page.add("errorMsg", "Job " + jobId + " doesn't exist in " + flow.getExecutionId()); return; } final List<ViewerPlugin> jobViewerPlugins = PluginRegistry.getRegistry() .getViewerPluginsForJobType(node.getType()); page.add("jobViewerPlugins", jobViewerPlugins); } catch (final ExecutorManagerException e) { page.add("errorMsg", "Error loading executing flow: " + e.getMessage()); page.render(); return; } final int projectId = flow.getProjectId(); final Project project = getProjectPageByPermission(page, projectId, user, Type.READ); if (project == null) { page.render(); return; } final Map<String, String> jobLogUrlsByAppId = this.executorManagerAdapter .getExternalJobLogUrls(flow, jobId, attempt); page.add("jobLogUrlsByAppId", jobLogUrlsByAppId); addExternalLinks(this.jobLevelExternalLinks, page, req, execId, jobId); page.add("projectName", project.getName()); page.add("flowid", flow.getId()); page.add("flowlist", flow.getId().split(Constants.PATH_DELIMITER, 0)); page.add("pathDelimiter", Constants.PATH_DELIMITER); page.add("parentflowid", node.getParentFlow().getFlowId()); page.add("jobname", node.getId()); page.add("jobType", node.getType()); page.add("attemptStatus", attempt == node.getAttempt() ? node.getStatus() : node.getPastAttemptList().get(attempt).getStatus()); page.add("pastAttempts", node.getAttempt() > 0 ? node.getPastAttemptList().size() : 0); page.add("jobFailed", node.getStatus() == Status.FAILED || node.getStatus() == Status.KILLED); page.render(); }
<pre> Enables queueProcessor if @param status is true disables queueProcessor if @param status is false. </pre>
handleExecutionJobDetailsPage
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void handleExecutionsPage(final HttpServletRequest req, final HttpServletResponse resp, final Session session) throws ServletException, IOException { final Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/executionspage.vm"); final List<Pair<ExecutableFlow, Optional<Executor>>> runningFlows = this.executorManagerAdapter.getActiveFlowsWithExecutor(); page.add("runningFlows", runningFlows.isEmpty() ? null : runningFlows); final List<ExecutableFlow> finishedFlows = this.executorManagerAdapter.getRecentlyFinishedFlows(); page.add("recentlyFinished", finishedFlows.isEmpty() ? null : finishedFlows); page.add("vmutils", new VelocityUtil(this.projectManager)); page.render(); }
<pre> Enables queueProcessor if @param status is true disables queueProcessor if @param status is false. </pre>
handleExecutionsPage
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void handleExecutionFlowPageByTriggerInstanceId(final HttpServletRequest req, final HttpServletResponse resp, final Session session) throws ServletException, IOException { final Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/executingflowpage.vm"); final User user = session.getUser(); final String triggerInstanceId = getParam(req, "triggerinstanceid"); final TriggerInstance triggerInst = this.flowTriggerService .findTriggerInstanceById(triggerInstanceId); if (triggerInst == null) { page.add("errorMsg", "Error loading trigger instance " + triggerInstanceId + " not found."); page.render(); return; } page.add("triggerInstanceId", triggerInstanceId); page.add("execid", triggerInst.getFlowExecId()); final int projectId = triggerInst.getProject().getId(); final Project project = getProjectPageByPermission(page, projectId, user, Type.READ); if (project == null) { page.render(); return; } addExternalLinks(this.flowLevelExternalLinks, page, req, triggerInst.getFlowExecId(), null); page.add("projectId", project.getId()); page.add("projectName", project.getName()); page.add("flowid", triggerInst.getFlowId()); page.add("flowlist", triggerInst.getFlowId().split(Constants.PATH_DELIMITER, 0)); page.add("pathDelimiter", Constants.PATH_DELIMITER); page.render(); }
<pre> Enables queueProcessor if @param status is true disables queueProcessor if @param status is false. </pre>
handleExecutionFlowPageByTriggerInstanceId
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void handleExecutionFlowPageByExecId(final HttpServletRequest req, final HttpServletResponse resp, final Session session) throws ServletException, IOException { final Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/executingflowpage.vm"); final User user = session.getUser(); final int execId = getIntParam(req, "execid"); page.add("execid", execId); page.add("triggerInstanceId", "-1"); ExecutableFlow flow = null; try { flow = this.executorManagerAdapter.getExecutableFlow(execId); if (flow == null) { page.add("errorMsg", "Error loading executing flow " + execId + " not found."); page.render(); return; } } catch (final ExecutorManagerException e) { page.add("errorMsg", "Error loading executing flow: " + e.getMessage()); page.render(); return; } final int projectId = flow.getProjectId(); final Project project = getProjectPageByPermission(page, projectId, user, Type.READ); if (project == null) { page.render(); return; } addExternalLinks(this.flowLevelExternalLinks, page, req, execId, null); page.add("projectId", project.getId()); page.add("projectName", project.getName()); page.add("flowid", flow.getFlowId()); page.add("flowlist", flow.getFlowId().split(Constants.PATH_DELIMITER, 0)); page.add("pathDelimiter", Constants.PATH_DELIMITER); page.add("parentExecutionID", 123); page.add("childExecutionID", 456); String autoRetryStatuses = flow.getExecutionOptions().getFlowParameters() .getOrDefault(FlowParameters.FLOW_PARAM_ALLOWED_RETRY_STATUS, ""); if (!autoRetryStatuses.isEmpty()){ Map<String, Object> retriesInfo = new HashMap<>(); retriesInfo.put("allowedStatuses", autoRetryStatuses); retriesInfo.put("strategy", flow.getExecutionOptions().getFlowParameters() .getOrDefault(FlowParameters.FLOW_PARAM_RETRY_STRATEGY, FlowRetryStrategy.DEFAULT.getName())); retriesInfo.put("userDefinedMax", Integer.valueOf(flow.getExecutionOptions().getFlowParameters() .getOrDefault(FlowParameters.FLOW_PARAM_MAX_RETRIES, "1"))); retriesInfo.put("userDefinedCount", flow.getUserDefinedRetryCount()); retriesInfo.put("systemDefinedMax", ExecutableFlow.DEFAULT_SYSTEM_FLOW_RETRY_LIMIT); retriesInfo.put("systemDefinedCount", flow.getSystemDefinedRetryCount()); retriesInfo.put("rootExecutionID", flow.getFlowRetryRootExecutionID()); retriesInfo.put("parentExecutionID", flow.getFlowRetryParentExecutionID()); retriesInfo.put("childExecutionID", flow.getFlowRetryChildExecutionID()); page.add("retries", retriesInfo); } // check the current flow definition to see if the flow is locked. final Flow currentFlow = project.getFlow(flow.getFlowId()); boolean isCurrentFlowLocked = false; if (currentFlow != null) { isCurrentFlowLocked = currentFlow.isLocked(); } else { logger.info("Flow {} not found in project {}.", flow.getFlowId(), project.getName()); } page.add("isLocked", isCurrentFlowLocked); page.render(); }
<pre> Enables queueProcessor if @param status is true disables queueProcessor if @param status is false. </pre>
handleExecutionFlowPageByExecId
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void addExternalLinks(final List<ExternalLink> extLinksTemplates, final Page page, final HttpServletRequest req, final int executionId, final String jobId) { List<ExternalLink> externalAnalyzers = ExternalLinkUtils.buildExternalLinksForRequest(extLinksTemplates, this.externalLinksTimeoutMs, req, executionId, jobId); page.add("externalAnalyzers", externalAnalyzers); }
<pre> Enables queueProcessor if @param status is true disables queueProcessor if @param status is false. </pre>
addExternalLinks
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
protected Project getProjectPageByPermission(final Page page, final int projectId, final User user, final Permission.Type type) { final Project project = this.projectManager.getProject(projectId); if (project == null) { page.add("errorMsg", "Project " + project + " not found."); } else if (!hasPermission(project, user, type)) { page.add("errorMsg", "User " + user.getUserId() + " doesn't have " + type.name() + " permissions on " + project.getName()); } else { return project; } return null; }
<pre> Enables queueProcessor if @param status is true disables queueProcessor if @param status is false. </pre>
getProjectPageByPermission
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
protected Project getProjectAjaxByPermission(final Map<String, Object> ret, final String projectName, final User user, final Permission.Type type) { return filterProjectByPermission(this.projectManager.getProject(projectName), user, type, ret); }
<pre> Enables queueProcessor if @param status is true disables queueProcessor if @param status is false. </pre>
getProjectAjaxByPermission
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
protected Project getProjectAjaxByPermission(final Map<String, Object> ret, final int projectId, final User user, final Permission.Type type) { return filterProjectByPermission(this.projectManager.getProject(projectId), user, type, ret); }
<pre> Enables queueProcessor if @param status is true disables queueProcessor if @param status is false. </pre>
getProjectAjaxByPermission
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxRestartFailed(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user, final ExecutableFlow exFlow) throws ServletException { final Project project = getProjectAjaxByPermission(ret, exFlow.getProjectId(), user, Type.EXECUTE); if (project == null) { return; } if (exFlow.getStatus() == Status.FAILED || exFlow.getStatus() == Status.SUCCEEDED) { ret.put("error", "Flow has already finished. Please re-execute."); return; } try { this.executorManagerAdapter.retryFailures(exFlow, user.getUserId()); } catch (final ExecutorManagerException e) { ret.put("error", e.getMessage()); } }
<pre> Enables queueProcessor if @param status is true disables queueProcessor if @param status is false. </pre>
ajaxRestartFailed
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxFetchExecFlowLogs(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user, final ExecutableFlow exFlow) throws ServletException { final Project project = getProjectAjaxByPermission(ret, exFlow.getProjectId(), user, Type.READ); if (project == null) { return; } final int offset = this.getIntParam(req, "offset"); final int length = this.getIntParam(req, "length"); resp.setCharacterEncoding("utf-8"); try { final LogData data = this.executorManagerAdapter.getExecutableFlowLog(exFlow, offset, length); ret.putAll(appendLogData(data, offset)); } catch (final ExecutorManagerException e) { throw new ServletException(e); } }
Gets the logs through plain text stream to reduce memory overhead.
ajaxFetchExecFlowLogs
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxFetchJobLogs(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user, final ExecutableFlow exFlow) throws ServletException { final Project project = getProjectAjaxByPermission(ret, exFlow.getProjectId(), user, Type.READ); if (project == null) { return; } final int offset = this.getIntParam(req, "offset"); final int length = this.getIntParam(req, "length"); final String jobId = this.getParam(req, "jobId"); resp.setCharacterEncoding("utf-8"); try { final ExecutableNode node = exFlow.getExecutableNodePath(jobId); if (node == null) { ret.put("error", "Job " + jobId + " doesn't exist in " + exFlow.getExecutionId()); return; } final int attempt = this.getIntParam(req, "attempt", node.getAttempt()); final LogData data = this.executorManagerAdapter .getExecutionJobLog(exFlow, jobId, offset, length, attempt); ret.putAll(appendLogData(data, offset)); } catch (final ExecutorManagerException e) { throw new ServletException(e); } }
Gets the logs through ajax plain text stream to reduce memory overhead.
ajaxFetchJobLogs
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private Map<String, Object> appendLogData(final LogData data, final int defaultOffset) { final Map<String, Object> parameters = new HashMap<>(); if (data == null) { parameters.put("length", 0); parameters.put("offset", defaultOffset); parameters.put("data", ""); } else { parameters.put("length", data.getLength()); parameters.put("offset", data.getOffset()); parameters.put("data", StringEscapeUtils.escapeHtml(data.getData())); } return parameters; }
Gets the logs through ajax plain text stream to reduce memory overhead.
appendLogData
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxFetchJobStats(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user, final ExecutableFlow exFlow) throws ServletException { final Project project = getProjectAjaxByPermission(ret, exFlow.getProjectId(), user, Type.READ); if (project == null) { return; } final String jobId = this.getParam(req, "jobid"); resp.setCharacterEncoding("utf-8"); try { final ExecutableNode node = exFlow.getExecutableNodePath(jobId); if (node == null) { ret.put("error", "Job " + jobId + " doesn't exist in " + exFlow.getExecutionId()); return; } final List<Object> jsonObj = this.executorManagerAdapter .getExecutionJobStats(exFlow, jobId, node.getAttempt()); ret.put("jobStats", jsonObj); } catch (final ExecutorManagerException e) { ret.put("error", "Error retrieving stats for job " + jobId); return; } }
Gets the logs through ajax plain text stream to reduce memory overhead.
ajaxFetchJobStats
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxFetchFlowInfo(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user, final String projectName, final String flowId) throws ServletException { final Project project = getProjectAjaxByPermission(ret, projectName, user, Type.READ); if (project == null) { return; } final Flow flow = project.getFlow(flowId); if (flow == null) { ret.put("error", "Error loading flow. Flow " + flowId + " doesn't exist in " + projectName); return; } ret.put("successEmails", flow.getSuccessEmails()); ret.put("failureEmails", flow.getFailureEmails()); Schedule sflow = null; try { for (final Schedule sched : this.scheduleManager.getSchedules()) { if (sched.getProjectId() == project.getId() && sched.getFlowName().equals(flowId)) { sflow = sched; break; } } } catch (final ScheduleManagerException e) { // TODO Auto-generated catch block throw new ServletException(e); } if (sflow != null) { ret.put("scheduled", sflow.getNextExecTime()); } }
Gets the logs through ajax plain text stream to reduce memory overhead.
ajaxFetchFlowInfo
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxFetchExecutableFlowInfo(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user, final ExecutableFlow exflow) throws ServletException { final Project project = getProjectAjaxByPermission(ret, exflow.getProjectId(), user, Type.READ); if (project == null) { return; } final Flow flow = project.getFlow(exflow.getFlowId()); if (flow == null) { ret.put("error", "Error loading flow. Flow " + exflow.getFlowId() + " doesn't exist in " + exflow.getProjectId()); return; } final ExecutionOptions options = exflow.getExecutionOptions(); ret.put("successEmails", options.getSuccessEmails()); ret.put("failureEmails", options.getFailureEmails()); ret.put("runtimeProperties", mergeRuntimeProperties(options)); // For legacy support. This is not used by the Azkaban UI any more. ret.put("flowParam", options.getFlowParameters()); final FailureAction action = options.getFailureAction(); String failureAction = null; switch (action) { case FINISH_CURRENTLY_RUNNING: failureAction = "finishCurrent"; break; case CANCEL_ALL: failureAction = "cancelImmediately"; break; case FINISH_ALL_POSSIBLE: failureAction = "finishPossible"; break; } ret.put("failureAction", failureAction); ret.put("notifyFailureFirst", options.getNotifyOnFirstFailure()); ret.put("notifyFailureLast", options.getNotifyOnLastFailure()); ret.put("failureEmailsOverride", options.isFailureEmailsOverridden()); ret.put("successEmailsOverride", options.isSuccessEmailsOverridden()); ret.put("concurrentOptions", options.getConcurrentOption()); ret.put("pipelineLevel", options.getPipelineLevel()); ret.put("pipelineExecution", options.getPipelineExecutionId()); ret.put("queueLevel", options.getQueueLevel()); final HashMap<String, String> nodeStatus = new HashMap<>(); for (final ExecutableNode node : exflow.getExecutableNodes()) { nodeStatus.put(node.getId(), node.getStatus().toString()); } ret.put("nodeStatus", nodeStatus); ret.put("disabled", options.getDisabledJobs()); }
Gets the logs through ajax plain text stream to reduce memory overhead.
ajaxFetchExecutableFlowInfo
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private static Map<String, Map<String, String>> mergeRuntimeProperties( final ExecutionOptions options) { final Map<String, Map<String, String>> runtimeProperties = new HashMap<>(); if (!options.getFlowParameters().isEmpty()) { runtimeProperties .put(Constants.ROOT_NODE_IDENTIFIER, new HashMap<>(options.getFlowParameters())); } for (final Entry<String, Map<String, String>> runtimeProp : options.getRuntimeProperties().entrySet()) { runtimeProperties.put(runtimeProp.getKey(), new HashMap<>(runtimeProp.getValue())); } return runtimeProperties; }
Copies flowOverrides under the key "ROOT".
mergeRuntimeProperties
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxCancelFlow(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user, final ExecutableFlow exFlow) throws ServletException { final Project project = getProjectAjaxByPermission(ret, exFlow.getProjectId(), user, Type.EXECUTE); if (project == null) { return; } try { this.executorManagerAdapter.cancelFlow(exFlow, user.getUserId()); } catch (final ExecutorManagerException e) { ret.put("error", e.getMessage()); } }
Copies flowOverrides under the key "ROOT".
ajaxCancelFlow
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxGetFlowRunning(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user, final String projectId, final String flowId) throws ServletException { final Project project = getProjectAjaxByPermission(ret, projectId, user, Type.EXECUTE); if (project == null) { return; } final List<Integer> refs = this.executorManagerAdapter.getRunningFlowIds(project.getId(), flowId); if (!refs.isEmpty()) { ret.put("execIds", refs); } }
Copies flowOverrides under the key "ROOT".
ajaxGetFlowRunning
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxPauseFlow(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user, final ExecutableFlow exFlow) throws ServletException { final Project project = getProjectAjaxByPermission(ret, exFlow.getProjectId(), user, Type.EXECUTE); if (project == null) { return; } try { this.executorManagerAdapter.pauseFlow(exFlow, user.getUserId()); } catch (final ExecutorManagerException e) { ret.put("error", e.getMessage()); } }
Copies flowOverrides under the key "ROOT".
ajaxPauseFlow
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxResumeFlow(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user, final ExecutableFlow exFlow) throws ServletException { final Project project = getProjectAjaxByPermission(ret, exFlow.getProjectId(), user, Type.EXECUTE); if (project == null) { return; } try { this.executorManagerAdapter.resumeFlow(exFlow, user.getUserId()); } catch (final ExecutorManagerException e) { ret.put("resume", e.getMessage()); } }
Copies flowOverrides under the key "ROOT".
ajaxResumeFlow
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private Map<String, Object> getExecutableFlowUpdateInfo(final ExecutableNode node, final long lastUpdateTime) { final HashMap<String, Object> nodeObj = new HashMap<>(); if (node instanceof ExecutableFlowBase) { final ExecutableFlowBase base = (ExecutableFlowBase) node; final ArrayList<Map<String, Object>> nodeList = new ArrayList<>(); for (final ExecutableNode subNode : base.getExecutableNodes()) { final Map<String, Object> subNodeObj = getExecutableFlowUpdateInfo(subNode, lastUpdateTime); if (!subNodeObj.isEmpty()) { nodeList.add(subNodeObj); } } if (!nodeList.isEmpty()) { nodeObj.put("flow", base.getFlowId()); nodeObj.put("nodes", nodeList); } } if (node.getUpdateTime() > lastUpdateTime || !nodeObj.isEmpty()) { nodeObj.put("id", node.getId()); nodeObj.put("status", node.getStatus()); nodeObj.put("startTime", node.getStartTime()); nodeObj.put("endTime", node.getEndTime()); nodeObj.put("updateTime", node.getUpdateTime()); nodeObj.put("attempt", node.getAttempt()); if (node.getAttempt() > 0) { nodeObj.put("pastAttempts", node.getAttemptObjects()); } } return nodeObj; }
Copies flowOverrides under the key "ROOT".
getExecutableFlowUpdateInfo
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private Map<String, Object> getExecutableNodeInfo(final ExecutableNode node) { final HashMap<String, Object> nodeObj = new HashMap<>(); nodeObj.put("id", node.getId()); nodeObj.put("status", node.getStatus()); nodeObj.put("startTime", node.getStartTime()); nodeObj.put("endTime", node.getEndTime()); nodeObj.put("updateTime", node.getUpdateTime()); nodeObj.put("type", node.getType()); if (node.getCondition() != null) { nodeObj.put("condition", node.getCondition()); } nodeObj.put("nestedId", node.getNestedId()); nodeObj.put("attempt", node.getAttempt()); if (node.getAttempt() > 0) { nodeObj.put("pastAttempts", node.getAttemptObjects()); } if (node.getInNodes() != null && !node.getInNodes().isEmpty()) { nodeObj.put("in", node.getInNodes()); } if (node instanceof ExecutableFlowBase) { final ExecutableFlowBase base = (ExecutableFlowBase) node; final ArrayList<Map<String, Object>> nodeList = new ArrayList<>(); for (final ExecutableNode subNode : base.getExecutableNodes()) { final Map<String, Object> subNodeObj = getExecutableNodeInfo(subNode); if (!subNodeObj.isEmpty()) { nodeList.add(subNodeObj); } } nodeObj.put("flow", base.getFlowId()); nodeObj.put("nodes", nodeList); nodeObj.put("flowId", base.getFlowId()); } else { final ClusterInfo cluster = node.getClusterInfo(); if (cluster != null && cluster.hadoopClusterURL != null) { nodeObj.put("cluster", cluster.hadoopClusterURL); } } return nodeObj; }
Copies flowOverrides under the key "ROOT".
getExecutableNodeInfo
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxFetchExecutableFlowUpdate(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user, final ExecutableFlow exFlow) throws ServletException { final Long lastUpdateTime = Long.parseLong(getParam(req, "lastUpdateTime")); logger.info("Fetching " + exFlow.getExecutionId()); final Project project = getProjectAjaxByPermission(ret, exFlow.getProjectId(), user, Type.READ); if (project == null) { return; } final Map<String, Object> map = getExecutableFlowUpdateInfo(exFlow, lastUpdateTime); map.put("status", exFlow.getStatus()); map.put("startTime", exFlow.getStartTime()); map.put("endTime", exFlow.getEndTime()); map.put("updateTime", exFlow.getUpdateTime()); ret.putAll(map); }
Copies flowOverrides under the key "ROOT".
ajaxFetchExecutableFlowUpdate
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxFetchExecutableFlow(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user, final ExecutableFlow exFlow) throws ServletException { logger.info("Fetching " + exFlow.getExecutionId()); final Project project = getProjectAjaxByPermission(ret, exFlow.getProjectId(), user, Type.READ); if (project == null) { return; } ret.put("submitTime", exFlow.getSubmitTime()); ret.put("submitUser", exFlow.getSubmitUser()); ret.put("execid", exFlow.getExecutionId()); ret.put("projectId", exFlow.getProjectId()); ret.put("project", project.getName()); String autoRetryStatuses = exFlow.getExecutionOptions().getFlowParameters() .getOrDefault(FlowParameters.FLOW_PARAM_ALLOWED_RETRY_STATUS, ""); if (!autoRetryStatuses.isEmpty()){ Integer userDefinedMaxRetry = Integer.valueOf(exFlow.getExecutionOptions().getFlowParameters() .getOrDefault(FlowParameters.FLOW_PARAM_MAX_RETRIES, "1")); Map<String, Object> retriesInfo = new HashMap<>(); retriesInfo.put("allowedStatuses", autoRetryStatuses); retriesInfo.put("userDefinedMax", userDefinedMaxRetry); retriesInfo.put("strategy", exFlow.getExecutionOptions().getFlowParameters() .getOrDefault(FlowParameters.FLOW_PARAM_RETRY_STRATEGY, FlowRetryStrategy.DEFAULT.getName())); retriesInfo.put("userDefinedCount", exFlow.getUserDefinedRetryCount()); retriesInfo.put("systemDefinedMax", ExecutableFlow.DEFAULT_SYSTEM_FLOW_RETRY_LIMIT); retriesInfo.put("systemDefinedCount", exFlow.getSystemDefinedRetryCount()); retriesInfo.put("rootExecutionID", exFlow.getFlowRetryRootExecutionID()); retriesInfo.put("parentExecutionID", exFlow.getFlowRetryParentExecutionID()); retriesInfo.put("childExecutionID", exFlow.getFlowRetryChildExecutionID()); ret.put("retries", retriesInfo); } final Map<String, Object> flowObj = getExecutableNodeInfo(exFlow); ret.putAll(flowObj); }
Copies flowOverrides under the key "ROOT".
ajaxFetchExecutableFlow
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxExecuteFlow(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user) throws ServletException { final String projectName = getParam(req, "project"); final String flowId = getParam(req, "flow"); final Project project = getProjectAjaxByPermission(ret, projectName, user, Type.EXECUTE); if (project == null) { ret.put("error", "Project '" + projectName + "' doesn't exist."); return; } ret.put("flow", flowId); final Flow flow = project.getFlow(flowId); if (flow == null) { ret.put("error", "Flow '" + flowId + "' cannot be found in project " + project); return; } ExecutableFlow exflow = executorManagerAdapter.createExecutableFlow(project, flow); exflow.setUploadUser(project.getUploadUser()); exflow.setSubmitUser(user.getUserId()); exflow.setExecutionSource(Constants.EXECUTION_SOURCE_ADHOC); final ExecutionOptions options; final Props azProps = getApplication().getServerProps(); try { options = HttpRequestUtils.parseFlowOptions(req, flowId); HttpRequestUtils.validatePreprocessFlowParameters(options, azProps); } catch (final ServletException e) { logger.info("parseFlowOptions failed", e); ret.put("error", "Error parsing flow options: " + e.getMessage()); return; } if (!options.isFailureEmailsOverridden()) { options.setFailureEmails(flow.getFailureEmails()); } if (!options.isSuccessEmailsOverridden()) { options.setSuccessEmails(flow.getSuccessEmails()); } options.setMailCreator(flow.getMailCreator()); exflow.getExecutionOptions().merge(options); /** * If the user has not explicitly overridden the failure action from the UI or * through API, we will consider the value specified in DSL/Yaml * By providing this override option, user can still choose to modify failure * option. */ if (!options.isFailureActionOverridden() && flow.getFailureAction() != null) { options.setFailureAction( options.mapToFailureAction(flow.getFailureAction())); } try { HttpRequestUtils.filterAdminOnlyFlowParams(this.userManager, options, user); final String message = this.executorManagerAdapter.submitExecutableFlow(exflow, user.getUserId()); ret.put("message", message); } catch (final Exception e) { e.printStackTrace(); ret.put("error", "Error submitting flow " + exflow.getFlowId() + ". " + e.getMessage()); } ret.put("execid", exflow.getExecutionId()); }
Copies flowOverrides under the key "ROOT".
ajaxExecuteFlow
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxUpdateProperty(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user) throws ServletException { try { if (!HttpRequestUtils.hasPermission(this.userManager, user, Type.ADMIN)) { ret.put("error", String.format("User %s doesn't have ADMIN permission for updating " + "property", user)); return; } String propType = getParam(req, "propType"); if (propType.equals("containerDispatch")) { if (this.executorManagerAdapter instanceof ContainerizedDispatchManager) { updateContainerDispatchProps(req, ret); } else { ret.put("error", "ExecutorManagerAdapter is not of type: " + ContainerizedDispatchManager.class .getName()); } } else if (propType.equals("containerizedImpl")) { if (this.containerizedImpl != null) { updateContainerizedImplProps(req, ret); } else { ret.put("error", "ContainerizedImpl is null"); } } else if (propType.equals("general")) { updateGeneralProps(req, ret); } else { ret.put("error", "Unsupported propType: " + propType); } } catch (final Exception e) { e.printStackTrace(); ret.put("error", "Error on update property. " + e.getMessage()); } }
This method is used to update the property. propType: Is the umbrella for properties for which values need to be updated subType: Actual property for which values need to be updated val: value to be updated <p> Example: propType=containerDispatch&subType=updateAllowList&val=spark,java propType=containerDispatch&subType=updateDenyList&val=azktest
ajaxUpdateProperty
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void updateContainerDispatchProps(final HttpServletRequest req, final HashMap<String, Object> ret) throws ServletException { ContainerizedDispatchManager containerizedDispatchManager = (ContainerizedDispatchManager) this.executorManagerAdapter; String subType = getParam(req, "subType"); PropUpdate containerPropUpdate = PropUpdate.fromParam(subType); String val = getParam(req, "val"); switch (containerPropUpdate) { case UPDATE_ALLOW_LIST: containerizedDispatchManager.getContainerJobTypeCriteria() .updateAllowList(ServletUtils.getSetFromString(val)); break; case APPEND_ALLOW_LIST: containerizedDispatchManager.getContainerJobTypeCriteria() .appendAllowList(ServletUtils.getSetFromString(val)); break; case REMOVE_FROM_ALLOW_LIST: containerizedDispatchManager.getContainerJobTypeCriteria() .removeFromAllowList(ServletUtils.getSetFromString(val)); break; case UPDATE_RAMP_UP: containerizedDispatchManager.getContainerRampUpCriteria().setRampUp(Integer.parseInt(val)); break; case APPEND_DENY_LIST: containerizedDispatchManager.getContainerProxyUserCriteria() .appendDenyList(ServletUtils.getSetFromString(val)); break; case REMOVE_FROM_DENY_LIST: containerizedDispatchManager.getContainerProxyUserCriteria() .removeFromDenyList(ServletUtils.getSetFromString(val)); break; case RELOAD_FLOW_FILTER: containerizedDispatchManager.getContainerFlowCriteria() .reloadFlowFilter(); break; default: break; } }
This method is used to update the property. propType: Is the umbrella for properties for which values need to be updated subType: Actual property for which values need to be updated val: value to be updated <p> Example: propType=containerDispatch&subType=updateAllowList&val=spark,java propType=containerDispatch&subType=updateDenyList&val=azktest
updateContainerDispatchProps
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void updateContainerizedImplProps(final HttpServletRequest req, final HashMap<String, Object> ret) throws ServletException { String subType = getParam(req, "subType"); PropUpdate propUpdate = PropUpdate.fromParam(subType); String val = getParam(req, "val"); switch (propUpdate) { case UPDATE_VPA_RAMP_UP: this.containerizedImpl.setVPARampUp(Integer.parseInt(val)); break; case UPDATE_VPA_ENABLED: this.containerizedImpl.setVPAEnabled(Boolean.parseBoolean(val)); break; case RELOAD_VPA_FLOW_FILTER: this.containerizedImpl.getVPAFlowCriteria().reloadFlowFilter(); break; default: break; } }
This method is used to update the property. propType: Is the umbrella for properties for which values need to be updated subType: Actual property for which values need to be updated val: value to be updated <p> Example: propType=containerDispatch&subType=updateAllowList&val=spark,java propType=containerDispatch&subType=updateDenyList&val=azktest
updateContainerizedImplProps
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void updateGeneralProps(final HttpServletRequest req, final HashMap<String, Object> ret) throws ServletException { String subType = getParam(req, "subType"); PropUpdate propUpdate = PropUpdate.fromParam(subType); String val = getParam(req, "val"); switch (propUpdate) { case ENABLE_OFFLINE_LOGS_LOADER: this.executorManagerAdapter.enableOfflineLogsLoader(Boolean.parseBoolean(val)); break; default: break; } }
This method is used to update the property. propType: Is the umbrella for properties for which values need to be updated subType: Actual property for which values need to be updated val: value to be updated <p> Example: propType=containerDispatch&subType=updateAllowList&val=spark,java propType=containerDispatch&subType=updateDenyList&val=azktest
updateGeneralProps
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private void ajaxRampActions(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user) throws ServletException { try { final Object body = HttpRequestUtils.getJsonBody(req); if (HttpRequestUtils.hasPermission(this.userManager, user, Type.ADMIN)) { Map<String, String> result = new HashMap<>(); if (body instanceof List) { // A list of actions final List<Map<String, Object>> rampActions = (List<Map<String, Object>>) body; result = this.executorManagerAdapter.doRampActions(rampActions); } else if (body instanceof Map) { final List<Map<String, Object>> rampActions = new ArrayList<>(); rampActions.add((Map<String, Object>) body); result = this.executorManagerAdapter.doRampActions(rampActions); } else { result.put("error", "Invalid Body Format"); } ret.putAll(result); } } catch (final Exception e) { e.printStackTrace(); ret.put("error", "Error on update Ramp. " + e.getMessage()); } }
This method is used to update the property. propType: Is the umbrella for properties for which values need to be updated subType: Actual property for which values need to be updated val: value to be updated <p> Example: propType=containerDispatch&subType=updateAllowList&val=spark,java propType=containerDispatch&subType=updateDenyList&val=azktest
ajaxRampActions
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
public String getParam() { return param; }
This method is used to update the property. propType: Is the umbrella for properties for which values need to be updated subType: Actual property for which values need to be updated val: value to be updated <p> Example: propType=containerDispatch&subType=updateAllowList&val=spark,java propType=containerDispatch&subType=updateDenyList&val=azktest
getParam
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
public static PropUpdate fromParam(String param) { for (PropUpdate value : PropUpdate.values()) { if (value.getParam().equals(param)) { return value; } } throw new IllegalArgumentException( "No PropUpdate corresponding to param value " + param); }
This method is used to update the property. propType: Is the umbrella for properties for which values need to be updated subType: Actual property for which values need to be updated val: value to be updated <p> Example: propType=containerDispatch&subType=updateAllowList&val=spark,java propType=containerDispatch&subType=updateDenyList&val=azktest
fromParam
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/ExecutorServlet.java
Apache-2.0
private DateTimeZone parseTimeZone(final String cronTimezone) { if (cronTimezone != null && cronTimezone.equals("UTC")) { return DateTimeZone.UTC; } return DateTimeZone.getDefault(); }
@param cronTimezone represents the timezone from remote API call @return if the string is equal to UTC, we return UTC; otherwise, we always return default timezone.
parseTimeZone
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/FlowTriggerInstanceServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/FlowTriggerInstanceServlet.java
Apache-2.0
private DateTime getPresentTimeByTimezone(final DateTimeZone timezone) { return new DateTime(timezone); }
@param cronTimezone represents the timezone from remote API call @return if the string is equal to UTC, we return UTC; otherwise, we always return default timezone.
getPresentTimeByTimezone
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/FlowTriggerInstanceServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/FlowTriggerInstanceServlet.java
Apache-2.0
public String getProjectName(final int id) { final Project project = FlowTriggerInstanceServlet.this.projectManager.getProject(id); if (project == null) { return String.valueOf(id); } return project.getName(); }
@param cronTimezone represents the timezone from remote API call @return if the string is equal to UTC, we return UTC; otherwise, we always return default timezone.
getProjectName
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/FlowTriggerInstanceServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/FlowTriggerInstanceServlet.java
Apache-2.0
@Override public void init(final ServletConfig config) throws ServletException { super.init(config); this.multipartParser = new MultipartParser( AbstractAzkabanServlet.DEFAULT_UPLOAD_DISK_SPOOL_SIZE); this.shouldLogRawUserAgent = getApplication().getServerProps().getBoolean("accesslog.raw.useragent", false); }
Abstract Servlet that handles auto login when the session hasn't been verified.
init
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
Apache-2.0
public static AzkabanAPI getLoginAPI() { return loginAPI; }
Abstract Servlet that handles auto login when the session hasn't been verified.
getLoginAPI
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
Apache-2.0
public void setResourceDirectory(final File file) { this.webResourceDirectory = file; }
Abstract Servlet that handles auto login when the session hasn't been verified.
setResourceDirectory
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
Apache-2.0
@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { getWebMetrics().markWebGetCall(); // Set session id final Session session = getSessionFromRequest(req); logRequest(req, session); if (hasParam(req, "logout")) { resp.sendRedirect(req.getContextPath()); if (session != null) { getApplication().getSessionCache().removeSession(session.getSessionId()); WebUtils.reportLoginEvent(EventType.USER_LOGOUT, session.getUser().getUserId(), WebUtils.getRealClientIpAddr(req)); } else { WebUtils.reportLoginEvent(EventType.USER_LOGOUT, null, WebUtils.getRealClientIpAddr(req), false, "Not logged in"); } return; } if (session != null) { if (logger.isDebugEnabled()) { logger.debug("Found session " + session.getUser()); } if (handleFileGet(req, resp)) { return; } handleGet(req, resp, session); } else { if (hasParam(req, "ajax")) { final Map<String, String> retVal = new HashMap<>(); retVal.put("error", "session"); this.writeJSON(resp, retVal); } else { handleLogin(req, resp); } } }
Abstract Servlet that handles auto login when the session hasn't been verified.
doGet
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
Apache-2.0
@Override protected void doDelete(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { getWebMetrics().markWebGetCall(); // Set session id final Session session = getSessionFromRequest(req); logRequest(req, session); if (hasParam(req, "logout")) { resp.sendRedirect(req.getContextPath()); if (session != null) { getApplication().getSessionCache().removeSession(session.getSessionId()); WebUtils.reportLoginEvent(EventType.USER_LOGOUT, session.getUser().getUserId(), WebUtils.getRealClientIpAddr(req)); } else { WebUtils.reportLoginEvent(EventType.USER_LOGOUT, null, WebUtils.getRealClientIpAddr(req), false, "Not logged in"); } return; } if (session != null) { if (logger.isDebugEnabled()) { logger.debug("Found session " + session.getUser()); } handleDelete(req, resp, session); } else { if (hasParam(req, "ajax")) { final Map<String, String> retVal = new HashMap<>(); retVal.put("error", "session"); this.writeJSON(resp, retVal); } else { handleLogin(req, resp); } } }
Abstract Servlet that handles auto login when the session hasn't been verified.
doDelete
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
Apache-2.0
protected boolean validateCSRFToken(final HttpServletRequest req) { final String sessionIdFromCookie = getSessionIdFromCookie(req); if (StringUtils.isEmpty(sessionIdFromCookie)) { logger.info("CSRF token validation successful. SessionId is not from cookie."); return true; } final String csrfTokenFromRequest = req .getHeader(AbstractAzkabanServlet.HTTP_HEADER_CSRF_TOKEN); if (StringUtils.isEmpty(csrfTokenFromRequest)) { logger.info("CSRF token validation failed. Unable to get CSRF token from http header."); return false; } final CSRFTokenUtility csrfTokenUtility = CSRFTokenUtility.getCSRFTokenUtility(); if (null == csrfTokenUtility) { logger.info("CSRF token validation failed. Unable to instantiate CSRFTokenUtility class."); return false; } final boolean isValidCSRFToken = csrfTokenUtility .validateCSRFToken(sessionIdFromCookie, csrfTokenFromRequest); if (isValidCSRFToken) { logger.info("CSRF token validation successful."); } else { logger.info("CSRF token validation failed. Invalid token value."); } return isValidCSRFToken; }
@param req HttpServletRequest @return True if the CSRF Token is valid, otherwise false
validateCSRFToken
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
Apache-2.0
protected boolean addCSRFTokenToPage(final Page page, final Session session) { final CSRFTokenUtility csrfTokenUtility = CSRFTokenUtility.getCSRFTokenUtility(); if (null == csrfTokenUtility) { return false; } final String csrfToken = csrfTokenUtility.getCSRFTokenFromSession(session); if (!StringUtils.isEmpty(csrfToken)) { page.add(AbstractAzkabanServlet.TEMPLATE_VAR_CSRF_TOKEN, csrfToken); return true; } return false; }
@param req HttpServletRequest @return True if the CSRF Token is valid, otherwise false
addCSRFTokenToPage
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
Apache-2.0
private Session getSessionFromSessionId(final String sessionId) { if (sessionId == null) { return null; } return getApplication().getSessionCache().getSession(sessionId); }
@param req HttpServletRequest @return True if the CSRF Token is valid, otherwise false
getSessionFromSessionId
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
Apache-2.0
public boolean isUserAuthenticated(final HttpServletRequest req) throws ServletException { return getSessionFromRequest(req) != null; }
@param req HttpServletRequest @return True if the CSRF Token is valid, otherwise false
isUserAuthenticated
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
Apache-2.0
private void handleLogin(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { handleLogin(req, resp, null); }
@param req HttpServletRequest @return True if the CSRF Token is valid, otherwise false
handleLogin
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
Apache-2.0
private void handleLogin(final HttpServletRequest req, final HttpServletResponse resp, final String errorMsg) throws IOException { if (handleOauth(req, resp)) { return; } final Page page = newPage(req, resp, "azkaban/webapp/servlet/velocity/login.vm"); page.add("passwordPlaceholder", this.passwordPlaceholder); if (errorMsg != null) { page.add("errorMsg", errorMsg); } page.render(); }
@param req HttpServletRequest @return True if the CSRF Token is valid, otherwise false
handleLogin
java
azkaban/azkaban
azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-web-server/src/main/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
Apache-2.0