HBASE-19496 (addendum) don't store the duplicate cp names in ServerMetrics
This commit is contained in:
parent
80c7e4ea79
commit
5a561e0882
|
@ -23,6 +23,7 @@ package org.apache.hadoop.hbase;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationLoadSink;
|
import org.apache.hadoop.hbase.replication.ReplicationLoadSink;
|
||||||
|
@ -403,7 +404,7 @@ public class ServerLoad implements ServerMetrics {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getCoprocessorNames() {
|
public Set<String> getCoprocessorNames() {
|
||||||
return metrics.getCoprocessorNames();
|
return metrics.getCoprocessorNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.hbase;
|
||||||
import edu.umd.cs.findbugs.annotations.Nullable;
|
import edu.umd.cs.findbugs.annotations.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationLoadSink;
|
import org.apache.hadoop.hbase.replication.ReplicationLoadSink;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationLoadSource;
|
import org.apache.hadoop.hbase.replication.ReplicationLoadSource;
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
|
@ -73,9 +74,9 @@ public interface ServerMetrics {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the RegionServer-level and Region-level coprocessors
|
* Return the RegionServer-level and Region-level coprocessors
|
||||||
* @return string list of loaded RegionServer-level and Region-level coprocessors
|
* @return string set of loaded RegionServer-level and Region-level coprocessors
|
||||||
*/
|
*/
|
||||||
List<String> getCoprocessorNames();
|
Set<String> getCoprocessorNames();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the timestamp (server side) of generating this metrics
|
* @return the timestamp (server side) of generating this metrics
|
||||||
|
|
|
@ -18,10 +18,13 @@
|
||||||
package org.apache.hadoop.hbase;
|
package org.apache.hadoop.hbase;
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.Nullable;
|
import edu.umd.cs.findbugs.annotations.Nullable;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import java.util.TreeSet;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationLoadSink;
|
import org.apache.hadoop.hbase.replication.ReplicationLoadSink;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationLoadSource;
|
import org.apache.hadoop.hbase.replication.ReplicationLoadSource;
|
||||||
|
@ -73,7 +76,7 @@ public final class ServerMetricsBuilder {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<HBaseProtos.Coprocessor> toCoprocessor(List<String> names) {
|
public static List<HBaseProtos.Coprocessor> toCoprocessor(Collection<String> names) {
|
||||||
return names.stream()
|
return names.stream()
|
||||||
.map(n -> HBaseProtos.Coprocessor.newBuilder().setName(n).build())
|
.map(n -> HBaseProtos.Coprocessor.newBuilder().setName(n).build())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
@ -116,7 +119,7 @@ public final class ServerMetricsBuilder {
|
||||||
@Nullable
|
@Nullable
|
||||||
private ReplicationLoadSink sink = null;
|
private ReplicationLoadSink sink = null;
|
||||||
private final Map<byte[], RegionMetrics> regionStatus = new TreeMap<>(Bytes.BYTES_COMPARATOR);
|
private final Map<byte[], RegionMetrics> regionStatus = new TreeMap<>(Bytes.BYTES_COMPARATOR);
|
||||||
private List<String> coprocessorNames = Collections.emptyList();
|
private final Set<String> coprocessorNames = new TreeSet<>();
|
||||||
private long reportTimestamp = System.currentTimeMillis();
|
private long reportTimestamp = System.currentTimeMillis();
|
||||||
private long lastReportTimestamp = 0;
|
private long lastReportTimestamp = 0;
|
||||||
private ServerMetricsBuilder(ServerName serverName) {
|
private ServerMetricsBuilder(ServerName serverName) {
|
||||||
|
@ -164,7 +167,7 @@ public final class ServerMetricsBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerMetricsBuilder setCoprocessorNames(List<String> value) {
|
public ServerMetricsBuilder setCoprocessorNames(List<String> value) {
|
||||||
this.coprocessorNames = value;
|
coprocessorNames.addAll(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,14 +208,14 @@ public final class ServerMetricsBuilder {
|
||||||
@Nullable
|
@Nullable
|
||||||
private final ReplicationLoadSink sink;
|
private final ReplicationLoadSink sink;
|
||||||
private final Map<byte[], RegionMetrics> regionStatus;
|
private final Map<byte[], RegionMetrics> regionStatus;
|
||||||
private final List<String> coprocessorNames;
|
private final Set<String> coprocessorNames;
|
||||||
private final long reportTimestamp;
|
private final long reportTimestamp;
|
||||||
private final long lastReportTimestamp;
|
private final long lastReportTimestamp;
|
||||||
|
|
||||||
ServerMetricsImpl(ServerName serverName, long requestCountPerSecond, long requestCount,
|
ServerMetricsImpl(ServerName serverName, long requestCountPerSecond, long requestCount,
|
||||||
Size usedHeapSize, Size maxHeapSize, int infoServerPort, List<ReplicationLoadSource> sources,
|
Size usedHeapSize, Size maxHeapSize, int infoServerPort, List<ReplicationLoadSource> sources,
|
||||||
ReplicationLoadSink sink, Map<byte[], RegionMetrics> regionStatus,
|
ReplicationLoadSink sink, Map<byte[], RegionMetrics> regionStatus,
|
||||||
List<String> coprocessorNames, long reportTimestamp, long lastReportTimestamp) {
|
Set<String> coprocessorNames, long reportTimestamp, long lastReportTimestamp) {
|
||||||
this.serverName = Preconditions.checkNotNull(serverName);
|
this.serverName = Preconditions.checkNotNull(serverName);
|
||||||
this.requestCountPerSecond = requestCountPerSecond;
|
this.requestCountPerSecond = requestCountPerSecond;
|
||||||
this.requestCount = requestCount;
|
this.requestCount = requestCount;
|
||||||
|
@ -272,8 +275,8 @@ public final class ServerMetricsBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getCoprocessorNames() {
|
public Set<String> getCoprocessorNames() {
|
||||||
return Collections.unmodifiableList(coprocessorNames);
|
return Collections.unmodifiableSet(coprocessorNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class TestCoprocessorTableEndpoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCoprocessorTableEndpoint() throws Throwable {
|
public void testCoprocessorTableEndpoint() throws Throwable {
|
||||||
final TableName tableName = TableName.valueOf(name.getMethodName());
|
final TableName tableName = TableName.valueOf(name.getMethodName());
|
||||||
|
|
||||||
HTableDescriptor desc = new HTableDescriptor(tableName);
|
HTableDescriptor desc = new HTableDescriptor(tableName);
|
||||||
|
|
Loading…
Reference in New Issue