azkaban-aplcache

Flow Trigger Dependency Interface (#1505) related feature

10/10/2017 8:45:56 PM

Details

diff --git a/azkaban-web-server/src/main/java/azkaban/flowtrigger/DependencyCheck.java b/azkaban-web-server/src/main/java/azkaban/flowtrigger/DependencyCheck.java
new file mode 100644
index 0000000..119567e
--- /dev/null
+++ b/azkaban-web-server/src/main/java/azkaban/flowtrigger/DependencyCheck.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017 LinkedIn Corp.
+ *
+ * Licensed 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 azkaban.flowtrigger;
+
+public interface DependencyCheck {
+
+
+  /**
+   * Non-blocking run of dependency check
+   *
+   * @return context of the running dependency.
+   */
+  DependencyInstanceContext run(DependencyInstanceConfig config);
+
+  /**
+   * Kill the dependency instance
+   */
+  void kill(DependencyInstanceContext depContext);
+
+  /**
+   * Shutdown the dependency plugin. Clean up resource if needed.
+   */
+  void shutdown();
+
+  /**
+   * Initialize the dependency plugin.
+   *
+   * @param config dependency plugin config.
+   * @param successCallback callback to invoke when the check succeeds.
+   */
+  void init(DependencyPluginConfig config, SuccessCallback successCallback);
+}
diff --git a/azkaban-web-server/src/main/java/azkaban/flowtrigger/DependencyInstanceConfig.java b/azkaban-web-server/src/main/java/azkaban/flowtrigger/DependencyInstanceConfig.java
new file mode 100644
index 0000000..44887c8
--- /dev/null
+++ b/azkaban-web-server/src/main/java/azkaban/flowtrigger/DependencyInstanceConfig.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2017 LinkedIn Corp.
+ *
+ * Licensed 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 azkaban.flowtrigger;
+
+/**
+ * Defines the dependency instance level configuration.
+ */
+public interface DependencyInstanceConfig {
+
+  /**
+   * @return value for the configuration key,
+   * null if the key doesn't exist in the configuration.
+   */
+  String get(final String key);
+}
diff --git a/azkaban-web-server/src/main/java/azkaban/flowtrigger/DependencyInstanceContext.java b/azkaban-web-server/src/main/java/azkaban/flowtrigger/DependencyInstanceContext.java
new file mode 100644
index 0000000..70250dd
--- /dev/null
+++ b/azkaban-web-server/src/main/java/azkaban/flowtrigger/DependencyInstanceContext.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2017 LinkedIn Corp.
+ *
+ * Licensed 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 azkaban.flowtrigger;
+
+/**
+ * Implementing class should hold context information for a running dependency
+ * instance.
+ */
+public interface DependencyInstanceContext {
+
+}
diff --git a/azkaban-web-server/src/main/java/azkaban/flowtrigger/DependencyPluginConfig.java b/azkaban-web-server/src/main/java/azkaban/flowtrigger/DependencyPluginConfig.java
new file mode 100644
index 0000000..e1f45d4
--- /dev/null
+++ b/azkaban-web-server/src/main/java/azkaban/flowtrigger/DependencyPluginConfig.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2017 LinkedIn Corp.
+ *
+ * Licensed 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 azkaban.flowtrigger;
+
+/**
+ * Defines the dependency plugin level configuration
+ */
+public interface DependencyPluginConfig {
+
+  /**
+   * @return value for the configuration key,
+   * null if the key doesn't exist in the configuration.
+   */
+  String get(final String key);
+}
diff --git a/azkaban-web-server/src/main/java/azkaban/flowtrigger/SuccessCallback.java b/azkaban-web-server/src/main/java/azkaban/flowtrigger/SuccessCallback.java
new file mode 100644
index 0000000..745e561
--- /dev/null
+++ b/azkaban-web-server/src/main/java/azkaban/flowtrigger/SuccessCallback.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2017 LinkedIn Corp.
+ *
+ * Licensed 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 azkaban.flowtrigger;
+
+/**
+ * Defines the action to take when dependency check instance is successfully finished.
+ */
+public interface SuccessCallback {
+
+  /**
+   * action to invoke when dependency check instance is successfully finished.
+   */
+  void onSuccess(DependencyInstanceContext dependencyInstance);
+}