Committed by
Gerrit Code Review
Update gRPC
- Update gRPC and it's dependencies to 0.13.2 - Use pre-defined default port if not specified by URI - Cosmetic fixes Change-Id: Iac8c3ba4c6fe1b5925ea8832e61d313adfad6f71
Showing
6 changed files
with
58 additions
and
36 deletions
| ... | @@ -14,24 +14,27 @@ | ... | @@ -14,24 +14,27 @@ |
| 14 | ~ See the License for the specific language governing permissions and | 14 | ~ See the License for the specific language governing permissions and |
| 15 | ~ limitations under the License. | 15 | ~ limitations under the License. |
| 16 | --> | 16 | --> |
| 17 | -<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}"> | 17 | +<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1" name="${project.artifactId}-${project.version}"> |
| 18 | <feature name="${project.artifactId}" version="${project.version}" | 18 | <feature name="${project.artifactId}" version="${project.version}" |
| 19 | description="${project.description}"> | 19 | description="${project.description}"> |
| 20 | <feature>onos-api</feature> | 20 | <feature>onos-api</feature> |
| 21 | - <bundle>mvn:com.google.protobuf/protobuf-java/3.0.0-beta-1</bundle> | 21 | + <bundle>mvn:com.google.protobuf/protobuf-java/3.0.0-beta-2</bundle> |
| 22 | - <bundle>mvn:io.netty/netty-common/4.1.0.Beta6</bundle> | 22 | + <bundle>mvn:io.netty/netty-common/4.1.0.CR3</bundle> |
| 23 | - <bundle>mvn:io.netty/netty-buffer/4.1.0.Beta6</bundle> | 23 | + <bundle>mvn:io.netty/netty-buffer/4.1.0.CR3</bundle> |
| 24 | - <bundle>mvn:io.netty/netty-transport/4.1.0.Beta6</bundle> | 24 | + <bundle>mvn:io.netty/netty-transport/4.1.0.CR3</bundle> |
| 25 | - <bundle>mvn:io.netty/netty-handler/4.1.0.Beta6</bundle> | 25 | + <bundle>mvn:io.netty/netty-handler/4.1.0.CR3</bundle> |
| 26 | - <bundle>mvn:io.netty/netty-codec/4.1.0.Beta6</bundle> | 26 | + <bundle>mvn:io.netty/netty-codec/4.1.0.CR3</bundle> |
| 27 | - <bundle>mvn:io.netty/netty-codec-http/4.1.0.Beta6</bundle> | 27 | + <bundle>mvn:io.netty/netty-codec-http/4.1.0.CR3</bundle> |
| 28 | - <bundle>mvn:io.netty/netty-codec-http2/4.1.0.Beta6</bundle> | 28 | + <bundle>mvn:io.netty/netty-codec-http2/4.1.0.CR3</bundle> |
| 29 | - <bundle>mvn:io.netty/netty-resolver/4.1.0.Beta6</bundle> | 29 | + <bundle>mvn:io.netty/netty-resolver/4.1.0.CR3</bundle> |
| 30 | - <bundle>mvn:com.twitter/hpack/0.11.0</bundle> | ||
| 31 | <!-- TODO: Create shaded jar for these. --> | 30 | <!-- TODO: Create shaded jar for these. --> |
| 32 | <bundle>wrap:mvn:com.google.auth/google-auth-library-credentials/0.3.0$Bundle-SymbolicName=com.google.auth.google-auth-library-credentials&Bundle-Version=0.3.0</bundle> | 31 | <bundle>wrap:mvn:com.google.auth/google-auth-library-credentials/0.3.0$Bundle-SymbolicName=com.google.auth.google-auth-library-credentials&Bundle-Version=0.3.0</bundle> |
| 33 | <bundle>wrap:mvn:com.google.auth/google-auth-library-oauth2-http/0.3.0$Bundle-SymbolicName=com.google.auth.google-auth-library-oauth2-http&Bundle-Version=0.3.0</bundle> | 32 | <bundle>wrap:mvn:com.google.auth/google-auth-library-oauth2-http/0.3.0$Bundle-SymbolicName=com.google.auth.google-auth-library-oauth2-http&Bundle-Version=0.3.0</bundle> |
| 34 | - <bundle>wrap:mvn:io.grpc/grpc-all/0.9.0$Bundle-SymbolicName=io.grpc.grpc-all&Bundle-Version=0.9.0&Import-Package=io.netty.*;version=4.1.0.Beta6,javax.net.ssl,com.google.protobuf.nano;resolution:=optional,okio;resolution:=optional,*</bundle> | 33 | + <bundle>wrap:mvn:io.grpc/grpc-core/0.13.2$Bundle-SymbolicName=io.grpc.grpc-core&Bundle-Version=0.13.2&</bundle> |
| 34 | + <bundle>wrap:mvn:io.grpc/grpc-protobuf/0.13.2$Bundle-SymbolicName=io.grpc.grpc-protobuf&Bundle-Version=0.13.2&</bundle> | ||
| 35 | + <bundle>wrap:mvn:io.grpc/grpc-stub/0.13.2$Bundle-SymbolicName=io.grpc.grpc-stub&Bundle-Version=0.13.2&</bundle> | ||
| 36 | + <bundle>wrap:mvn:io.grpc/grpc-netty/0.13.2$Bundle-SymbolicName=io.grpc.grpc-netty&Bundle-Version=0.13.2&Import-Package=io.netty.*;version=4.1.0.CR3,*</bundle> | ||
| 37 | + <bundle>wrap:mvn:io.grpc/grpc-auth/0.13.2$Bundle-SymbolicName=io.grpc.grpc-auth&Bundle-Version=0.13.2&Import-Package=javax.net.ssl,*</bundle> | ||
| 35 | <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle> | 38 | <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle> |
| 36 | </feature> | 39 | </feature> |
| 37 | </features> | 40 | </features> | ... | ... |
| ... | @@ -32,18 +32,10 @@ | ... | @@ -32,18 +32,10 @@ |
| 32 | <onos.app.name>org.onosproject.incubator.rpc.grpc</onos.app.name> | 32 | <onos.app.name>org.onosproject.incubator.rpc.grpc</onos.app.name> |
| 33 | <onos.app.requires>org.onosproject.incubator.rpc</onos.app.requires> | 33 | <onos.app.requires>org.onosproject.incubator.rpc</onos.app.requires> |
| 34 | <!-- Note: update feature.xml when updating --> | 34 | <!-- Note: update feature.xml when updating --> |
| 35 | - <grpc.version>0.9.0</grpc.version> | 35 | + <grpc.version>0.13.2</grpc.version> |
| 36 | - <grpc.netty.version>4.1.0.Beta6</grpc.netty.version> | 36 | + <grpc.netty.version>4.1.0.CR3</grpc.netty.version> |
| 37 | </properties> | 37 | </properties> |
| 38 | 38 | ||
| 39 | - <pluginRepositories> | ||
| 40 | - <pluginRepository> | ||
| 41 | - <id>protoc-plugin</id> | ||
| 42 | - <url>https://dl.bintray.com/sergei-ivanov/maven/</url> | ||
| 43 | - </pluginRepository> | ||
| 44 | - </pluginRepositories> | ||
| 45 | - | ||
| 46 | - | ||
| 47 | <dependencies> | 39 | <dependencies> |
| 48 | <dependency> | 40 | <dependency> |
| 49 | <groupId>org.onosproject</groupId> | 41 | <groupId>org.onosproject</groupId> |
| ... | @@ -117,10 +109,21 @@ | ... | @@ -117,10 +109,21 @@ |
| 117 | <extension> | 109 | <extension> |
| 118 | <groupId>kr.motd.maven</groupId> | 110 | <groupId>kr.motd.maven</groupId> |
| 119 | <artifactId>os-maven-plugin</artifactId> | 111 | <artifactId>os-maven-plugin</artifactId> |
| 120 | - <version>1.4.0.Final</version> | 112 | + <version>1.4.1.Final</version> |
| 121 | </extension> | 113 | </extension> |
| 122 | </extensions> | 114 | </extensions> |
| 123 | 115 | ||
| 116 | + <pluginManagement> | ||
| 117 | + <plugins> | ||
| 118 | + <plugin> | ||
| 119 | + <groupId>org.apache.karaf.tooling</groupId> | ||
| 120 | + <artifactId>karaf-maven-plugin</artifactId> | ||
| 121 | + <version>3.0.5</version> | ||
| 122 | + <extensions>true</extensions> | ||
| 123 | + </plugin> | ||
| 124 | + </plugins> | ||
| 125 | + </pluginManagement> | ||
| 126 | + | ||
| 124 | <plugins> | 127 | <plugins> |
| 125 | <!-- TODO This is included to suppress the generation of javadocs for | 128 | <!-- TODO This is included to suppress the generation of javadocs for |
| 126 | this package. There is a problem when we try to package the | 129 | this package. There is a problem when we try to package the |
| ... | @@ -196,16 +199,17 @@ | ... | @@ -196,16 +199,17 @@ |
| 196 | </plugin> | 199 | </plugin> |
| 197 | 200 | ||
| 198 | <plugin> | 201 | <plugin> |
| 199 | - <groupId>com.google.protobuf.tools</groupId> | 202 | + <groupId>org.xolstice.maven.plugins</groupId> |
| 200 | - <artifactId>maven-protoc-plugin</artifactId> | 203 | + <artifactId>protobuf-maven-plugin</artifactId> |
| 201 | - <version>0.4.2</version> | 204 | + <version>0.5.0</version> |
| 202 | <configuration> | 205 | <configuration> |
| 203 | <!-- The version of protoc must match protobuf-java. If you don't | 206 | <!-- The version of protoc must match protobuf-java. If you don't |
| 204 | depend on protobuf-java directly, you will be transitively depending on the | 207 | depend on protobuf-java directly, you will be transitively depending on the |
| 205 | protobuf-java version that grpc depends on. --> | 208 | protobuf-java version that grpc depends on. --> |
| 206 | - <protocArtifact>com.google.protobuf:protoc:3.0.0-beta-1:exe:${os.detected.classifier}</protocArtifact> | 209 | + <protocArtifact>com.google.protobuf:protoc:3.0.0-beta-2:exe:${os.detected.classifier}</protocArtifact> |
| 207 | <pluginId>grpc-java</pluginId> | 210 | <pluginId>grpc-java</pluginId> |
| 208 | <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact> | 211 | <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact> |
| 212 | + <checkStaleness>true</checkStaleness> | ||
| 209 | </configuration> | 213 | </configuration> |
| 210 | <executions> | 214 | <executions> |
| 211 | <execution> | 215 | <execution> |
| ... | @@ -220,7 +224,7 @@ | ... | @@ -220,7 +224,7 @@ |
| 220 | <plugin> | 224 | <plugin> |
| 221 | <groupId>org.codehaus.mojo</groupId> | 225 | <groupId>org.codehaus.mojo</groupId> |
| 222 | <artifactId>build-helper-maven-plugin</artifactId> | 226 | <artifactId>build-helper-maven-plugin</artifactId> |
| 223 | - <version>1.9.1</version> | 227 | + <version>1.10</version> |
| 224 | <executions> | 228 | <executions> |
| 225 | <execution> | 229 | <execution> |
| 226 | <id>add-source</id> | 230 | <id>add-source</id> | ... | ... |
| ... | @@ -55,7 +55,7 @@ final class DeviceProviderRegistryClientProxy | ... | @@ -55,7 +55,7 @@ final class DeviceProviderRegistryClientProxy |
| 55 | 55 | ||
| 56 | // Create session | 56 | // Create session |
| 57 | DeviceProviderServiceClientProxy pService = new DeviceProviderServiceClientProxy(provider, channel); | 57 | DeviceProviderServiceClientProxy pService = new DeviceProviderServiceClientProxy(provider, channel); |
| 58 | - log.debug("Created DeviceProviderServiceClientProxy", pService); | 58 | + log.debug("Created DeviceProviderServiceClientProxy {}", pService); |
| 59 | 59 | ||
| 60 | DeviceProviderServiceClientProxy old = pServices.put(provider, pService); | 60 | DeviceProviderServiceClientProxy old = pServices.put(provider, pService); |
| 61 | if (old != null) { | 61 | if (old != null) { |
| ... | @@ -68,7 +68,7 @@ final class DeviceProviderRegistryClientProxy | ... | @@ -68,7 +68,7 @@ final class DeviceProviderRegistryClientProxy |
| 68 | @Override | 68 | @Override |
| 69 | public synchronized void unregister(DeviceProvider provider) { | 69 | public synchronized void unregister(DeviceProvider provider) { |
| 70 | DeviceProviderServiceClientProxy pService = pServices.remove(provider); | 70 | DeviceProviderServiceClientProxy pService = pServices.remove(provider); |
| 71 | - log.debug("Unregistering DeviceProviderServiceClientProxy", pService); | 71 | + log.debug("Unregistering DeviceProviderServiceClientProxy {}", pService); |
| 72 | super.unregister(provider); | 72 | super.unregister(provider); |
| 73 | if (pService != null) { | 73 | if (pService != null) { |
| 74 | pService.shutdown(); | 74 | pService.shutdown(); | ... | ... |
| ... | @@ -58,7 +58,7 @@ public class GrpcRemoteServiceProvider implements RemoteServiceContextProvider { | ... | @@ -58,7 +58,7 @@ public class GrpcRemoteServiceProvider implements RemoteServiceContextProvider { |
| 58 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 58 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 59 | protected RemoteServiceProviderRegistry rpcRegistry; | 59 | protected RemoteServiceProviderRegistry rpcRegistry; |
| 60 | 60 | ||
| 61 | - private Map<URI, ManagedChannel> channels = new ConcurrentHashMap<>(); | 61 | + private final Map<URI, ManagedChannel> channels = new ConcurrentHashMap<>(); |
| 62 | 62 | ||
| 63 | private RemoteServiceContextProviderService providerService; | 63 | private RemoteServiceContextProviderService providerService; |
| 64 | 64 | ||
| ... | @@ -67,8 +67,8 @@ public class GrpcRemoteServiceProvider implements RemoteServiceContextProvider { | ... | @@ -67,8 +67,8 @@ public class GrpcRemoteServiceProvider implements RemoteServiceContextProvider { |
| 67 | protected void activate() { | 67 | protected void activate() { |
| 68 | providerService = rpcRegistry.register(this); | 68 | providerService = rpcRegistry.register(this); |
| 69 | 69 | ||
| 70 | - // FIXME remove me. test code to see if gRPC loads in karaf | 70 | + // Uncomment to test if gRPC can be loaded in karaf |
| 71 | - //getChannel(URI.create("grpc://localhost:8080")); | 71 | + //getChannel(URI.create("grpc://localhost:11984")); |
| 72 | 72 | ||
| 73 | log.info("Started"); | 73 | log.info("Started"); |
| 74 | } | 74 | } |
| ... | @@ -111,7 +111,11 @@ public class GrpcRemoteServiceProvider implements RemoteServiceContextProvider { | ... | @@ -111,7 +111,11 @@ public class GrpcRemoteServiceProvider implements RemoteServiceContextProvider { |
| 111 | 111 | ||
| 112 | private ManagedChannel createChannel(URI uri) { | 112 | private ManagedChannel createChannel(URI uri) { |
| 113 | log.debug("Creating channel for {}", uri); | 113 | log.debug("Creating channel for {}", uri); |
| 114 | - return NettyChannelBuilder.forAddress(uri.getHost(), uri.getPort()) | 114 | + int port = GrpcRemoteServiceServer.DEFAULT_LISTEN_PORT; |
| 115 | + if (uri.getPort() != -1) { | ||
| 116 | + port = uri.getPort(); | ||
| 117 | + } | ||
| 118 | + return NettyChannelBuilder.forAddress(uri.getHost(), port) | ||
| 115 | .negotiationType(NegotiationType.PLAINTEXT) | 119 | .negotiationType(NegotiationType.PLAINTEXT) |
| 116 | .build(); | 120 | .build(); |
| 117 | } | 121 | } | ... | ... |
| ... | @@ -165,6 +165,7 @@ public class GrpcRemoteServiceServer { | ... | @@ -165,6 +165,7 @@ public class GrpcRemoteServiceServer { |
| 165 | * Unregisters all registered LinkProviders. | 165 | * Unregisters all registered LinkProviders. |
| 166 | */ | 166 | */ |
| 167 | private synchronized void unregisterLinkProviders() { | 167 | private synchronized void unregisterLinkProviders() { |
| 168 | + // TODO remove all links registered by these providers | ||
| 168 | linkProviders.values().forEach(linkProviderRegistry::unregister); | 169 | linkProviders.values().forEach(linkProviderRegistry::unregister); |
| 169 | linkProviders.clear(); | 170 | linkProviders.clear(); |
| 170 | linkProviderServices.clear(); | 171 | linkProviderServices.clear(); |
| ... | @@ -250,6 +251,7 @@ public class GrpcRemoteServiceServer { | ... | @@ -250,6 +251,7 @@ public class GrpcRemoteServiceServer { |
| 250 | // TODO Do we care about provider name? | 251 | // TODO Do we care about provider name? |
| 251 | pairedProvider.setProviderId(new ProviderId(registerProvider.getProviderScheme(), RPC_PROVIDER_NAME)); | 252 | pairedProvider.setProviderId(new ProviderId(registerProvider.getProviderScheme(), RPC_PROVIDER_NAME)); |
| 252 | registeredProviders.add(pairedProvider); | 253 | registeredProviders.add(pairedProvider); |
| 254 | + log.info("registering DeviceProvider {} via gRPC", pairedProvider.id()); | ||
| 253 | deviceProviderService = deviceProviderRegistry.register(pairedProvider); | 255 | deviceProviderService = deviceProviderRegistry.register(pairedProvider); |
| 254 | break; | 256 | break; |
| 255 | 257 | ||
| ... | @@ -319,8 +321,13 @@ public class GrpcRemoteServiceServer { | ... | @@ -319,8 +321,13 @@ public class GrpcRemoteServiceServer { |
| 319 | @Override | 321 | @Override |
| 320 | public void onError(Throwable e) { | 322 | public void onError(Throwable e) { |
| 321 | log.error("DeviceProviderServiceServerProxy#onError", e); | 323 | log.error("DeviceProviderServiceServerProxy#onError", e); |
| 322 | - deviceProviderRegistry.unregister(pairedProvider); | 324 | + if (pairedProvider != null) { |
| 323 | - registeredProviders.remove(pairedProvider); | 325 | + // TODO call deviceDisconnected against all devices |
| 326 | + // registered for this provider scheme | ||
| 327 | + log.info("unregistering DeviceProvider {} via gRPC", pairedProvider.id()); | ||
| 328 | + deviceProviderRegistry.unregister(pairedProvider); | ||
| 329 | + registeredProviders.remove(pairedProvider); | ||
| 330 | + } | ||
| 324 | // TODO What is the proper clean up for bi-di stream on error? | 331 | // TODO What is the proper clean up for bi-di stream on error? |
| 325 | // sample suggests no-op | 332 | // sample suggests no-op |
| 326 | toDeviceProvider.onError(e); | 333 | toDeviceProvider.onError(e); |
| ... | @@ -364,6 +371,7 @@ public class GrpcRemoteServiceServer { | ... | @@ -364,6 +371,7 @@ public class GrpcRemoteServiceServer { |
| 364 | 371 | ||
| 365 | /** | 372 | /** |
| 366 | * Registers RPC stream in other direction. | 373 | * Registers RPC stream in other direction. |
| 374 | + * | ||
| 367 | * @param deviceProviderServiceProxy {@link DeviceProviderServiceServerProxy} | 375 | * @param deviceProviderServiceProxy {@link DeviceProviderServiceServerProxy} |
| 368 | */ | 376 | */ |
| 369 | void pair(DeviceProviderServiceServerProxy deviceProviderServiceProxy) { | 377 | void pair(DeviceProviderServiceServerProxy deviceProviderServiceProxy) { | ... | ... |
| ... | @@ -51,6 +51,9 @@ final class LinkProviderServiceServerProxy | ... | @@ -51,6 +51,9 @@ final class LinkProviderServiceServerProxy |
| 51 | 51 | ||
| 52 | private final GrpcRemoteServiceServer server; | 52 | private final GrpcRemoteServiceServer server; |
| 53 | 53 | ||
| 54 | + // TODO implement aging mechanism to automatically remove | ||
| 55 | + // stale links reported by dead client, etc. | ||
| 56 | + | ||
| 54 | LinkProviderServiceServerProxy(GrpcRemoteServiceServer server) { | 57 | LinkProviderServiceServerProxy(GrpcRemoteServiceServer server) { |
| 55 | this.server = checkNotNull(server); | 58 | this.server = checkNotNull(server); |
| 56 | } | 59 | } | ... | ... |
-
Please register or login to post a comment