You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by hu...@apache.org on 2014/11/18 14:14:14 UTC

[1/2] git commit: updated refs/heads/master to e1d4a32

Repository: cloudstack
Updated Branches:
  refs/heads/master 638da54fc -> e1d4a329c


Fix for potential NPE


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

Branch: refs/heads/master
Commit: 16de4a71761efe69053fefb6f77f16ddfff63c0f
Parents: 638da54
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Tue Nov 18 14:09:34 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Tue Nov 18 14:12:14 2014 +0100

----------------------------------------------------------------------
 utils/src/com/cloud/utils/net/NetUtils.java     | 45 ++++++++++----------
 .../test/com/cloud/utils/net/NetUtilsTest.java  | 35 ++++++++++-----
 2 files changed, 47 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/16de4a71/utils/src/com/cloud/utils/net/NetUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/NetUtils.java b/utils/src/com/cloud/utils/net/NetUtils.java
index b092c94..3ce3697 100755
--- a/utils/src/com/cloud/utils/net/NetUtils.java
+++ b/utils/src/com/cloud/utils/net/NetUtils.java
@@ -19,16 +19,6 @@
 
 package com.cloud.utils.net;
 
-import com.cloud.utils.IteratorUtil;
-import com.cloud.utils.Pair;
-import com.cloud.utils.script.Script;
-import com.googlecode.ipv6.IPv6Address;
-import com.googlecode.ipv6.IPv6AddressRange;
-import com.googlecode.ipv6.IPv6Network;
-import org.apache.commons.lang.SystemUtils;
-import org.apache.commons.net.util.SubnetUtils;
-import org.apache.log4j.Logger;
-
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
@@ -51,6 +41,18 @@ import java.util.TreeSet;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.commons.lang.SystemUtils;
+import org.apache.commons.net.util.SubnetUtils;
+import org.apache.log4j.Logger;
+
+import com.googlecode.ipv6.IPv6Address;
+import com.googlecode.ipv6.IPv6AddressRange;
+import com.googlecode.ipv6.IPv6Network;
+
+import com.cloud.utils.IteratorUtil;
+import com.cloud.utils.Pair;
+import com.cloud.utils.script.Script;
+
 public class NetUtils {
     protected final static Logger s_logger = Logger.getLogger(NetUtils.class);
     public final static String HTTP_PORT = "80";
@@ -321,6 +323,8 @@ public class NetUtils {
             }
         } catch (SocketException e) {
             s_logger.error("SocketException when trying to retrieve MAC address", e);
+        } finally {
+            formatter.close();
         }
         return sb.toString();
     }
@@ -456,6 +460,7 @@ public class NetUtils {
         StringBuilder result = new StringBuilder(17);
         Formatter formatter = new Formatter(result);
         formatter.format("%02x:%02x:%02x:%02x:%02x:%02x", m[0], m[1], m[2], m[3], m[4], m[5]);
+        formatter.close();
         return result.toString();
     }
 
@@ -464,7 +469,7 @@ public class NetUtils {
         Formatter formatter = new Formatter(result);
         formatter.format("%02x:%02x:%02x:%02x:%02x:%02x", (macAddress >> 40) & 0xff, (macAddress >> 32) & 0xff, (macAddress >> 24) & 0xff, (macAddress >> 16) & 0xff,
                 (macAddress >> 8) & 0xff, (macAddress & 0xff));
-
+        formatter.close();
         return result.toString();
     }
 
