mirror of https://github.com/apache/druid.git
Add dimension partitioningType to metrics to track usage of different partitioning schemes (#11902)
Add method ShardSpec.getType() to get name of shard spec type List all names of shard spec types in the interface ShardSpec itself for easy reference and maintenance Add dimension partitioningType to metric segment/added/bytes
This commit is contained in:
parent
fe2f7742f7
commit
223c5692a8
|
@ -39,8 +39,6 @@ import java.util.Objects;
|
|||
*/
|
||||
public class BuildingDimensionRangeShardSpec implements BuildingShardSpec<DimensionRangeShardSpec>
|
||||
{
|
||||
public static final String TYPE = "building_range";
|
||||
|
||||
private final int bucketId;
|
||||
private final List<String> dimensions;
|
||||
@Nullable
|
||||
|
@ -124,6 +122,12 @@ public class BuildingDimensionRangeShardSpec implements BuildingShardSpec<Dimens
|
|||
return new NumberedPartitionChunk<>(partitionId, 0, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return Type.BUILDING_RANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
|
|
@ -36,8 +36,6 @@ import java.util.Objects;
|
|||
*/
|
||||
public class BuildingHashBasedNumberedShardSpec implements BuildingShardSpec<HashBasedNumberedShardSpec>
|
||||
{
|
||||
public static final String TYPE = "building_hashed";
|
||||
|
||||
private final int partitionId;
|
||||
private final int bucketId;
|
||||
private final int numBuckets;
|
||||
|
@ -120,6 +118,12 @@ public class BuildingHashBasedNumberedShardSpec implements BuildingShardSpec<Has
|
|||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return Type.BUILDING_HASHED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
|
|
@ -35,7 +35,6 @@ import java.util.Objects;
|
|||
*/
|
||||
public class BuildingNumberedShardSpec implements BuildingShardSpec<NumberedShardSpec>
|
||||
{
|
||||
public static final String TYPE = "building_numbered";
|
||||
|
||||
private final int partitionId;
|
||||
|
||||
|
@ -74,6 +73,12 @@ public class BuildingNumberedShardSpec implements BuildingShardSpec<NumberedShar
|
|||
return partitionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return Type.BUILDING_NUMBERED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
|
|
@ -37,8 +37,6 @@ import java.util.Objects;
|
|||
*/
|
||||
public class BuildingSingleDimensionShardSpec extends BuildingDimensionRangeShardSpec
|
||||
{
|
||||
public static final String TYPE = "building_single_dim";
|
||||
|
||||
private final String dimension;
|
||||
|
||||
@Nullable
|
||||
|
@ -110,6 +108,12 @@ public class BuildingSingleDimensionShardSpec extends BuildingDimensionRangeShar
|
|||
return new NumberedPartitionChunk<>(getPartitionNum(), 0, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return Type.BUILDING_SINGLE_DIM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
|
|
@ -42,8 +42,6 @@ import java.util.Objects;
|
|||
*/
|
||||
public class DimensionRangeBucketShardSpec implements BucketNumberedShardSpec<BuildingDimensionRangeShardSpec>
|
||||
{
|
||||
public static final String TYPE = "bucket_range";
|
||||
|
||||
private final int bucketId;
|
||||
private final List<String> dimensions;
|
||||
@Nullable
|
||||
|
@ -139,6 +137,12 @@ public class DimensionRangeBucketShardSpec implements BucketNumberedShardSpec<Bu
|
|||
return DimensionRangeShardSpec.isInChunk(dimensions, start, end, inputRow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return Type.BUCKET_RANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
|
|
@ -212,6 +212,12 @@ public class DimensionRangeShardSpec implements ShardSpec
|
|||
return values != null && values.size() > 0 ? values.get(0) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return Type.RANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
|
|
@ -245,6 +245,12 @@ public class HashBasedNumberedShardSpec extends NumberedShardSpec
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return Type.HASHED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
|
|
@ -35,8 +35,6 @@ import java.util.Objects;
|
|||
*/
|
||||
public class HashBucketShardSpec implements BucketNumberedShardSpec<BuildingHashBasedNumberedShardSpec>
|
||||
{
|
||||
public static final String TYPE = "bucket_hash";
|
||||
|
||||
private final int bucketId;
|
||||
private final int numBuckets;
|
||||
private final List<String> partitionDimensions;
|
||||
|
@ -110,6 +108,12 @@ public class HashBucketShardSpec implements BucketNumberedShardSpec<BuildingHash
|
|||
).createHashLookup(shardSpecs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return Type.BUCKET_HASH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
|
|
@ -79,6 +79,12 @@ public final class LinearShardSpec implements ShardSpec
|
|||
return new LinearPartitionChunk<>(partitionNum, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return Type.LINEAR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
|
|
@ -83,6 +83,12 @@ public class NoneShardSpec implements ShardSpec
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return Type.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
|
|
|
@ -53,7 +53,6 @@ import java.util.Objects;
|
|||
*/
|
||||
public class NumberedOverwriteShardSpec implements OverwriteShardSpec
|
||||
{
|
||||
public static final String TYPE = "numbered_overwrite";
|
||||
private final int partitionId;
|
||||
|
||||
private final short startRootPartitionId;
|
||||
|
@ -199,6 +198,12 @@ public class NumberedOverwriteShardSpec implements OverwriteShardSpec
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return Type.NUMBERED_OVERWRITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
|
|
@ -106,6 +106,12 @@ public class NumberedShardSpec implements ShardSpec
|
|||
return NumberedPartitionChunk.make(partitionNum, partitions, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return Type.NUMBERED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -33,25 +33,25 @@ import java.util.Map;
|
|||
*/
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(name = "none", value = NoneShardSpec.class),
|
||||
@JsonSubTypes.Type(name = "single", value = SingleDimensionShardSpec.class),
|
||||
@JsonSubTypes.Type(name = "range", value = DimensionRangeShardSpec.class),
|
||||
@JsonSubTypes.Type(name = "linear", value = LinearShardSpec.class),
|
||||
@JsonSubTypes.Type(name = "numbered", value = NumberedShardSpec.class),
|
||||
@JsonSubTypes.Type(name = "hashed", value = HashBasedNumberedShardSpec.class),
|
||||
@JsonSubTypes.Type(name = NumberedOverwriteShardSpec.TYPE, value = NumberedOverwriteShardSpec.class),
|
||||
@JsonSubTypes.Type(name = ShardSpec.Type.NONE, value = NoneShardSpec.class),
|
||||
@JsonSubTypes.Type(name = ShardSpec.Type.SINGLE, value = SingleDimensionShardSpec.class),
|
||||
@JsonSubTypes.Type(name = ShardSpec.Type.RANGE, value = DimensionRangeShardSpec.class),
|
||||
@JsonSubTypes.Type(name = ShardSpec.Type.LINEAR, value = LinearShardSpec.class),
|
||||
@JsonSubTypes.Type(name = ShardSpec.Type.NUMBERED, value = NumberedShardSpec.class),
|
||||
@JsonSubTypes.Type(name = ShardSpec.Type.HASHED, value = HashBasedNumberedShardSpec.class),
|
||||
@JsonSubTypes.Type(name = ShardSpec.Type.NUMBERED_OVERWRITE, value = NumberedOverwriteShardSpec.class),
|
||||
// BuildingShardSpecs are the shardSpec with missing numCorePartitions, and thus must not be published.
|
||||
// See BuildingShardSpec for more details.
|
||||
@JsonSubTypes.Type(name = BuildingNumberedShardSpec.TYPE, value = BuildingNumberedShardSpec.class),
|
||||
@JsonSubTypes.Type(name = BuildingHashBasedNumberedShardSpec.TYPE, value = BuildingHashBasedNumberedShardSpec.class),
|
||||
@JsonSubTypes.Type(name = BuildingSingleDimensionShardSpec.TYPE, value = BuildingSingleDimensionShardSpec.class),
|
||||
@JsonSubTypes.Type(name = BuildingDimensionRangeShardSpec.TYPE, value = BuildingDimensionRangeShardSpec.class),
|
||||
@JsonSubTypes.Type(name = ShardSpec.Type.BUILDING_NUMBERED, value = BuildingNumberedShardSpec.class),
|
||||
@JsonSubTypes.Type(name = ShardSpec.Type.BUILDING_HASHED, value = BuildingHashBasedNumberedShardSpec.class),
|
||||
@JsonSubTypes.Type(name = ShardSpec.Type.BUILDING_SINGLE_DIM, value = BuildingSingleDimensionShardSpec.class),
|
||||
@JsonSubTypes.Type(name = ShardSpec.Type.BUILDING_RANGE, value = BuildingDimensionRangeShardSpec.class),
|
||||
// BucketShardSpecs are the shardSpec with missing partitionId and numCorePartitions.
|
||||
// These shardSpecs must not be used in segment push.
|
||||
// See BucketShardSpec for more details.
|
||||
@JsonSubTypes.Type(name = HashBucketShardSpec.TYPE, value = HashBucketShardSpec.class),
|
||||
@JsonSubTypes.Type(name = SingleDimensionRangeBucketShardSpec.TYPE, value = SingleDimensionRangeBucketShardSpec.class),
|
||||
@JsonSubTypes.Type(name = DimensionRangeBucketShardSpec.TYPE, value = DimensionRangeBucketShardSpec.class)
|
||||
@JsonSubTypes.Type(name = ShardSpec.Type.BUCKET_HASH, value = HashBucketShardSpec.class),
|
||||
@JsonSubTypes.Type(name = ShardSpec.Type.BUCKET_SINGLE_DIM, value = SingleDimensionRangeBucketShardSpec.class),
|
||||
@JsonSubTypes.Type(name = ShardSpec.Type.BUCKET_RANGE, value = DimensionRangeBucketShardSpec.class)
|
||||
})
|
||||
public interface ShardSpec
|
||||
{
|
||||
|
@ -123,6 +123,15 @@ public interface ShardSpec
|
|||
@JsonIgnore
|
||||
boolean possibleInDomain(Map<String, RangeSet<String>> domain);
|
||||
|
||||
/**
|
||||
* Get the type name of this ShardSpec.
|
||||
*/
|
||||
@JsonIgnore
|
||||
default String getType()
|
||||
{
|
||||
return Type.UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this shardSpec and the given {@link PartialShardSpec} share the same partition space.
|
||||
* All shardSpecs except {@link OverwriteShardSpec} use the root-generation partition space and thus share the same
|
||||
|
@ -134,4 +143,30 @@ public interface ShardSpec
|
|||
{
|
||||
return !partialShardSpec.useNonRootGenerationPartitionSpace();
|
||||
}
|
||||
|
||||
/**
|
||||
* ShardSpec type names.
|
||||
*/
|
||||
interface Type
|
||||
{
|
||||
String UNKNOWN = "unknown";
|
||||
String NONE = "none";
|
||||
|
||||
String SINGLE = "single";
|
||||
String RANGE = "range";
|
||||
String LINEAR = "linear";
|
||||
String NUMBERED = "numbered";
|
||||
String HASHED = "hashed";
|
||||
|
||||
String NUMBERED_OVERWRITE = "numbered_overwrite";
|
||||
|
||||
String BUILDING_NUMBERED = "building_numbered";
|
||||
String BUILDING_HASHED = "building_hashed";
|
||||
String BUILDING_SINGLE_DIM = "building_single_dim";
|
||||
String BUILDING_RANGE = "building_range";
|
||||
|
||||
String BUCKET_HASH = "bucket_hash";
|
||||
String BUCKET_SINGLE_DIM = "bucket_single_dim";
|
||||
String BUCKET_RANGE = "bucket_range";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,8 +35,6 @@ import java.util.Objects;
|
|||
*/
|
||||
public class SingleDimensionRangeBucketShardSpec implements BucketNumberedShardSpec<BuildingSingleDimensionShardSpec>
|
||||
{
|
||||
public static final String TYPE = "bucket_single_dim";
|
||||
|
||||
private final int bucketId;
|
||||
private final String dimension;
|
||||
@Nullable
|
||||
|
@ -109,6 +107,12 @@ public class SingleDimensionRangeBucketShardSpec implements BucketNumberedShardS
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return Type.BUCKET_SINGLE_DIM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
|
|
@ -203,6 +203,12 @@ public class SingleDimensionShardSpec extends DimensionRangeShardSpec
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return Type.SINGLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
|
|
@ -93,6 +93,7 @@ public class DataSegmentTest
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public class BuildingDimensionRangeShardSpecTest
|
|||
{
|
||||
final ObjectMapper mapper = ShardSpecTestUtils.initObjectMapper();
|
||||
mapper.registerSubtypes(
|
||||
new NamedType(BuildingDimensionRangeShardSpec.class, BuildingDimensionRangeShardSpec.TYPE)
|
||||
new NamedType(BuildingDimensionRangeShardSpec.class, ShardSpec.Type.BUILDING_RANGE)
|
||||
);
|
||||
mapper.setInjectableValues(new Std().addValue(ObjectMapper.class, mapper));
|
||||
final BuildingDimensionRangeShardSpec original = new BuildingDimensionRangeShardSpec(
|
||||
|
@ -100,10 +100,10 @@ public class BuildingDimensionRangeShardSpecTest
|
|||
5
|
||||
);
|
||||
final String json = mapper.writeValueAsString(original);
|
||||
final BuildingDimensionRangeShardSpec fromJson = (BuildingDimensionRangeShardSpec) mapper.readValue(
|
||||
json,
|
||||
ShardSpec.class
|
||||
);
|
||||
ShardSpec shardSpec = mapper.readValue(json, ShardSpec.class);
|
||||
Assert.assertEquals(ShardSpec.Type.BUILDING_RANGE, shardSpec.getType());
|
||||
|
||||
final BuildingDimensionRangeShardSpec fromJson = (BuildingDimensionRangeShardSpec) shardSpec;
|
||||
Assert.assertEquals(original, fromJson);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public class BuildingHashBasedNumberedShardSpecTest
|
|||
public void testSerde() throws JsonProcessingException
|
||||
{
|
||||
mapper.registerSubtypes(
|
||||
new NamedType(BuildingHashBasedNumberedShardSpec.class, BuildingHashBasedNumberedShardSpec.TYPE)
|
||||
new NamedType(BuildingHashBasedNumberedShardSpec.class, ShardSpec.Type.BUILDING_HASHED)
|
||||
);
|
||||
mapper.setInjectableValues(new Std().addValue(ObjectMapper.class, mapper));
|
||||
final BuildingHashBasedNumberedShardSpec original = new BuildingHashBasedNumberedShardSpec(
|
||||
|
@ -80,10 +80,9 @@ public class BuildingHashBasedNumberedShardSpecTest
|
|||
mapper
|
||||
);
|
||||
final String json = mapper.writeValueAsString(original);
|
||||
final BuildingHashBasedNumberedShardSpec fromJson = (BuildingHashBasedNumberedShardSpec) mapper.readValue(
|
||||
json,
|
||||
ShardSpec.class
|
||||
);
|
||||
ShardSpec shardSpec = mapper.readValue(json, ShardSpec.class);
|
||||
Assert.assertEquals(ShardSpec.Type.BUILDING_HASHED, shardSpec.getType());
|
||||
final BuildingHashBasedNumberedShardSpec fromJson = (BuildingHashBasedNumberedShardSpec) shardSpec;
|
||||
Assert.assertEquals(original, fromJson);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,10 +49,12 @@ public class BuildingNumberedShardSpecTest
|
|||
{
|
||||
final ObjectMapper mapper = ShardSpecTestUtils.initObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.registerSubtypes(new NamedType(BuildingNumberedShardSpec.class, BuildingNumberedShardSpec.TYPE));
|
||||
mapper.registerSubtypes(new NamedType(BuildingNumberedShardSpec.class, ShardSpec.Type.BUILDING_NUMBERED));
|
||||
final BuildingNumberedShardSpec original = new BuildingNumberedShardSpec(5);
|
||||
final String json = mapper.writeValueAsString(original);
|
||||
final BuildingNumberedShardSpec fromJson = (BuildingNumberedShardSpec) mapper.readValue(json, ShardSpec.class);
|
||||
ShardSpec shardSpec = mapper.readValue(json, ShardSpec.class);
|
||||
Assert.assertEquals(ShardSpec.Type.BUILDING_NUMBERED, shardSpec.getType());
|
||||
final BuildingNumberedShardSpec fromJson = (BuildingNumberedShardSpec) shardSpec;
|
||||
Assert.assertEquals(original, fromJson);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,8 +56,10 @@ public class BuildingSingleDimensionShardSpecTest
|
|||
final BuildingSingleDimensionShardSpec original =
|
||||
new BuildingSingleDimensionShardSpec(1, "dim", "start", "end", 5);
|
||||
final String json = serialize(original);
|
||||
final BuildingSingleDimensionShardSpec fromJson =
|
||||
(BuildingSingleDimensionShardSpec) deserialize(json, ShardSpec.class);
|
||||
ShardSpec shardSpec = deserialize(json, ShardSpec.class);
|
||||
Assert.assertEquals(ShardSpec.Type.BUILDING_SINGLE_DIM, shardSpec.getType());
|
||||
|
||||
final BuildingSingleDimensionShardSpec fromJson = (BuildingSingleDimensionShardSpec) shardSpec;
|
||||
Assert.assertEquals(original, fromJson);
|
||||
}
|
||||
|
||||
|
@ -80,7 +82,7 @@ public class BuildingSingleDimensionShardSpecTest
|
|||
@Test
|
||||
public void testDeserializeFromMap()
|
||||
{
|
||||
final String json = "{\"type\": \"" + BuildingSingleDimensionShardSpec.TYPE + "\","
|
||||
final String json = "{\"type\": \"" + ShardSpec.Type.BUILDING_SINGLE_DIM + "\","
|
||||
+ " \"bucketId\":1,"
|
||||
+ " \"dimension\": \"dim\","
|
||||
+ " \"start\": \"abc\","
|
||||
|
@ -108,7 +110,7 @@ public class BuildingSingleDimensionShardSpecTest
|
|||
{
|
||||
final ObjectMapper mapper = ShardSpecTestUtils.initObjectMapper();
|
||||
mapper.registerSubtypes(
|
||||
new NamedType(BuildingSingleDimensionShardSpec.class, BuildingSingleDimensionShardSpec.TYPE)
|
||||
new NamedType(BuildingSingleDimensionShardSpec.class, ShardSpec.Type.BUILDING_SINGLE_DIM)
|
||||
);
|
||||
mapper.setInjectableValues(new Std().addValue(ObjectMapper.class, mapper));
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ public class DimensionRangeBucketShardSpecTest
|
|||
final ObjectMapper mapper = ShardSpecTestUtils.initObjectMapper();
|
||||
mapper.registerSubtypes(new NamedType(
|
||||
DimensionRangeBucketShardSpec.class,
|
||||
DimensionRangeBucketShardSpec.TYPE
|
||||
ShardSpec.Type.BUCKET_RANGE
|
||||
));
|
||||
mapper.setInjectableValues(new Std().addValue(ObjectMapper.class, mapper));
|
||||
final DimensionRangeBucketShardSpec original = new DimensionRangeBucketShardSpec(
|
||||
|
@ -158,11 +158,9 @@ public class DimensionRangeBucketShardSpecTest
|
|||
StringTuple.create("end1", "end2")
|
||||
);
|
||||
final String json = mapper.writeValueAsString(original);
|
||||
final DimensionRangeBucketShardSpec fromJson = (DimensionRangeBucketShardSpec) mapper.readValue(
|
||||
json,
|
||||
ShardSpec.class
|
||||
);
|
||||
Assert.assertEquals(original, fromJson);
|
||||
ShardSpec shardSpec = mapper.readValue(json, ShardSpec.class);
|
||||
Assert.assertEquals(ShardSpec.Type.BUCKET_RANGE, shardSpec.getType());
|
||||
Assert.assertEquals(original, shardSpec);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -99,6 +99,7 @@ public class HashBasedNumberedShardSpecTest
|
|||
"{\"type\": \"hashed\", \"partitions\": 2, \"partitionNum\": 1, \"partitionDimensions\":[\"visitor_id\"]}",
|
||||
ShardSpec.class
|
||||
);
|
||||
Assert.assertEquals(ShardSpec.Type.HASHED, specWithPartitionDimensions.getType());
|
||||
Assert.assertEquals(1, specWithPartitionDimensions.getPartitionNum());
|
||||
Assert.assertEquals(2, specWithPartitionDimensions.getNumCorePartitions());
|
||||
Assert.assertEquals(2, ((HashBasedNumberedShardSpec) specWithPartitionDimensions).getNumBuckets());
|
||||
|
|
|
@ -113,7 +113,7 @@ public class HashBucketShardSpecTest
|
|||
@Test
|
||||
public void testSerde() throws JsonProcessingException
|
||||
{
|
||||
mapper.registerSubtypes(new NamedType(HashBucketShardSpec.class, HashBucketShardSpec.TYPE));
|
||||
mapper.registerSubtypes(new NamedType(HashBucketShardSpec.class, ShardSpec.Type.BUCKET_HASH));
|
||||
mapper.setInjectableValues(new Std().addValue(ObjectMapper.class, mapper));
|
||||
|
||||
final HashBucketShardSpec original = new HashBucketShardSpec(
|
||||
|
@ -124,7 +124,10 @@ public class HashBucketShardSpecTest
|
|||
mapper
|
||||
);
|
||||
final String json = mapper.writeValueAsString(original);
|
||||
final HashBucketShardSpec fromJson = (HashBucketShardSpec) mapper.readValue(json, ShardSpec.class);
|
||||
ShardSpec shardSpec = mapper.readValue(json, ShardSpec.class);
|
||||
Assert.assertEquals(ShardSpec.Type.BUCKET_HASH, shardSpec.getType());
|
||||
|
||||
final HashBucketShardSpec fromJson = (HashBucketShardSpec) shardSpec;
|
||||
Assert.assertEquals(original, fromJson);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ public class NoneShardSpecTest
|
|||
// Serde should return same object instead of creating new one every time.
|
||||
Assert.assertTrue(serde1 == serde2);
|
||||
Assert.assertTrue(one == serde1);
|
||||
Assert.assertEquals(ShardSpec.Type.NONE, serde1.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -38,7 +38,7 @@ public class NumberedOverwriteShardSpecTest
|
|||
public void testSerde() throws JsonProcessingException
|
||||
{
|
||||
final ObjectMapper mapper = ShardSpecTestUtils.initObjectMapper();
|
||||
mapper.registerSubtypes(new NamedType(NumberedOverwriteShardSpec.class, NumberedOverwriteShardSpec.TYPE));
|
||||
mapper.registerSubtypes(new NamedType(NumberedOverwriteShardSpec.class, ShardSpec.Type.NUMBERED_OVERWRITE));
|
||||
final NumberedOverwriteShardSpec original = new NumberedOverwriteShardSpec(
|
||||
PartitionIds.NON_ROOT_GEN_START_PARTITION_ID + 2,
|
||||
0,
|
||||
|
@ -47,7 +47,9 @@ public class NumberedOverwriteShardSpecTest
|
|||
(short) 3
|
||||
);
|
||||
final String json = mapper.writeValueAsString(original);
|
||||
final NumberedOverwriteShardSpec fromJson = (NumberedOverwriteShardSpec) mapper.readValue(json, ShardSpec.class);
|
||||
ShardSpec shardSpec = mapper.readValue(json, ShardSpec.class);
|
||||
Assert.assertEquals(ShardSpec.Type.NUMBERED_OVERWRITE, shardSpec.getType());
|
||||
final NumberedOverwriteShardSpec fromJson = (NumberedOverwriteShardSpec) shardSpec;
|
||||
Assert.assertEquals(original, fromJson);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ public class NumberedShardSpecTest
|
|||
);
|
||||
Assert.assertEquals(1, spec.getPartitionNum());
|
||||
Assert.assertEquals(2, spec.getNumCorePartitions());
|
||||
Assert.assertEquals(ShardSpec.Type.NUMBERED, spec.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -99,11 +99,14 @@ public class SingleDimensionRangeBucketShardSpecTest
|
|||
public void testSerde() throws JsonProcessingException
|
||||
{
|
||||
final ObjectMapper mapper = ShardSpecTestUtils.initObjectMapper();
|
||||
mapper.registerSubtypes(new NamedType(SingleDimensionRangeBucketShardSpec.class, SingleDimensionRangeBucketShardSpec.TYPE));
|
||||
mapper.registerSubtypes(new NamedType(SingleDimensionRangeBucketShardSpec.class, ShardSpec.Type.BUCKET_SINGLE_DIM));
|
||||
mapper.setInjectableValues(new Std().addValue(ObjectMapper.class, mapper));
|
||||
final SingleDimensionRangeBucketShardSpec original = new SingleDimensionRangeBucketShardSpec(1, "dim", "start", "end");
|
||||
final String json = mapper.writeValueAsString(original);
|
||||
final SingleDimensionRangeBucketShardSpec fromJson = (SingleDimensionRangeBucketShardSpec) mapper.readValue(json, ShardSpec.class);
|
||||
ShardSpec shardSpec = mapper.readValue(json, ShardSpec.class);
|
||||
Assert.assertEquals(ShardSpec.Type.BUCKET_SINGLE_DIM, shardSpec.getType());
|
||||
|
||||
final SingleDimensionRangeBucketShardSpec fromJson = (SingleDimensionRangeBucketShardSpec) shardSpec;
|
||||
Assert.assertEquals(original, fromJson);
|
||||
}
|
||||
|
||||
|
|
|
@ -175,6 +175,7 @@ public class SingleDimensionShardSpecTest
|
|||
+ "\"numCorePartitions\": 10}";
|
||||
ShardSpec shardSpec = OBJECT_MAPPER.readValue(json, ShardSpec.class);
|
||||
Assert.assertTrue(shardSpec instanceof SingleDimensionShardSpec);
|
||||
Assert.assertEquals(ShardSpec.Type.SINGLE, shardSpec.getType());
|
||||
|
||||
SingleDimensionShardSpec singleDimShardSpec = (SingleDimensionShardSpec) shardSpec;
|
||||
Assert.assertEquals(
|
||||
|
|
|
@ -252,6 +252,10 @@ public class SegmentTransactionalInsertAction implements TaskAction<SegmentPubli
|
|||
// getSegments() should return an empty set if announceHistoricalSegments() failed
|
||||
for (DataSegment segment : retVal.getSegments()) {
|
||||
metricBuilder.setDimension(DruidMetrics.INTERVAL, segment.getInterval().toString());
|
||||
metricBuilder.setDimension(
|
||||
DruidMetrics.PARTITIONING_TYPE,
|
||||
segment.getShardSpec() == null ? null : segment.getShardSpec().getType()
|
||||
);
|
||||
toolbox.getEmitter().emit(metricBuilder.build("segment/added/bytes", segment.getSize()));
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ public class DruidMetrics
|
|||
public static final String TASK_ID = "taskId";
|
||||
public static final String STATUS = "status";
|
||||
|
||||
public static final String PARTITIONING_TYPE = "partitioningType";
|
||||
|
||||
// task metrics
|
||||
public static final String TASK_TYPE = "taskType";
|
||||
public static final String TASK_STATUS = "taskStatus";
|
||||
|
|
Loading…
Reference in New Issue