View Javadoc

1   /**
2    *
3    * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4    *
5    * ====================================================================
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   * ====================================================================
18   */
19  package org.jclouds.cloudsigma.domain;
20  
21  
22  /**
23   * 
24   * @author Adrian Cole
25   */
26  public class DriveMetrics {
27     public static class Builder {
28        protected long readBytes;
29        protected long readRequests;
30        protected long writeBytes;
31        protected long writeRequests;
32  
33        public Builder readBytes(long readBytes) {
34           this.readBytes = readBytes;
35           return this;
36        }
37  
38        public Builder readRequests(long readRequests) {
39           this.readRequests = readRequests;
40           return this;
41        }
42  
43        public Builder writeBytes(long writeBytes) {
44           this.writeBytes = writeBytes;
45           return this;
46        }
47  
48        public Builder writeRequests(long writeRequests) {
49           this.writeRequests = writeRequests;
50           return this;
51        }
52  
53        public DriveMetrics build() {
54           return new DriveMetrics(readBytes, readRequests, writeBytes, writeRequests);
55        }
56     }
57  
58     protected final long readBytes;
59     protected final long readRequests;
60     protected final long writeBytes;
61     protected final long writeRequests;
62  
63     public DriveMetrics(long readBytes, long readRequests, long writeBytes, long writeRequests) {
64        this.readBytes = readBytes;
65        this.readRequests = readRequests;
66        this.writeBytes = writeBytes;
67        this.writeRequests = writeRequests;
68     }
69  
70     /**
71      * 
72      * @return Cumulative i/o byte/request count for each drive
73      */
74     public long getReadBytes() {
75        return readBytes;
76     }
77  
78     /**
79      * 
80      * @return Cumulative i/o byte/request count for each drive
81      */
82     public long getReadRequests() {
83        return readRequests;
84     }
85  
86     /**
87      * 
88      * @return Cumulative i/o byte/request count for each drive
89      */
90     public long getWriteBytes() {
91        return writeBytes;
92     }
93  
94     /**
95      * 
96      * @return Cumulative i/o byte/request count for each drive
97      */
98     public long getWriteRequests() {
99        return writeRequests;
100    }
101 
102    @Override
103    public int hashCode() {
104       final int prime = 31;
105       int result = 1;
106       result = prime * result + (int) (readBytes ^ (readBytes >>> 32));
107       result = prime * result + (int) (readRequests ^ (readRequests >>> 32));
108       result = prime * result + (int) (writeBytes ^ (writeBytes >>> 32));
109       result = prime * result + (int) (writeRequests ^ (writeRequests >>> 32));
110       return result;
111    }
112 
113    @Override
114    public boolean equals(Object obj) {
115       if (this == obj)
116          return true;
117       if (obj == null)
118          return false;
119       if (getClass() != obj.getClass())
120          return false;
121       DriveMetrics other = (DriveMetrics) obj;
122       if (readBytes != other.readBytes)
123          return false;
124       if (readRequests != other.readRequests)
125          return false;
126       if (writeBytes != other.writeBytes)
127          return false;
128       if (writeRequests != other.writeRequests)
129          return false;
130       return true;
131    }
132 
133    @Override
134    public String toString() {
135       return "[readBytes=" + readBytes + ", readRequests=" + readRequests + ", writeBytes=" + writeBytes
136             + ", writeRequests=" + writeRequests + "]";
137    }
138 }