You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 20
Next »
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
![](/confluence/download/attachments/65875426/Screen%20Shot%202016-10-17%20at%203.44.35%20PM.png?version=1&modificationDate=1476690331000&api=v2)
// 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
![](/confluence/download/attachments/65875426/Screen%20Shot%202016-10-17%20at%203.42.14%20PM.png?version=1&modificationDate=1476690363000&api=v2)
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
![](/confluence/download/attachments/65875426/Screen%20Shot%202016-10-17%20at%202.53.32%20PM.png?version=1&modificationDate=1476690394000&api=v2)
![](/confluence/download/attachments/65875426/Screen%20Shot%202016-10-17%20at%202.53.39%20PM.png?version=1&modificationDate=1476690409000&api=v2)