This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for custom evictor and trigger policies (#2653)
* Add support for custom evictor and trigger policies Add support in both the streamlet and topology apis for the usage of custom eviction policies extending com.twitter.heron.api.windowing.EvictionPolicy and trigger policies extending com.twitter.heron.api.windowing.TriggerPolicy to enable user-defined windowing schemes. * Fixed Checkstyle Issues Fixed Checkstyle Issues * Fixed extra line errors, reorganized if statement in WIndowedBoltExecutor to require both Policies to be provided if one of them is * Reversed policy order to fix null pointer exception * Trial push (local compilation not working for some reason, going to push then pull clean copy) * Added Changes necessary to allow custom trigger policies to attach WindowManager, Config object, TriggerHandler and EvictionPolicy * Fixed test errors due to lack of setting necessary paramters and defining "started" again for CountTriggerPolicy * Remove flags and checks on AbstractBaseTriggerPolicy
- Loading branch information
1 parent
850461c
commit 2d86042
Showing
12 changed files
with
320 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
heron/api/src/java/com/twitter/heron/api/windowing/triggers/AbstractBaseTriggerPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// Copyright 2017 Twitter. All rights reserved. | ||
// | ||
// 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. | ||
|
||
/** | ||
* 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 com.twitter.heron.api.windowing.triggers; | ||
|
||
import java.io.Serializable; | ||
import java.util.Map; | ||
|
||
import com.twitter.heron.api.windowing.EvictionPolicy; | ||
import com.twitter.heron.api.windowing.TriggerHandler; | ||
import com.twitter.heron.api.windowing.TriggerPolicy; | ||
import com.twitter.heron.api.windowing.WindowManager; | ||
|
||
|
||
public abstract class AbstractBaseTriggerPolicy<T extends Serializable, S> | ||
implements TriggerPolicy<T, S> { | ||
protected TriggerHandler handler; | ||
protected EvictionPolicy<T, ?> evictionPolicy; | ||
protected WindowManager<T> windowManager; | ||
protected Boolean started; | ||
protected Map<String, Object> topoConf; | ||
|
||
private boolean requiresEvictionPolicy = false; | ||
private boolean requiresWindowManager = false; | ||
private boolean requiresTopologyConfig = false; | ||
|
||
/** | ||
* Set the requirements in the constructor | ||
*/ | ||
public AbstractBaseTriggerPolicy() { | ||
} | ||
|
||
/** | ||
* Set the eviction policy to whatever eviction policy to use this with | ||
* | ||
* @param evictionPolicy the eviction policy | ||
*/ | ||
public void setEvictionPolicy(EvictionPolicy<T, ?> evictionPolicy) { | ||
this.evictionPolicy = evictionPolicy; | ||
} | ||
|
||
/** | ||
* Set the trigger handler for this trigger policy to trigger | ||
* | ||
* @param triggerHandler the trigger handler | ||
*/ | ||
public void setTriggerHandler(TriggerHandler triggerHandler) { | ||
this.handler = triggerHandler; | ||
} | ||
|
||
/** | ||
* Sets the window manager that uses this trigger policy | ||
* | ||
* @param windowManager the window manager | ||
*/ | ||
public void setWindowManager(WindowManager<T> windowManager) { | ||
this.windowManager = windowManager; | ||
} | ||
|
||
/** | ||
* Sets the Config used for this topology | ||
* | ||
* @param config the configuration object | ||
*/ | ||
public void setTopologyConfig(Map<String, Object> config) { | ||
this.topoConf = config; | ||
} | ||
|
||
/** | ||
* Starts the trigger policy. This can be used | ||
* during recovery to start the triggers after | ||
* recovery is complete. | ||
*/ | ||
@Override | ||
public void start() { | ||
started = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.