Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes auto-value dependency and maven metadata from core jar #2062

Merged
merged 2 commits into from
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,12 @@
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<archive>
<!-- prevents huge pom file from also being added to the jar under META-INF/maven -->
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>

<plugin>
Expand Down
2 changes: 2 additions & 0 deletions zipkin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@
<id>default-jar</id>
<configuration>
<archive>
<!-- prevents huge pom file from also being added to the jar under META-INF/maven -->
<addMavenDescriptor>false</addMavenDescriptor>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
Expand Down
18 changes: 16 additions & 2 deletions zipkin/src/test/java/zipkin/internal/V2SpanStoreAdapterTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015-2017 The OpenZipkin Authors
* Copyright 2015-2018 The OpenZipkin Authors
*
* Licensed 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
Expand Down Expand Up @@ -40,6 +40,7 @@
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static zipkin.TestObjects.DAY;
import static zipkin.TestObjects.TODAY;

public class V2SpanStoreAdapterTest {
Expand Down Expand Up @@ -436,7 +437,7 @@ public void getDependencies_sync_wrapsIOE() throws IOException {
.lookback(60L)
.limit(100)
.build()))
.isEqualTo(zipkin2.storage.QueryRequest.newBuilder()
.isEqualToComparingFieldByField(zipkin2.storage.QueryRequest.newBuilder()
.serviceName("service")
.spanName("span")
.parseAnnotationQuery("annotation and tag=value")
Expand All @@ -448,6 +449,19 @@ public void getDependencies_sync_wrapsIOE() throws IOException {
.build());
}

@Test public void convert_queryRequest_less() {
// from CassandraSpanStoreTest.overFetchesToCompensateForDuplicateIndexData
QueryRequest input = QueryRequest.builder()
.serviceName("web")
.lookback(DAY).limit(2000).build();
zipkin2.storage.QueryRequest converted = V2SpanStoreAdapter.convertRequest(input);

assertThat(converted.serviceName()).isEqualTo(input.serviceName);
assertThat(converted.endTs()).isEqualTo(input.endTs);
assertThat(converted.lookback()).isEqualTo(input.lookback);
assertThat(converted.limit()).isEqualTo(input.limit);
}

void doEnqueue(Consumer<zipkin2.Callback> answer) {
doAnswer(invocation -> {
answer.accept((zipkin2.Callback) invocation.getArguments()[0]);
Expand Down
14 changes: 2 additions & 12 deletions zipkin2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@
</properties>

<dependencies>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<scope>provided</scope>
</dependency>
<!-- generated code includes Generated annotations! -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jvnet</groupId>
<artifactId>animal-sniffer-annotation</artifactId>
Expand Down Expand Up @@ -145,6 +133,8 @@
<id>default-jar</id>
<configuration>
<archive>
<!-- prevents huge pom file from also being added to the jar under META-INF/maven -->
<addMavenDescriptor>false</addMavenDescriptor>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
Expand Down
8 changes: 4 additions & 4 deletions zipkin2/src/main/java/zipkin2/Call.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015-2017 The OpenZipkin Authors
* Copyright 2015-2018 The OpenZipkin Authors
*
* Licensed 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
Expand Down Expand Up @@ -228,8 +228,8 @@ static final class Mapping<R, V> extends Base<R> {
final Mapper<V, R> mapper;
final Call<V> delegate;

Mapping(Mapper<V, R> Mapper, Call<V> delegate) {
this.mapper = Mapper;
Mapping(Mapper<V, R> mapper, Call<V> delegate) {
this.mapper = mapper;
this.delegate = delegate;
}

Expand Down Expand Up @@ -320,7 +320,7 @@ static final class ErrorHandling<V> extends Base<V> {
try {
return delegate.execute();
} catch (IOException | RuntimeException | Error e) {
final AtomicReference ref = new AtomicReference(SENTINEL);
final AtomicReference ref = new AtomicReference<>(SENTINEL);
errorHandler.onErrorReturn(e, new Callback<V>() {
@Override public void onSuccess(V value) {
ref.set(value);
Expand Down
33 changes: 23 additions & 10 deletions zipkin2/src/main/java/zipkin2/CheckResult.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015-2017 The OpenZipkin Authors
* Copyright 2015-2018 The OpenZipkin Authors
*
* Licensed 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
Expand All @@ -13,7 +13,6 @@
*/
package zipkin2;

import com.google.auto.value.AutoValue;
import zipkin2.internal.Nullable;

/**
Expand All @@ -25,20 +24,34 @@
*
* @see CheckResult#OK
*/
@AutoValue
//@Immutable
public abstract class CheckResult {
public static final CheckResult OK = new AutoValue_CheckResult(true, null);
// @Immutable
public final class CheckResult {
public static final CheckResult OK = new CheckResult(true, null);

public static CheckResult failed(Throwable error) {
return new AutoValue_CheckResult(false, error);
return new CheckResult(false, error);
}

public abstract boolean ok();
public boolean ok() {
return ok;
}

/** Present when not ok */
@Nullable public abstract Throwable error();
@Nullable
public Throwable error() {
return error;
}

final boolean ok;
final Throwable error;

CheckResult(boolean ok, @Nullable Throwable error) {
this.ok = ok;
this.error = error;
}

CheckResult() {
@Override
public String toString() {
return "CheckResult{ok=" + ok + ", " + "error=" + error + "}";
}
}
2 changes: 1 addition & 1 deletion zipkin2/src/main/java/zipkin2/internal/Buffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ long readVarint64() {
if (i == 9 && (b & 0xf0) != 0) {
throw new IllegalArgumentException("Greater than 64-bit varint at position " + (pos - 1));
}
result |= (long) (b & 0x7f) << i * 7;
result |= (long) (b & 0x7f) << (i * 7);
}
return result;
}
Expand Down
39 changes: 28 additions & 11 deletions zipkin2/src/main/java/zipkin2/internal/DependencyLinker.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package zipkin2.internal;

import com.google.auto.value.AutoValue;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -217,7 +216,7 @@ void addLink(String parent, String child, boolean isError) {
if (logger.isLoggable(FINE)) {
logger.fine("incrementing " + (isError ? "error " : "") + "link " + parent + " -> " + child);
}
Pair key = Pair.of(parent, child);
Pair key = new Pair(parent, child);
if (callCounts.containsKey(key)) {
callCounts.put(key, callCounts.get(key) + 1);
} else {
Expand All @@ -241,7 +240,7 @@ public static List<DependencyLink> merge(Iterable<DependencyLink> in) {
Map<Pair, Long> errorCounts = new LinkedHashMap<>();

for (DependencyLink link : in) {
Pair parentChild = Pair.of(link.parent(), link.child());
Pair parentChild = new Pair(link.parent(), link.child());
long callCount = callCounts.containsKey(parentChild) ? callCounts.get(parentChild) : 0L;
callCount += link.callCount();
callCounts.put(parentChild, callCount);
Expand All @@ -259,21 +258,39 @@ static List<DependencyLink> link(Map<Pair, Long> callCounts,
for (Map.Entry<Pair, Long> entry : callCounts.entrySet()) {
Pair parentChild = entry.getKey();
result.add(DependencyLink.newBuilder()
.parent(parentChild.left())
.child(parentChild.right())
.parent(parentChild.left)
.child(parentChild.right)
.callCount(entry.getValue())
.errorCount(errorCounts.containsKey(parentChild) ? errorCounts.get(parentChild) : 0L)
.build());
}
return result;
}

@AutoValue
static abstract class Pair {
static Pair of(String left, String right) {
return new AutoValue_DependencyLinker_Pair(left, right);
static final class Pair {
final String left, right;

Pair(String left, String right) {
this.left = left;
this.right = right;
}

@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof Pair)) return false;
Pair that = (DependencyLinker.Pair) o;
return left.equals(that.left) && right.equals(that.right);
}

@Override
public int hashCode() {
int h$ = 1;
h$ *= 1000003;
h$ ^= left.hashCode();
h$ *= 1000003;
h$ ^= right.hashCode();
return h$;
}
abstract String left();
abstract String right();
}
}
44 changes: 27 additions & 17 deletions zipkin2/src/main/java/zipkin2/internal/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package zipkin2.internal;

import com.google.auto.value.AutoValue;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -39,12 +38,12 @@
public final class Node<V> {

/** Set via {@link #addChild(Node)} */
private Node<V> parent;
Node<V> parent;
/** mutable as some transformations, such as clock skew, adjust this. */
private V value;
V value;
/** mutable to avoid allocating lists for childless nodes */
private List<Node<V>> children = Collections.emptyList();
private boolean missingRootDummyNode;
List<Node<V>> children = Collections.emptyList();
boolean missingRootDummyNode;

/** Returns the parent, or null if root */
@Nullable public Node<V> parent() {
Expand Down Expand Up @@ -161,14 +160,14 @@ public boolean addNode(@Nullable String parentId, String id, V value) {
}
}
idToParent.put(id, parentId);
entries.add(Entry.create(parentId, id, value));
entries.add(new Entry<>(parentId, id, value));
return true;
}

void processNode(Entry<V> entry) {
String parentId = entry.parentId() != null ? entry.parentId() : idToParent.get(entry.id());
String id = entry.id();
V value = entry.value();
String parentId = entry.parentId != null ? entry.parentId : idToParent.get(entry.id);
String id = entry.id;
V value = entry.value;

if (parentId == null) {
if (rootId != null) {
Expand Down Expand Up @@ -224,16 +223,27 @@ public Node<V> build() {
}
}

@AutoValue
static abstract class Entry<V> {
static <V> Entry<V> create(@Nullable String parentId, String id, V value) {
return new AutoValue_Node_Entry(parentId, id, value);
static final class Entry<V> {
@Nullable final String parentId;
final String id;
final V value;

Entry(@Nullable String parentId, String id, V value) {
if (id == null) throw new NullPointerException("id == null");
if (value == null) throw new NullPointerException("value == null");
this.parentId = parentId;
this.id = id;
this.value = value;
}

@Nullable abstract String parentId();

abstract String id();
@Override
public String toString() {
return "Entry{parentId=" + parentId + ", id=" + id + ", value=" + value + "}";
}
}

abstract V value();
@Override
public String toString() {
return "Node{parent=" + parent + ", value=" + value + ", children=" + children + "}";
}
}
Loading