[ONOS-4520] Move Protobuf to ONOS model conversion util protobuf bundle.
Change-Id: I0fbfd750d569cb5da6dd29af5aa77d19d6f29494
diff --git a/incubator/protobuf/pom.xml b/incubator/protobuf/pom.xml
index c486af2..4be8695 100644
--- a/incubator/protobuf/pom.xml
+++ b/incubator/protobuf/pom.xml
@@ -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>
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcDeviceUtils.java b/incubator/protobuf/src/main/java/org/onosproject/incubator/protobuf/net/ProtobufUtils.java
similarity index 97%
rename from incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcDeviceUtils.java
rename to incubator/protobuf/src/main/java/org/onosproject/incubator/protobuf/net/ProtobufUtils.java
index 647acf7b24..0f2e3be 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcDeviceUtils.java
+++ b/incubator/protobuf/src/main/java/org/onosproject/incubator/protobuf/net/ProtobufUtils.java
@@ -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.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 @@
}
// Utility class not intended for instantiation.
- private GrpcDeviceUtils() {}
+ private ProtobufUtils() {}
}
diff --git a/incubator/protobuf/src/main/java/org/onosproject/incubator/protobuf/net/package-info.java b/incubator/protobuf/src/main/java/org/onosproject/incubator/protobuf/net/package-info.java
new file mode 100644
index 0000000..aa17131
--- /dev/null
+++ b/incubator/protobuf/src/main/java/org/onosproject/incubator/protobuf/net/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * 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;
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java
index 185e094..a6712b9 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java
@@ -17,7 +17,7 @@
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.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 @@
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 @@
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())
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java
index a36b21e..62bdfb2 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java
@@ -17,7 +17,7 @@
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.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 @@
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 @@
deviceProviderService.updatePortStatistics(deviceId(updatePortStatistics.getDeviceId()),
updatePortStatistics.getPortStatisticsList()
.stream()
- .map(GrpcDeviceUtils::translate)
+ .map(ProtobufUtils::translate)
.collect(toList()));
break;
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java
index 4dd4a0a..b576033 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java
@@ -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;
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java
index 1878426..608f6e3 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java
@@ -25,6 +25,7 @@
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 @@
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);
}