Skip to content

Commit

Permalink
Solve #1011, Add action scheduler interface
Browse files Browse the repository at this point in the history
  • Loading branch information
littlezhou committed Aug 29, 2017
1 parent 75dbb57 commit f7dbdbb
Show file tree
Hide file tree
Showing 8 changed files with 282 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
*/
public enum CmdletState {
NOTINITED(0),
PENDING(1), // Ready for execution
PENDING(1), // Ready for schedule
EXECUTING(2), // Still running
PAUSED(3),
DONE(4), // Execution successful
CANCELLED(5),
DISABLED(6), // Disable this Cmdlet, kill all executing actions
DRYRUN(7), // TODO Don't Run, but keep status
FAILED(8); // Running cmdlet failed
DRYRUN(7), // TODO Don't Run, but keep status
FAILED(8), // Running cmdlet failed
SCHEDULED(9);

private int value;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.smartdata.model.action;

import org.smartdata.model.ActionInfo;
import org.smartdata.model.LaunchAction;

import java.util.List;

public interface ActionScheduler {

List<String> getSupportedActions();

/**
* Called when new action submitted to CmdletManager.
*
* @param actionInfo
* @return acceptable if true, or discard
*/
boolean onSubmit(ActionInfo actionInfo);

/**
* Trying to schedule an action for Dispatch.
* @param actionInfo
* @param action
* @return
*/
ScheduleResult onSchedule(ActionInfo actionInfo, LaunchAction action);

/**
* Called after and an Cmdlet get scheduled.
*
* @param actionInfo
* @param result
*/
void postSchedule(ActionInfo actionInfo, ScheduleResult result);

/**
* Called just before dispatch for execution.
*
* @param action
*/
void onPreDispatch(LaunchAction action);

/**
* Called when action finished execution.
*
* @param actionInfo
*/
void onActionFinished(ActionInfo actionInfo);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.smartdata.model.action;

// TODO: to be implemented
public interface CmdletScheduler {

boolean onSubmitCmdlet();
boolean postSubmitCmdlet();

ScheduleResult onSchedule();
void postSchedule();

void onDispatch();

void onActionMessage();
void onCmdletFinished();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,8 @@
*/
package org.smartdata.model.action;

import org.smartdata.model.LaunchAction;

import java.util.List;

public interface ActionPreProcessor {

List<String> getSupportedActions();

void beforeExecution(LaunchAction action);

void afterExecution(LaunchAction action);
public enum ScheduleResult {
SUCCESS, // OK for dispatch
RETRY, // Need re-schedule later
FAIL
}
Loading

0 comments on commit f7dbdbb

Please sign in to comment.