-
Notifications
You must be signed in to change notification settings - Fork 113
feat(operator): sleep operator #3537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
3c4b7fa
init
aglinxinyuan 5d3998a
fix
aglinxinyuan 408483d
fix
aglinxinyuan 5b7fbca
fix
aglinxinyuan 085cb09
init
aglinxinyuan 6165283
fix fmt
aglinxinyuan ed8cc64
Merge branch 'master' into xinyuan-sk-training
aglinxinyuan dd09917
update
aglinxinyuan 7cd87e4
update
aglinxinyuan dcaa7e2
Update core/workflow-operator/src/main/scala/edu/uci/ics/amber/operat…
aglinxinyuan da9c87f
Merge branch 'master' into xinyuan-sk-testing
aglinxinyuan f725dbd
Merge branch 'xinyuan-sk-testing' into xinyuan-sk-training
aglinxinyuan 77a55c8
init
aglinxinyuan f239526
Merge branch 'xinyuan-sk-training' into xinyuan-op-sleep
aglinxinyuan f4e3c0e
update
aglinxinyuan c6aa92f
update
aglinxinyuan a26629d
Merge branch 'xinyuan-sk-training' into xinyuan-op-sleep
aglinxinyuan a8be38c
update
aglinxinyuan c6dd870
update
aglinxinyuan 54c47ce
Merge branch 'master' into xinyuan-op-sleep
aglinxinyuan 4a6b8a0
update
aglinxinyuan caad8db
Merge remote-tracking branch 'origin/xinyuan-op-sleep' into xinyuan-o…
aglinxinyuan e76e2ef
update
aglinxinyuan 6b98064
Merge branch 'master' into xinyuan-op-sleep
aglinxinyuan 7401dc8
update
aglinxinyuan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
66 changes: 66 additions & 0 deletions
66
core/workflow-operator/src/main/scala/edu/uci/ics/amber/operator/sleep/SleepOpDesc.scala
This file contains hidden or 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,66 @@ | ||
| /* | ||
| * 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 edu.uci.ics.amber.operator.sleep | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty | ||
| import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaTitle | ||
| import edu.uci.ics.amber.core.executor.OpExecWithClassName | ||
| import edu.uci.ics.amber.core.virtualidentity.{ExecutionIdentity, WorkflowIdentity} | ||
| import edu.uci.ics.amber.core.workflow.{InputPort, OutputPort, PhysicalOp} | ||
| import edu.uci.ics.amber.operator.LogicalOp | ||
| import edu.uci.ics.amber.operator.metadata.{OperatorGroupConstants, OperatorInfo} | ||
| import edu.uci.ics.amber.util.JSONUtils.objectMapper | ||
|
|
||
| class SleepOpDesc extends LogicalOp { | ||
|
|
||
| @JsonProperty(required = true) | ||
| @JsonSchemaTitle("Sleep Time (seconds)") | ||
| var sleepTime: Int = _ | ||
|
|
||
| override def getPhysicalOp( | ||
| workflowId: WorkflowIdentity, | ||
| executionId: ExecutionIdentity | ||
| ): PhysicalOp = { | ||
| PhysicalOp | ||
| .oneToOnePhysicalOp( | ||
| workflowId, | ||
| executionId, | ||
| operatorIdentifier, | ||
| OpExecWithClassName( | ||
| "edu.uci.ics.amber.operator.sleep.SleepOpExec", | ||
| objectMapper.writeValueAsString(this) | ||
| ) | ||
| ) | ||
| .withInputPorts(operatorInfo.inputPorts) | ||
| .withOutputPorts(operatorInfo.outputPorts) | ||
| .withParallelizable(false) | ||
| .withSuggestedWorkerNum(1) | ||
|
|
||
| } | ||
|
|
||
| override def operatorInfo: OperatorInfo = | ||
| OperatorInfo( | ||
| "Sleep", | ||
| "Sleep n seconds between each tuple", | ||
| OperatorGroupConstants.CONTROL_GROUP, | ||
| inputPorts = List(InputPort()), | ||
| outputPorts = List(OutputPort()) | ||
| ) | ||
| } | ||
33 changes: 33 additions & 0 deletions
33
core/workflow-operator/src/main/scala/edu/uci/ics/amber/operator/sleep/SleepOpExec.scala
This file contains hidden or 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,33 @@ | ||
| /* | ||
| * 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 edu.uci.ics.amber.operator.sleep | ||
|
|
||
aglinxinyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import edu.uci.ics.amber.core.executor.OperatorExecutor | ||
| import edu.uci.ics.amber.core.tuple.{Tuple, TupleLike} | ||
| import edu.uci.ics.amber.util.JSONUtils.objectMapper | ||
|
|
||
| class SleepOpExec(descString: String) extends OperatorExecutor { | ||
| private val desc: SleepOpDesc = objectMapper.readValue(descString, classOf[SleepOpDesc]) | ||
|
|
||
| override def processTuple(tuple: Tuple, port: Int): Iterator[TupleLike] = { | ||
| Thread.sleep(1000 * desc.sleepTime) | ||
| Iterator(tuple) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.