HIGUCHI Yuta
Committed by Yuta HIGUCHI

[ONOS-4520] Move Protobuf to ONOS model conversion util protobuf bundle.

Change-Id: I0fbfd750d569cb5da6dd29af5aa77d19d6f29494
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
90 <extensions>true</extensions> 90 <extensions>true</extensions>
91 <configuration> 91 <configuration>
92 <instructions> 92 <instructions>
93 - <Export-Package>org.onosproject.grpc.net</Export-Package> 93 + <Export-Package>org.onosproject.grpc.net,org.onosproject.incubator.protobuf.net</Export-Package>
94 </instructions> 94 </instructions>
95 </configuration> 95 </configuration>
96 </plugin> 96 </plugin>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.incubator.rpc.grpc; 16 +package org.onosproject.incubator.protobuf.net;
17 17
18 import java.net.URI; 18 import java.net.URI;
19 import java.util.HashMap; 19 import java.util.HashMap;
...@@ -39,15 +39,16 @@ import org.onosproject.net.device.PortStatistics; ...@@ -39,15 +39,16 @@ import org.onosproject.net.device.PortStatistics;
39 import org.slf4j.Logger; 39 import org.slf4j.Logger;
40 import org.slf4j.LoggerFactory; 40 import org.slf4j.LoggerFactory;
41 41
42 -import com.google.api.client.repackaged.com.google.common.annotations.Beta; 42 +import com.google.common.annotations.Beta;
43 +
43 44
44 /** 45 /**
45 * gRPC message conversion related utilities. 46 * gRPC message conversion related utilities.
46 */ 47 */
47 @Beta 48 @Beta
48 -public final class GrpcDeviceUtils { 49 +public final class ProtobufUtils {
49 50
50 - private static final Logger log = LoggerFactory.getLogger(GrpcDeviceUtils.class); 51 + private static final Logger log = LoggerFactory.getLogger(ProtobufUtils.class);
51 52
52 /** 53 /**
53 * Translates gRPC enum MastershipRole to ONOS enum. 54 * Translates gRPC enum MastershipRole to ONOS enum.
...@@ -378,5 +379,5 @@ public final class GrpcDeviceUtils { ...@@ -378,5 +379,5 @@ public final class GrpcDeviceUtils {
378 } 379 }
379 380
380 // Utility class not intended for instantiation. 381 // Utility class not intended for instantiation.
381 - private GrpcDeviceUtils() {} 382 + private ProtobufUtils() {}
382 } 383 }
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +/**
17 + * Utilities to handle ProtoBuf version of ONOS network models.
18 + */
19 +package org.onosproject.incubator.protobuf.net;
...@@ -17,7 +17,7 @@ package org.onosproject.incubator.rpc.grpc; ...@@ -17,7 +17,7 @@ package org.onosproject.incubator.rpc.grpc;
17 17
18 import static com.google.common.base.Preconditions.checkNotNull; 18 import static com.google.common.base.Preconditions.checkNotNull;
19 import static java.util.stream.Collectors.toList; 19 import static java.util.stream.Collectors.toList;
20 -import static org.onosproject.incubator.rpc.grpc.GrpcDeviceUtils.translate; 20 +import static org.onosproject.incubator.protobuf.net.ProtobufUtils.translate;
21 import static org.onosproject.net.DeviceId.deviceId; 21 import static org.onosproject.net.DeviceId.deviceId;
22 22
23 import java.util.Collection; 23 import java.util.Collection;
...@@ -31,6 +31,7 @@ import org.onosproject.grpc.net.device.DeviceService.DeviceProviderServiceMsg; ...@@ -31,6 +31,7 @@ import org.onosproject.grpc.net.device.DeviceService.DeviceProviderServiceMsg;
31 import org.onosproject.grpc.net.device.DeviceService.IsReachableRequest; 31 import org.onosproject.grpc.net.device.DeviceService.IsReachableRequest;
32 import org.onosproject.grpc.net.device.DeviceService.RoleChanged; 32 import org.onosproject.grpc.net.device.DeviceService.RoleChanged;
33 import org.onosproject.grpc.net.device.DeviceService.TriggerProbe; 33 import org.onosproject.grpc.net.device.DeviceService.TriggerProbe;
34 +import org.onosproject.incubator.protobuf.net.ProtobufUtils;
34 import org.onosproject.net.DeviceId; 35 import org.onosproject.net.DeviceId;
35 import org.onosproject.net.MastershipRole; 36 import org.onosproject.net.MastershipRole;
36 import org.onosproject.net.device.DeviceDescription; 37 import org.onosproject.net.device.DeviceDescription;
...@@ -114,7 +115,7 @@ final class DeviceProviderServiceClientProxy ...@@ -114,7 +115,7 @@ final class DeviceProviderServiceClientProxy
114 DeviceProviderServiceMsg.Builder builder = DeviceProviderServiceMsg.newBuilder(); 115 DeviceProviderServiceMsg.Builder builder = DeviceProviderServiceMsg.newBuilder();
115 List<org.onosproject.grpc.net.Port.PortDescription> portDescs = 116 List<org.onosproject.grpc.net.Port.PortDescription> portDescs =
116 portDescriptions.stream() 117 portDescriptions.stream()
117 - .map(GrpcDeviceUtils::translate) 118 + .map(ProtobufUtils::translate)
118 .collect(toList()); 119 .collect(toList());
119 120
120 builder.setUpdatePorts(builder.getUpdatePortsBuilder() 121 builder.setUpdatePorts(builder.getUpdatePortsBuilder()
...@@ -162,7 +163,7 @@ final class DeviceProviderServiceClientProxy ...@@ -162,7 +163,7 @@ final class DeviceProviderServiceClientProxy
162 DeviceProviderServiceMsg.Builder builder = DeviceProviderServiceMsg.newBuilder(); 163 DeviceProviderServiceMsg.Builder builder = DeviceProviderServiceMsg.newBuilder();
163 List<org.onosproject.grpc.net.Port.PortStatistics> portStats = 164 List<org.onosproject.grpc.net.Port.PortStatistics> portStats =
164 portStatistics.stream() 165 portStatistics.stream()
165 - .map(GrpcDeviceUtils::translate) 166 + .map(ProtobufUtils::translate)
166 .collect(toList()); 167 .collect(toList());
167 builder.setUpdatePortStatistics(builder.getUpdatePortStatisticsBuilder() 168 builder.setUpdatePortStatistics(builder.getUpdatePortStatisticsBuilder()
168 .setDeviceId(deviceId.toString()) 169 .setDeviceId(deviceId.toString())
......
...@@ -17,7 +17,7 @@ package org.onosproject.incubator.rpc.grpc; ...@@ -17,7 +17,7 @@ package org.onosproject.incubator.rpc.grpc;
17 17
18 import static com.google.common.base.Preconditions.checkNotNull; 18 import static com.google.common.base.Preconditions.checkNotNull;
19 import static java.util.stream.Collectors.toList; 19 import static java.util.stream.Collectors.toList;
20 -import static org.onosproject.incubator.rpc.grpc.GrpcDeviceUtils.translate; 20 +import static org.onosproject.incubator.protobuf.net.ProtobufUtils.translate;
21 import static org.onosproject.net.DeviceId.deviceId; 21 import static org.onosproject.net.DeviceId.deviceId;
22 22
23 import java.io.IOException; 23 import java.io.IOException;
...@@ -49,6 +49,7 @@ import org.onosproject.grpc.net.device.DeviceService.RegisterProvider; ...@@ -49,6 +49,7 @@ import org.onosproject.grpc.net.device.DeviceService.RegisterProvider;
49 import org.onosproject.grpc.net.device.DeviceService.UpdatePortStatistics; 49 import org.onosproject.grpc.net.device.DeviceService.UpdatePortStatistics;
50 import org.onosproject.grpc.net.device.DeviceService.UpdatePorts; 50 import org.onosproject.grpc.net.device.DeviceService.UpdatePorts;
51 import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc; 51 import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc;
52 +import org.onosproject.incubator.protobuf.net.ProtobufUtils;
52 import org.onosproject.net.DeviceId; 53 import org.onosproject.net.DeviceId;
53 import org.onosproject.net.MastershipRole; 54 import org.onosproject.net.MastershipRole;
54 import org.onosproject.net.PortNumber; 55 import org.onosproject.net.PortNumber;
...@@ -269,7 +270,7 @@ public class GrpcRemoteServiceServer { ...@@ -269,7 +270,7 @@ public class GrpcRemoteServiceServer {
269 deviceProviderService.updatePorts(deviceId(updatePorts.getDeviceId()), 270 deviceProviderService.updatePorts(deviceId(updatePorts.getDeviceId()),
270 updatePorts.getPortDescriptionsList() 271 updatePorts.getPortDescriptionsList()
271 .stream() 272 .stream()
272 - .map(GrpcDeviceUtils::translate) 273 + .map(ProtobufUtils::translate)
273 .collect(toList())); 274 .collect(toList()));
274 break; 275 break;
275 case PORT_STATUS_CHANGED: 276 case PORT_STATUS_CHANGED:
...@@ -288,7 +289,7 @@ public class GrpcRemoteServiceServer { ...@@ -288,7 +289,7 @@ public class GrpcRemoteServiceServer {
288 deviceProviderService.updatePortStatistics(deviceId(updatePortStatistics.getDeviceId()), 289 deviceProviderService.updatePortStatistics(deviceId(updatePortStatistics.getDeviceId()),
289 updatePortStatistics.getPortStatisticsList() 290 updatePortStatistics.getPortStatisticsList()
290 .stream() 291 .stream()
291 - .map(GrpcDeviceUtils::translate) 292 + .map(ProtobufUtils::translate)
292 .collect(toList())); 293 .collect(toList()));
293 break; 294 break;
294 295
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
15 */ 15 */
16 package org.onosproject.incubator.rpc.grpc; 16 package org.onosproject.incubator.rpc.grpc;
17 17
18 -import static org.onosproject.incubator.rpc.grpc.GrpcDeviceUtils.asMap; 18 +import static org.onosproject.incubator.protobuf.net.ProtobufUtils.asMap;
19 19
20 import java.util.concurrent.ExecutionException; 20 import java.util.concurrent.ExecutionException;
21 import java.util.concurrent.TimeUnit; 21 import java.util.concurrent.TimeUnit;
......
...@@ -25,6 +25,7 @@ import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc.LinkProviderServ ...@@ -25,6 +25,7 @@ import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc.LinkProviderServ
25 import org.onosproject.grpc.net.link.LinkService.LinkDetectedMsg; 25 import org.onosproject.grpc.net.link.LinkService.LinkDetectedMsg;
26 import org.onosproject.grpc.net.link.LinkService.LinkVanishedMsg; 26 import org.onosproject.grpc.net.link.LinkService.LinkVanishedMsg;
27 import org.onosproject.grpc.net.link.LinkService.Void; 27 import org.onosproject.grpc.net.link.LinkService.Void;
28 +import org.onosproject.incubator.protobuf.net.ProtobufUtils;
28 import org.onosproject.net.ConnectPoint; 29 import org.onosproject.net.ConnectPoint;
29 import org.onosproject.net.DeviceId; 30 import org.onosproject.net.DeviceId;
30 import org.onosproject.net.Link; 31 import org.onosproject.net.Link;
...@@ -153,7 +154,7 @@ final class LinkProviderServiceServerProxy ...@@ -153,7 +154,7 @@ final class LinkProviderServiceServerProxy
153 ConnectPoint src = translate(linkDescription.getSrc()); 154 ConnectPoint src = translate(linkDescription.getSrc());
154 ConnectPoint dst = translate(linkDescription.getDst()); 155 ConnectPoint dst = translate(linkDescription.getDst());
155 Link.Type type = translate(linkDescription.getType()); 156 Link.Type type = translate(linkDescription.getType());
156 - SparseAnnotations annotations = GrpcDeviceUtils.asAnnotations(linkDescription.getAnnotations()); 157 + SparseAnnotations annotations = ProtobufUtils.asAnnotations(linkDescription.getAnnotations());
157 return new DefaultLinkDescription(src, dst, type, annotations); 158 return new DefaultLinkDescription(src, dst, type, annotations);
158 } 159 }
159 160
......