[NEMO-385]LambdaPass, LambdaPolicy and ResourceLambdaProperty (#214)
JIRA: [NEMO-385: Support Lambda Pass with lambda policy and lambda resource property](https://issues.apache.org/jira/browse/NEMO-385)
**Major changes:**
- Implement LambdaPass, LambdaPolicy and ResourceLambdaProperty
**Tests for the changes:**
- No test suites implemented
**Other comments:**
- This issue is a subissue under [NEMO-352 Nemo on AWS Lambda](https://issues.apache.org/jira/projects/NEMO/issues/NEMO-352)
- This PR relates to GSoC2019
diff --git a/common/src/main/java/org/apache/nemo/common/ir/vertex/executionproperty/ResourceLambdaProperty.java b/common/src/main/java/org/apache/nemo/common/ir/vertex/executionproperty/ResourceLambdaProperty.java
new file mode 100644
index 0000000..4e56144
--- /dev/null
+++ b/common/src/main/java/org/apache/nemo/common/ir/vertex/executionproperty/ResourceLambdaProperty.java
@@ -0,0 +1,53 @@
+/*
+ * 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 org.apache.nemo.common.ir.vertex.executionproperty;
+
+import org.apache.nemo.common.ir.executionproperty.VertexExecutionProperty;
+
+/**
+ * Resource property supporting Lambda Pass.
+ */
+public final class ResourceLambdaProperty extends VertexExecutionProperty<ResourceLambdaProperty.Value> {
+ /**
+ * Constructor.
+ *
+ * @param value value of the execution property.
+ */
+ private ResourceLambdaProperty(final ResourceLambdaProperty.Value value) {
+ super(value);
+ }
+
+ /**
+ * Static method exposing the constructor.
+ *
+ * @param value value of the new execution property.
+ * @return the newly created execution property.
+ */
+ public static ResourceLambdaProperty of(final ResourceLambdaProperty.Value value) {
+ return new ResourceLambdaProperty(value);
+ }
+
+ /**
+ * Possible values of DataStore ExecutionProperty.
+ */
+ public enum Value {
+ On,
+ Off,
+ }
+}
diff --git a/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/pass/compiletime/annotating/LambdaPass.java b/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/pass/compiletime/annotating/LambdaPass.java
new file mode 100644
index 0000000..c9f62ec
--- /dev/null
+++ b/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/pass/compiletime/annotating/LambdaPass.java
@@ -0,0 +1,42 @@
+/*
+ * 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 org.apache.nemo.compiler.optimizer.pass.compiletime.annotating;
+
+import org.apache.nemo.common.ir.IRDAG;
+import org.apache.nemo.common.ir.vertex.executionproperty.ResourceLambdaProperty;
+
+/**
+ * Lambda Pass.
+ * Description: A part of lambda executor, assigning LambdaResourceProperty
+ */
+@Annotates(ResourceLambdaProperty.class)
+public final class LambdaPass extends AnnotatingPass {
+
+ public LambdaPass() {
+ super(LambdaPass.class);
+ }
+
+ @Override
+ public IRDAG apply(final IRDAG dag) {
+ dag.getVertices().forEach(vertex -> {
+ vertex.setPropertyPermanently(ResourceLambdaProperty.of(ResourceLambdaProperty.Value.On));
+ });
+ return dag;
+ }
+}
diff --git a/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/policy/LambdaPolicy.java b/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/policy/LambdaPolicy.java
new file mode 100644
index 0000000..97b8c05
--- /dev/null
+++ b/compiler/optimizer/src/main/java/org/apache/nemo/compiler/optimizer/policy/LambdaPolicy.java
@@ -0,0 +1,52 @@
+/*
+ * 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 org.apache.nemo.compiler.optimizer.policy;
+
+import org.apache.nemo.common.ir.IRDAG;
+import org.apache.nemo.compiler.optimizer.pass.compiletime.annotating.LambdaPass;
+import org.apache.nemo.compiler.optimizer.pass.compiletime.composite.DefaultCompositePass;
+import org.apache.nemo.compiler.optimizer.pass.runtime.Message;
+
+/**
+ * Lambda Policy
+ * Description: A part of lambda executor, to support Lambda policy.
+ */
+public final class LambdaPolicy implements Policy {
+ private final Policy policy;
+
+ /**
+ * Default constructor.
+ */
+ public LambdaPolicy() {
+ final PolicyBuilder builder = new PolicyBuilder();
+ builder.registerCompileTimePass(new DefaultCompositePass());
+ builder.registerCompileTimePass(new LambdaPass());
+ this.policy = builder.build();
+ }
+
+ @Override
+ public IRDAG runCompileTimeOptimization(final IRDAG dag, final String dagDirectory) {
+ return this.policy.runCompileTimeOptimization(dag, dagDirectory);
+ }
+
+ @Override
+ public IRDAG runRunTimeOptimizations(final IRDAG dag, final Message<?> message) {
+ return this.policy.runRunTimeOptimizations(dag, message);
+ }
+}