@@ -1307,20 +1312,14 @@ public class NetUtils {
         if (ips.length > 1) {
             endIp = ips[1];
         }
-        IPv6Address start, end;
         try {
-            start = IPv6Address.fromString(startIp);
-            end = IPv6Address.fromString(endIp);
-        } catch (IllegalArgumentException ex) {
-            return null;
-        }
-        BigInteger startInt = convertIPv6AddressToBigInteger(start);
-        BigInteger endInt = convertIPv6AddressToBigInteger(end);
-        if (endInt != null) {
-            if (startInt == null || startInt.compareTo(endInt) > 0) {
-                return null;
+            BigInteger startInt = convertIPv6AddressToBigInteger(IPv6Address.fromString(startIp));
+            BigInteger endInt = convertIPv6AddressToBigInteger(IPv6Address.fromString(endIp));
+            if (endInt != null && startInt != null && startInt.compareTo(endInt) <= 0) {
+                return endInt.subtract(startInt).add(BigInteger.ONE);
             }
-            return endInt.subtract(startInt).add(BigInteger.ONE);
+        } catch (IllegalArgumentException ex) {
+            s_logger.error("Failed to convert a string to an IPv6 address", ex);
         }
         return null;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/16de4a71/utils/test/com/cloud/utils/net/NetUtilsTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/net/NetUtilsTest.java b/utils/test/com/cloud/utils/net/NetUtilsTest.java
index 96c3baf..e48faa1 100644
--- a/utils/test/com/cloud/utils/net/NetUtilsTest.java
+++ b/utils/test/com/cloud/utils/net/NetUtilsTest.java
@@ -19,14 +19,6 @@
 
 package com.cloud.utils.net;
 
-import com.googlecode.ipv6.IPv6Address;
-import org.apache.log4j.Logger;
-import org.junit.Test;
-
-import java.math.BigInteger;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
 import static org.hamcrest.Matchers.anyOf;
 import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.equalTo;
@@ -39,6 +31,15 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
+import java.math.BigInteger;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.apache.log4j.Logger;
+import org.junit.Test;
+
+import com.googlecode.ipv6.IPv6Address;
+
 public class NetUtilsTest {
 
     private static final Logger s_logger = Logger.getLogger(NetUtilsTest.class);
@@ -138,8 +139,22 @@ public class NetUtilsTest {
 
     @Test
     public void testCountIp6InRange() {
-        assertEquals(NetUtils.countIp6InRange("1234:5678::1-1234:5678::2"), new BigInteger("2"));
-        assertEquals(NetUtils.countIp6InRange("1234:5678::2-1234:5678::0"), null);
+        assertEquals(new BigInteger("2"), NetUtils.countIp6InRange("1234:5678::1-1234:5678::2"));
+    }
+
+    @Test
+    public void testCountIp6InRangeWithInvalidRange() {
+        assertEquals(null, NetUtils.countIp6InRange("1234:5678::2-1234:5678::0"));
+    }
+
+    @Test
+    public void testCountIp6InRangeWithNullStart() {
+        assertEquals(null, NetUtils.countIp6InRange("-1234:5678::0"));
+    }
+
+    @Test
+    public void testCountIp6InRangeWithNoEnd() {
+        assertEquals(new BigInteger("1"), NetUtils.countIp6InRange("1234:5678::2"));
     }
 
     @Test


[2/2] git commit: updated refs/heads/master to e1d4a32

Posted by hu...@apache.org.
Package name should reflect the location on the filesystem or viseversa


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

Branch: refs/heads/master
Commit: e1d4a329c4bf1201573c15aaf2e0c489db4cafbd
Parents: 16de4a7
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Tue Nov 18 14:12:44 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Tue Nov 18 14:12:44 2014 +0100

----------------------------------------------------------------------
 server/src/com/cloud/server/StatsCollector.java | 61 ++++++++++----------
 .../utils/graphite/GraphiteClient.java          | 12 ++--
 .../utils/graphite/GraphiteException.java       |  2 +-
 3 files changed, 37 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1d4a329/server/src/com/cloud/server/StatsCollector.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/StatsCollector.java b/server/src/com/cloud/server/StatsCollector.java
index cd4475f..1fcaa62 100755
--- a/server/src/com/cloud/server/StatsCollector.java
+++ b/server/src/com/cloud/server/StatsCollector.java
@@ -16,6 +16,8 @@
 // under the License.
 package com.cloud.server;
 
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
@@ -29,9 +31,6 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
-import java.net.URI;
-import java.net.URISyntaxException;
-
 import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
@@ -46,8 +45,8 @@ import org.apache.cloudstack.managed.context.ManagedContextRunnable;
 import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
-import org.apache.cloudstack.graphite.GraphiteClient;
-import org.apache.cloudstack.graphite.GraphiteException;
+import org.apache.cloudstack.utils.graphite.GraphiteClient;
+import org.apache.cloudstack.utils.graphite.GraphiteException;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
@@ -350,7 +349,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
             _usageAggregationRange = USAGE_AGGREGATION_RANGE_MIN;
         }
         _diskStatsUpdateExecutor.scheduleAtFixedRate(new VmDiskStatsUpdaterTask(), (endDate - System.currentTimeMillis()), (_usageAggregationRange * 60 * 1000),
-            TimeUnit.MILLISECONDS);
+                TimeUnit.MILLISECONDS);
 
     }
 
@@ -469,7 +468,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
                                 /**
                                  * Add statistics to HashMap only when they should be send to a external stats collector
                                  * Performance wise it seems best to only append to the HashMap when needed
-                                */
+                                 */
                                 if (externalStatsEnabled) {
                                     VMInstanceVO vmVO = _vmInstance.findById(vmId);
                                     String vmName = vmVO.getUuid();
@@ -586,7 +585,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
                         SearchCriteria<HostVO> sc = _hostDao.createSearchCriteria();
                         sc.addAnd("status", SearchCriteria.Op.EQ, Status.Up.toString());
                         sc.addAnd("resourceState", SearchCriteria.Op.NIN, ResourceState.Maintenance, ResourceState.PrepareForMaintenance,
-                            ResourceState.ErrorInMaintenance);
+                                ResourceState.ErrorInMaintenance);
                         sc.addAnd("type", SearchCriteria.Op.EQ, Host.Type.Routing.toString());
                         sc.addAnd("hypervisorType", SearchCriteria.Op.EQ, HypervisorType.KVM); // support KVM only util 2013.06.25
                         List<HostVO> hosts = _hostDao.search(sc, null);
@@ -618,36 +617,36 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
                                         break;
                                     VolumeVO volume = volumes.get(0);
                                     VmDiskStatisticsVO previousVmDiskStats =
-                                        _vmDiskStatsDao.findBy(userVm.getAccountId(), userVm.getDataCenterId(), vmId, volume.getId());
+                                            _vmDiskStatsDao.findBy(userVm.getAccountId(), userVm.getDataCenterId(), vmId, volume.getId());
                                     VmDiskStatisticsVO vmDiskStat_lock = _vmDiskStatsDao.lock(userVm.getAccountId(), userVm.getDataCenterId(), vmId, volume.getId());
 
                                     if ((vmDiskStat.getBytesRead() == 0) && (vmDiskStat.getBytesWrite() == 0) && (vmDiskStat.getIORead() == 0) &&
-                                        (vmDiskStat.getIOWrite() == 0)) {
+                                            (vmDiskStat.getIOWrite() == 0)) {
                                         s_logger.debug("IO/bytes read and write are all 0. Not updating vm_disk_statistics");
                                         continue;
                                     }
 
                                     if (vmDiskStat_lock == null) {
                                         s_logger.warn("unable to find vm disk stats from host for account: " + userVm.getAccountId() + " with vmId: " + userVm.getId() +
-                                            " and volumeId:" + volume.getId());
+                                                " and volumeId:" + volume.getId());
                                         continue;
                                     }
 
                                     if (previousVmDiskStats != null &&
-                                        ((previousVmDiskStats.getCurrentBytesRead() != vmDiskStat_lock.getCurrentBytesRead()) ||
-                                            (previousVmDiskStats.getCurrentBytesWrite() != vmDiskStat_lock.getCurrentBytesWrite()) ||
-                                            (previousVmDiskStats.getCurrentIORead() != vmDiskStat_lock.getCurrentIORead()) || (previousVmDiskStats.getCurrentIOWrite() != vmDiskStat_lock.getCurrentIOWrite()))) {
+                                            ((previousVmDiskStats.getCurrentBytesRead() != vmDiskStat_lock.getCurrentBytesRead()) ||
+                                                    (previousVmDiskStats.getCurrentBytesWrite() != vmDiskStat_lock.getCurrentBytesWrite()) ||
+                                                    (previousVmDiskStats.getCurrentIORead() != vmDiskStat_lock.getCurrentIORead()) || (previousVmDiskStats.getCurrentIOWrite() != vmDiskStat_lock.getCurrentIOWrite()))) {
                                         s_logger.debug("vm disk stats changed from the time GetVmDiskStatsCommand was sent. " + "Ignoring current answer. Host: " +
-                                            host.getName() + " . VM: " + vmDiskStat.getVmName() + " Read(Bytes): " + vmDiskStat.getBytesRead() + " write(Bytes): " +
-                                            vmDiskStat.getBytesWrite() + " Read(IO): " + vmDiskStat.getIORead() + " write(IO): " + vmDiskStat.getIOWrite());
+                                                host.getName() + " . VM: " + vmDiskStat.getVmName() + " Read(Bytes): " + vmDiskStat.getBytesRead() + " write(Bytes): " +
+                                                vmDiskStat.getBytesWrite() + " Read(IO): " + vmDiskStat.getIORead() + " write(IO): " + vmDiskStat.getIOWrite());
                                         continue;
                                     }
 
                                     if (vmDiskStat_lock.getCurrentBytesRead() > vmDiskStat.getBytesRead()) {
                                         if (s_logger.isDebugEnabled()) {
                                             s_logger.debug("Read # of bytes that's less than the last one.  " +
-                                                "Assuming something went wrong and persisting it. Host: " + host.getName() + " . VM: " + vmDiskStat.getVmName() +
-                                                " Reported: " + vmDiskStat.getBytesRead() + " Stored: " + vmDiskStat_lock.getCurrentBytesRead());
+                                                    "Assuming something went wrong and persisting it. Host: " + host.getName() + " . VM: " + vmDiskStat.getVmName() +
+                                                    " Reported: " + vmDiskStat.getBytesRead() + " Stored: " + vmDiskStat_lock.getCurrentBytesRead());
                                         }
                                         vmDiskStat_lock.setNetBytesRead(vmDiskStat_lock.getNetBytesRead() + vmDiskStat_lock.getCurrentBytesRead());
                                     }
