OutputStreamStatistics.java
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.fs.aliyun.oss.statistics.impl;
import org.apache.hadoop.fs.aliyun.oss.statistics.BlockOutputStreamStatistics;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
/**
* Implementation of {@link BlockOutputStreamStatistics}.
*/
public class OutputStreamStatistics implements BlockOutputStreamStatistics {
private final AtomicInteger blocksAllocated = new AtomicInteger(0);
private final AtomicInteger blocksReleased = new AtomicInteger(0);
private final AtomicInteger diskBlocksAllocated = new AtomicInteger(0);
private final AtomicInteger diskBlocksReleased = new AtomicInteger(0);
private final AtomicLong bytesAllocated = new AtomicLong(0);
private final AtomicLong bytesReleased = new AtomicLong(0);
@Override
public void blockAllocated() {
blocksAllocated.incrementAndGet();
}
@Override
public void blockReleased() {
blocksReleased.incrementAndGet();
}
@Override
public void diskBlockAllocated() {
diskBlocksAllocated.incrementAndGet();
}
@Override
public void diskBlockReleased() {
diskBlocksReleased.incrementAndGet();
}
@Override
public int getBlocksAllocated() {
return blocksAllocated.get();
}
@Override
public int getBlocksReleased() {
return blocksReleased.get();
}
@Override
public int getDiskBlocksAllocated() {
return diskBlocksAllocated.get();
}
@Override
public int getDiskBlocksReleased() {
return diskBlocksReleased.get();
}
@Override
public void bytesAllocated(long size) {
bytesAllocated.getAndAdd(size);
}
@Override
public void bytesReleased(long size) {
bytesReleased.getAndAdd(size);
}
@Override
public long getBytesAllocated() {
return bytesAllocated.get();
}
@Override
public long getBytesReleased() {
return bytesReleased.get();
}
}