Skip to content
This repository has been archived by the owner on Apr 12, 2019. It is now read-only.

fix (badly) broken build #10

Closed
wants to merge 17 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ install: true

script:
- mvn -U -s .travis-maven-settings.xml clean package -B -V

before_install:
- sudo apt-get install -y etcd
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ The plan is contribute this to opendaylight.org, if and when successful.

## How to build? [![Build Status](https://travis-ci.org/vorburger/opendaylight-etcd.svg?branch=master)](https://travis-ci.org/vorburger/opendaylight-etcd)

1. To get a more recent version of jetcd-core than the currently used 0.0.2, just
1. To get a more recent version of jetcd-core than the currently used 0.0.3, just
`git clone https://github.com/coreos/jetcd.git ; cd jetcd ; mvn [-DskipTests] clean install`

and change POMs in bom/, features/odl-mdsal-broker/ & features/odl-etcd-demo-restconf/.

2. If you're hitting an NPE in org.apache.maven.plugins:maven-javadoc-plugin:3.0.0:jar,
just use `mvn -Dmaven.javadoc.skip=true -Dduplicate-finder.skip -DskipTests -Dcheckstyle.skip clean install` to work around it; it's possibly
Expand Down
2 changes: 1 addition & 1 deletion artifacts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
<version>3.1.3</version>
<version>4.0.9</version>
<relativePath />
</parent>

Expand Down
6 changes: 3 additions & 3 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
<version>3.1.3</version>
<version>4.0.9</version>
<relativePath/>
</parent>

Expand All @@ -22,7 +22,7 @@
<packaging>pom</packaging>

<properties>
<jetcd.version>0.3.0-SNAPSHOT</jetcd.version>
<jetcd.version>0.3.0</jetcd.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -130,7 +130,7 @@
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>3.0.6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
54 changes: 33 additions & 21 deletions bundle-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,6 @@
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<failOnError>true</failOnError>
</configuration>
</plugin>
<!-- TODO Eclipse JDT null analysis POC -->
</plugins>
</build>

<dependencyManagement>
<dependencies>
<dependency>
Expand All @@ -50,6 +30,32 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<!-- TODO remove this again when pax-cdi-api has been replaced with Blueprint annotations. -->
<groupId>org.ops4j.pax.cdi</groupId>
<artifactId>pax-cdi-api</artifactId>
<optional>true</optional>
<version>1.0.0.RC2</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<exclusions>
<!-- https://github.com/etcd-io/jetcd/pull/493 -->
<exclusion>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.checkerframework</groupId>
<artifactId>checker-compat-qual</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -62,7 +68,13 @@
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<exclusions>
<exclusion>
<!-- https://github.com/etcd-io/jetcd/pull/493 -->
<groupId>org.checkerframework</groupId>
<artifactId>checker-compat-qual</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

</project>
6 changes: 3 additions & 3 deletions demo/src/main/java/org/opendaylight/etcd/demo/DemoMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
*/
package org.opendaylight.etcd.demo;

import static com.google.common.base.Charsets.US_ASCII;
import static io.etcd.jetcd.options.GetOption.SortOrder.ASCEND;
import static io.etcd.jetcd.options.GetOption.SortTarget.KEY;
import static java.nio.charset.StandardCharsets.US_ASCII;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;

import com.google.common.collect.Lists;
import io.etcd.jetcd.ByteSequence;
import io.etcd.jetcd.Client;
import io.etcd.jetcd.data.ByteSequence;
import io.etcd.jetcd.data.KeyValue;
import io.etcd.jetcd.KeyValue;
import io.etcd.jetcd.options.GetOption;
import java.util.List;
import java.util.concurrent.ExecutionException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
package org.opendaylight.etcd.demo;

import static com.google.common.base.Charsets.UTF_8;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;

import io.etcd.jetcd.Client;
Expand Down
27 changes: 18 additions & 9 deletions ds/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
terms of the Eclipse Public License v1.0 which accompanies this distribution,
and is available at http://www.eclipse.org/legal/epl-v10.html
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand Down Expand Up @@ -44,10 +45,10 @@
<artifactId>sal-core-compat</artifactId>
</dependency>
<dependency>
<groupId>org.ops4j.pax.cdi</groupId>
<artifactId>pax-cdi-api</artifactId>
<optional>true</optional>
</dependency>
<groupId>org.ops4j.pax.cdi</groupId>
<artifactId>pax-cdi-api</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
Expand All @@ -70,9 +71,17 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.aries.blueprint</groupId>
<artifactId>blueprint-maven-plugin</artifactId>
</plugin>
<groupId>org.apache.aries.blueprint</groupId>
<artifactId>blueprint-maven-plugin</artifactId>
<dependencies>
<dependency>
<!-- TODO remove this weird hack after version bump... -->
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-dom-api</artifactId>
<version>3.0.6</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
package org.opendaylight.etcd.ds.impl;

import static com.google.common.base.Charsets.US_ASCII;
import static java.nio.charset.StandardCharsets.US_ASCII;

import com.google.common.io.Files;
import io.etcd.jetcd.Client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*/
package org.opendaylight.etcd.ds.impl;

import io.etcd.jetcd.ByteSequence;
import io.etcd.jetcd.Client;
import io.etcd.jetcd.KV;
import io.etcd.jetcd.data.ByteSequence;
import io.etcd.jetcd.data.KeyValue;
import io.etcd.jetcd.KeyValue;
import io.etcd.jetcd.watch.WatchEvent;
import java.time.Duration;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import static java.util.concurrent.TimeUnit.MILLISECONDS;

