Policy Creator UI Design
Framework Interface
enum PolicyTemplateScope { General,Embedded, // Customized: possible to support save certain ad-hoc policy as template } interface PolicyTemplate { String getName(); // "SINGLE_SOURCE_THRESHOLD_ALERT" String getDescription(); // "An alert policy template consuming single stream source." String getFormPath(); // "/path/to/form" <Class extends PolicyTemplateConfig> getConfigType(); PolicyTemplateScope getScope(); PolicyDefinition render(PolicyTemplateConfig); } abstract class PolicyTemplateConfig { internal: String } final class PolicyTemplateEntity { uuid: UUID, config: PolicyTemplateConfig, template: "org.apache.eagle.policy.PolicyTemplate" }
General Mode
Policy Editor (General Mode) mainly supports some general alert template and provide easy-to-use template form and general native eagle policy in backend using the submitted form data and policy template.
Backend Support
// Template Interface and GeneralPolicyTemplateDesc for API abstract class GeneralPolicyTemplate extends PolicyTemplate{ final PolicyTemplateScope getScope() { return PolicyTemplateScope.General; } } // Case Example SingleStreamThresholdPolicyTemplateConfig extend PolicyTemplateConfig { from: HDFS_AUDIT_SRC_STREAM, partition: { type: "GROUPBY",field: "USER" }, window: { type: "SLIDING_WINDOW", configs: { length: "20 hour" } }, aggregators: [ { function: "SUM", field: "USER", alias: "USER_COUNT" } ], filters: [ { field: "USER_COUNT", function: ">", value: 20 }, { field: "USER", function: "NOT IN", value: "HADOOP, HDFS, MAPRED" } ] }
Embedded Mode
Backend Support
abstract class EmbeddedPolicyTemplate extends PolicyTemplate{ final PolicyTemplateScope getScope() { return PolicyTemplateScope.Embedded; } } // Case Example TOO_LARGE_DELETION_ALERT_CONFIG extend PolicyTemplateConfig { users: List<String>, hdfsSizeThreshhold: Long }
Advanced Mode