tez-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bi...@apache.org
Subject [2/2] git commit: TEZ-1372. Fix preWarm to work after recent API changes (bikas)
Date Fri, 08 Aug 2014 20:18:26 GMT
TEZ-1372. Fix preWarm to work after recent API changes (bikas)


Project: http://git-wip-us.apache.org/repos/asf/tez/repo
Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/80542718
Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/80542718
Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/80542718

Branch: refs/heads/master
Commit: 80542718645d96cf23865428a166fe6aa3594a61
Parents: 6741582
Author: Bikas Saha <bikas@apache.org>
Authored: Fri Aug 8 13:18:13 2014 -0700
Committer: Bikas Saha <bikas@apache.org>
Committed: Fri Aug 8 13:18:13 2014 -0700

----------------------------------------------------------------------
 .../org/apache/tez/client/PreWarmVertex.java    | 37 +++++++++++
 .../library/processor/PreWarmProcessor.java     | 67 ++++++++++++++++++++
 2 files changed, 104 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/80542718/tez-api/src/main/java/org/apache/tez/client/PreWarmVertex.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/client/PreWarmVertex.java b/tez-api/src/main/java/org/apache/tez/client/PreWarmVertex.java
new file mode 100644
index 0000000..6601480
--- /dev/null
+++ b/tez-api/src/main/java/org/apache/tez/client/PreWarmVertex.java
@@ -0,0 +1,37 @@
+/**
+ * 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.tez.client;
+
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.tez.dag.api.ProcessorDescriptor;
+import org.apache.tez.dag.api.Vertex;
+
+public class PreWarmVertex extends Vertex {
+
+  public PreWarmVertex(String vertexName, ProcessorDescriptor processorDescriptor, int parallelism,
+      Resource taskResource) {
+    super(vertexName, processorDescriptor, parallelism, taskResource);
+  }
+  
+  public PreWarmVertex(String vertexName, int parallelism, Resource taskResource) {
+    this(vertexName, new ProcessorDescriptor(
+        "org.apache.tez.runtime.library.processor.PreWarmProcessor"), parallelism, taskResource);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/tez/blob/80542718/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/processor/PreWarmProcessor.java
----------------------------------------------------------------------
diff --git a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/processor/PreWarmProcessor.java
b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/processor/PreWarmProcessor.java
new file mode 100644
index 0000000..d7de601
--- /dev/null
+++ b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/processor/PreWarmProcessor.java
@@ -0,0 +1,67 @@
+/*
+ * 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.tez.runtime.library.processor;
+
+import org.apache.tez.runtime.api.Processor;
+import org.apache.tez.runtime.api.TezProcessorContext;
+
+/**
+ * Built-in convenience {@link Processor} to be used for pre-warming
+ * @author bikas
+ *
+ */
+public class PreWarmProcessor extends SimpleProcessor {
+
+  public PreWarmProcessor(TezProcessorContext context) {
+    super(context);
+  }
+
+  @Override
+  public void run() throws Exception {
+    preWarmTezCode();
+    preWarmUserCode();
+  }
+  
+  /**
+   * Pre-warm Tez code. Users can override this with an empty method
+   * to not pre-warm Tez code if they want to.
+   */
+  protected void preWarmTezCode() {
+    // Do nothing. Can potentially pre-warm Tez library components
+    
+    // Currently, must sleep for some time so that container re-use
+    // can be prevented from kicking in. This will allow sufficient 
+    // time to obtain containers from YARN as long as those resources 
+    // are available
+    try {
+      Thread.sleep(3000);
+    } catch (InterruptedException e) {
+      e.printStackTrace();
+    }
+  }
+  
+  /**
+   * Pre-warm user code. Users can override this 
+   * to pre-warm their own code if they want to. 
+   */
+  protected void preWarmUserCode() {
+    // Do nothing
+  }
+
+}


Mime
View raw message