import io.etcd.jetcd.ByteSequence;
import io.etcd.jetcd.KV;
import io.etcd.jetcd.data.ByteSequence;
import io.etcd.jetcd.data.Response.Header;
import io.etcd.jetcd.Response.Header;
import io.etcd.jetcd.options.GetOption;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
Expand Down
48 changes: 14 additions & 34 deletions ds/src/main/java/org/opendaylight/etcd/ds/impl/EtcdWatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@

import static java.util.Objects.requireNonNull;

import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import io.etcd.jetcd.ByteSequence;
import io.etcd.jetcd.Client;
import io.etcd.jetcd.Watch;
import io.etcd.jetcd.Watch.Watcher;
import io.etcd.jetcd.common.exception.ClosedClientException;
import io.etcd.jetcd.data.ByteSequence;
import io.etcd.jetcd.options.WatchOption;
import io.etcd.jetcd.watch.WatchEvent;
import io.etcd.jetcd.watch.WatchResponse;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.PreDestroy;
Expand Down Expand Up @@ -76,36 +71,21 @@ public void close() {
}

private Watcher watch(long revision) {
Watcher watcher = etcdWatch.watch(prefix,
WatchOption.newBuilder().withPrefix(prefix).withRevision(revision).build());
// TODO is .withRange(prefix + 1) needed?!
Futures.addCallback(executor.submit(() -> {
while (isOpen.get()) {
WatchResponse response = watcher.listen();
List<WatchEvent> events = response.getEvents();
for (WatchEvent event : events) {
LOG.info("{} watch: eventType={}, KV={}", name, event.getEventType(),
KeyValues.toStringable(event.getKeyValue()));
}
consumer.accept(response.getHeader().getRevision(), events);
}
return null;
}), new FutureCallback<Void>() {

@Override
public void onFailure(Throwable throwable) {
// InterruptedException is normal during close() above
// ClosedClientException happens if we close abruptly due to an error (not normally)
if (!(throwable instanceof InterruptedException) && !(throwable instanceof ClosedClientException)) {
LOG.error("{} watch: executor.submit() (eventually) failed: ", name, throwable);
}
Watch.Listener listener = Watch.listener(response -> {
List<WatchEvent> events = response.getEvents();
for (WatchEvent event : events) {
LOG.info("{} watch: eventType={}, KV={}", name, event.getEventType(),
KeyValues.toStringable(event.getKeyValue()));
}

@Override
public void onSuccess(Void nothing) {
// This will happen when isOpen becomes false on close()
try {
consumer.accept(response.getHeader().getRevision(), events);
} catch (EtcdException e) {
LOG.error("watch consumer accept failed", e);
}
}, MoreExecutors.directExecutor());
});
Watcher watcher = etcdWatch.watch(prefix,
WatchOption.newBuilder().withPrefix(prefix).withRevision(revision).build(), listener);
// TODO is .withRange(prefix + 1) needed?!
return watcher;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.ImmutableSet;
import io.etcd.jetcd.data.ByteSequence;
import io.etcd.jetcd.ByteSequence;
import io.etcd.jetcd.watch.WatchEvent;
import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import io.etcd.jetcd.ByteSequence;
import io.etcd.jetcd.Client;
import io.etcd.jetcd.KV;
import io.etcd.jetcd.KeyValue;
import io.etcd.jetcd.Txn;
import io.etcd.jetcd.data.ByteSequence;
import io.etcd.jetcd.data.KeyValue;
import io.etcd.jetcd.kv.TxnResponse;
import io.etcd.jetcd.op.Op;
import io.etcd.jetcd.options.DeleteOption;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/
package org.opendaylight.etcd.ds.inmemory.copypaste;

import com.google.common.base.Preconditions;
import static java.util.Objects.requireNonNull;

import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
Expand All @@ -22,7 +23,7 @@ final class ChainedTransactionCommitImpl extends InMemoryDOMStoreThreePhaseCommi
final DOMStoreTransactionChainImpl txChain,
final Exception operationError) {
super(store, transaction, modification, operationError);
this.txChain = Preconditions.checkNotNull(txChain);
this.txChain = requireNonNull(txChain);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/
package org.opendaylight.etcd.ds.inmemory.copypaste;

import com.google.common.base.Preconditions;
import static java.util.Objects.requireNonNull;

import org.opendaylight.mdsal.dom.spi.store.AbstractSnapshotBackedTransactionChain;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction;
Expand All @@ -19,7 +20,7 @@ final class DOMStoreTransactionChainImpl extends AbstractSnapshotBackedTransacti
private final InMemoryDOMDataStore store;

DOMStoreTransactionChainImpl(final InMemoryDOMDataStore store) {
this.store = Preconditions.checkNotNull(store);
this.store = requireNonNull(store);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/
package org.opendaylight.etcd.ds.inmemory.copypaste;

import com.google.common.base.Preconditions;
import static java.util.Objects.requireNonNull;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
Expand Down Expand Up @@ -69,8 +70,8 @@ public InMemoryDOMDataStore(final String name, final ExecutorService dataChangeL

public InMemoryDOMDataStore(final String name, final ExecutorService dataChangeListenerExecutor,
final int maxDataChangeListenerQueueSize, final boolean debugTransactions) {
this.name = Preconditions.checkNotNull(name);
this.dataChangeListenerExecutor = Preconditions.checkNotNull(dataChangeListenerExecutor);
this.name = requireNonNull(name);
this.dataChangeListenerExecutor = requireNonNull(dataChangeListenerExecutor);
this.debugTransactions = debugTransactions;
changePublisher = new InMemoryDOMStoreTreeChangePublisher(this.dataChangeListenerExecutor,
maxDataChangeListenerQueueSize);
Expand Down
Loading