use of jp.ossc.nimbus.service.scheduler2.Schedule in project nimbus by nimbus-org.
the class ScheduleManagerServlet method processScheduleResponse.
/**
* スケジュール検索リクエスト処理を行う。<p>
*
* @param req HTTPリクエスト
* @param resp HTTPレスポンス
* @param responseType レスポンス種別
* @exception ServletException
* @exception IOException
*/
protected void processScheduleResponse(HttpServletRequest req, HttpServletResponse resp, String responseType) throws ServletException, IOException {
String id = getParameter(req, "search_id");
String groupId = getParameter(req, "search_groupId");
String masterId = getParameter(req, "search_masterId");
String masterGroupId = getParameter(req, "search_masterGroupId");
Date from = null;
try {
from = getDateParameter(req, "search_from", "yyyyMMddHHmmssSSS", false);
} catch (ParseException e) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter 'search_from' is illegal." + e.toString());
return;
}
Date to = null;
try {
to = getDateParameter(req, "search_to", "yyyyMMddHHmmssSSS", false);
} catch (ParseException e) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter 'search_to' is illegal." + e.toString());
return;
}
int[] states = null;
try {
states = getIntParameterValues(req, "search_state");
} catch (NumberFormatException e) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter 'search_state' is illegal." + e.toString());
return;
}
Exception exception = null;
List schedules = null;
if (id != null && id.length() != 0) {
try {
Schedule schedule = scheduleManager.findSchedule(id);
schedules = new ArrayList(1);
schedules.add(schedule);
} catch (ScheduleManageException e) {
exception = e;
}
} else {
final String action = getParameter(req, "action");
if (action == null && from == null && to == null && states == null && masterId == null && masterGroupId == null && groupId == null) {
states = new int[] { Schedule.STATE_INITIAL, Schedule.STATE_RETRY };
}
try {
schedules = scheduleManager.findSchedules(from, to, states, masterId, masterGroupId, groupId);
} catch (ScheduleManageException e) {
exception = e;
}
}
final StringBuilder buf = new StringBuilder();
if ("json".equals(responseType)) {
resp.setContentType("application/json;charset=UTF-8");
Map jsonMap = new HashMap();
if (exception == null) {
jsonMap.put("schedules", schedules);
} else {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
exception.printStackTrace(pw);
pw.flush();
jsonMap.put("exception", sw.toString());
}
buf.append(toStringConverter.convertToObject(jsonConverter.convertToStream(jsonMap)));
} else {
resp.setContentType("text/html;charset=UTF-8");
if (exception != null) {
buf.append(exception(exception));
} else {
buf.append("<html>");
buf.append(header(HEADER_SCHEDULE));
buf.append("<body>");
buf.append(scheduleSearchCondition(getCurrentPath(req), id, groupId, masterId, masterGroupId, from, to, states));
try {
buf.append(schedules(req, schedules, states));
} catch (Exception e) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter is illegal. " + e.getMessage());
return;
}
buf.append("</body>");
buf.append("</html>");
}
}
resp.getWriter().println(buf.toString());
}
use of jp.ossc.nimbus.service.scheduler2.Schedule in project nimbus by nimbus-org.
the class ScheduleManagerServlet method schedules.
/**
* スケジュール管理画面HTMLのスケジュールデータ部分HTMLを生成する。<p>
*
* @param action サーブレットパス(FormタグのAction文字列)
* @param schedules スケジュールオブジェクトのリスト
* @param states 検索条件値(states)
* @return スケジュール管理画面HTMLのスケジュールデータ部分HTML
*/
private String schedules(HttpServletRequest req, List schedules, int[] states) throws Exception {
final String action = getCurrentPath(req);
final StringBuilder buf = new StringBuilder();
buf.append("<table border=\"1\"><tr>");
buf.append(th("Legend"));
buf.append("<td bgcolor=\"#ffadad\">FAILED</td>");
buf.append("<td bgcolor=\"#ffffad\">RUN</td>");
buf.append("<td bgcolor=\"#ffadff\">TIMEOVER</td>");
buf.append("<td bgcolor=\"#a9a9a9\">END</td>");
buf.append("<td bgcolor=\"#add6ff\">DISABLE</td>");
buf.append("<td bgcolor=\"#ffd6ad\">PAUSE or ABORT</td>");
buf.append("</tr></table>");
buf.append("<br>");
buf.append("<table border=\"1\">");
buf.append("<tr bgcolor=\"#cccccc\">");
buf.append(th("<a href=\"#\" onclick=\"allCheckTable();return false;\">#</a>"));
buf.append(th("Id"));
buf.append(th("MasterId"));
buf.append(th("Time"));
buf.append(th("State"));
buf.append(th("ControlState"));
buf.append(th("ExecutorKey"));
if (isRescheduleEnabled()) {
buf.append(th("Reschedule"));
}
buf.append(th("MasterGroupIds"));
buf.append(th("TaskName"));
buf.append(th("Input"));
buf.append(th("Depends"));
buf.append(th("Depended"));
buf.append(th("Output"));
buf.append(th("InitialTime"));
buf.append(th("RetryInterval"));
buf.append(th("RetryEndTime"));
buf.append(th("Retry"));
buf.append(th("MaxDelayTime"));
buf.append(th("CheckState"));
buf.append(th("ExecutorType"));
buf.append(th("ExecuteStartTime"));
buf.append(th("ExecuteEndTime"));
if (isRemoveEnabled()) {
buf.append(th("Remove"));
}
buf.append("</tr>");
int count = 0;
final StringBuilder tdBuf = new StringBuilder();
if (schedules != null) {
for (int i = 0; i < schedules.size(); i++) {
Schedule schedule = (Schedule) schedules.get(i);
int state = schedule.getState();
int controlState = schedule.getControlState();
int checkState = schedule.getCheckState();
String id = schedule.getId();
String masterId = schedule.getMasterId();
String name = null;
String title = " title=\"" + format(id) + "(" + format(masterId) + ")\"";
String tr = "<tr" + title + ">";
switch(state) {
case Schedule.STATE_RUN:
tr = "<tr bgcolor=\"#ffffad\" " + title + ">";
break;
case Schedule.STATE_END:
tr = "<tr bgcolor=\"#a9a9a9\" " + title + ">";
break;
case Schedule.STATE_FAILED:
tr = "<tr bgcolor=\"#ffadad\" " + title + ">";
break;
case Schedule.STATE_DISABLE:
tr = "<tr bgcolor=\"#add6ff\" " + title + ">";
break;
case Schedule.STATE_PAUSE:
case Schedule.STATE_ABORT:
tr = "<tr bgcolor=\"#ffd6ad\" " + title + ">";
break;
}
buf.append(tr);
buf.append(td(checkbox("check", count, null) + hidden("id", "id_" + count, id) + hidden("state", "state_" + count, String.valueOf(state)) + hidden("controlState", "controlState_" + count, String.valueOf(controlState))));
buf.append(td(format(id)));
buf.append(td(format(masterId)));
String time = formatDateTime(schedule.getTime());
buf.append(td(time));
tdBuf.setLength(0);
tdBuf.append(getScheduleStateString(state));
if (isChangeStateEnabled()) {
name = "newState_" + count;
tdBuf.append(" : " + stateSelect(name, name, state));
tdBuf.append(button("ChangeState", "javascript:changeStateOne('" + id + "','" + state + "','" + name + "');"));
}
buf.append(td(tdBuf.toString()));
tdBuf.setLength(0);
tdBuf.append(getScheduleControlStateString(controlState));
if (isChangeControlStateEnabled()) {
name = "newControlState_" + count;
tdBuf.append(" : " + controlStateSelect(name, name, controlState));
tdBuf.append(button("ChangeControlState", "javascript:changeControlStateOne('" + id + "','" + controlState + "','" + name + "');"));
}
buf.append(td(tdBuf.toString()));
tdBuf.setLength(0);
String executorKey = format(schedule.getExecutorKey());
tdBuf.append(executorKey);
if (isChangeExecutorKeyEnabled()) {
name = "newExecutorKey_" + count;
tdBuf.append(" : " + text(name, name, executorKey, 10));
tdBuf.append(button("ChangeExecutorKey", "javascript:changeExecutorKeyOne('" + id + "','" + name + "');"));
}
buf.append(td(tdBuf.toString()));
tdBuf.setLength(0);
String output = format(schedule.getOutput());
if (isRescheduleEnabled()) {
String timeName = "time_" + count;
tdBuf.append("Time:" + text(timeName, timeName, time, 15) + " ");
String outputName = "output_" + count;
tdBuf.append("Output:" + textarea(outputName, outputName, output, 50, 3, false));
buf.append(td(tdBuf.toString() + " " + button("Reschedule", "javascript:rescheduleOne('" + id + "','" + timeName + "','" + outputName + "');")));
}
buf.append(td(format(schedule.getMasterGroupIds())));
buf.append(td(format(schedule.getTaskName())));
buf.append(td(textarea(format(schedule.getInput()), 50, 3)));
buf.append(td(button("ShowDepends", "javascript:showDepends('" + id + "');")));
buf.append(td(button("ShowDepended", "javascript:showDepended('" + id + "');")));
buf.append(td(textarea(output, 50, 3)));
buf.append(td(formatDateTime(schedule.getInitialTime())));
buf.append(td(schedule.getRetryInterval()));
buf.append(td(formatDateTime(schedule.getRetryEndTime())));
buf.append(td(schedule.isRetry()));
buf.append(td(schedule.getMaxDelayTime()));
buf.append("<td nowrap");
if (Schedule.CHECK_STATE_TIMEOVER == checkState) {
buf.append(" bgcolor=\"#ffadff\" title=\"TIMEOVER\"");
}
buf.append(">" + getScheduleCheckStateString(checkState) + "</td>");
buf.append(td(format(schedule.getExecutorType())));
buf.append(td(formatDateTime(schedule.getExecuteStartTime())));
buf.append(td(formatDateTime(schedule.getExecuteEndTime())));
if (isRemoveEnabled()) {
buf.append(td(button("Remove", "javascript:removeOne('" + id + "');")));
}
buf.append("</tr>");
count++;
}
}
buf.append("</table>");
if (isChangeStateEnabled()) {
buf.append("<form name=\"changeState\" id=\"changeState\" action=\"" + action + "\" method=\"post\" style=\"display: inline\">");
buf.append(hidden("action", null, "changeState"));
buf.append(hidden("oldState", null, ""));
buf.append(hidden("newState", null, ""));
buf.append(hidden("id", null, ""));
buf.append(getSearchForm(req));
buf.append("</form>");
}
if (isChangeControlStateEnabled()) {
buf.append("<form name=\"changeControlState\" id=\"changeControlState\" action=\"" + action + "\" method=\"post\" style=\"display: inline\">");
buf.append(hidden("action", null, "changeControlState"));
buf.append(hidden("oldState", null, ""));
buf.append(hidden("newState", null, ""));
buf.append(hidden("id", null, ""));
buf.append(getSearchForm(req));
buf.append("</form>");
}
if (isRemoveEnabled()) {
buf.append("<form name=\"removeSchedule\" id=\"removeSchedule\" action=\"" + action + "\" method=\"post\" style=\"display: inline\">");
buf.append(hidden("action", null, "remove"));
buf.append(hidden("id", null, ""));
buf.append(getSearchForm(req));
buf.append("</form>");
}
if (isRescheduleEnabled()) {
buf.append("<form name=\"reschedule\" id=\"reschedule\" action=\"" + action + "\" method=\"post\" style=\"display: inline\">");
buf.append(hidden("action", null, "reschedule"));
buf.append(hidden("id", null, ""));
buf.append(hidden("time", null, ""));
buf.append(hidden("output", null, ""));
buf.append(getSearchForm(req));
buf.append("</form>");
}
if (isChangeExecutorKeyEnabled()) {
buf.append("<form name=\"changeExecutorKey\" id=\"changeExecutorKey\" action=\"" + action + "\" method=\"post\" style=\"display: inline\">");
buf.append(hidden("action", null, "changeExecutorKey"));
buf.append(hidden("id", null, ""));
buf.append(hidden("executorKey", null, ""));
buf.append(getSearchForm(req));
buf.append("</form>");
}
if (isStopEntryEnabled()) {
buf.append("<form name=\"stopEntry\" id=\"stopEntry\" action=\"" + action + "\" method=\"post\" style=\"display: inline\">");
buf.append(hidden("action", null, "stopEntry"));
buf.append(getSearchForm(req));
buf.append("</form>");
buf.append("<form name=\"startEntry\" id=\"startEntry\" action=\"" + action + "\" method=\"post\" style=\"display: inline\">");
buf.append(hidden("action", null, "startEntry"));
buf.append(getSearchForm(req));
buf.append("</form>");
}
buf.append("<form name=\"depends\" id=\"depends\" action=\"" + action + "\" method=\"post\" target=\"_blank\" style=\"display: inline\">");
buf.append(hidden("action", null, "depends"));
buf.append(hidden("id", null, ""));
buf.append(getSearchForm(req));
buf.append("</form>");
buf.append("<form name=\"depended\" id=\"depended\" action=\"" + action + "\" method=\"post\" target=\"_blank\" style=\"display: inline\">");
buf.append(hidden("action", null, "depended"));
buf.append(hidden("id", null, ""));
buf.append(getSearchForm(req));
buf.append("</form>");
return buf.toString();
}
use of jp.ossc.nimbus.service.scheduler2.Schedule in project nimbus by nimbus-org.
the class ScheduleWaitActionService method execute.
/**
* リソースの内容を読み込んで、{@link ScheduleMakeActionService}で作成したスケジュールの終了を待ち合わせる。<p>
* 待ち合わせに失敗した場合は、例外をthrowする。<br>
* リソースのフォーマットは、以下。<br>
* <pre>
* waitScheduleId
* timeout
* waitStates
* successStates
* </pre>
* waitScheduleIdは、スケジュールを作成した{@link ScheduleMakeActionService}のアクションIDを指定する。指定しない場合は、preResultを使用する。<br>
* timeoutは、スケジュールの待ち合わせタイムアウト[ms]を指定する。<br>
* waitStatesは、スケジュールを待ち合わせするスケジュール状態を指定する。複数指定する場合は、カンマ区切りで指定する。指定可能な、スケジュール状態は、END、FAILED、RETRY。指定しない場合は、END、FAILEDで待ち合わせる。<br>
* successStatesは、待ち合わせた後、戻り値でtrueを返すスケジュール状態を指定する。複数指定する場合は、カンマ区切りで指定する。指定可能な、スケジュール状態は、END、FAILED、RETRY。指定しない場合は、ENDの場合、trueを返す。<br>
*
* @param context コンテキスト
* @param actionId アクションID
* @param preResult 直前のアクションの結果
* @param resource リソース
* @return 待ち合わせ結果
*/
public boolean execute(TestContext context, String actionId, Object preResult, Reader resource) throws Exception {
BufferedReader br = new BufferedReader(resource);
List waitSchedules = new ArrayList();
long timeout = 0;
int[] waitStates = new int[] { Schedule.STATE_END, Schedule.STATE_FAILED };
int[] successStates = new int[] { Schedule.STATE_END };
try {
final String waitScheduleId = br.readLine();
if (waitScheduleId == null || waitScheduleId.length() == 0) {
throw new Exception("Unexpected EOF on waitScheduleId");
}
if (preResult == null && (waitScheduleId == null || waitScheduleId.length() == 0)) {
throw new Exception("Unexpected EOF on waitScheduleId");
}
if (waitScheduleId != null && waitScheduleId.length() != 0) {
Object actionResult = null;
if (waitScheduleId.indexOf(",") == -1) {
actionResult = context.getTestActionResult(waitScheduleId);
} else {
String[] ids = waitScheduleId.split(",");
if (ids.length != 2) {
throw new Exception("Illegal waitScheduleId format. id=" + waitScheduleId);
}
actionResult = context.getTestActionResult(ids[0], ids[1]);
}
if (actionResult == null) {
throw new Exception("TestActionResult not found. id=" + waitScheduleId);
}
if (!(actionResult instanceof List) || (((List) actionResult).size() != 0 && !(((List) actionResult).get(0) instanceof Schedule))) {
throw new Exception("TestActionResult not instance of Schedule List. result=" + actionResult);
}
waitSchedules.addAll((List) actionResult);
} else {
if (preResult == null) {
throw new Exception("preResult is null.");
}
if (!(preResult instanceof List) || (((List) preResult).size() != 0 && !(((List) preResult).get(0) instanceof Schedule))) {
throw new Exception("preResult not instance of Schedule List. result=" + preResult);
}
waitSchedules.addAll((List) preResult);
}
if (waitSchedules.size() == 0) {
throw new Exception("Wait Schedule not found.");
}
final String timeoutStr = br.readLine();
if (timeoutStr == null || timeoutStr.length() == 0) {
throw new Exception("Unexpected EOF on timeout");
}
try {
timeout = Long.parseLong(timeoutStr);
} catch (NumberFormatException e) {
throw new Exception("Illegal timeout format. timeout=" + timeoutStr);
}
final String waitStatesStr = br.readLine();
if (waitStatesStr != null && waitStatesStr.length() != 0) {
String[] waitStatesArray = waitStatesStr.split(",");
waitStates = new int[waitStatesArray.length];
for (int i = 0; i < waitStatesArray.length; i++) {
if ("END".equals(waitStatesArray[i])) {
waitStates[i] = Schedule.STATE_END;
} else if ("FAILED".equals(waitStatesArray[i])) {
waitStates[i] = Schedule.STATE_FAILED;
} else if ("RETRY".equals(waitStatesArray[i])) {
waitStates[i] = Schedule.STATE_RETRY;
} else if ("DISABLE".equals(waitStatesArray[i])) {
waitStates[i] = Schedule.STATE_DISABLE;
} else {
throw new Exception("Illegal waitState format. waitState=" + waitStatesArray[i]);
}
}
}
final String successStatesStr = br.readLine();
if (successStatesStr != null && successStatesStr.length() != 0) {
String[] successStatesArray = successStatesStr.split(",");
successStates = new int[successStatesArray.length];
for (int i = 0; i < successStatesArray.length; i++) {
if ("END".equals(successStatesArray[i])) {
successStates[i] = Schedule.STATE_END;
} else if ("FAILED".equals(successStatesArray[i])) {
successStates[i] = Schedule.STATE_FAILED;
} else if ("RETRY".equals(successStatesArray[i])) {
successStates[i] = Schedule.STATE_RETRY;
} else if ("DISABLE".equals(successStatesArray[i])) {
successStates[i] = Schedule.STATE_DISABLE;
} else {
throw new Exception("Illegal successState format. successState=" + successStatesArray[i]);
}
}
}
} finally {
br.close();
br = null;
}
final long waitEndTime = System.currentTimeMillis() + timeout;
long interval = Math.min(waitInterval, timeout);
boolean result = true;
do {
String id = ((Schedule) waitSchedules.get(0)).getId();
Schedule schedule = scheduleManager.findSchedule(id);
if (schedule == null) {
throw new Exception("Schedule not found. id=" + id);
}
boolean isNotify = false;
for (int i = 0; i < waitStates.length; i++) {
if (schedule.getState() == waitStates[i]) {
boolean isSuccess = false;
for (int j = 0; j < successStates.length; j++) {
if (schedule.getState() == successStates[j]) {
isSuccess = true;
break;
}
}
result &= isSuccess;
waitSchedules.remove(0);
isNotify = true;
break;
}
}
if (!isNotify) {
if (System.currentTimeMillis() >= waitEndTime) {
List dependsSchedules = scheduleManager.findDependsSchedules(id);
throw new Exception("The timeout has been reached due to waiting for the schedule. schedule=" + schedule + ", dependsSchedules=" + dependsSchedules);
}
Thread.sleep(interval);
}
} while (waitSchedules.size() != 0);
return result;
}
use of jp.ossc.nimbus.service.scheduler2.Schedule in project java-docs-samples by GoogleCloudPlatform.
the class Triggers method createTrigger.
// [START dlp_create_trigger]
/**
* Schedule a DLP inspection trigger for a GCS location.
*
* @param triggerId (Optional) name of the trigger to be created
* @param displayName (Optional) display name for the trigger to be created
* @param description (Optional) description for the trigger to be created
* @param scanPeriod How often to wait between scans, in days (minimum = 1 day)
* @param infoTypes infoTypes of information to match eg. InfoType.PHONE_NUMBER,
* InfoType.EMAIL_ADDRESS
* @param minLikelihood minimum likelihood required before returning a match
* @param maxFindings maximum number of findings to report per request (0 = server maximum)
* @param projectId The project ID to run the API call under
*/
private static void createTrigger(String triggerId, String displayName, String description, String bucketName, String fileName, int scanPeriod, List<InfoType> infoTypes, Likelihood minLikelihood, int maxFindings, String projectId) throws Exception {
// instantiate a client
DlpServiceClient dlpServiceClient = DlpServiceClient.create();
try {
CloudStorageOptions cloudStorageOptions = CloudStorageOptions.newBuilder().setFileSet(CloudStorageOptions.FileSet.newBuilder().setUrl("gs://" + bucketName + "/" + fileName)).build();
StorageConfig storageConfig = StorageConfig.newBuilder().setCloudStorageOptions(cloudStorageOptions).build();
InspectConfig.FindingLimits findingLimits = InspectConfig.FindingLimits.newBuilder().setMaxFindingsPerRequest(maxFindings).build();
InspectConfig inspectConfig = InspectConfig.newBuilder().addAllInfoTypes(infoTypes).setMinLikelihood(minLikelihood).setLimits(findingLimits).build();
InspectJobConfig inspectJobConfig = InspectJobConfig.newBuilder().setInspectConfig(inspectConfig).setStorageConfig(storageConfig).build();
// Schedule scan of GCS bucket every scanPeriod number of days (minimum = 1 day)
Duration duration = Duration.newBuilder().setSeconds(scanPeriod * 24 * 3600).build();
Schedule schedule = Schedule.newBuilder().setRecurrencePeriodDuration(duration).build();
JobTrigger.Trigger trigger = JobTrigger.Trigger.newBuilder().setSchedule(schedule).build();
JobTrigger jobTrigger = JobTrigger.newBuilder().setInspectJob(inspectJobConfig).setName(triggerId).setDisplayName(displayName).setDescription(description).setStatus(JobTrigger.Status.HEALTHY).addTriggers(trigger).build();
// Create scan request
CreateJobTriggerRequest createJobTriggerRequest = CreateJobTriggerRequest.newBuilder().setParent(ProjectName.of(projectId).toString()).setJobTrigger(jobTrigger).build();
JobTrigger createdJobTrigger = dlpServiceClient.createJobTrigger(createJobTriggerRequest);
System.out.println("Created Trigger: " + createdJobTrigger.getName());
} catch (Exception e) {
System.out.println("Error creating trigger: " + e.getMessage());
}
}
use of jp.ossc.nimbus.service.scheduler2.Schedule in project nimbus by nimbus-org.
the class ScheduleManagerServlet method processAddResponse.
/**
* スケジュール追加リクエスト処理を行う。<p>
*
* @param req HTTPリクエスト
* @param resp HTTPレスポンス
* @param responseType レスポンス種別
* @exception ServletException
* @exception IOException
*/
protected void processAddResponse(HttpServletRequest req, HttpServletResponse resp, String responseType) throws ServletException, IOException {
String masterId = getParameter(req, "masterId");
Date time = null;
try {
time = getDateParameter(req, "time", "yyyyMMddHHmmssSSS", true);
} catch (ParseException e) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter 'time' is illegal." + e.toString());
return;
}
String taskName = getParameter(req, "taskName");
String input = getParameter(req, "input");
String[] depends = getParameterValues(req, "depends");
ScheduleDepends[] dependsArray = null;
if (depends != null) {
dependsArray = new ScheduleDepends[depends.length];
for (int i = 0; i < dependsArray.length; i++) {
dependsArray[i] = new DefaultScheduleDepends(depends[i], false);
}
}
String executorKey = getParameter(req, "executorKey");
String executorType = getParameter(req, "executorType");
Long retryInterval = getLongParameter(req, "retryInterval");
Date retryEndTime = null;
try {
retryEndTime = getDateParameter(req, "retryEndTime", "yyyyMMddHHmmssSSS", false);
} catch (ParseException e) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter 'retryEndTime' is illegal." + e.toString());
return;
}
Long maxDelayTime = getLongParameter(req, "maxDelayTime");
Exception exception = null;
DefaultSchedule schedule = null;
try {
schedule = new DefaultSchedule(masterId, null, time, taskName, input, dependsArray, null, null, null, executorKey, executorType, retryInterval == null ? 0l : retryInterval.longValue(), retryEndTime, maxDelayTime == null ? 0l : maxDelayTime.longValue());
scheduleManager.addSchedule(schedule);
} catch (ScheduleManageException e) {
exception = e;
}
final StringBuilder buf = new StringBuilder();
if ("json".equals(responseType)) {
resp.setContentType("application/json;charset=UTF-8");
Map jsonMap = new HashMap();
if (exception == null) {
jsonMap.put("schedule", schedule);
} else {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
exception.printStackTrace(pw);
pw.flush();
jsonMap.put("exception", sw.toString());
}
buf.append(toStringConverter.convertToObject(jsonConverter.convertToStream(jsonMap)));
} else {
if (exception != null) {
resp.setContentType("text/html;charset=UTF-8");
buf.append(exception(exception));
} else {
processScheduleResponse(req, resp, responseType);
return;
}
}
resp.getWriter().println(buf.toString());
}
Aggregations