@@ -655,8 +654,8 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
                                     if (vmDiskStat_lock.getCurrentBytesWrite() > vmDiskStat.getBytesWrite()) {
                                         if (s_logger.isDebugEnabled()) {
                                             s_logger.debug("Write # of bytes that's less than the last one.  " +
-                                                "Assuming something went wrong and persisting it. Host: " + host.getName() + " . VM: " + vmDiskStat.getVmName() +
-                                                " Reported: " + vmDiskStat.getBytesWrite() + " Stored: " + vmDiskStat_lock.getCurrentBytesWrite());
+                                                    "Assuming something went wrong and persisting it. Host: " + host.getName() + " . VM: " + vmDiskStat.getVmName() +
+                                                    " Reported: " + vmDiskStat.getBytesWrite() + " Stored: " + vmDiskStat_lock.getCurrentBytesWrite());
                                         }
                                         vmDiskStat_lock.setNetBytesWrite(vmDiskStat_lock.getNetBytesWrite() + vmDiskStat_lock.getCurrentBytesWrite());
                                     }
@@ -664,8 +663,8 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
                                     if (vmDiskStat_lock.getCurrentIORead() > vmDiskStat.getIORead()) {
                                         if (s_logger.isDebugEnabled()) {
                                             s_logger.debug("Read # of IO that's less than the last one.  " + "Assuming something went wrong and persisting it. Host: " +
-                                                host.getName() + " . VM: " + vmDiskStat.getVmName() + " Reported: " + vmDiskStat.getIORead() + " Stored: " +
-                                                vmDiskStat_lock.getCurrentIORead());
+                                                    host.getName() + " . VM: " + vmDiskStat.getVmName() + " Reported: " + vmDiskStat.getIORead() + " Stored: " +
+                                                    vmDiskStat_lock.getCurrentIORead());
                                         }
                                         vmDiskStat_lock.setNetIORead(vmDiskStat_lock.getNetIORead() + vmDiskStat_lock.getCurrentIORead());
                                     }
