HIGUCHI Yuta
Committed by Yuta HIGUCHI

[ONOS-4520] Separate model messages from service messages in ProtoBuf IDL.

- move ProtoBuf generated code in a package similar to ONOS models.

Change-Id: I5deb591094c2b8af2b22041da935567fc8dacd87
......@@ -24,13 +24,13 @@ import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.onosproject.grpc.Device.DeviceProviderMsg;
import org.onosproject.grpc.Device.DeviceProviderServiceMsg;
import org.onosproject.grpc.Device.IsReachableRequest;
import org.onosproject.grpc.Device.RoleChanged;
import org.onosproject.grpc.Device.TriggerProbe;
import org.onosproject.grpc.DeviceProviderRegistryRpcGrpc;
import org.onosproject.grpc.DeviceProviderRegistryRpcGrpc.DeviceProviderRegistryRpcStub;
import org.onosproject.grpc.net.device.DeviceProviderRegistryRpcGrpc;
import org.onosproject.grpc.net.device.DeviceProviderRegistryRpcGrpc.DeviceProviderRegistryRpcStub;
import org.onosproject.grpc.net.device.DeviceService.DeviceProviderMsg;
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.net.DeviceId;
import org.onosproject.net.MastershipRole;
import org.onosproject.net.device.DeviceDescription;
......@@ -112,7 +112,7 @@ final class DeviceProviderServiceClientProxy
checkValidity();
DeviceProviderServiceMsg.Builder builder = DeviceProviderServiceMsg.newBuilder();
List<org.onosproject.grpc.Port.PortDescription> portDescs =
List<org.onosproject.grpc.net.Port.PortDescription> portDescs =
portDescriptions.stream()
.map(GrpcDeviceUtils::translate)
.collect(toList());
......@@ -160,7 +160,7 @@ final class DeviceProviderServiceClientProxy
checkValidity();
DeviceProviderServiceMsg.Builder builder = DeviceProviderServiceMsg.newBuilder();
List<org.onosproject.grpc.Port.PortStatistics> portStats =
List<org.onosproject.grpc.net.Port.PortStatistics> portStats =
portStatistics.stream()
.map(GrpcDeviceUtils::translate)
.collect(toList());
......
......@@ -20,8 +20,8 @@ import java.util.HashMap;
import java.util.Map;
import org.onlab.packet.ChassisId;
import org.onosproject.grpc.Device.DeviceType;
import org.onosproject.grpc.Port.PortType;
import org.onosproject.grpc.net.Device.DeviceType;
import org.onosproject.grpc.net.Port.PortType;
import org.onosproject.net.Annotations;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.Device;
......@@ -55,7 +55,7 @@ public final class GrpcDeviceUtils {
* @param role mastership role in gRPC enum
* @return equivalent in ONOS enum
*/
public static MastershipRole translate(org.onosproject.grpc.Device.MastershipRole role) {
public static MastershipRole translate(org.onosproject.grpc.net.Device.MastershipRole role) {
switch (role) {
case NONE:
return MastershipRole.NONE;
......@@ -77,15 +77,15 @@ public final class GrpcDeviceUtils {
* @param newRole ONOS' mastership role
* @return equivalent in gRPC message enum
*/
public static org.onosproject.grpc.Device.MastershipRole translate(MastershipRole newRole) {
public static org.onosproject.grpc.net.Device.MastershipRole translate(MastershipRole newRole) {
switch (newRole) {
case MASTER:
return org.onosproject.grpc.Device.MastershipRole.MASTER;
return org.onosproject.grpc.net.Device.MastershipRole.MASTER;
case STANDBY:
return org.onosproject.grpc.Device.MastershipRole.STANDBY;
return org.onosproject.grpc.net.Device.MastershipRole.STANDBY;
case NONE:
default:
return org.onosproject.grpc.Device.MastershipRole.NONE;
return org.onosproject.grpc.net.Device.MastershipRole.NONE;
}
}
......@@ -96,7 +96,7 @@ public final class GrpcDeviceUtils {
* @param deviceDescription gRPC message
* @return {@link DeviceDescription}
*/
public static DeviceDescription translate(org.onosproject.grpc.Device.DeviceDescription deviceDescription) {
public static DeviceDescription translate(org.onosproject.grpc.net.Device.DeviceDescription deviceDescription) {
URI uri = URI.create(deviceDescription.getDeviceUri());
Device.Type type = translate(deviceDescription.getType());
String manufacturer = deviceDescription.getManufacturer();
......@@ -116,9 +116,9 @@ public final class GrpcDeviceUtils {
* @param deviceDescription {@link DeviceDescription}
* @return gRPC DeviceDescription message
*/
public static org.onosproject.grpc.Device.DeviceDescription translate(DeviceDescription deviceDescription) {
public static org.onosproject.grpc.net.Device.DeviceDescription translate(DeviceDescription deviceDescription) {
return org.onosproject.grpc.Device.DeviceDescription.newBuilder()
return org.onosproject.grpc.net.Device.DeviceDescription.newBuilder()
.setDeviceUri(deviceDescription.deviceUri().toString())
.setType(translate(deviceDescription.type()))
.setManufacturer(deviceDescription.manufacturer())
......@@ -137,7 +137,7 @@ public final class GrpcDeviceUtils {
* @param type gRPC message
* @return {@link Device.Type}
*/
public static Device.Type translate(org.onosproject.grpc.Device.DeviceType type) {
public static Device.Type translate(org.onosproject.grpc.net.Device.DeviceType type) {
switch (type) {
case BALANCER:
return Device.Type.BALANCER;
......@@ -224,7 +224,7 @@ public final class GrpcDeviceUtils {
* @param portDescription gRPC message
* @return {@link PortDescription}
*/
public static PortDescription translate(org.onosproject.grpc.Port.PortDescription portDescription) {
public static PortDescription translate(org.onosproject.grpc.net.Port.PortDescription portDescription) {
PortNumber number = PortNumber.fromString(portDescription.getPortNumber());
boolean isEnabled = portDescription.getIsEnabled();
Port.Type type = translate(portDescription.getType());
......@@ -240,9 +240,9 @@ public final class GrpcDeviceUtils {
* @param portDescription {@link PortDescription}
* @return gRPC PortDescription message
*/
public static org.onosproject.grpc.Port.PortDescription translate(PortDescription portDescription) {
public static org.onosproject.grpc.net.Port.PortDescription translate(PortDescription portDescription) {
// TODO How to deal with more specific Port...
return org.onosproject.grpc.Port.PortDescription.newBuilder()
return org.onosproject.grpc.net.Port.PortDescription.newBuilder()
.setPortNumber(portDescription.portNumber().toString())
.setIsEnabled(portDescription.isEnabled())
.setType(translate(portDescription.type()))
......@@ -316,7 +316,7 @@ public final class GrpcDeviceUtils {
* @param portStatistics gRPC PortStatistics message
* @return {@link PortStatistics}
*/
public static PortStatistics translate(org.onosproject.grpc.Port.PortStatistics portStatistics) {
public static PortStatistics translate(org.onosproject.grpc.net.Port.PortStatistics portStatistics) {
// TODO implement adding missing fields
return DefaultPortStatistics.builder()
.setPort(portStatistics.getPort())
......@@ -331,9 +331,9 @@ public final class GrpcDeviceUtils {
* @param portStatistics {@link PortStatistics}
* @return gRPC PortStatistics message
*/
public static org.onosproject.grpc.Port.PortStatistics translate(PortStatistics portStatistics) {
public static org.onosproject.grpc.net.Port.PortStatistics translate(PortStatistics portStatistics) {
// TODO implement adding missing fields
return org.onosproject.grpc.Port.PortStatistics.newBuilder()
return org.onosproject.grpc.net.Port.PortStatistics.newBuilder()
.setPort(portStatistics.port())
.setPacketsReceived(portStatistics.packetsReceived())
.setPacketsSent(portStatistics.packetsSent())
......
......@@ -36,19 +36,19 @@ import org.apache.felix.scr.annotations.Modified;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onosproject.grpc.Device.DeviceConnected;
import org.onosproject.grpc.Device.DeviceDisconnected;
import org.onosproject.grpc.Device.DeviceProviderMsg;
import org.onosproject.grpc.Device.DeviceProviderServiceMsg;
import org.onosproject.grpc.Device.IsReachableResponse;
import org.onosproject.grpc.Device.PortStatusChanged;
import org.onosproject.grpc.Device.ReceivedRoleReply;
import org.onosproject.grpc.Device.RegisterProvider;
import org.onosproject.grpc.Device.UpdatePortStatistics;
import org.onosproject.grpc.Device.UpdatePorts;
import org.onosproject.grpc.DeviceProviderRegistryRpcGrpc;
import org.onosproject.grpc.DeviceProviderRegistryRpcGrpc.DeviceProviderRegistryRpc;
import org.onosproject.grpc.LinkProviderServiceRpcGrpc;
import org.onosproject.grpc.net.device.DeviceProviderRegistryRpcGrpc;
import org.onosproject.grpc.net.device.DeviceProviderRegistryRpcGrpc.DeviceProviderRegistryRpc;
import org.onosproject.grpc.net.device.DeviceService.DeviceConnected;
import org.onosproject.grpc.net.device.DeviceService.DeviceDisconnected;
import org.onosproject.grpc.net.device.DeviceService.DeviceProviderMsg;
import org.onosproject.grpc.net.device.DeviceService.DeviceProviderServiceMsg;
import org.onosproject.grpc.net.device.DeviceService.IsReachableResponse;
import org.onosproject.grpc.net.device.DeviceService.PortStatusChanged;
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.net.DeviceId;
import org.onosproject.net.MastershipRole;
import org.onosproject.net.PortNumber;
......
......@@ -21,12 +21,12 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.onosproject.grpc.Link.LinkDetectedMsg;
import org.onosproject.grpc.Link.LinkType;
import org.onosproject.grpc.Link.LinkVanishedMsg;
import org.onosproject.grpc.Link.Void;
import org.onosproject.grpc.LinkProviderServiceRpcGrpc;
import org.onosproject.grpc.LinkProviderServiceRpcGrpc.LinkProviderServiceRpcFutureStub;
import org.onosproject.grpc.net.Link.LinkType;
import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc;
import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc.LinkProviderServiceRpcFutureStub;
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.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link.Type;
......@@ -237,7 +237,7 @@ class LinkProviderServiceClientProxy
/**
* Translates ONOS object to gRPC message.
*
* @param type {@link Link.Type}
* @param type {@link org.onosproject.net.Link.Type Link.Type}
* @return gRPC LinkType
*/
private LinkType translate(Type type) {
......@@ -267,8 +267,8 @@ class LinkProviderServiceClientProxy
* @param cp {@link ConnectPoint}
* @return gRPC ConnectPoint
*/
private org.onosproject.grpc.Link.ConnectPoint translate(ConnectPoint cp) {
return org.onosproject.grpc.Link.ConnectPoint.newBuilder()
private org.onosproject.grpc.net.Link.ConnectPoint translate(ConnectPoint cp) {
return org.onosproject.grpc.net.Link.ConnectPoint.newBuilder()
.setDeviceId(cp.deviceId().toString())
.setPortNumber(cp.port().toString())
.build();
......
......@@ -19,12 +19,12 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.net.DeviceId.deviceId;
import org.onosproject.grpc.Link.LinkDetectedMsg;
import org.onosproject.grpc.Link.LinkType;
import org.onosproject.grpc.Link.LinkVanishedMsg;
import org.onosproject.grpc.Link.Void;
import org.onosproject.grpc.Link.ConnectPoint.ElementIdCase;
import org.onosproject.grpc.LinkProviderServiceRpcGrpc.LinkProviderServiceRpc;
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.LinkService.LinkDetectedMsg;
import org.onosproject.grpc.net.link.LinkService.LinkVanishedMsg;
import org.onosproject.grpc.net.link.LinkService.Void;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
......@@ -136,7 +136,7 @@ final class LinkProviderServiceServerProxy
* @param connectPoint gRPC message.
* @return {@link ConnectPoint}
*/
private ConnectPoint translate(org.onosproject.grpc.Link.ConnectPoint connectPoint) {
private ConnectPoint translate(org.onosproject.grpc.net.Link.ConnectPoint connectPoint) {
checkArgument(connectPoint.getElementIdCase() == ElementIdCase.DEVICE_ID,
"Only DeviceId supported.");
return new ConnectPoint(deviceId(connectPoint.getDeviceId()),
......@@ -149,7 +149,7 @@ final class LinkProviderServiceServerProxy
* @param linkDescription gRPC message
* @return {@link LinkDescription}
*/
private LinkDescription translate(org.onosproject.grpc.Link.LinkDescription linkDescription) {
private LinkDescription translate(org.onosproject.grpc.net.Link.LinkDescription linkDescription) {
ConnectPoint src = translate(linkDescription.getSrc());
ConnectPoint dst = translate(linkDescription.getDst());
Link.Type type = translate(linkDescription.getType());
......@@ -161,7 +161,7 @@ final class LinkProviderServiceServerProxy
* Translates gRPC message to corresponding ONOS object.
*
* @param type gRPC message enum
* @return {@link Type}
* @return {@link org.onosproject.net.Link.Type Link.Type}
*/
private Link.Type translate(LinkType type) {
switch (type) {
......
syntax = "proto3";
option java_package = "org.onosproject.grpc";
option java_package = "org.onosproject.grpc.net";
import "Port.proto";
package Device;
enum DeviceType {
......@@ -37,95 +36,3 @@ enum MastershipRole {
MASTER = 1;
STANDBY = 2;
}
message DeviceConnected {
// DeviceID as String DeviceId#toString
string device_id = 1;
DeviceDescription device_description = 2;
}
message DeviceDisconnected {
// DeviceID as String DeviceId#toString
string device_id = 1;
}
message UpdatePorts {
// DeviceID as String DeviceId#toString
string device_id = 1;
repeated Port.PortDescription port_descriptions= 2;
}
message PortStatusChanged {
// DeviceID as String DeviceId#toString
string device_id = 1;
Port.PortDescription port_description= 2;
}
message ReceivedRoleReply {
// DeviceID as String DeviceId#toString
string device_id = 1;
MastershipRole requested = 2;
MastershipRole response = 3;
}
message UpdatePortStatistics {
// DeviceID as String DeviceId#toString
string device_id = 1;
repeated Port.PortStatistics port_statistics = 2;
}
message RegisterProvider {
// DeviceProvider's ProviderId scheme
string provider_scheme = 1;
}
message DeviceProviderServiceMsg {
oneof method {
DeviceConnected device_connected= 1;
DeviceDisconnected device_disconnected = 2;
UpdatePorts update_ports= 3;
PortStatusChanged port_status_changed = 4;
ReceivedRoleReply received_role_reply = 5;
UpdatePortStatistics update_port_statistics = 6;
// This message is for return value of DeviceProvider#isReachable
IsReachableResponse is_reachable_response = 7;
// This MUST be the 1st message over the stream
RegisterProvider register_provider = 8;
}
}
message TriggerProbe {
// DeviceID as String DeviceId#toString
string device_id = 1;
}
message RoleChanged {
// DeviceID as String DeviceId#toString
string device_id = 1;
MastershipRole new_role = 2;
}
message IsReachableRequest {
int32 xid = 1;
// DeviceID as String DeviceId#toString
string device_id = 2;
}
message IsReachableResponse {
int32 xid = 1;
bool is_reachable = 2;
}
message DeviceProviderMsg {
oneof method {
TriggerProbe trigger_probe = 1;
RoleChanged role_changed = 2;
IsReachableRequest is_reachable_request= 3;
}
}
service DeviceProviderRegistryRpc {
rpc Register(stream DeviceProviderServiceMsg) returns (stream DeviceProviderMsg);
}
......
syntax = "proto3";
option java_package = "org.onosproject.grpc.net.device";
import "Device.proto";
import "Port.proto";
package Device;
message DeviceConnected {
// DeviceID as String DeviceId#toString
string device_id = 1;
DeviceDescription device_description = 2;
}
message DeviceDisconnected {
// DeviceID as String DeviceId#toString
string device_id = 1;
}
message UpdatePorts {
// DeviceID as String DeviceId#toString
string device_id = 1;
repeated Port.PortDescription port_descriptions= 2;
}
message PortStatusChanged {
// DeviceID as String DeviceId#toString
string device_id = 1;
Port.PortDescription port_description= 2;
}
message ReceivedRoleReply {
// DeviceID as String DeviceId#toString
string device_id = 1;
MastershipRole requested = 2;
MastershipRole response = 3;
}
message UpdatePortStatistics {
// DeviceID as String DeviceId#toString
string device_id = 1;
repeated Port.PortStatistics port_statistics = 2;
}
message RegisterProvider {
// DeviceProvider's ProviderId scheme
string provider_scheme = 1;
}
message DeviceProviderServiceMsg {
oneof method {
DeviceConnected device_connected= 1;
DeviceDisconnected device_disconnected = 2;
UpdatePorts update_ports= 3;
PortStatusChanged port_status_changed = 4;
ReceivedRoleReply received_role_reply = 5;
UpdatePortStatistics update_port_statistics = 6;
// This message is for return value of DeviceProvider#isReachable
IsReachableResponse is_reachable_response = 7;
// This MUST be the 1st message over the stream
RegisterProvider register_provider = 8;
}
}
message TriggerProbe {
// DeviceID as String DeviceId#toString
string device_id = 1;
}
message RoleChanged {
// DeviceID as String DeviceId#toString
string device_id = 1;
MastershipRole new_role = 2;
}
message IsReachableRequest {
int32 xid = 1;
// DeviceID as String DeviceId#toString
string device_id = 2;
}
message IsReachableResponse {
int32 xid = 1;
bool is_reachable = 2;
}
message DeviceProviderMsg {
oneof method {
TriggerProbe trigger_probe = 1;
RoleChanged role_changed = 2;
IsReachableRequest is_reachable_request= 3;
}
}
service DeviceProviderRegistryRpc {
rpc Register(stream DeviceProviderServiceMsg) returns (stream DeviceProviderMsg);
}
syntax = "proto3";
option java_package = "org.onosproject.grpc";
option java_package = "org.onosproject.grpc.net";
package Link;
......@@ -44,27 +44,3 @@ message LinkDescription {
LinkType type = 3;
map<string, string> annotations = 4;
}
// Message te represent no return value
message Void {}
message LinkDetectedMsg {
// ProviderId scheme only
string provider_id = 1;
LinkDescription link_description = 2;
}
message LinkVanishedMsg {
// ProviderId scheme only
string provider_id = 1;
oneof subject {
LinkDescription link_description = 2;
ConnectPoint connect_point = 3;
string device_id = 4;
}
}
service LinkProviderServiceRpc {
rpc LinkDetected(LinkDetectedMsg) returns (Void);
rpc LinkVanished(LinkVanishedMsg) returns (Void);
}
......
syntax = "proto3";
option java_package = "org.onosproject.grpc.net.link";
import "Link.proto";
package Link;
// Message to represent no return value
message Void {}
message LinkDetectedMsg {
// ProviderId scheme only
string provider_id = 1;
LinkDescription link_description = 2;
}
message LinkVanishedMsg {
// ProviderId scheme only
string provider_id = 1;
oneof subject {
LinkDescription link_description = 2;
ConnectPoint connect_point = 3;
string device_id = 4;
}
}
service LinkProviderServiceRpc {
rpc LinkDetected(LinkDetectedMsg) returns (Void);
rpc LinkVanished(LinkVanishedMsg) returns (Void);
}
syntax = "proto3";
option java_package = "org.onosproject.grpc";
option java_package = "org.onosproject.grpc.net";
package Port;
......@@ -22,7 +22,6 @@ enum PortType {
VIRTUAL = 6;
}
// TODO What are we going to do with more specific PortDescription ...
message PortDescription {
// PortNumber as String PortNumber#toString
string port_number = 1;
......