cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [2/2] git commit: updated refs/heads/master to e1d4a32
Date Tue, 18 Nov 2014 13:14:15 GMT
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 <htrippaers@schubergphilis.com>
Authored: Tue Nov 18 14:12:44 2014 +0100
Committer: Hugo Trippaers <htrippaers@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 {
 


Mime
View raw message