Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix bugs in delete

  • Loading branch information...
commit 582cef64241e7c008fd0b150a872600458bd63c9 1 parent 5b6b901
Lin Guo authored
View
26 azkaban/src/java/azkaban/app/JobDescriptor.java
@@ -76,6 +76,8 @@ public int compare(JobDescriptor d1, JobDescriptor d2) {
private Boolean _valid = null;
+ private final String _folder;
+
public JobDescriptor(String id, String conicalPath, String fullpath, Props props, ClassLoader classLoader) {
this._id = id;
this._path = conicalPath;
@@ -109,8 +111,14 @@ public JobDescriptor(String id, String conicalPath, String fullpath, Props props
Collections.sort(this._writeResourceLocks);
this._emailList = props.getStringList(NOTIFY_EMAIL);
+
+ this._folder = getJobPath(_path);
}
+ public String getFolder() {
+ return _folder;
+ }
+
public Boolean isValid() {
return _valid;
}
@@ -176,6 +184,24 @@ public String toString() {
);
}
+ static public final String getJobPath(String in) {
+ String jobPath = in;
+ if (jobPath.contains("/")) {
+ String[] split = jobPath.split("/");
+ if (split[0].isEmpty()) {
+ jobPath = split[1];
+ }
+ else {
+ jobPath = split[0];
+ }
+ }
+ else {
+ jobPath = "default";
+ }
+ return jobPath;
+ }
+
+
public ClassLoader getClassLoader() {
return this._classLoader;
}
View
9 azkaban/src/java/azkaban/flow/CachingFlowManager.java
@@ -191,13 +191,8 @@ private void addToCache(FlowExecutionHolder retVal)
}
@Override
- public Set<String> getContainedJobs(String folder) {
- return baseManager.getContainedJobs(folder);
- }
-
- @Override
- public Set<String> getDependantFlows(Set<String> jobs) {
- return baseManager.getDependantFlows(jobs);
+ public Map<String, String> getDependantFlows(String folder) {
+ return baseManager.getDependantFlows(folder);
}
}
View
11 azkaban/src/java/azkaban/flow/FlowManager.java
@@ -23,6 +23,7 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
/**
@@ -138,19 +139,11 @@
void reload() throws IOException;
/**
- * Get all jobs contained in a folder
- *
- * @param folder
- * @return
- */
- Set<String> getContainedJobs(String folder);
-
- /**
* Get all flows dependent on jobs in the input set
*
* @param jobs
* @return
*/
- Set<String> getDependantFlows(Set<String> jobs);
+ Map<String, String> getDependantFlows(String folder);
}
View
8 azkaban/src/java/azkaban/flow/ImmutableFlowManager.java
@@ -195,13 +195,7 @@ public void reload() throws IOException
}
@Override
- public Set<String> getContainedJobs(String folder) {
- throw new UnsupportedOperationException();
- }
-
-
- @Override
- public Set<String> getDependantFlows(Set<String> jobs) {
+ public Map<String, String> getDependantFlows(String folder) {
throw new UnsupportedOperationException();
}
View
90 azkaban/src/java/azkaban/flow/RefreshableFlowManager.java
@@ -125,51 +125,6 @@ public void reload() throws IOException
reloadInternal(null);
}
- private final String getJobPath(String in) {
- String jobPath = in;
- if (jobPath.contains("/")) {
- String[] split = jobPath.split("/");
- if (split[0].isEmpty()) {
- jobPath = split[1];
- }
- else {
- jobPath = split[0];
- }
- }
- else {
- jobPath = "default";
- }
- return jobPath;
- }
-
-
- public Set<String> getContainedJobs(String folder) {
-
- Set<String> ret = new HashSet<String>();
-
- List<String> rootNames = getRootNamesByFolder(folder);
- if (rootNames == null) return ret;
-
- LinkedList<JobDescriptor> queue = new LinkedList<JobDescriptor>();
-
- for (String jobName : rootNames) {
- JobDescriptor jobDesc = jobManager.getJobDescriptor(jobName);
- queue.clear();
- queue.addAll(jobDesc.getDependencies());
- while (!queue.isEmpty()) {
- JobDescriptor job = queue.pollFirst();
- String jobPath = getJobPath(job.getPath());
- if (jobPath.equals(folder)) {
- ret.add(job.getId());
- }
-
- queue.addAll(job.getDependencies());
- }
-
- }
-
- return ret;
- }
private final void reloadInternal(Long lastId) throws IOException
{
@@ -187,12 +142,13 @@ private final void reloadInternal(Long lastId) throws IOException
rootFlows.add(rootDescriptor.getId());
// For folder path additions
- String jobPath = getJobPath(rootDescriptor.getPath());
+ String folder = rootDescriptor.getFolder();
- List<String> root = folderToRoot.get(jobPath);
+ //System.out.println("add folder:" + jobPath + "\tjob:" + rootDescriptor.getId());
+ List<String> root = folderToRoot.get(folder);
if (root == null) {
root = new ArrayList<String>();
- folderToRoot.put(jobPath, root);
+ folderToRoot.put(folder, root);
}
root.add(rootDescriptor.getId());
}
@@ -225,31 +181,33 @@ private final void reloadInternal(Long lastId) throws IOException
}
@Override
- public Set<String> getDependantFlows(Set<String> toDel) {
- Set<String> rootFlows = this.getRootFlowNames();
- Set<String> ret = new HashSet<String>();
+ public Map<String, String> getDependantFlows(String folder) {
+
+ Set<String> rootFlows = getRootFlowNames();
+ Map<String, String> ret = new HashMap<String, String>();
LinkedList<JobDescriptor> queue = new LinkedList<JobDescriptor>();
for (String rootFlow: rootFlows) {
- //ignore flows already in the input job set
- if (toDel.contains(rootFlow)) continue;
-
JobDescriptor descriptor = jobManager.getJobDescriptor(rootFlow);
- queue.clear();
+ final String jobFolder = descriptor.getFolder();
+
+ // ignore root jobs already in the folder
+ if (folder.equals(jobFolder)) continue;
queue.add(descriptor);
+ }
+
+ while (!queue.isEmpty()) {
+ JobDescriptor top = queue.pollFirst();
- while (!queue.isEmpty()) {
- JobDescriptor top = queue.pollFirst();
-
- Set<JobDescriptor> dependents = top.getDependencies();
- for (JobDescriptor dependent: dependents) {
- if (toDel.contains(dependent.getId())) {
- ret.add(top.getId());
- }
- else {
- queue.add(dependent);
- }
+ Set<JobDescriptor> dependents = top.getDependencies();
+ for (JobDescriptor dependent: dependents) {
+ // ignore jobs in the folder
+ if (folder.equals(dependent.getFolder())) {
+ ret.put(top.getId(), top.getFolder());
+ }
+ else {
+ queue.add(dependent);
}
}
View
12 azkaban/src/java/azkaban/web/pages/IndexServlet.java
@@ -187,16 +187,16 @@ private Page getPage(HttpServletRequest req, HttpServletResponse resp, String qu
JobManager jobMgr = app.getJobManager();
if ("true".equals(toCheck)) {
- Set<String> containedJobs = flowMgr.getContainedJobs(folder);
- Set<String> dependantFlows = flowMgr.getDependantFlows(containedJobs);
+ Map<String, String> dependantFlows = flowMgr.getDependantFlows(folder);
+
if (dependantFlows != null && dependantFlows.size()>0) {
StringBuffer msg = new StringBuffer("The following flows will become "
- + "invalid: <br>");
- for (String d: dependantFlows) {
- msg.append(d + "<br>");
+ + "invalid: <br> <br>");
+ for (Map.Entry<String, String> entry: dependantFlows.entrySet()) {
+ msg.append(entry.getKey() + " in " + entry.getValue() + "<br>");
}
- msg.append("Do you want to proceed?");
+ msg.append("<br>Do you want to proceed?");
return toJson("confirm", msg.toString());
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.