@@ -673,8 +672,8 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
                                     if (vmDiskStat_lock.getCurrentIOWrite() > vmDiskStat.getIOWrite()) {
                                         if (s_logger.isDebugEnabled()) {
                                             s_logger.debug("Write # of IO that's less than the last one.  " + "Assuming something went wrong and persisting it. Host: " +
-                                                host.getName() + " . VM: " + vmDiskStat.getVmName() + " Reported: " + vmDiskStat.getIOWrite() + " Stored: " +
-                                                vmDiskStat_lock.getCurrentIOWrite());
+                                                    host.getName() + " . VM: " + vmDiskStat.getVmName() + " Reported: " + vmDiskStat.getIOWrite() + " Stored: " +
+                                                    vmDiskStat_lock.getCurrentIOWrite());
                                         }
                                         vmDiskStat_lock.setNetIOWrite(vmDiskStat_lock.getNetIOWrite() + vmDiskStat_lock.getCurrentIOWrite());
                                     }
@@ -726,7 +725,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
                     if (answer != null && answer.getResult()) {
                         storageStats.put(storeId, (StorageStats)answer);
                         s_logger.trace("HostId: " + storeId + " Used: " + ((StorageStats)answer).getByteUsed() + " Total Available: " +
-                            ((StorageStats)answer).getCapacityBytes());
+                                ((StorageStats)answer).getCapacityBytes());
                     }
                 }
                 _storageStats = storageStats;
@@ -787,7 +786,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
                         long now = (new Date()).getTime();
                         if (asGroup.getLastInterval() != null)
                             if ((now - asGroup.getLastInterval().getTime()) < asGroup
-                                .getInterval()) {
+                                    .getInterval()) {
                                 continue;
                             }
 
@@ -966,10 +965,10 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
                                 Double avg = sum / currentVM;
                                 Operator op = conditionVO.getRelationalOperator();
                                 boolean bConditionCheck = ((op == com.cloud.network.as.Condition.Operator.EQ) && (thresholdPercent.equals(avg)))
