Skip to content
This repository has been archived by the owner on Mar 27, 2021. It is now read-only.

Commit

Permalink
[component] Partially remove lombok. (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
hexedpackets authored Sep 20, 2019
1 parent d859297 commit 5af6615
Show file tree
Hide file tree
Showing 49 changed files with 562 additions and 718 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ allprojects {

dependency 'junit:junit:4.12'
dependency 'org.hamcrest:java-hamcrest:2.0.0.0'
dependency 'org.mockito:mockito-core:2.0.31-beta'
dependency 'org.mockito:mockito-core:3.0.0'
dependencySet(group: 'com.google.code.findbugs', version: '3.0.1') {
entry 'annotations'
entry 'jsr305'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.spotify.heroic.common.GrokProcessor;
import com.spotify.heroic.ingestion.Ingestion;
import com.spotify.heroic.ingestion.IngestionGroup;
import com.spotify.heroic.ingestion.Request;
import eu.toolchain.async.AsyncFramework;
import eu.toolchain.async.AsyncFuture;
import io.netty.channel.ChannelHandlerContext;
Expand Down Expand Up @@ -57,8 +58,7 @@ public CollectdChannelHandler(final AsyncFramework async, final IngestionGroup i
}

@Override
protected void channelRead0(final ChannelHandlerContext ctx, final DatagramPacket msg)
throws Exception {
protected void channelRead0(final ChannelHandlerContext ctx, final DatagramPacket msg) {
final Iterator<CollectdSample> samples = CollectdParser.parse(msg.content());

while (samples.hasNext()) {
Expand All @@ -67,7 +67,7 @@ protected void channelRead0(final ChannelHandlerContext ctx, final DatagramPacke
final Set<Map.Entry<String, String>> base =
ImmutableMap.of("host", s.getHost(), "plugin", s.getPlugin()).entrySet();

final List<Ingestion.Request> ingestions;
final List<Request> ingestions;

if (hostProcessor.isPresent()) {
final Map<String, Object> parts = hostProcessor.get().parse(s.getHost());
Expand All @@ -83,7 +83,7 @@ protected void channelRead0(final ChannelHandlerContext ctx, final DatagramPacke

final List<AsyncFuture<Ingestion>> futures = new ArrayList<>();

for (final Ingestion.Request w : ingestions) {
for (final Request w : ingestions) {
futures.add(ingestion.write(w));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.spotify.heroic.common.Series;
import com.spotify.heroic.ingestion.Ingestion;
import com.spotify.heroic.ingestion.Request;
import com.spotify.heroic.metric.MetricCollection;
import com.spotify.heroic.metric.Point;
import java.util.HashMap;
Expand Down Expand Up @@ -118,7 +118,7 @@ public static CollectdTypes supplyDefault() {
Optional.empty(), Optional.empty());
}

public List<Ingestion.Request> convert(
public List<Request> convert(
final CollectdSample sample, final Iterable<Map.Entry<String, String>> tags
) {
final Mapper mapping = mappings.get(sample.getType());
Expand All @@ -134,13 +134,13 @@ public List<Ingestion.Request> convert(
/**
* Default conversion of collectd samples.
*/
private List<Ingestion.Request> convertDefault(
private List<Request> convertDefault(
final CollectdSample sample, final Iterable<Map.Entry<String, String>> tags
) {
final long time = sample.getTime() * 1000;

final Iterator<CollectdValue> values = sample.getValues().iterator();
final ImmutableList.Builder<Ingestion.Request> ingestions = ImmutableList.builder();
final ImmutableList.Builder<Request> ingestions = ImmutableList.builder();
final Iterable<Map.Entry<String, String>> sampleTags = defaultTags(sample);

while (values.hasNext()) {
Expand All @@ -151,7 +151,7 @@ private List<Ingestion.Request> convertDefault(

final MetricCollection data = MetricCollection.points(ImmutableList.of(point));

ingestions.add(new Ingestion.Request(series, data));
ingestions.add(new Request(series, data));
}

return ingestions.build();
Expand Down Expand Up @@ -200,7 +200,7 @@ interface Plugin {
}

interface Mapper {
List<Ingestion.Request> convert(
List<Request> convert(
final CollectdSample sample, final Iterable<Map.Entry<String, String>> tags
);
}
Expand All @@ -221,7 +221,7 @@ public Mapper setup(CollectdTypes types) {
final Iterator<Field> fields = this.fields.iterator();
final Iterator<CollectdValue> values = sample.getValues().iterator();

final ImmutableList.Builder<Ingestion.Request> ingestions = ImmutableList.builder();
final ImmutableList.Builder<Request> ingestions = ImmutableList.builder();

final Map<String, String> base = plugin.tags(sample);

Expand All @@ -240,7 +240,7 @@ public Mapper setup(CollectdTypes types) {

final MetricCollection data = MetricCollection.points(ImmutableList.of(point));

ingestions.add(new Ingestion.Request(series, data));
ingestions.add(new Request(series, data));
}

return ingestions.build();
Expand Down
1 change: 0 additions & 1 deletion heroic-component/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ dependencies {
implementation 'com.google.protobuf:protobuf-java'

compileOnly 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok'
}

task testJar(type: Jar) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,24 @@
import com.spotify.heroic.common.Duration;
import com.spotify.heroic.filter.Filter;
import com.spotify.heroic.grammar.QueryParser;
import lombok.Data;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;

@Data
public class ExtraParameters {
public static final ParameterSpecification CONFIGURE =
ParameterSpecification.parameter("configure", "Automatically configure all backends.");

public static final Joiner SCOPE_JOINER = Joiner.on('.');
private static final Joiner SCOPE_JOINER = Joiner.on('.');

private final List<String> scope;
private final Multimap<String, String> parameters;

public ExtraParameters(final List<String> scope, final Multimap<String, String> parameters) {
this.scope = scope;
this.parameters = parameters;
}

public boolean containsAny(String... keys) {
return Arrays.stream(keys).anyMatch(parameters::containsKey);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
import java.util.SortedSet;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import lombok.Data;

@Data
public class ObjectHasher {
private enum Kind {
START_OBJECT, END_OBJECT, LIST, SET, FIELD, INTEGER, LONG, DOUBLE, STRING, BOOLEAN, ENUM,
Expand All @@ -40,6 +38,10 @@ private enum Kind {

private final Hasher hasher;

public ObjectHasher(Hasher hasher) {
this.hasher = hasher;
}

public <T> void putField(
final String name, final T value, final Consumer<T> hashTo
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,30 @@

package com.spotify.heroic;

import lombok.Data;

import java.io.PrintWriter;
import java.text.BreakIterator;
import java.util.Locale;
import java.util.Optional;

@Data
public class ParameterSpecification {
private final String name;
private final String description;
private final Optional<String> metavar;

public ParameterSpecification(
final String name,
final String description,
final Optional<String> metavar
) {
this.name = name;
this.description = description;
this.metavar = metavar;
}

public String getName() {
return name;
}

public static ParameterSpecification parameter(String name, String description) {
return new ParameterSpecification(name, description, Optional.empty());
}
Expand Down
38 changes: 38 additions & 0 deletions heroic-component/src/main/java/com/spotify/heroic/Query.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2019 Spotify AB.
*
* 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 com.spotify.heroic

import com.spotify.heroic.aggregation.Aggregation
import com.spotify.heroic.common.FeatureSet
import com.spotify.heroic.filter.Filter
import com.spotify.heroic.metric.MetricType
import java.util.*

data class Query(
val aggregation: Optional<Aggregation>,
val source: Optional<MetricType>,
val range: Optional<QueryDateRange>,
val filter: Optional<Filter>,
val options: Optional<QueryOptions>,
// set of experimental features to enable
val features: Optional<FeatureSet>
)
128 changes: 0 additions & 128 deletions heroic-component/src/main/java/com/spotify/heroic/QueryDateRange.java

This file was deleted.

Loading

0 comments on commit 5af6615

Please sign in to comment.