Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Removes WalrusStatistics and the walrus-stats.log file. Fixes EUCA-4724.

WalrusStatistics and StorageStatistics are no longer used since reporting
has become the source for usage. The log files are no longer needed.
  • Loading branch information...
commit 0deaa6f04460acb369ac968a55fc495bdebaac73 1 parent 43d4bbc
Zach Hill zhill authored
151 clc/modules/core/src/main/java/edu/ucsb/eucalyptus/cloud/entities/StorageStatsInfo.java
... ... @@ -1,151 +0,0 @@
1   -/*************************************************************************
2   - * Copyright 2009-2012 Eucalyptus Systems, Inc.
3   - *
4   - * This program is free software: you can redistribute it and/or modify
5   - * it under the terms of the GNU General Public License as published by
6   - * the Free Software Foundation; version 3 of the License.
7   - *
8   - * This program is distributed in the hope that it will be useful,
9   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11   - * GNU General Public License for more details.
12   - *
13   - * You should have received a copy of the GNU General Public License
14   - * along with this program. If not, see http://www.gnu.org/licenses/.
15   - *
16   - * Please contact Eucalyptus Systems, Inc., 6755 Hollister Ave., Goleta
17   - * CA 93117, USA or visit http://www.eucalyptus.com/licenses/ if you need
18   - * additional information or have any questions.
19   - *
20   - * This file may incorporate work covered under the following copyright
21   - * and permission notice:
22   - *
23   - * Software License Agreement (BSD License)
24   - *
25   - * Copyright (c) 2008, Regents of the University of California
26   - * All rights reserved.
27   - *
28   - * Redistribution and use of this software in source and binary forms,
29   - * with or without modification, are permitted provided that the
30   - * following conditions are met:
31   - *
32   - * Redistributions of source code must retain the above copyright
33   - * notice, this list of conditions and the following disclaimer.
34   - *
35   - * Redistributions in binary form must reproduce the above copyright
36   - * notice, this list of conditions and the following disclaimer
37   - * in the documentation and/or other materials provided with the
38   - * distribution.
39   - *
40   - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41   - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42   - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
43   - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
44   - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
45   - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
46   - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47   - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
48   - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49   - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
50   - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
51   - * POSSIBILITY OF SUCH DAMAGE. USERS OF THIS SOFTWARE ACKNOWLEDGE
52   - * THE POSSIBLE PRESENCE OF OTHER OPEN SOURCE LICENSED MATERIAL,
53   - * COPYRIGHTED MATERIAL OR PATENTED MATERIAL IN THIS SOFTWARE,
54   - * AND IF ANY SUCH MATERIAL IS DISCOVERED THE PARTY DISCOVERING
55   - * IT MAY INFORM DR. RICH WOLSKI AT THE UNIVERSITY OF CALIFORNIA,
56   - * SANTA BARBARA WHO WILL THEN ASCERTAIN THE MOST APPROPRIATE REMEDY,
57   - * WHICH IN THE REGENTS' DISCRETION MAY INCLUDE, WITHOUT LIMITATION,
58   - * REPLACEMENT OF THE CODE SO IDENTIFIED, LICENSING OF THE CODE SO
59   - * IDENTIFIED, OR WITHDRAWAL OF THE CODE CAPABILITY TO THE EXTENT
60   - * NEEDED TO COMPLY WITH ANY SUCH LICENSES OR RIGHTS.
61   - ************************************************************************/
62   -
63   -package edu.ucsb.eucalyptus.cloud.entities;
64   -
65   -import javax.persistence.Column;
66   -import org.hibernate.annotations.Entity;
67   -import javax.persistence.GeneratedValue;
68   -import javax.persistence.Id;
69   -import javax.persistence.PersistenceContext;
70   -import javax.persistence.Table;
71   -import org.hibernate.annotations.Cache;
72   -import org.hibernate.annotations.CacheConcurrencyStrategy;
73   -import com.eucalyptus.entities.AbstractPersistent;
74   -
75   -@Entity @javax.persistence.Entity
76   -@PersistenceContext(name="eucalyptus_storage")
77   -@Table( name = "storage_stats_info" )
78   -@Cache( usage = CacheConcurrencyStrategy.TRANSACTIONAL )
79   -public class StorageStatsInfo extends AbstractPersistent {
80   - @Column(name = "storage_name")
81   - private String name;
82   - @Column( name = "number_volumes" )
83   - private Integer numberOfVolumes;
84   - @Column( name = "total_space_used" )
85   - private Long totalSpaceUsed;
86   -
87   - public StorageStatsInfo() {}
88   -
89   - public StorageStatsInfo(final String name) {
90   - this.name = name;
91   - }
92   -
93   - public StorageStatsInfo(final String name,
94   - Integer numberOfVolumes,
95   - Long totalSpaceUsed) {
96   - this.name = name;
97   - this.numberOfVolumes = numberOfVolumes;
98   - this.totalSpaceUsed = totalSpaceUsed;
99   - }
100   -
101   - public String getName() {
102   - return name;
103   - }
104   -
105   - public void setName(String name) {
106   - this.name = name;
107   - }
108   -
109   - public Integer getNumberOfVolumes() {
110   - return numberOfVolumes;
111   - }
112   -
113   - public void setNumberOfVolumes(Integer numberOfVolumes) {
114   - this.numberOfVolumes = numberOfVolumes;
115   - }
116   -
117   - public Long getTotalSpaceUsed() {
118   - return totalSpaceUsed;
119   - }
120   -
121   - public void setTotalSpaceUsed(Long totalSpaceUsed) {
122   - this.totalSpaceUsed = totalSpaceUsed;
123   - }
124   -
125   - @Override
126   - public int hashCode() {
127   - final int prime = 31;
128   - int result = 1;
129   - result = prime * result + ((name == null) ? 0 : name.hashCode());
130   - return result;
131   - }
132   -
133   - @Override
134   - public boolean equals(Object obj) {
135   - if (this == obj)
136   - return true;
137   - if (obj == null)
138   - return false;
139   - if (getClass() != obj.getClass())
140   - return false;
141   - StorageStatsInfo other = (StorageStatsInfo) obj;
142   - if (name == null) {
143   - if (other.name != null)
144   - return false;
145   - } else if (!name.equals(other.name))
146   - return false;
147   - return true;
148   - }
149   -
150   -
151   -}
24 clc/modules/core/src/main/resources/log4j.xml
@@ -127,22 +127,6 @@
127 127 <param name="ConversionPattern" value="%d{EEE MMM d HH:mm:ss yyyy} %5p [%C.%M(%F):%L] %m%n" />
128 128 </layout>
129 129 </appender>
130   - <appender name="walrus-stats-log" class="org.apache.log4j.RollingFileAppender">
131   - <param name="File" value="${euca.log.dir}/walrus-stats.log" />
132   - <param name="MaxFileSize" value="10MB" />
133   - <param name="MaxBackupIndex" value="10" />
134   - <layout class="org.apache.log4j.PatternLayout">
135   - <param name="ConversionPattern" value="Timestamp: %d{ISO8601} %m%n" />
136   - </layout>
137   - </appender>
138   - <appender name="sc-stats-log" class="org.apache.log4j.RollingFileAppender">
139   - <param name="File" value="${euca.log.dir}/sc-stats.log" />
140   - <param name="MaxFileSize" value="10MB" />
141   - <param name="MaxBackupIndex" value="10" />
142   - <layout class="org.apache.log4j.PatternLayout">
143   - <param name="ConversionPattern" value="Timestamp: %d{ISO8601} %m%n" />
144   - </layout>
145   - </appender>
146 130 <appender name="upgrade" class="org.apache.log4j.FileAppender">
147 131 <param name="File" value="${euca.log.dir}/upgrade.log" />
148 132 <layout class="org.apache.log4j.PatternLayout">
@@ -312,14 +296,6 @@
312 296 <priority value="FATAL" />
313 297 <appender-ref ref="cloud-exhaust" />
314 298 </category>
315   - <category name="edu.ucsb.eucalyptus.cloud.ws.WalrusStatistics" additivity="true">
316   - <priority value="INFO" />
317   - <appender-ref ref="walrus-stats-log" />
318   - </category>
319   - <category name="edu.ucsb.eucalyptus.cloud.ws.BlockStorageStatistics" additivity="true">
320   - <priority value="INFO" />
321   - <appender-ref ref="sc-stats-log" />
322   - </category>
323 299 <category name="org.apache.commons.httpclient" additivity="true">
324 300 <priority value="ERROR" />
325 301 <appender-ref ref="${euca.log.appender}" />
38 clc/modules/walrus/src/main/java/edu/ucsb/eucalyptus/cloud/ws/WalrusManager.java
@@ -232,11 +232,8 @@
232 232
233 233 private StorageManager storageManager;
234 234 private WalrusImageManager walrusImageManager;
235   - private static WalrusStatistics walrusStatistics = null;
236 235
237   - public static void configure() {
238   - walrusStatistics = new WalrusStatistics();
239   - }
  236 + public static void configure() {}
