HIGUCHI Yuta
Committed by Yuta HIGUCHI

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

Change-Id: I0fbfd750d569cb5da6dd29af5aa77d19d6f29494
......@@ -90,7 +90,7 @@
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>org.onosproject.grpc.net</Export-Package>
<Export-Package>org.onosproject.grpc.net,org.onosproject.incubator.protobuf.net</Export-Package>
</instructions>
</configuration>
</plugin>
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.incubator.rpc.grpc;
package org.onosproject.incubator.protobuf.net;
import java.net.URI;
import java.util.HashMap;
......@@ -39,15 +39,16 @@ import org.onosproject.net.device.PortStatistics;
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;
/**
* gRPC message conversion related utilities.
*/
@Beta
public final class GrpcDeviceUtils {
public final class ProtobufUtils {
private static final Logger log = LoggerFactory.getLogger(GrpcDeviceUtils.class);
private static final Logger log = LoggerFactory.getLogger(ProtobufUtils.class);
/**
* Translates gRPC enum MastershipRole to ONOS enum.
......@@ -378,5 +379,5 @@ public final class GrpcDeviceUtils {
}
// Utility class not intended for instantiation.
private GrpcDeviceUtils() {}
private ProtobufUtils() {}
}
......
/*
* Copyright 2016-present Open Networking Laboratory
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Utilities to handle ProtoBuf version of ONOS network models.
*/
package org.onosproject.incubator.protobuf.net;
......@@ -17,7 +17,7 @@ package org.onosproject.incubator.rpc.grpc;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.stream.Collectors.toList;
import static org.onosproject.incubator.rpc.grpc.GrpcDeviceUtils.translate;
import static org.onosproject.incubator.protobuf.net.ProtobufUtils.translate;
import static org.onosproject.net.DeviceId.deviceId;
import java.util.Collection;
......@@ -31,6 +31,7 @@ import org.onosproject.grpc.net.device.DeviceService.DeviceProviderServiceMsg;
import org.onosproject.grpc.net.device.DeviceService.IsReachableRequest;
import org.onosproject.grpc.net.device.DeviceService.RoleChanged;
import org.onosproject.grpc.net.device.DeviceService.TriggerProbe;
import org.onosproject.incubator.protobuf.net.ProtobufUtils;
import org.onosproject.net.DeviceId;
import org.onosproject.net.MastershipRole;
import org.onosproject.net.device.DeviceDescription;
......@@ -114,7 +115,7 @@ final class DeviceProviderServiceClientProxy
DeviceProviderServiceMsg.Builder builder = DeviceProviderServiceMsg.newBuilder();
List<org.onosproject.grpc.net.Port.PortDescription> portDescs =
portDescriptions.stream()
.map(GrpcDeviceUtils::translate)
.map(ProtobufUtils::translate)
.collect(toList());
builder.setUpdatePorts(builder.getUpdatePortsBuilder()
......@@ -162,7 +163,7 @@ final class DeviceProviderServiceClientProxy
DeviceProviderServiceMsg.Builder builder = DeviceProviderServiceMsg.newBuilder();
List<org.onosproject.grpc.net.Port.PortStatistics> portStats =
portStatistics.stream()
.map(GrpcDeviceUtils::translate)
.map(ProtobufUtils::translate)
.collect(toList());
builder.setUpdatePortStatistics(builder.getUpdatePortStatisticsBuilder()
.setDeviceId(deviceId.toString())
......
......@@ -17,7 +17,7 @@ package org.onosproject.incubator.rpc.grpc;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.stream.Collectors.toList;
import static org.onosproject.incubator.rpc.grpc.GrpcDeviceUtils.translate;
import static org.onosproject.incubator.protobuf.net.ProtobufUtils.translate;
import static org.onosproject.net.DeviceId.deviceId;
import java.io.IOException;
......@@ -49,6 +49,7 @@ 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;
import org.onosproject.net.PortNumber;
......@@ -269,7 +270,7 @@ public class GrpcRemoteServiceServer {
deviceProviderService.updatePorts(deviceId(updatePorts.getDeviceId()),
updatePorts.getPortDescriptionsList()
.stream()
.map(GrpcDeviceUtils::translate)
.map(ProtobufUtils::translate)
.collect(toList()));
break;
case PORT_STATUS_CHANGED:
......@@ -288,7 +289,7 @@ public class GrpcRemoteServiceServer {
deviceProviderService.updatePortStatistics(deviceId(updatePortStatistics.getDeviceId()),
updatePortStatistics.getPortStatisticsList()
.stream()
.map(GrpcDeviceUtils::translate)
.map(ProtobufUtils::translate)
.collect(toList()));
break;
......
......@@ -15,7 +15,7 @@
*/
package org.onosproject.incubator.rpc.grpc;
import static org.onosproject.incubator.rpc.grpc.GrpcDeviceUtils.asMap;
import static org.onosproject.incubator.protobuf.net.ProtobufUtils.asMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
......
......@@ -25,6 +25,7 @@ import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc.LinkProviderServ
import org.onosproject.grpc.net.link.LinkService.LinkDetectedMsg;
import org.onosproject.grpc.net.link.LinkService.LinkVanishedMsg;
import org.onosproject.grpc.net.link.LinkService.Void;
import org.onosproject.incubator.protobuf.net.ProtobufUtils;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
......@@ -153,7 +154,7 @@ final class LinkProviderServiceServerProxy
ConnectPoint src = translate(linkDescription.getSrc());
ConnectPoint dst = translate(linkDescription.getDst());
Link.Type type = translate(linkDescription.getType());
SparseAnnotations annotations = GrpcDeviceUtils.asAnnotations(linkDescription.getAnnotations());
SparseAnnotations annotations = ProtobufUtils.asAnnotations(linkDescription.getAnnotations());
return new DefaultLinkDescription(src, dst, type, annotations);
}
......