PageRenderTime 29ms CodeModel.GetById 12ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

/hazelcast/src/main/java/com/hazelcast/impl/monitor/LocalMapStatsImpl.java

https://bitbucket.org/gabral6_gmailcom/hazelcast
Java | 240 lines | 182 code | 40 blank | 18 comment | 0 complexity | cf1bfd4b1c15012b32b98bd8d08fe9c4 MD5 | raw file
  1/*
  2 * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
  3 *
  4 * Licensed under the Apache License, Version 2.0 (the "License");
  5 * you may not use this file except in compliance with the License.
  6 * You may obtain a copy of the License at
  7 *
  8 * http://www.apache.org/licenses/LICENSE-2.0
  9 *
 10 * Unless required by applicable law or agreed to in writing, software
 11 * distributed under the License is distributed on an "AS IS" BASIS,
 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 * See the License for the specific language governing permissions and
 14 * limitations under the License.
 15 */
 16
 17package com.hazelcast.impl.monitor;
 18
 19import com.hazelcast.monitor.LocalMapOperationStats;
 20import com.hazelcast.monitor.LocalMapStats;
 21
 22import java.io.DataInput;
 23import java.io.DataOutput;
 24import java.io.IOException;
 25import java.util.concurrent.atomic.AtomicLong;
 26
 27public class LocalMapStatsImpl extends LocalInstanceStatsSupport<LocalMapOperationStats> implements LocalMapStats {
 28    private final AtomicLong lastAccessTime = new AtomicLong();
 29    private final AtomicLong hits = new AtomicLong();
 30    private final AtomicLong misses = new AtomicLong();
 31    private long ownedEntryCount;
 32    private long backupEntryCount;
 33    private long markedAsRemovedEntryCount;
 34    private long ownedEntryMemoryCost;
 35    private long backupEntryMemoryCost;
 36    private long markedAsRemovedMemoryCost;
 37    private long creationTime;
 38    private long lastUpdateTime;
 39    private long lastEvictionTime;
 40    private long lockedEntryCount;
 41    private long lockWaitCount;
 42    private long dirtyEntryCount;
 43
 44    enum Op {
 45        CREATE,
 46        READ,
 47        UPDATE,
 48        REMOVE,
 49        LOCK,
 50        UNLOCK,
 51        ADD_LOCK_WAIT,
 52        REMOVE_LOCK_WAIT
 53    }
 54
 55    public LocalMapStatsImpl() {
 56    }
 57
 58    void writeDataInternal(DataOutput out) throws IOException {
 59        out.writeLong(lastAccessTime.get());
 60        out.writeLong(hits.get());
 61//        out.writeLong(misses.get());
 62        out.writeLong(ownedEntryCount);
 63        out.writeLong(backupEntryCount);
 64        out.writeLong(markedAsRemovedEntryCount);
 65        out.writeLong(ownedEntryMemoryCost);
 66        out.writeLong(backupEntryMemoryCost);
 67        out.writeLong(markedAsRemovedMemoryCost);
 68        out.writeLong(creationTime);
 69        out.writeLong(lastUpdateTime);
 70        out.writeLong(lastEvictionTime);
 71        out.writeLong(lockedEntryCount);
 72        out.writeLong(lockWaitCount);
 73        out.writeLong(dirtyEntryCount);
 74    }
 75
 76    void readDataInternal(DataInput in) throws IOException {
 77        lastAccessTime.set(in.readLong());
 78        hits.set(in.readLong());
 79//        misses.set(in.readLong());
 80        ownedEntryCount = in.readLong();
 81        backupEntryCount = in.readLong();
 82        markedAsRemovedEntryCount = in.readLong();
 83        ownedEntryMemoryCost = in.readLong();
 84        backupEntryMemoryCost = in.readLong();
 85        markedAsRemovedMemoryCost = in.readLong();
 86        creationTime = in.readLong();
 87        lastUpdateTime = in.readLong();
 88        lastEvictionTime = in.readLong();
 89        lockedEntryCount = in.readLong();
 90        lockWaitCount = in.readLong();
 91        dirtyEntryCount = in.readLong();
 92    }
 93
 94    @Override
 95    LocalMapOperationStats newOperationStatsInstance() {
 96        return new LocalMapOperationStatsImpl();
 97    }
 98
 99    public long getOwnedEntryCount() {
100        return ownedEntryCount;
101    }
102
103    public void setOwnedEntryCount(long ownedEntryCount) {
104        this.ownedEntryCount = ownedEntryCount;
105    }
106
107    public long getBackupEntryCount() {
108        return backupEntryCount;
109    }
110
111    public void setBackupEntryCount(long backupEntryCount) {
112        this.backupEntryCount = backupEntryCount;
113    }
114
115    public long getMarkedAsRemovedEntryCount() {
116        return markedAsRemovedEntryCount;
117    }
118
119    public void setMarkedAsRemovedEntryCount(long markedAsRemovedEntryCount) {
120        this.markedAsRemovedEntryCount = markedAsRemovedEntryCount;
121    }
122
123    public long getOwnedEntryMemoryCost() {
124        return ownedEntryMemoryCost;
125    }
126
127    public void setOwnedEntryMemoryCost(long ownedEntryMemoryCost) {
128        this.ownedEntryMemoryCost = ownedEntryMemoryCost;
129    }
130
131    public long getBackupEntryMemoryCost() {
132        return backupEntryMemoryCost;
133    }
134
135    public void setBackupEntryMemoryCost(long backupEntryMemoryCost) {
136        this.backupEntryMemoryCost = backupEntryMemoryCost;
137    }
138
139    public long getMarkedAsRemovedMemoryCost() {
140        return markedAsRemovedMemoryCost;
141    }
142
143    public void setMarkedAsRemovedMemoryCost(long markedAsRemovedMemoryCost) {
144        this.markedAsRemovedMemoryCost = markedAsRemovedMemoryCost;
145    }
146
147    public long getCreationTime() {
148        return creationTime;
149    }
150
151    public void setCreationTime(long creationTime) {
152        this.creationTime = creationTime;
153    }
154
155    public long getLastAccessTime() {
156        return lastAccessTime.get();
157    }
158
159    public void setLastAccessTime(long lastAccessTime) {
160        this.lastAccessTime.set(Math.max(this.lastAccessTime.get(), lastAccessTime));
161    }
162
163    public long getLastUpdateTime() {
164        return lastUpdateTime;
165    }
166
167    public void setLastUpdateTime(long lastUpdateTime) {
168        this.lastUpdateTime = Math.max(this.lastUpdateTime, lastUpdateTime);
169    }
170
171    public long getLastEvictionTime() {
172        return lastEvictionTime;
173    }
174
175    public void setLastEvictionTime(long lastEvictionTime) {
176        this.lastEvictionTime = lastEvictionTime;
177    }
178
179    public long getHits() {
180        return hits.get();
181    }
182
183    public void setHits(long hits) {
184        this.hits.set(hits);
185    }
186
187    public long getMisses() {
188        return misses.get();
189    }
190
191    public void setMisses(long misses) {
192        this.misses.set(misses);
193    }
194
195    public long getLockedEntryCount() {
196        return lockedEntryCount;
197    }
198
199    public void setLockedEntryCount(long lockedEntryCount) {
200        this.lockedEntryCount = lockedEntryCount;
201    }
202
203    public long getLockWaitCount() {
204        return lockWaitCount;
205    }
206
207    public void setLockWaitCount(long lockWaitCount) {
208        this.lockWaitCount = lockWaitCount;
209    }
210
211    public long getDirtyEntryCount() {
212        return dirtyEntryCount;
213    }
214
215    public void setDirtyEntryCount(long l) {
216        this.dirtyEntryCount = l;
217    }
218
219    @Override
220    public String toString() {
221        return "LocalMapStatsImpl{" +
222                "ownedEntryCount=" + ownedEntryCount +
223                ", backupEntryCount=" + backupEntryCount +
224                ", markedAsRemovedEntryCount=" + markedAsRemovedEntryCount +
225                ", ownedEntryMemoryCost=" + ownedEntryMemoryCost +
226                ", backupEntryMemoryCost=" + backupEntryMemoryCost +
227                ", markedAsRemovedMemoryCost=" + markedAsRemovedMemoryCost +
228                ", creationTime=" + creationTime +
229                ", lastAccessTime=" + lastAccessTime.get() +
230                ", lastUpdateTime=" + lastUpdateTime +
231                ", lastEvictionTime=" + lastEvictionTime +
232                ", hits=" + hits.get() +
233//                ", misses=" + misses.get() +
234                ", lockedEntryCount=" + lockedEntryCount +
235                ", lockWaitCount=" + lockWaitCount +
236                ", dirtyEntryCount=" + dirtyEntryCount +
237                ", " + operationStats +
238                '}';
239    }
240}