PageRenderTime 26ms CodeModel.GetById 20ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/gabral6_gmailcom/hazelcast
Java | 116 lines | 82 code | 19 blank | 15 comment | 0 complexity | b6256c6492fb644275c9871ba7cd7d97 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.LocalSemaphoreOperationStats;
 20
 21import java.io.DataInput;
 22import java.io.DataOutput;
 23import java.io.IOException;
 24
 25public class LocalSemaphoreOperationStatsImpl extends LocalOperationStatsSupport
 26        implements LocalSemaphoreOperationStats {
 27
 28    OperationStat acquires = new OperationStat(0, 0);
 29    OperationStat nonAcquires = new OperationStat(0, 0);
 30    long numberOfRejectedAcquires;
 31    long numberOfPermitsAcquired;
 32    long numberOfPermitsReleased;
 33    long numberOfPermitsAttached;
 34    long numberOfPermitsDetached;
 35    long numberOfPermitsReduced;
 36
 37    void writeDataInternal(DataOutput out) throws IOException {
 38        acquires.writeData(out);
 39        nonAcquires.writeData(out);
 40        out.writeLong(numberOfRejectedAcquires);
 41        out.writeLong(numberOfPermitsAcquired);
 42        out.writeLong(numberOfPermitsReleased);
 43        out.writeLong(numberOfPermitsAttached);
 44        out.writeLong(numberOfPermitsDetached);
 45        out.writeLong(numberOfPermitsReduced);
 46    }
 47
 48    void readDataInternal(DataInput in) throws IOException {
 49        (acquires = new OperationStat()).readData(in);
 50        (nonAcquires = new OperationStat()).readData(in);
 51        numberOfRejectedAcquires = in.readLong();
 52        numberOfPermitsAcquired = in.readLong();
 53        numberOfPermitsReleased = in.readLong();
 54        numberOfPermitsAttached = in.readLong();
 55        numberOfPermitsDetached = in.readLong();
 56        numberOfPermitsReduced = in.readLong();
 57    }
 58
 59    public long total() {
 60        return acquires.count + nonAcquires.count;
 61    }
 62
 63    public long getNumberOfAcquireOps() {
 64        return acquires.count;
 65    }
 66
 67    public long getNumberOfNonAcquireOps() {
 68        return nonAcquires.count;
 69    }
 70
 71    public long getTotalAcquireLatency() {
 72        return acquires.totalLatency;
 73    }
 74
 75    public long getTotalNonAcquireLatency() {
 76        return nonAcquires.totalLatency;
 77    }
 78
 79    public long getNumberOfRejectedAcquires() {
 80        return numberOfRejectedAcquires;
 81    }
 82
 83    public long getNumberOfPermitsAcquired() {
 84        return numberOfPermitsAcquired;
 85    }
 86
 87    public long getNumberOfPermitsReduced() {
 88        return numberOfPermitsReduced;
 89    }
 90
 91    public long getNumberOfPermitsReleased() {
 92        return numberOfPermitsReleased;
 93    }
 94
 95    public long getNumberOfAttachedPermits() {
 96        return numberOfPermitsAttached;
 97    }
 98
 99    public long getNumberOfDetachedPermits() {
100        return numberOfPermitsDetached;
101    }
102
103    public String toString() {
104        return "LocalSemaphoreOperationStats{" +
105                "total= " + total() +
106                ", acquires total:" + acquires +
107                ", acquires rejected:" + numberOfRejectedAcquires +
108                ", non-acquires:" + nonAcquires +
109                ", permits acquired: " + numberOfPermitsAcquired +
110                ", permits released: " + numberOfPermitsReleased +
111                ", permits attached: " + numberOfPermitsAttached +
112                ", permits detached: " + numberOfPermitsDetached +
113                ", permits reduced: " + numberOfPermitsReduced +
114                "}";
115    }
116}