PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/hazelcast/src/main/java/com/hazelcast/util/ThreadStats.java

https://bitbucket.org/gabral6_gmailcom/hazelcast
Java | 67 lines | 42 code | 10 blank | 15 comment | 0 complexity | 4f94254deec922cda515d73dc03143e4 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.util;
18
19public class ThreadStats {
20    private final long waitCount;
21    private final long runCount;
22    private final int utilizationPercentage;
23    private final long createMillis;
24    private final boolean running;
25
26    public ThreadStats(int utilizationPercentage, long runCount, long waitCount, boolean running) {
27        this.utilizationPercentage = utilizationPercentage;
28        this.runCount = runCount;
29        this.waitCount = waitCount;
30        this.running = running;
31        this.createMillis = Clock.currentTimeMillis();
32    }
33
34    public long getRunCount() {
35        return runCount;
36    }
37
38    public int getUtilizationPercentage() {
39        return utilizationPercentage;
40    }
41
42    public long getWaitCount() {
43        return waitCount;
44    }
45
46    public long getCreateMillis() {
47        return createMillis;
48    }
49
50    public long getSecondsBetween(long millis) {
51        return (millis - createMillis) / 1000;
52    }
53
54    public boolean isRunning() {
55        return running;
56    }
57
58    @Override
59    public String toString() {
60        return "ThreadStats{" +
61                "utilization=" + utilizationPercentage +
62                ", runs=" + runCount +
63                ", waits=" + waitCount +
64                ", running=" + running +
65                '}';
66    }
67}