You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2013/12/28 08:00:51 UTC

svn commit: r1553793 - in /hive/trunk/testutils/ptest2: ./ src/main/java/org/apache/hive/ptest/execution/context/ src/test/java/org/apache/hive/ptest/execution/context/

Author: hashutosh
Date: Sat Dec 28 07:00:51 2013
New Revision: 1553793

URL: http://svn.apache.org/r1553793
Log:
HIVE-6118 : PTest2 is banned periodically by AWS because JClouds is too agressive (Brock Noland via Ashutosh Chauhan)

Modified:
    hive/trunk/testutils/ptest2/pom.xml
    hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/context/CloudComputeService.java
    hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/context/CloudExecutionContextProvider.java
    hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/context/TestCloudComputeService.java

Modified: hive/trunk/testutils/ptest2/pom.xml
URL: http://svn.apache.org/viewvc/hive/trunk/testutils/ptest2/pom.xml?rev=1553793&r1=1553792&r2=1553793&view=diff
==============================================================================
Binary files - no diff available.

Modified: hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/context/CloudComputeService.java
URL: http://svn.apache.org/viewvc/hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/context/CloudComputeService.java?rev=1553793&r1=1553792&r2=1553793&view=diff
==============================================================================
--- hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/context/CloudComputeService.java (original)
+++ hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/context/CloudComputeService.java Sat Dec 28 07:00:51 2013
@@ -22,6 +22,7 @@ import java.util.Collections;
 import java.util.Properties;
 import java.util.Set;
 
+import org.jclouds.Constants;
 import org.jclouds.ContextBuilder;
 import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions;
 import org.jclouds.compute.ComputeService;
@@ -59,11 +60,13 @@ public class CloudComputeService {
     mMaxBid = maxBid;
     mGroupTag = "group=" + mGroupName;
     Properties overrides = new Properties();
-    overrides.put(ComputeServiceProperties.POLL_INITIAL_PERIOD, String.valueOf(10L * 1000L));
-    overrides.put(ComputeServiceProperties.POLL_MAX_PERIOD, String.valueOf(30L * 1000L));
+    overrides.put(ComputeServiceProperties.POLL_INITIAL_PERIOD, String.valueOf(60L * 1000L));
+    overrides.put(ComputeServiceProperties.POLL_MAX_PERIOD, String.valueOf(600L * 1000L));
+    overrides.put(Constants.PROPERTY_MAX_RETRIES, String.valueOf(60));
     mComputeServiceContext = ContextBuilder.newBuilder("aws-ec2")
         .credentials(apiKey, accessKey)
         .modules(ImmutableSet.of(new Log4JLoggingModule()))
+        .overrides(overrides)
         .buildView(ComputeServiceContext.class);
     mComputeService = mComputeServiceContext.getComputeService();
   }

Modified: hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/context/CloudExecutionContextProvider.java
URL: http://svn.apache.org/viewvc/hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/context/CloudExecutionContextProvider.java?rev=1553793&r1=1553792&r2=1553793&view=diff
==============================================================================
--- hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/context/CloudExecutionContextProvider.java (original)
+++ hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/context/CloudExecutionContextProvider.java Sat Dec 28 07:00:51 2013
@@ -67,7 +67,7 @@ public class CloudExecutionContextProvid
   public static final String USERNAME = "user";
   public static final String INSTANCE_TYPE = "instanceType";
   public static final String NUM_THREADS = "numThreads";
-  
+
   private final RandomAccessFile mHostLog;
   private final String mPrivateKey;
   private final String mUser;
@@ -126,7 +126,7 @@ public class CloudExecutionContextProvid
       public void run() {
         while (true) {
           try {
-            TimeUnit.MINUTES.sleep(15);
+            TimeUnit.MINUTES.sleep(60);
             performBackgroundWork();
           } catch (Exception e) {
             LOG.error("Unexpected error in background worker", e);
@@ -194,11 +194,19 @@ public class CloudExecutionContextProvid
     Set<NodeMetadata> result = Sets.newHashSet();
     int attempts = 0;
     int numRequired = numHosts;
+    // pause so we don't get banned
+    try {
+      TimeUnit.SECONDS.sleep(mRetrySleepInterval);
+    } catch (InterruptedException e) {
+     Thread.currentThread().interrupt();
+    }
     do {
+      boolean error = false;
       LOG.info("Attempting to create " + numRequired + " nodes");
       try {
-        result.addAll(mCloudComputeService.createNodes(numRequired));
+        result.addAll(mCloudComputeService.createNodes(Math.min(2, numRequired)));
       } catch (RunNodesException e) {
+        error = true;
         LOG.warn("Error creating nodes", e);
         terminateInternal(e.getNodeErrors().keySet());
         result.addAll(e.getSuccessfulNodes());
@@ -206,9 +214,14 @@ public class CloudExecutionContextProvid
       result = verifyHosts(result);
       LOG.info("Successfully created " + result.size() + " nodes");
       numRequired = numHosts - result.size();
-      if(numRequired > 0) {
+      if (numRequired > 0) {
+        long sleepTime = mRetrySleepInterval;
+        if (error) {
+          sleepTime *= ++attempts;
+        }
+        LOG.info("Pausing creation process for " + sleepTime + " seconds");
         try {
-          TimeUnit.SECONDS.sleep(++attempts * mRetrySleepInterval);
+          TimeUnit.SECONDS.sleep(sleepTime);
         } catch(InterruptedException e) {
           throw new CreateHostsFailedException("Interrupted while trying to create hosts", e);
         }
@@ -308,12 +321,18 @@ public class CloudExecutionContextProvid
     mTerminationExecutor.submit(new Runnable() {
       @Override
       public void run() {
+        // pause so we don't get banned
+        try {
+          TimeUnit.SECONDS.sleep(mRetrySleepInterval);
+        } catch (InterruptedException e) {
+         Thread.currentThread().interrupt();
+        }
         try {
           LOG.info("Terminating " + node.getHostname());
-          mCloudComputeService.destroyNode(node.getId());
           if (!mTerminatedHosts.containsKey(node.getHostname())) {
             mTerminatedHosts.put(node.getHostname(), System.currentTimeMillis());
           }
+          mCloudComputeService.destroyNode(node.getId());
         } catch (Exception e) {
           LOG.error("Error attempting to terminate host " + node, e);
         }

Modified: hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/context/TestCloudComputeService.java
URL: http://svn.apache.org/viewvc/hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/context/TestCloudComputeService.java?rev=1553793&r1=1553792&r2=1553793&view=diff
==============================================================================
--- hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/context/TestCloudComputeService.java (original)
+++ hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/context/TestCloudComputeService.java Sat Dec 28 07:00:51 2013
@@ -1,3 +1,21 @@
+/*
+ * 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.hive.ptest.execution.context;
 
 import java.util.Set;