-                                    || ((op == com.cloud.network.as.Condition.Operator.GE) && (avg.doubleValue() >= thresholdPercent.doubleValue()))
-                                    || ((op == com.cloud.network.as.Condition.Operator.GT) && (avg.doubleValue() > thresholdPercent.doubleValue()))
-                                    || ((op == com.cloud.network.as.Condition.Operator.LE) && (avg.doubleValue() <= thresholdPercent.doubleValue()))
-                                    || ((op == com.cloud.network.as.Condition.Operator.LT) && (avg.doubleValue() < thresholdPercent.doubleValue()));
+                                        || ((op == com.cloud.network.as.Condition.Operator.GE) && (avg.doubleValue() >= thresholdPercent.doubleValue()))
+                                        || ((op == com.cloud.network.as.Condition.Operator.GT) && (avg.doubleValue() > thresholdPercent.doubleValue()))
+                                        || ((op == com.cloud.network.as.Condition.Operator.LE) && (avg.doubleValue() <= thresholdPercent.doubleValue()))
+                                        || ((op == com.cloud.network.as.Condition.Operator.LT) && (avg.doubleValue() < thresholdPercent.doubleValue()));
 
                                 if (!bConditionCheck) {
                                     bValid = false;
@@ -1000,7 +999,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
         }
 
         public List<Pair<String, Integer>> getPairofCounternameAndDuration(
-            long groupId) {
+                long groupId) {
             AutoScaleVmGroupVO groupVo = _asGroupDao.findById(groupId);
             if (groupVo == null)
                 return null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1d4a329/utils/src/org/apache/cloudstack/utils/graphite/GraphiteClient.java
----------------------------------------------------------------------
diff --git a/utils/src/org/apache/cloudstack/utils/graphite/GraphiteClient.java b/utils/src/org/apache/cloudstack/utils/graphite/GraphiteClient.java
index 5dca8cb..6fbd4c3 100644
--- a/utils/src/org/apache/cloudstack/utils/graphite/GraphiteClient.java
+++ b/utils/src/org/apache/cloudstack/utils/graphite/GraphiteClient.java
@@ -17,7 +17,7 @@
 // under the License.
 //
 
-package org.apache.cloudstack.graphite;
+package org.apache.cloudstack.utils.graphite;
 
 import java.io.IOException;
 import java.net.DatagramPacket;
@@ -50,7 +50,7 @@ public class GraphiteClient {
      */
     public GraphiteClient(String graphiteHost) {
         this.graphiteHost = graphiteHost;
-        this.graphitePort = 2003;
+        graphitePort = 2003;
     }
 
     /**
@@ -68,7 +68,7 @@ public class GraphiteClient {
      * @param metrics the metrics as key-value-pairs
      */
     public void sendMetrics(Map<String, Integer> metrics) {
-        sendMetrics(metrics, this.getCurrentSystemTime());
+        sendMetrics(metrics, getCurrentSystemTime());
     }
 
     /**
@@ -80,11 +80,11 @@ public class GraphiteClient {
     public void sendMetrics(Map<String, Integer> metrics, long timeStamp) {
         try {
             DatagramSocket sock = new DatagramSocket();
-            InetAddress addr = InetAddress.getByName(this.graphiteHost);
+            InetAddress addr = InetAddress.getByName(graphiteHost);
 
             for (Map.Entry<String, Integer> metric: metrics.entrySet()) {
                 byte[] message = new String(metric.getKey() + " " + metric.getValue() + " " + timeStamp + "\n").getBytes();
-                DatagramPacket packet = new DatagramPacket(message, message.length, addr, this.graphitePort);
+                DatagramPacket packet = new DatagramPacket(message, message.length, addr, graphitePort);
                 sock.send(packet);
             }
 
@@ -105,7 +105,7 @@ public class GraphiteClient {
      * @throws GraphiteException if sending data to graphite failed
      */
     public void sendMetric(String key, int value) {
-        sendMetric(key, value, this.getCurrentSystemTime());
+        sendMetric(key, value, getCurrentSystemTime());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1d4a329/utils/src/org/apache/cloudstack/utils/graphite/GraphiteException.java
----------------------------------------------------------------------
diff --git a/utils/src/org/apache/cloudstack/utils/graphite/GraphiteException.java b/utils/src/org/apache/cloudstack/utils/graphite/GraphiteException.java
index b11532e..9148764 100644
--- a/utils/src/org/apache/cloudstack/utils/graphite/GraphiteException.java
+++ b/utils/src/org/apache/cloudstack/utils/graphite/GraphiteException.java
@@ -17,7 +17,7 @@
 // under the License.
 //
 
-package org.apache.cloudstack.graphite;
+package org.apache.cloudstack.utils.graphite;
 
 public class GraphiteException extends RuntimeException {