Yuta HIGUCHI
Committed by Gerrit Code Review

Update ProtoBuf 3 & gRPC

- Protocol Buffers: 3.0.0
- gRPC: 1.0.0-pre2

Change-Id: Ic80d3f660d4a0aa37a99d4e6d4dc45e0b70b073b
Showing 19 changed files with 67 additions and 64 deletions
......@@ -36,7 +36,7 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.0.0-beta-2</version>
<version>3.0.0</version>
</dependency>
<dependency>
......
......@@ -16,7 +16,8 @@
package org.onosproject.kafkaintegration.api;
import com.google.protobuf.GeneratedMessage;
import com.google.protobuf.GeneratedMessageV3;
import org.onosproject.kafkaintegration.api.dto.OnosEvent.Type;
/**
......@@ -30,5 +31,6 @@ public interface KafkaPublisherService {
* @param eventType the ONOS eventtype
* @param message generated Protocol buffer message from ONOS event data
*/
void publish(Type eventType, GeneratedMessage message);
// FIXME reconsider message type, something similar to "OnosEvent"?
void publish(Type eventType, GeneratedMessageV3 message);
}
......
......@@ -16,13 +16,14 @@ package org.onosproject.kafkaintegration.api.dto;
import org.onosproject.event.AbstractEvent;
import com.google.protobuf.GeneratedMessage;
import com.google.protobuf.GeneratedMessageV3;
/**
* Represents the converted Onos Event data into protobuf format.
*
*/
public class OnosEvent extends AbstractEvent<OnosEvent.Type, GeneratedMessage> {
// FIXME lack of abstraction in subject type is biting us
public class OnosEvent extends AbstractEvent<OnosEvent.Type, GeneratedMessageV3> {
/**
* Creates a new Onos Event.
......@@ -30,7 +31,7 @@ public class OnosEvent extends AbstractEvent<OnosEvent.Type, GeneratedMessage> {
* @param type The Type of Onos Event
* @param subject Protobuf message corresponding to the Onos Event
*/
public OnosEvent(Type type, GeneratedMessage subject) {
public OnosEvent(Type type, GeneratedMessageV3 subject) {
super(type, subject);
}
......
......@@ -50,7 +50,6 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
......@@ -74,7 +73,7 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.0.0-beta-2</version>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
......
......@@ -14,7 +14,8 @@
*/
package org.onosproject.kafkaintegration.converter;
import com.google.protobuf.GeneratedMessage;
import com.google.protobuf.GeneratedMessageV3;
import org.onosproject.event.Event;
import org.onosproject.grpc.net.Device.DeviceCore;
import org.onosproject.grpc.net.Device.DeviceType;
......@@ -34,7 +35,7 @@ public class DeviceEventConverter implements EventConverter {
private final Logger log = LoggerFactory.getLogger(getClass());
@Override
public GeneratedMessage convertToProtoMessage(Event<?, ?> event) {
public GeneratedMessageV3 convertToProtoMessage(Event<?, ?> event) {
DeviceEvent deviceEvent = (DeviceEvent) event;
......
......@@ -16,7 +16,7 @@ package org.onosproject.kafkaintegration.converter;
import org.onosproject.event.Event;
import com.google.protobuf.GeneratedMessage;
import com.google.protobuf.GeneratedMessageV3;
/**
*
......@@ -32,5 +32,6 @@ public interface EventConverter {
* @param event ONOS Event object
* @return converted data in protobuf format.
*/
GeneratedMessage convertToProtoMessage(Event<?, ?> event);
// FIXME reconsider return type, something similar to "OnosEvent"?
GeneratedMessageV3 convertToProtoMessage(Event<?, ?> event);
}
......
......@@ -25,7 +25,7 @@ import org.onosproject.net.link.LinkEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.protobuf.GeneratedMessage;
import com.google.protobuf.GeneratedMessageV3;
/**
* Converts for ONOS Link event message to protobuf format.
......@@ -35,7 +35,7 @@ public class LinkEventConverter implements EventConverter {
private final Logger log = LoggerFactory.getLogger(getClass());
@Override
public GeneratedMessage convertToProtoMessage(Event<?, ?> event) {
public GeneratedMessageV3 convertToProtoMessage(Event<?, ?> event) {
LinkEvent linkEvent = (LinkEvent) event;
......
......@@ -22,7 +22,7 @@ import org.onosproject.kafkaintegration.api.dto.OnosEvent.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.protobuf.GeneratedMessage;
import com.google.protobuf.GeneratedMessageV3;
/**
* Dispatch ONOS Events to all interested Listeners.
......@@ -53,7 +53,7 @@ public final class KafkaPublisherManager
}
@Override
public void publish(Type eventType, GeneratedMessage message) {
public void publish(Type eventType, GeneratedMessageV3 message) {
log.debug("Dispatching ONOS Event {}", eventType);
post(new OnosEvent(eventType, message));
}
......
......@@ -87,7 +87,7 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.0.0-beta-2</version>
<version>3.0.0</version>
</dependency>
<dependency>
......
......@@ -18,7 +18,7 @@
<feature name="${project.artifactId}" version="${project.version}"
description="${project.description}">
<feature>onos-api</feature>
<bundle>mvn:com.google.protobuf/protobuf-java/3.0.0-beta-2</bundle>
<bundle>mvn:com.google.protobuf/protobuf-java/3.0.0</bundle>
<bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
</feature>
</features>
......
......@@ -30,9 +30,9 @@
<properties>
<onos.app.name>org.onosproject.incubator.protobuf</onos.app.name>
<onos.app.requires>org.onosproject.incubator.rpc</onos.app.requires>
<onos.app.title>ONOS Protocol Buffers models</onos.app.title>
<!-- Note: update feature.xml when updating -->
<protobuf.version>3.0.0-beta-2</protobuf.version>
<protobuf.version>3.0.0</protobuf.version>
</properties>
<dependencies>
......@@ -129,7 +129,6 @@
depend on protobuf-java directly, you will be transitively depending on the
protobuf-java version that grpc depends on. -->
<protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
<checkStaleness>true</checkStaleness>
</configuration>
<executions>
<execution>
......@@ -143,7 +142,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version>
<version>1.11</version>
<executions>
<execution>
<id>add-source</id>
......
......@@ -18,24 +18,25 @@
<feature name="${project.artifactId}" version="${project.version}"
description="${project.description}">
<feature>onos-api</feature>
<bundle>mvn:com.google.protobuf/protobuf-java/3.0.0-beta-2</bundle>
<bundle>mvn:io.netty/netty-common/4.1.0.CR7</bundle>
<bundle>mvn:io.netty/netty-buffer/4.1.0.CR7</bundle>
<bundle>mvn:io.netty/netty-transport/4.1.0.CR7</bundle>
<bundle>mvn:io.netty/netty-handler/4.1.0.CR7</bundle>
<bundle>mvn:io.netty/netty-codec/4.1.0.CR7</bundle>
<bundle>mvn:io.netty/netty-codec-http/4.1.0.CR7</bundle>
<bundle>mvn:io.netty/netty-codec-http2/4.1.0.CR7</bundle>
<bundle>mvn:io.netty/netty-resolver/4.1.0.CR7</bundle>
<bundle>mvn:com.google.protobuf/protobuf-java/3.0.0</bundle>
<bundle>mvn:io.netty/netty-common/4.1.3.Final</bundle>
<bundle>mvn:io.netty/netty-buffer/4.1.3.Final</bundle>
<bundle>mvn:io.netty/netty-transport/4.1.3.Final</bundle>
<bundle>mvn:io.netty/netty-handler/4.1.3.Final</bundle>
<bundle>mvn:io.netty/netty-codec/4.1.3.Final</bundle>
<bundle>mvn:io.netty/netty-codec-http/4.1.3.Final</bundle>
<bundle>mvn:io.netty/netty-codec-http2/4.1.3.Final</bundle>
<bundle>mvn:io.netty/netty-resolver/4.1.3.Final</bundle>
<!-- TODO: Create shaded jar for these. -->
<bundle>wrap:mvn:com.google.auth/google-auth-library-credentials/0.3.0$Bundle-SymbolicName=com.google.auth.google-auth-library-credentials&amp;Bundle-Version=0.3.0</bundle>
<bundle>wrap:mvn:com.google.auth/google-auth-library-oauth2-http/0.3.0$Bundle-SymbolicName=com.google.auth.google-auth-library-oauth2-http&amp;Bundle-Version=0.3.0</bundle>
<bundle>wrap:mvn:io.grpc/grpc-core/0.14.0$Bundle-SymbolicName=io.grpc.grpc-core&amp;Bundle-Version=0.14.0&amp;</bundle>
<bundle>wrap:mvn:io.grpc/grpc-protobuf-lite/0.14.0$Bundle-SymbolicName=io.grpc.grpc-protobuf-lite&amp;Bundle-Version=0.14.0&amp;</bundle>
<bundle>wrap:mvn:io.grpc/grpc-protobuf/0.14.0$Bundle-SymbolicName=io.grpc.grpc-protobuf&amp;Bundle-Version=0.14.0&amp;</bundle>
<bundle>wrap:mvn:io.grpc/grpc-stub/0.14.0$Bundle-SymbolicName=io.grpc.grpc-stub&amp;Bundle-Version=0.14.0&amp;</bundle>
<bundle>wrap:mvn:io.grpc/grpc-netty/0.14.0$Bundle-SymbolicName=io.grpc.grpc-netty&amp;Bundle-Version=0.14.0&amp;Import-Package=io.netty.*;version=4.1.0.CR7,*</bundle>
<bundle>wrap:mvn:io.grpc/grpc-auth/0.14.0$Bundle-SymbolicName=io.grpc.grpc-auth&amp;Bundle-Version=0.14.0&amp;Import-Package=javax.net.ssl,*</bundle>
<bundle>wrap:mvn:com.google.auth/google-auth-library-credentials/0.4.0$Bundle-SymbolicName=com.google.auth.google-auth-library-credentials&amp;Bundle-Version=0.4.0</bundle>
<bundle>wrap:mvn:com.google.auth/google-auth-library-oauth2-http/0.4.0$Bundle-SymbolicName=com.google.auth.google-auth-library-oauth2-http&amp;Bundle-Version=0.4.0</bundle>
<!-- io.grpc.internal required for DnsNameResolverProvider -->
<bundle>wrap:mvn:io.grpc/grpc-core/1.0.0-pre2$Bundle-SymbolicName=io.grpc.grpc-core&amp;Bundle-Version=1.0.0&amp;Export-Package=*;version=1.0.0,io.grpc.internal;version=1.0.0&amp;</bundle>
<bundle>wrap:mvn:io.grpc/grpc-protobuf-lite/1.0.0-pre2$Bundle-SymbolicName=io.grpc.grpc-protobuf-lite&amp;Bundle-Version=1.0.0&amp;</bundle>
<bundle>wrap:mvn:io.grpc/grpc-protobuf/1.0.0-pre2$Bundle-SymbolicName=io.grpc.grpc-protobuf&amp;Bundle-Version=1.0.0&amp;</bundle>
<bundle>wrap:mvn:io.grpc/grpc-stub/1.0.0-pre2$Bundle-SymbolicName=io.grpc.grpc-stub&amp;Bundle-Version=1.0.0&amp;</bundle>
<bundle>wrap:mvn:io.grpc/grpc-netty/1.0.0-pre2$Bundle-SymbolicName=io.grpc.grpc-netty&amp;Bundle-Version=1.0.0&amp;Import-Package=io.netty.*;version=4.1.3,*</bundle>
<bundle>wrap:mvn:io.grpc/grpc-auth/1.0.0-pre2$Bundle-SymbolicName=io.grpc.grpc-auth&amp;Bundle-Version=1.0.0&amp;Import-Package=javax.net.ssl,*</bundle>
<bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
</feature>
</features>
......
......@@ -30,11 +30,15 @@
<properties>
<onos.app.name>org.onosproject.incubator.rpc.grpc</onos.app.name>
<onos.app.requires>org.onosproject.incubator.rpc,org.onosproject.incubator.protobuf</onos.app.requires>
<protobuf.version>3.0.0-beta-2</protobuf.version>
<onos.app.title>ONOS gRPC API</onos.app.title>
<onos.app.requires>
org.onosproject.incubator.rpc,
org.onosproject.incubator.protobuf
</onos.app.requires>
<protobuf.version>3.0.0</protobuf.version>
<!-- Note: update feature.xml when updating -->
<grpc.version>0.14.0</grpc.version>
<grpc.netty.version>4.1.0.CR7</grpc.netty.version>
<grpc.version>1.0.0-pre2</grpc.version>
<grpc.netty.version>4.1.3.Final</grpc.netty.version>
</properties>
<dependencies>
......@@ -211,7 +215,6 @@
<protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
<checkStaleness>true</checkStaleness>
</configuration>
<executions>
<execution>
......@@ -226,7 +229,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version>
<version>1.11</version>
<executions>
<execution>
<id>add-source</id>
......@@ -274,12 +277,6 @@
<artifactId>netty-common</artifactId>
<version>${grpc.netty.version}</version>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>hpack</artifactId>
<!-- 0.11.0 and later are published as a bundle -->
<version>0.11.0</version>
</dependency>
</dependencies>
</dependencyManagement>
......
......@@ -36,6 +36,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.grpc.ManagedChannel;
import io.grpc.internal.DnsNameResolverProvider;
import io.grpc.netty.NegotiationType;
import io.grpc.netty.NettyChannelBuilder;
......@@ -62,7 +63,6 @@ public class GrpcRemoteServiceProvider implements RemoteServiceContextProvider {
private RemoteServiceContextProviderService providerService;
@Activate
protected void activate() {
providerService = rpcRegistry.register(this);
......@@ -116,6 +116,10 @@ public class GrpcRemoteServiceProvider implements RemoteServiceContextProvider {
}
return NettyChannelBuilder.forAddress(uri.getHost(), port)
.negotiationType(NegotiationType.PLAINTEXT)
// TODO Not ideal fix, gRPC discovers name resolvers
// in the class path, but OSGi was preventing it.
// Manually specifying the default dns resolver for now.
.nameResolverFactory(new DnsNameResolverProvider())
.build();
}
......
......@@ -39,8 +39,7 @@ import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.util.Tools;
import org.onosproject.grpc.net.device.DeviceProviderRegistryRpcGrpc;
import org.onosproject.grpc.net.device.DeviceProviderRegistryRpcGrpc.DeviceProviderRegistryRpc;
import org.onosproject.grpc.net.device.DeviceProviderRegistryRpcGrpc.DeviceProviderRegistryRpcImplBase;
import org.onosproject.grpc.net.device.DeviceService.DeviceConnected;
import org.onosproject.grpc.net.device.DeviceService.DeviceDisconnected;
import org.onosproject.grpc.net.device.DeviceService.DeviceProviderMsg;
......@@ -51,7 +50,6 @@ import org.onosproject.grpc.net.device.DeviceService.ReceivedRoleReply;
import org.onosproject.grpc.net.device.DeviceService.RegisterProvider;
import org.onosproject.grpc.net.device.DeviceService.UpdatePortStatistics;
import org.onosproject.grpc.net.device.DeviceService.UpdatePorts;
import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc;
import org.onosproject.incubator.protobuf.net.ProtobufUtils;
import org.onosproject.net.DeviceId;
import org.onosproject.net.MastershipRole;
......@@ -123,8 +121,8 @@ public class GrpcRemoteServiceServer {
log.debug("Server starting on {}", listenPort);
try {
server = NettyServerBuilder.forPort(listenPort)
.addService(DeviceProviderRegistryRpcGrpc.bindService(new DeviceProviderRegistryServerProxy()))
.addService(LinkProviderServiceRpcGrpc.bindService(new LinkProviderServiceServerProxy(this)))
.addService(new DeviceProviderRegistryServerProxy())
.addService(new LinkProviderServiceServerProxy(this))
.build().start();
} catch (IOException e) {
log.error("Failed to start gRPC server", e);
......@@ -202,7 +200,7 @@ public class GrpcRemoteServiceServer {
/**
* Relays DeviceProviderRegistry calls from RPC client.
*/
class DeviceProviderRegistryServerProxy implements DeviceProviderRegistryRpc {
class DeviceProviderRegistryServerProxy extends DeviceProviderRegistryRpcImplBase {
@Override
public StreamObserver<DeviceProviderServiceMsg> register(StreamObserver<DeviceProviderMsg> toDeviceProvider) {
......
......@@ -22,7 +22,7 @@ import org.onosproject.net.link.LinkProviderRegistry;
import org.onosproject.net.link.LinkProviderService;
import org.onosproject.net.provider.AbstractProviderRegistry;
import com.google.api.client.repackaged.com.google.common.annotations.Beta;
import com.google.common.annotations.Beta;
import io.grpc.Channel;
......
......@@ -38,7 +38,7 @@ import org.onosproject.net.provider.ProviderId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.api.client.repackaged.com.google.common.annotations.Beta;
import com.google.common.annotations.Beta;
import com.google.common.util.concurrent.ListenableFuture;
import io.grpc.Channel;
......
......@@ -27,7 +27,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.tuple.Pair;
import org.onosproject.grpc.net.Link.ConnectPoint.ElementIdCase;
import org.onosproject.grpc.net.Link.LinkType;
import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc.LinkProviderServiceRpc;
import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc.LinkProviderServiceRpcImplBase;
import org.onosproject.grpc.net.link.LinkService.LinkDetectedMsg;
import org.onosproject.grpc.net.link.LinkService.LinkVanishedMsg;
import org.onosproject.grpc.net.link.LinkService.Void;
......@@ -44,10 +44,10 @@ import org.onosproject.net.link.LinkProviderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.api.client.repackaged.com.google.common.annotations.Beta;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.RemovalNotification;
import com.google.common.annotations.Beta;
import io.grpc.stub.StreamObserver;
......@@ -57,7 +57,7 @@ import io.grpc.stub.StreamObserver;
*/
@Beta
final class LinkProviderServiceServerProxy
implements LinkProviderServiceRpc {
extends LinkProviderServiceRpcImplBase {
/**
* Silence time in seconds, until link gets treated as vanished.
......
......@@ -19,7 +19,7 @@ import org.onosproject.net.link.LinkProvider;
import org.onosproject.net.provider.AbstractProvider;
import org.onosproject.net.provider.ProviderId;
import com.google.api.client.repackaged.com.google.common.annotations.Beta;
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
/**
......