Skip to content

Commit

Permalink
Cleanup for statistics (#1125)
Browse files Browse the repository at this point in the history
* Cleanup for statistics

* fixing test

* fixing mvn spotless:apply
  • Loading branch information
guljain committed Mar 14, 2024
1 parent b0fff1c commit fb30864
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 380 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,6 @@
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.DIRECTORIES_CREATED;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.FILES_CREATED;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.FILES_DELETED;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.FILES_DELETE_REJECTED;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.INVOCATION_COPY_FROM_LOCAL_FILE;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.INVOCATION_EXISTS;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.INVOCATION_GET_DELEGATION_TOKEN;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.INVOCATION_GET_FILE_CHECKSUM;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.INVOCATION_GET_FILE_STATUS;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.INVOCATION_GLOB_STATUS;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.INVOCATION_LIST_FILES;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.INVOCATION_LIST_LOCATED_STATUS;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.INVOCATION_LIST_STATUS;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.INVOCATION_MKDIRS;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.STREAM_READ_EXCEPTIONS;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.STREAM_READ_OPERATIONS;
import static com.google.cloud.hadoop.fs.gcs.GhfsStatistic.STREAM_READ_SEEK_OPERATIONS;
import static com.google.cloud.hadoop.gcsio.GoogleCloudStorageStatistics.EXCEPTION_COUNT;
import static com.google.cloud.hadoop.gcsio.GoogleCloudStorageStatistics.GCS_CLIENT_RATE_LIMIT_COUNT;
import static com.google.cloud.hadoop.gcsio.GoogleCloudStorageStatistics.GCS_CLIENT_SIDE_ERROR_COUNT;
Expand Down Expand Up @@ -334,14 +320,6 @@ void streamReadOperationInComplete(int requested, int actual) {
}
}

void streamReadOperations() {
incrementCounter(STREAM_READ_OPERATIONS, 1);
}

void streamReadSeekOperations() {
incrementCounter(STREAM_READ_SEEK_OPERATIONS, 1);
}

void streamReadSeekBackward(long negativeOffset) {
increment(GhfsStatistic.STREAM_READ_SEEK_BACKWARD_OPERATIONS);
incrementCounter(GhfsStatistic.STREAM_READ_SEEK_BYTES_BACKWARDS, -negativeOffset);
Expand Down Expand Up @@ -371,54 +349,6 @@ public void directoryCreated() {
incrementCounter(DIRECTORIES_CREATED, 1);
}

public void filesDeleteRejected() {
incrementCounter(FILES_DELETE_REJECTED, 1);
}

public void invocationListStatus() {
incrementCounter(INVOCATION_LIST_STATUS, 1);
}

public void invocationListFiles() {
incrementCounter(INVOCATION_LIST_FILES, 1);
}

public void invocationGetFileStatus() {
incrementCounter(INVOCATION_GET_FILE_STATUS, 1);
}

public void invocationGlobStatus() {
incrementCounter(INVOCATION_GLOB_STATUS, 1);
}

public void invocationGetDelegationToken() {
incrementCounter(INVOCATION_GET_DELEGATION_TOKEN, 1);
}

public void invocationCopyFromLocalFile() {
incrementCounter(INVOCATION_COPY_FROM_LOCAL_FILE, 1);
}

public void invocationGetFileChecksum() {
incrementCounter(INVOCATION_GET_FILE_CHECKSUM, 1);
}

public void invocationExists() {
incrementCounter(INVOCATION_EXISTS, 1);
}

public void invocationListLocatedStatus() {
incrementCounter(INVOCATION_LIST_LOCATED_STATUS, 1);
}

public void streamReadExceptions() {
incrementCounter(STREAM_READ_EXCEPTIONS, 1);
}

public void invocationMkdirs() {
incrementCounter(INVOCATION_MKDIRS, 1);
}

private class LongIterator implements Iterator<LongStatistic> {
private Iterator<String> iterator = getMetricNames();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ interface GhfsInputStreamStatistics extends AutoCloseable, GhfsStatisticInterfac
*/
void bytesRead(long bytes);

/**
* A {@code read(byte[] buf, int off, int len)} operation has started.
*
* @param pos starting position of the read
* @param len length of bytes to read
*/
void readOperationStarted(long pos, long len);

/**
* A read operation has completed.
*
Expand All @@ -65,56 +57,4 @@ interface GhfsInputStreamStatistics extends AutoCloseable, GhfsStatisticInterfac

@Override
void close();

/** The bytes read in read() operations. */
long getBytesRead();

/**
* The total number of bytes read, including all read and discarded when closing streams or
* skipped during seek calls.
*/
long getTotalBytesRead();

/** The total number of bytes skipped during seek calls. */
long getBytesSkippedOnSeek();

/** The total number of bytes skipped during backward seek calls. */
long getBytesBackwardsOnSeek();

/** The total number of seek operations in an input stream */
long getSeekOperations();

/** The total number of exceptions raised during input stream reads. */
long getReadExceptions();

/** The total number of times the read() operation in an input stream has been called. */
long getReadOperations();

/** The total number of Incomplete read() operations */
long getReadsIncomplete();

/** The total number of times the input stream has been closed. */
long getCloseOperations();

/** The total number of executed seek operations which went forward in an input stream. */
long getForwardSeekOperations();

/** The total number of executed seek operations which went backward in an input stream. */
long getBackwardSeekOperations();

/**
* Get the value of a counter.
*
* @param name counter name
* @return the value or null if no matching counter was found.
*/
Long lookupCounterValue(String name);

/**
* Get the value of a gauge.
*
* @param name gauge name
* @return the value or null if no matching gauge was found.
*/
Long lookupGaugeValue(String name);
}
Loading

0 comments on commit fb30864

Please sign in to comment.