240 237
241 238 public WalrusManager(StorageManager storageManager, WalrusImageManager walrusImageManager) {
242 239 this.storageManager = storageManager;
@@ -439,9 +436,6 @@ public CreateBucketResponseType createBucket(CreateBucketType request)
439 436 db.add(bucket);
440 437 db.commit();
441 438 storageManager.createBucket(bucketName);
442   - if (WalrusProperties.trackUsageStatistics)
443   - walrusStatistics.incrementBucketCount();
444   -
445 439 } catch (IOException ex) {
446 440 LOG.error(ex, ex);
447 441 throw new BucketAlreadyExistsException(bucketName);
@@ -558,10 +552,7 @@ public DeleteBucketResponseType deleteBucket(DeleteBucketType request) throws Eu
558 552 // Actually remove the bucket from the backing store
559 553 try {
560 554 storageManager.deleteBucket(bucketName);
561   - if (WalrusProperties.trackUsageStatistics) {
562   - walrusStatistics.decrementBucketCount();
563   - }
564   -
  555 +
565 556 /* Send an event to reporting to report this S3 usage. */
566 557
567 558 //fireBucketUsageEvent(S3BucketAction.BUCKETDELETE, bucketFound.getNaturalId(),
@@ -1025,10 +1016,6 @@ public PutObjectResponseType putObject(PutObjectType request) throws EucalyptusC
1025 1016 foundObject.setDeleted(false);
1026 1017 reply.setSize(size);
1027 1018
1028   - if (WalrusProperties.trackUsageStatistics) {
1029   - walrusStatistics.updateBytesIn(size);
1030   - walrusStatistics.updateSpaceUsed(size);
1031   - }
1032 1019 if (logData != null) {
1033 1020 logData.setObjectSize(size);
1034 1021 updateLogData(bucket, logData);
@@ -1408,10 +1395,6 @@ public PutObjectInlineResponseType putObjectInline(
1408 1395 foundObject.setEtag(md5);
1409 1396 foundObject.setSize(size);
1410 1397
1411   - if (WalrusProperties.trackUsageStatistics) {
1412   - walrusStatistics.updateBytesIn(size);
1413   - walrusStatistics.updateSpaceUsed(size);
1414   - }
1415 1398 // Add meta data if specified
1416 1399 if (request.getMetaData() != null)
1417 1400 foundObject.replaceMetaData(request.getMetaData());
@@ -1736,7 +1719,6 @@ public void run() {
1736 1719 try {
1737 1720 storageManager.deleteObject(bucketName, objectName);
1738 1721 if (WalrusProperties.trackUsageStatistics && (size > 0))
1739   - walrusStatistics.updateSpaceUsed(-size);
1740 1722
1741 1723 /* Send an event to reporting to report this S3 usage. */
1742 1724 if ( size > 0 ) {
@@ -2494,9 +2476,7 @@ public GetObjectResponseType getObject(GetObjectType request) throws EucalyptusC
2494 2476 + ".torrent;", request
2495 2477 .getIsCompressed(),
2496 2478 null, logData);
2497   - if (WalrusProperties.trackUsageStatistics) {
2498   - walrusStatistics.updateBytesOut(torrentLength);
2499   - }
  2479 +
2500 2480 return null;
2501 2481 } else {
2502 2482 //No torrent exists
@@ -2553,9 +2533,6 @@ public GetObjectResponseType getObject(GetObjectType request) throws EucalyptusC
2553 2533 //fireUsageEvent For Get Object
2554 2534 } else {
2555 2535 // support for large objects
2556   - if (WalrusProperties.trackUsageStatistics) {
2557   - walrusStatistics.updateBytesOut(objectInfo.getSize());
2558   - }
2559 2536 storageManager.sendObject(request,
2560 2537 httpResponse, bucketName, objectName, size,
2561 2538 etag, DateUtils.format(lastModified
@@ -2759,9 +2736,6 @@ public GetObjectExtendedResponseType getObjectExtended(GetObjectExtendedType req
2759 2736 : WalrusProperties.NULL_VERSION_ID;
2760 2737 }
2761 2738 if (request.getGetData()) {
2762   - if (WalrusProperties.trackUsageStatistics) {
2763   - walrusStatistics.updateBytesOut(size);
2764   - }
2765 2739 storageManager.sendObject(request,
2766 2740 httpResponse, bucketName, objectName,
2767 2741 byteRangeStart, byteRangeEnd + 1, size, etag,
@@ -3048,10 +3022,6 @@ public CopyObjectResponseType copyObject(CopyObjectType request)
3048 3022 storageManager.copyObject(sourceBucket,
3049 3023 sourceObjectName, destinationBucket,
3050 3024 destinationObjectName);
3051   - if (WalrusProperties.trackUsageStatistics)
3052   - walrusStatistics
3053   - .updateSpaceUsed(sourceObjectInfo
3054   - .getSize());
3055 3025 } catch (Exception ex) {
3056 3026 LOG.error(ex);
3057 3027 db.rollback();
@@ -3768,8 +3738,6 @@ public void fastDeleteBucket(DeleteBucketType request) throws EucalyptusCloudExc
3768 3738 // Actually remove the bucket from the backing store
3769 3739 try {
3770 3740 storageManager.deleteBucket(bucketName);
3771   - if (WalrusProperties.trackUsageStatistics)
3772   - walrusStatistics.decrementBucketCount();
3773 3741 } catch (IOException ex) {
3774 3742 // set exception code in reply
3775 3743 LOG.error(ex);
164 clc/modules/walrus/src/main/java/edu/ucsb/eucalyptus/cloud/ws/WalrusStatistics.java
... ... @@ -1,164 +0,0 @@
1   -/*************************************************************************
2   - * Copyright 2009-2012 Eucalyptus Systems, Inc.
3   - *
4   - * This program is free software: you can redistribute it and/or modify
5   - * it under the terms of the GNU General Public License as published by
6   - * the Free Software Foundation; version 3 of the License.
7   - *
8   - * This program is distributed in the hope that it will be useful,
9   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11   - * GNU General Public License for more details.
12   - *
13   - * You should have received a copy of the GNU General Public License
14   - * along with this program. If not, see http://www.gnu.org/licenses/.
15   - *
16   - * Please contact Eucalyptus Systems, Inc., 6755 Hollister Ave., Goleta
17   - * CA 93117, USA or visit http://www.eucalyptus.com/licenses/ if you need
18   - * additional information or have any questions.
19   - *
20   - * This file may incorporate work covered under the following copyright
21   - * and permission notice:
22   - *
23   - * Software License Agreement (BSD License)
24   - *
25   - * Copyright (c) 2008, Regents of the University of California
26   - * All rights reserved.
27   - *
28   - * Redistribution and use of this software in source and binary forms,
29   - * with or without modification, are permitted provided that the
30   - * following conditions are met:
31   - *
32   - * Redistributions of source code must retain the above copyright
33   - * notice, this list of conditions and the following disclaimer.
34   - *
35   - * Redistributions in binary form must reproduce the above copyright
36   - * notice, this list of conditions and the following disclaimer
37   - * in the documentation and/or other materials provided with the
38   - * distribution.
39   - *
40   - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41   - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42   - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
43   - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
44   - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
45   - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
46   - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47   - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
48   - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49   - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
50   - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
51   - * POSSIBILITY OF SUCH DAMAGE. USERS OF THIS SOFTWARE ACKNOWLEDGE
52   - * THE POSSIBLE PRESENCE OF OTHER OPEN SOURCE LICENSED MATERIAL,
53   - * COPYRIGHTED MATERIAL OR PATENTED MATERIAL IN THIS SOFTWARE,
54   - * AND IF ANY SUCH MATERIAL IS DISCOVERED THE PARTY DISCOVERING
55   - * IT MAY INFORM DR. RICH WOLSKI AT THE UNIVERSITY OF CALIFORNIA,
56   - * SANTA BARBARA WHO WILL THEN ASCERTAIN THE MOST APPROPRIATE REMEDY,
57   - * WHICH IN THE REGENTS' DISCRETION MAY INCLUDE, WITHOUT LIMITATION,
58   - * REPLACEMENT OF THE CODE SO IDENTIFIED, LICENSING OF THE CODE SO
59   - * IDENTIFIED, OR WITHDRAWAL OF THE CODE CAPABILITY TO THE EXTENT
60   - * NEEDED TO COMPLY WITH ANY SUCH LICENSES OR RIGHTS.
61   - ************************************************************************/
62   -
63   -package edu.ucsb.eucalyptus.cloud.ws;
64   -
65   -import org.apache.log4j.Logger;
66   -
67   -import com.eucalyptus.entities.EntityWrapper;
68   -import com.eucalyptus.util.EucalyptusCloudException;
69   -import com.eucalyptus.util.WalrusProperties;
70   -
71   -import edu.ucsb.eucalyptus.cloud.entities.WalrusStatsInfo;
72   -import edu.ucsb.eucalyptus.msgs.WalrusUsageStatsRecord;
73   -
74   -public class WalrusStatistics {
75   - private Logger LOG = Logger.getLogger( WalrusStatistics.class );
76   - private Long totalBytesIn;
77   - private Long totalBytesOut;
78   - private Long totalSpaceUsed;
79   - private Integer numberOfBuckets;
80   -
81   - public WalrusStatistics() {
82   - totalBytesIn = 0L;
83   - totalBytesOut = 0L;
84   - totalSpaceUsed = 0L;
85   - numberOfBuckets = 0;
86   - getStateInfo();
87   - dump();
88   - }
89   -
90   - public void updateBytesIn(Long bytes) {
91   - totalBytesIn += bytes;
92   - dump();
93   - }
94   -
95   - public void updateBytesOut(Long bytes) {
96   - totalBytesOut += bytes;
97   - dump();
98   - }
99   -
100   - public void updateSpaceUsed(Long bytes) {
101   - totalSpaceUsed += bytes;
102   - updateStateInfo();
103   - dump();
104   - }
105   -
106   - public void incrementBucketCount() {
107   - numberOfBuckets++;
108   - updateStateInfo();
109   - dump();
110   - }
111   -
112   - public void decrementBucketCount() {
113   - numberOfBuckets--;
114   - updateStateInfo();
115   - dump();
116   - }
117   -
118   - public void resetBytesIn() {
119   - totalBytesIn = 0L;
120   - }
121   -
122   - public void resetBytesOut() {
123   - totalBytesOut = 0L;
124   - }
125   -
126   - public void dump() {
127   - LOG.info(WalrusUsageStatsRecord.create(totalBytesIn, totalBytesOut, numberOfBuckets, totalSpaceUsed));
128   - }
129   -
130   - private void getStateInfo() {
131   - EntityWrapper<WalrusStatsInfo> db = EntityWrapper.get(WalrusStatsInfo.class);
132   - try {
133   - WalrusStatsInfo walrusStats = db.getUnique(new WalrusStatsInfo(WalrusProperties.NAME));
134   - numberOfBuckets = walrusStats.getNumberOfBuckets();
135   - totalSpaceUsed = walrusStats.getTotalSpaceUsed();
136   - } catch(EucalyptusCloudException ex) {
137   - WalrusStatsInfo walrusStats = new WalrusStatsInfo(WalrusProperties.NAME,
138   - numberOfBuckets,
139   - totalSpaceUsed);
140   - db.add(walrusStats);
141   - }
142   - db.commit();
143   - }
144   -
145   - private void updateStateInfo() {
146   - EntityWrapper<WalrusStatsInfo> db = EntityWrapper.get(WalrusStatsInfo.class);
147   - try {
148   - WalrusStatsInfo walrusStats = db.getUnique(new WalrusStatsInfo(WalrusProperties.NAME));
149   - walrusStats.setNumberOfBuckets(numberOfBuckets);
150   - walrusStats.setTotalSpaceUsed(totalSpaceUsed);
151   - } catch(EucalyptusCloudException ex) {
152   - WalrusStatsInfo walrusStats = new WalrusStatsInfo(WalrusProperties.NAME,
153   - numberOfBuckets,
154   - totalSpaceUsed);
155   - db.add(walrusStats);
156   - }
157   - try {
158   - db.commit();
159   - } catch(Exception ex) {
160   - //log it and ignore it
161   - LOG.error(ex);
162   - }
163   - }
164   -}

0 comments on commit 0deaa6f

Please sign in to comment.
Something went wrong with that request. Please try again.