You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by an...@apache.org on 2013/11/13 14:22:04 UTC

[1/2] git commit: Revert "JCLOUDS-375: Fix VirtualGuestToNodeMetadata when server returns SoftLayer_Exception_Order_Item_Duplicate" to correct JIRA issue number

Updated Branches:
  refs/heads/master 43f2f0ba3 -> 4e75e0a1e


Revert "JCLOUDS-375: Fix VirtualGuestToNodeMetadata when server returns SoftLayer_Exception_Order_Item_Duplicate" to correct JIRA issue number

This reverts commit 43f2f0ba3b071c58aa8ddec6c9673f4b72ff6185.


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

Branch: refs/heads/master
Commit: 2abc98ab6bd3ef8224ce255682d036166b9a9c2b
Parents: 43f2f0b
Author: Andrew Phillips <an...@apache.org>
Authored: Wed Nov 13 14:19:56 2013 +0100
Committer: Andrew Phillips <an...@apache.org>
Committed: Wed Nov 13 14:19:56 2013 +0100

----------------------------------------------------------------------
 .../functions/VirtualGuestToNodeMetadata.java   | 17 +------------
 .../SoftLayerOrderItemDuplicateException.java   | 25 --------------------
 .../handlers/SoftLayerErrorHandler.java         |  3 ---
 3 files changed, 1 insertion(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/2abc98ab/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java
index 7c60f8a..6475a33 100644
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java
@@ -22,9 +22,7 @@ import static com.google.common.collect.FluentIterable.from;
 import java.util.Map;
 import java.util.Set;
 
-import javax.annotation.Resource;
 import javax.inject.Inject;
-import javax.inject.Named;
 import javax.inject.Singleton;
 
 import org.jclouds.collect.Memoized;
@@ -34,15 +32,12 @@ import org.jclouds.compute.domain.NodeMetadata;
 import org.jclouds.compute.domain.NodeMetadata.Status;
 import org.jclouds.compute.domain.NodeMetadataBuilder;
 import org.jclouds.compute.functions.GroupNamingConvention;
-import org.jclouds.compute.reference.ComputeServiceConstants;
 import org.jclouds.domain.Location;
 import org.jclouds.location.predicates.LocationPredicates;
-import org.jclouds.logging.Logger;
 import org.jclouds.softlayer.SoftLayerApi;
 import org.jclouds.softlayer.domain.ProductItem;
 import org.jclouds.softlayer.domain.ProductOrder;
 import org.jclouds.softlayer.domain.VirtualGuest;
-import org.jclouds.softlayer.exceptions.SoftLayerOrderItemDuplicateException;
 import org.jclouds.softlayer.predicates.ProductItemPredicates;
 
 import com.google.common.base.Function;
@@ -136,10 +131,6 @@ public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMe
    @Singleton
    public static class GetImageForVirtualGuest {
 
-      @Resource
-      @Named(ComputeServiceConstants.COMPUTE_LOGGER)
-      protected Logger logger = Logger.NULL;
-
       private SoftLayerApi api;
 
       @Inject
@@ -148,16 +139,10 @@ public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMe
       }
 
       public Image getImage(VirtualGuest guest) {
-         ProductOrder order = null;
          // 'bad' orders have no start cpu's and cause the order lookup to fail.
          if (guest.getStartCpus() < 1)
             return null;
-         try {
-            order = api.getVirtualGuestApi().getOrderTemplate(guest.getId());
-         } catch (SoftLayerOrderItemDuplicateException e) {
-            // this is a workaround because SoftLayer throws sometimes 500 internal server errors for the above method call
-            logger.warn(e, "Cannot get order template for virtualGuestId(%s)", guest.getId());
-         }
+         ProductOrder order = api.getVirtualGuestApi().getOrderTemplate(guest.getId());
          if (order == null)
             return null;
          Iterable<ProductItem> items = Iterables.transform(order.getPrices(), ProductItems.item());

http://git-wip-us.apache.org/repos/asf/jclouds/blob/2abc98ab/providers/softlayer/src/main/java/org/jclouds/softlayer/exceptions/SoftLayerOrderItemDuplicateException.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/exceptions/SoftLayerOrderItemDuplicateException.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/exceptions/SoftLayerOrderItemDuplicateException.java
deleted file mode 100644
index a08a61b..0000000
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/exceptions/SoftLayerOrderItemDuplicateException.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.jclouds.softlayer.exceptions;
-
-public class SoftLayerOrderItemDuplicateException extends RuntimeException {
-
-   public SoftLayerOrderItemDuplicateException(String message, Exception exception) {
-      super(message, exception);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/2abc98ab/providers/softlayer/src/main/java/org/jclouds/softlayer/handlers/SoftLayerErrorHandler.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/handlers/SoftLayerErrorHandler.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/handlers/SoftLayerErrorHandler.java
index e2d7092..129e051 100644
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/handlers/SoftLayerErrorHandler.java
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/handlers/SoftLayerErrorHandler.java
@@ -26,7 +26,6 @@ import org.jclouds.http.HttpResponse;
 import org.jclouds.http.HttpResponseException;
 import org.jclouds.rest.AuthorizationException;
 import org.jclouds.rest.ResourceNotFoundException;
-import org.jclouds.softlayer.exceptions.SoftLayerOrderItemDuplicateException;
 import org.jclouds.util.Strings2;
 
 import com.google.common.base.Throwables;
@@ -65,8 +64,6 @@ public class SoftLayerErrorHandler implements HttpErrorHandler {
                      exception = new ResourceNotFoundException(message, exception);
                   } else if (message.indexOf("currently an active transaction") != -1) {
                      exception = new IllegalStateException(message, exception);
-                  } else if (message.indexOf("SoftLayer_Exception_Order_Item_Duplicate") != -1) {
-                     exception = new SoftLayerOrderItemDuplicateException(message, exception);
                   }
                }
          }


[2/2] git commit: JCLOUDS-373: Fix VirtualGuestToNodeMetadata when server returns SoftLayer_Exception_Order_Item_Duplicate

Posted by an...@apache.org.
JCLOUDS-373: Fix VirtualGuestToNodeMetadata when server returns SoftLayer_Exception_Order_Item_Duplicate

* Wrap getOrderTemplate in VirtualGuestToNodeMetadata.getImage with try/catch
* Address comments from @nacx and @demobox:
  - remove the fields of the custom SoftLayerOrderItemDuplicateException and propagate the HttpResponseException
  - use of order = null instead of return null
  - extend RuntimeException instead IllegalStateException in SoftLayerOrderItemDuplicateException

Conflicts solved:
	providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java


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

Branch: refs/heads/master
Commit: 4e75e0a1e1323122499716bdb8b7bf19fe1768e2
Parents: 2abc98a
Author: Andrea Turli <an...@gmail.com>
Authored: Mon Nov 11 17:38:33 2013 +0100
Committer: Andrew Phillips <an...@apache.org>
Committed: Wed Nov 13 14:20:40 2013 +0100

----------------------------------------------------------------------
 .../functions/VirtualGuestToNodeMetadata.java   | 17 ++++++++++++-
 .../SoftLayerOrderItemDuplicateException.java   | 25 ++++++++++++++++++++
 .../handlers/SoftLayerErrorHandler.java         |  3 +++
 3 files changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/4e75e0a1/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java
index 6475a33..7c60f8a 100644
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java
@@ -22,7 +22,9 @@ import static com.google.common.collect.FluentIterable.from;
 import java.util.Map;
 import java.util.Set;
 
+import javax.annotation.Resource;
 import javax.inject.Inject;
+import javax.inject.Named;
 import javax.inject.Singleton;
 
 import org.jclouds.collect.Memoized;
@@ -32,12 +34,15 @@ import org.jclouds.compute.domain.NodeMetadata;
 import org.jclouds.compute.domain.NodeMetadata.Status;
 import org.jclouds.compute.domain.NodeMetadataBuilder;
 import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.compute.reference.ComputeServiceConstants;
 import org.jclouds.domain.Location;
 import org.jclouds.location.predicates.LocationPredicates;
+import org.jclouds.logging.Logger;
 import org.jclouds.softlayer.SoftLayerApi;
 import org.jclouds.softlayer.domain.ProductItem;
 import org.jclouds.softlayer.domain.ProductOrder;
 import org.jclouds.softlayer.domain.VirtualGuest;
+import org.jclouds.softlayer.exceptions.SoftLayerOrderItemDuplicateException;
 import org.jclouds.softlayer.predicates.ProductItemPredicates;
 
 import com.google.common.base.Function;
@@ -131,6 +136,10 @@ public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMe
    @Singleton
    public static class GetImageForVirtualGuest {
 
+      @Resource
+      @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+      protected Logger logger = Logger.NULL;
+
       private SoftLayerApi api;
 
       @Inject
@@ -139,10 +148,16 @@ public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMe
       }
 
       public Image getImage(VirtualGuest guest) {
+         ProductOrder order = null;
          // 'bad' orders have no start cpu's and cause the order lookup to fail.
          if (guest.getStartCpus() < 1)
             return null;
-         ProductOrder order = api.getVirtualGuestApi().getOrderTemplate(guest.getId());
+         try {
+            order = api.getVirtualGuestApi().getOrderTemplate(guest.getId());
+         } catch (SoftLayerOrderItemDuplicateException e) {
+            // this is a workaround because SoftLayer throws sometimes 500 internal server errors for the above method call
+            logger.warn(e, "Cannot get order template for virtualGuestId(%s)", guest.getId());
+         }
          if (order == null)
             return null;
          Iterable<ProductItem> items = Iterables.transform(order.getPrices(), ProductItems.item());

http://git-wip-us.apache.org/repos/asf/jclouds/blob/4e75e0a1/providers/softlayer/src/main/java/org/jclouds/softlayer/exceptions/SoftLayerOrderItemDuplicateException.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/exceptions/SoftLayerOrderItemDuplicateException.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/exceptions/SoftLayerOrderItemDuplicateException.java
new file mode 100644
index 0000000..a08a61b
--- /dev/null
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/exceptions/SoftLayerOrderItemDuplicateException.java
@@ -0,0 +1,25 @@
+/*
+ * 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.jclouds.softlayer.exceptions;
+
+public class SoftLayerOrderItemDuplicateException extends RuntimeException {
+
+   public SoftLayerOrderItemDuplicateException(String message, Exception exception) {
+      super(message, exception);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/4e75e0a1/providers/softlayer/src/main/java/org/jclouds/softlayer/handlers/SoftLayerErrorHandler.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/handlers/SoftLayerErrorHandler.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/handlers/SoftLayerErrorHandler.java
index 129e051..e2d7092 100644
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/handlers/SoftLayerErrorHandler.java
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/handlers/SoftLayerErrorHandler.java
@@ -26,6 +26,7 @@ import org.jclouds.http.HttpResponse;
 import org.jclouds.http.HttpResponseException;
 import org.jclouds.rest.AuthorizationException;
 import org.jclouds.rest.ResourceNotFoundException;
+import org.jclouds.softlayer.exceptions.SoftLayerOrderItemDuplicateException;
 import org.jclouds.util.Strings2;
 
 import com.google.common.base.Throwables;
@@ -64,6 +65,8 @@ public class SoftLayerErrorHandler implements HttpErrorHandler {
                      exception = new ResourceNotFoundException(message, exception);
                   } else if (message.indexOf("currently an active transaction") != -1) {
                      exception = new IllegalStateException(message, exception);
+                  } else if (message.indexOf("SoftLayer_Exception_Order_Item_Duplicate") != -1) {
+                     exception = new SoftLayerOrderItemDuplicateException(message, exception);
                   }
                }
          }