Skip to content

Commit

Permalink
HADOOP-13028 add low level counter metrics for S3A; use in read perfo…
Browse files Browse the repository at this point in the history
…rmance tests. contributed by: stevel

patch includes
HADOOP-12844 Recover when S3A fails on IOException in read()
HADOOP-13058 S3A FS fails during init against a read-only FS if multipart purge
HADOOP-13047 S3a Forward seek in stream length to be configurable
  • Loading branch information
steveloughran committed May 12, 2016
1 parent 6b53802 commit 27c4e90
Show file tree
Hide file tree
Showing 21 changed files with 1,753 additions and 667 deletions.
Expand Up @@ -234,4 +234,13 @@ public void unbuffer() {
"support unbuffering.");
}
}

/**
* String value. Includes the string value of the inner stream
* @return the stream
*/
@Override
public String toString() {
return super.toString() + ": " + in;
}
}
@@ -0,0 +1,141 @@
/*
* 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.metrics2;

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;

/**
* Build a string dump of the metrics.
*
* The {@link #toString()} operator dumps out all values collected.
*
* Every entry is formatted as
* {@code prefix + name + separator + value + suffix}
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public class MetricStringBuilder extends MetricsRecordBuilder {

private final StringBuilder builder = new StringBuilder(256);

private final String prefix;
private final String suffix;
private final String separator;
private final MetricsCollector parent;

/**
* Build an instance.
* @param parent parent collector. Unused in this instance; only used for
* the {@link #parent()} method
* @param prefix string before each entry
* @param separator separator between name and value
* @param suffix suffix after each entry
*/
public MetricStringBuilder(MetricsCollector parent,
String prefix,
String separator,
String suffix) {
this.parent = parent;
this.prefix = prefix;
this.suffix = suffix;
this.separator = separator;
}

public MetricStringBuilder add(MetricsInfo info, Object value) {
return tuple(info.name(), value.toString());
}

/**
* Add any key,val pair to the string, between the prefix and suffix,
* separated by the separator.
* @param key key
* @param value value
* @return this instance
*/
public MetricStringBuilder tuple(String key, String value) {
builder.append(prefix)
.append(key)
.append(separator)
.append(value)
.append(suffix);
return this;
}

@Override
public MetricsRecordBuilder tag(MetricsInfo info, String value) {
return add(info, value);
}

@Override
public MetricsRecordBuilder add(MetricsTag tag) {
return tuple(tag.name(), tag.value());
}

@Override
public MetricsRecordBuilder add(AbstractMetric metric) {
add(metric.info(), metric.toString());
return this;
}

@Override
public MetricsRecordBuilder setContext(String value) {
return tuple("context", value);
}

@Override
public MetricsRecordBuilder addCounter(MetricsInfo info, int value) {
return add(info, value);
}

@Override
public MetricsRecordBuilder addCounter(MetricsInfo info, long value) {
return add(info, value);
}

@Override
public MetricsRecordBuilder addGauge(MetricsInfo info, int value) {
return add(info, value);
}

@Override
public MetricsRecordBuilder addGauge(MetricsInfo info, long value) {
return add(info, value);
}

@Override
public MetricsRecordBuilder addGauge(MetricsInfo info, float value) {
return add(info, value);
}

@Override
public MetricsRecordBuilder addGauge(MetricsInfo info, double value) {
return add(info, value);
}

@Override
public MetricsCollector parent() {
return parent;
}

@Override
public String toString() {
return builder.toString();
}
}
Expand Up @@ -34,7 +34,7 @@ public class MutableCounterLong extends MutableCounter {

private AtomicLong value = new AtomicLong();

MutableCounterLong(MetricsInfo info, long initValue) {
public MutableCounterLong(MetricsInfo info, long initValue) {
super(info);
this.value.set(initValue);
}
Expand Down
Expand Up @@ -938,7 +938,15 @@
uploading (fs.s3a.threads.max) or queueing (fs.s3a.max.total.tasks)</description>
</property>

<property>
<property>
<name>fs.s3a.readahead.range</name>
<value>65536</value>
<description>Bytes to read ahead during a seek() before closing and
re-opening the S3 HTTP connection. This option will be overridden if
any call to setReadahead() is made to an open stream.</description>
</property>

<property>
<name>fs.s3a.fast.buffer.size</name>
<value>1048576</value>
<description>Size of initial memory buffer in bytes allocated for an
Expand Down

0 comments on commit 27c4e90

Please sign in to comment.