Sho SHIMIZU
Committed by Gerrit Code Review

Use LF as line separator

Change-Id: I41ed7eeefe076ab3f8b09f26d1e091e6d3394846
Showing 21 changed files with 1268 additions and 1268 deletions
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.message;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Objects;
import org.onosproject.ovsdb.rfc.notation.json.UpdateNotificationConverter;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
/**
* The "update" notification is sent by the server to the client to report
* changes in tables that are being monitored following a "monitor" request. The
* "params" of the result JsonNode.
*/
@JsonDeserialize(converter = UpdateNotificationConverter.class)
public final class UpdateNotification {
private final Object jsonValue;
private final JsonNode tbUpdatesJsonNode;
/**
* Constructs a UpdateNotification object.
* @param jsonValue the "json-value" in "params" of the result JsonNode
* @param tbUpdatesJsonNode the "table-updates" in "params" of the result JsonNode
*/
public UpdateNotification(Object jsonValue, JsonNode tbUpdatesJsonNode) {
checkNotNull(jsonValue, "jsonValue cannot be null");
checkNotNull(tbUpdatesJsonNode, "tablebUpdates JsonNode cannot be null");
this.jsonValue = jsonValue;
this.tbUpdatesJsonNode = tbUpdatesJsonNode;
}
/**
* Return context.
* @return context
*/
public Object jsonValue() {
return jsonValue;
}
/**
* Return tbUpdatesJsonNode.
* @return tbUpdatesJsonNode
*/
public JsonNode tbUpdatesJsonNode() {
return tbUpdatesJsonNode;
}
@Override
public int hashCode() {
return Objects.hash(jsonValue, tbUpdatesJsonNode);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof UpdateNotification) {
final UpdateNotification other = (UpdateNotification) obj;
return Objects.equals(this.jsonValue, other.jsonValue)
&& Objects.equals(this.tbUpdatesJsonNode,
other.tbUpdatesJsonNode);
}
return false;
}
@Override
public String toString() {
return toStringHelper(this).add("jsonValue", jsonValue)
.add("tbUpdatesJsonNode", tbUpdatesJsonNode).toString();
}
}
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.message;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Objects;
import org.onosproject.ovsdb.rfc.notation.json.UpdateNotificationConverter;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
/**
* The "update" notification is sent by the server to the client to report
* changes in tables that are being monitored following a "monitor" request. The
* "params" of the result JsonNode.
*/
@JsonDeserialize(converter = UpdateNotificationConverter.class)
public final class UpdateNotification {
private final Object jsonValue;
private final JsonNode tbUpdatesJsonNode;
/**
* Constructs a UpdateNotification object.
* @param jsonValue the "json-value" in "params" of the result JsonNode
* @param tbUpdatesJsonNode the "table-updates" in "params" of the result JsonNode
*/
public UpdateNotification(Object jsonValue, JsonNode tbUpdatesJsonNode) {
checkNotNull(jsonValue, "jsonValue cannot be null");
checkNotNull(tbUpdatesJsonNode, "tablebUpdates JsonNode cannot be null");
this.jsonValue = jsonValue;
this.tbUpdatesJsonNode = tbUpdatesJsonNode;
}
/**
* Return context.
* @return context
*/
public Object jsonValue() {
return jsonValue;
}
/**
* Return tbUpdatesJsonNode.
* @return tbUpdatesJsonNode
*/
public JsonNode tbUpdatesJsonNode() {
return tbUpdatesJsonNode;
}
@Override
public int hashCode() {
return Objects.hash(jsonValue, tbUpdatesJsonNode);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof UpdateNotification) {
final UpdateNotification other = (UpdateNotification) obj;
return Objects.equals(this.jsonValue, other.jsonValue)
&& Objects.equals(this.tbUpdatesJsonNode,
other.tbUpdatesJsonNode);
}
return false;
}
@Override
public String toString() {
return toStringHelper(this).add("jsonValue", jsonValue)
.add("tbUpdatesJsonNode", tbUpdatesJsonNode).toString();
}
}
......
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.notation;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Objects;
/**
* Column is the basic element of the OpenVswitch database.
*/
public final class Column {
private final String columnName;
private final Object data;
/**
* Column constructor.
* @param columnName the column name
* @param obj the data of the column
*/
public Column(String columnName, Object obj) {
checkNotNull(columnName, "columnName cannot be null");
checkNotNull(obj, "data cannot be null");
this.columnName = columnName;
this.data = obj;
}
/**
* Returns column data.
* @return column data
*/
public Object data() {
return data;
}
/**
* Returns columnName.
* @return columnName
*/
public String columnName() {
return columnName;
}
@Override
public int hashCode() {
return Objects.hash(columnName, data);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof Column) {
final Column other = (Column) obj;
return Objects.equals(this.columnName, other.columnName)
&& Objects.equals(this.data, other.data);
}
return false;
}
@Override
public String toString() {
return toStringHelper(this).add("columnName", columnName)
.add("data", data).toString();
}
}
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.notation;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Objects;
/**
* Column is the basic element of the OpenVswitch database.
*/
public final class Column {
private final String columnName;
private final Object data;
/**
* Column constructor.
* @param columnName the column name
* @param obj the data of the column
*/
public Column(String columnName, Object obj) {
checkNotNull(columnName, "columnName cannot be null");
checkNotNull(obj, "data cannot be null");
this.columnName = columnName;
this.data = obj;
}
/**
* Returns column data.
* @return column data
*/
public Object data() {
return data;
}
/**
* Returns columnName.
* @return columnName
*/
public String columnName() {
return columnName;
}
@Override
public int hashCode() {
return Objects.hash(columnName, data);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof Column) {
final Column other = (Column) obj;
return Objects.equals(this.columnName, other.columnName)
&& Objects.equals(this.data, other.data);
}
return false;
}
@Override
public String toString() {
return toStringHelper(this).add("columnName", columnName)
.add("data", data).toString();
}
}
......
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.notation;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import com.google.common.collect.Maps;
/**
* Row is the basic element of the OpenVswitch's table.
*/
public final class Row {
private String tableName;
private Map<String, Column> columns;
/**
* Row constructor.
*/
public Row() {
this.columns = Maps.newHashMap();
}
/**
* Row constructor.
* @param tableName table name
*/
public Row(String tableName) {
checkNotNull(tableName, "tableName cannot be null");
this.tableName = tableName;
this.columns = Maps.newHashMap();
}
/**
* Row constructor.
* @param tableName table name
* @param columns Map of Column entity
*/
public Row(String tableName, Map<String, Column> columns) {
checkNotNull(tableName, "table name cannot be null");
checkNotNull(columns, "columns cannot be null");
this.tableName = tableName;
this.columns = columns;
}
/**
* Returns tableName.
* @return tableName
*/
public String tableName() {
return tableName;
}
/**
* Set tableName value.
* @param tableName table name
*/
public void setTableName(String tableName) {
this.tableName = tableName;
}
/**
* Returns Column by ColumnSchema.
* @param columnName column name
* @return Column
*/
public Column getColumn(String columnName) {
return columns.get(columnName);
}
/**
* Returns Collection of Column.
* @return Collection of Column
*/
public Collection<Column> getColumns() {
return columns.values();
}
/**
* add Column.
* @param columnName column name
* @param data Column entity
*/
public void addColumn(String columnName, Column data) {
this.columns.put(columnName, data);
}
@Override
public int hashCode() {
return Objects.hash(tableName, columns);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof Row) {
final Row other = (Row) obj;
return Objects.equals(this.tableName, other.tableName)
&& Objects.equals(this.columns, other.columns);
}
return false;
}
@Override
public String toString() {
return toStringHelper(this).add("tableName", tableName)
.add("columns", columns).toString();
}
}
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.notation;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import com.google.common.collect.Maps;
/**
* Row is the basic element of the OpenVswitch's table.
*/
public final class Row {
private String tableName;
private Map<String, Column> columns;
/**
* Row constructor.
*/
public Row() {
this.columns = Maps.newHashMap();
}
/**
* Row constructor.
* @param tableName table name
*/
public Row(String tableName) {
checkNotNull(tableName, "tableName cannot be null");
this.tableName = tableName;
this.columns = Maps.newHashMap();
}
/**
* Row constructor.
* @param tableName table name
* @param columns Map of Column entity
*/
public Row(String tableName, Map<String, Column> columns) {
checkNotNull(tableName, "table name cannot be null");
checkNotNull(columns, "columns cannot be null");
this.tableName = tableName;
this.columns = columns;
}
/**
* Returns tableName.
* @return tableName
*/
public String tableName() {
return tableName;
}
/**
* Set tableName value.
* @param tableName table name
*/
public void setTableName(String tableName) {
this.tableName = tableName;
}
/**
* Returns Column by ColumnSchema.
* @param columnName column name
* @return Column
*/
public Column getColumn(String columnName) {
return columns.get(columnName);
}
/**
* Returns Collection of Column.
* @return Collection of Column
*/
public Collection<Column> getColumns() {
return columns.values();
}
/**
* add Column.
* @param columnName column name
* @param data Column entity
*/
public void addColumn(String columnName, Column data) {
this.columns.put(columnName, data);
}
@Override
public int hashCode() {
return Objects.hash(tableName, columns);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof Row) {
final Row other = (Row) obj;
return Objects.equals(this.tableName, other.tableName)
&& Objects.equals(this.columns, other.columns);
}
return false;
}
@Override
public String toString() {
return toStringHelper(this).add("tableName", tableName)
.add("columns", columns).toString();
}
}
......
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.notation.json;
import org.onosproject.ovsdb.rfc.notation.UUID;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.util.StdConverter;
/**
* UUIDConverter Converter.
*/
public class UUIDConverter extends StdConverter<JsonNode, UUID> {
@Override
public UUID convert(JsonNode json) {
return UUID.uuid(json.get(1).asText());
}
}
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.notation.json;
import org.onosproject.ovsdb.rfc.notation.UUID;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.util.StdConverter;
/**
* UUIDConverter Converter.
*/
public class UUIDConverter extends StdConverter<JsonNode, UUID> {
@Override
public UUID convert(JsonNode json) {
return UUID.uuid(json.get(1).asText());
}
}
......
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.operations;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List;
import org.onosproject.ovsdb.rfc.notation.Condition;
import org.onosproject.ovsdb.rfc.schema.TableSchema;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* delete operation.Refer to RFC 7047 Section 5.2.
*/
public final class Delete implements Operation {
@JsonIgnore
private final TableSchema tableSchema;
private final String op;
private final List<Condition> where;
/**
* Constructs a Delete object.
* @param schema TableSchema entity
* @param where the List of Condition entity
*/
public Delete(TableSchema schema, List<Condition> where) {
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(where, "where is not null");
this.tableSchema = schema;
this.op = Operations.DELETE.op();
this.where = where;
}
/**
* Returns the where member of delete operation.
* @return the where member of delete operation
*/
public List<Condition> getWhere() {
return where;
}
@Override
public String getOp() {
return op;
}
@Override
public TableSchema getTableSchema() {
return tableSchema;
}
/**
* For the use of serialization.
* @return the table member of update operation
*/
@JsonProperty
public String getTable() {
return tableSchema.name();
}
}
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.operations;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List;
import org.onosproject.ovsdb.rfc.notation.Condition;
import org.onosproject.ovsdb.rfc.schema.TableSchema;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* delete operation.Refer to RFC 7047 Section 5.2.
*/
public final class Delete implements Operation {
@JsonIgnore
private final TableSchema tableSchema;
private final String op;
private final List<Condition> where;
/**
* Constructs a Delete object.
* @param schema TableSchema entity
* @param where the List of Condition entity
*/
public Delete(TableSchema schema, List<Condition> where) {
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(where, "where is not null");
this.tableSchema = schema;
this.op = Operations.DELETE.op();
this.where = where;
}
/**
* Returns the where member of delete operation.
* @return the where member of delete operation
*/
public List<Condition> getWhere() {
return where;
}
@Override
public String getOp() {
return op;
}
@Override
public TableSchema getTableSchema() {
return tableSchema;
}
/**
* For the use of serialization.
* @return the table member of update operation
*/
@JsonProperty
public String getTable() {
return tableSchema.name();
}
}
......
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.operations;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.Map;
import org.onosproject.ovsdb.rfc.notation.Column;
import org.onosproject.ovsdb.rfc.notation.Row;
import org.onosproject.ovsdb.rfc.schema.TableSchema;
import org.onosproject.ovsdb.rfc.utils.TransValueUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Maps;
/**
* insert operation.Refer to RFC 7047 Section 5.2.
*/
public final class Insert implements Operation {
@JsonIgnore
private final TableSchema tableSchema;
private final String op;
@JsonProperty("uuid-name")
private final String uuidName;
private final Map<String, Object> row;
/**
* Constructs a Insert object.
* @param schema TableSchema entity
* @param uuidName uuid-name
* @param row Row entity
*/
public Insert(TableSchema schema, String uuidName, Row row) {
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(uuidName, "uuid name cannot be null");
checkNotNull(row, "row cannot be null");
this.tableSchema = schema;
this.op = Operations.INSERT.op();
this.uuidName = uuidName;
this.row = Maps.newHashMap();
generateOperationRow(row);
}
/**
* Row entity convert into the row format of insert operation. Refer to RFC
* 7047 Section 5.2.
* @param row Row entity
*/
private void generateOperationRow(Row row) {
Collection<Column> columns = row.getColumns();
for (Column column : columns) {
String columnName = column.columnName();
Object value = column.data();
Object formatValue = TransValueUtil.getFormatData(value);
this.row.put(columnName, formatValue);
}
}
/**
* Returns the uuid-name member of insert operation.
* @return the uuid-name member of insert operation
*/
public String getUuidName() {
return uuidName;
}
/**
* Returns the row member of insert operation.
* @return the row member of insert operation
*/
public Map<String, Object> getRow() {
return row;
}
@Override
public String getOp() {
return op;
}
@Override
public TableSchema getTableSchema() {
return tableSchema;
}
/**
* For the use of serialization.
* @return the table member of update operation
*/
@JsonProperty
public String getTable() {
return tableSchema.name();
}
}
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.operations;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.Map;
import org.onosproject.ovsdb.rfc.notation.Column;
import org.onosproject.ovsdb.rfc.notation.Row;
import org.onosproject.ovsdb.rfc.schema.TableSchema;
import org.onosproject.ovsdb.rfc.utils.TransValueUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Maps;
/**
* insert operation.Refer to RFC 7047 Section 5.2.
*/
public final class Insert implements Operation {
@JsonIgnore
private final TableSchema tableSchema;
private final String op;
@JsonProperty("uuid-name")
private final String uuidName;
private final Map<String, Object> row;
/**
* Constructs a Insert object.
* @param schema TableSchema entity
* @param uuidName uuid-name
* @param row Row entity
*/
public Insert(TableSchema schema, String uuidName, Row row) {
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(uuidName, "uuid name cannot be null");
checkNotNull(row, "row cannot be null");
this.tableSchema = schema;
this.op = Operations.INSERT.op();
this.uuidName = uuidName;
this.row = Maps.newHashMap();
generateOperationRow(row);
}
/**
* Row entity convert into the row format of insert operation. Refer to RFC
* 7047 Section 5.2.
* @param row Row entity
*/
private void generateOperationRow(Row row) {
Collection<Column> columns = row.getColumns();
for (Column column : columns) {
String columnName = column.columnName();
Object value = column.data();
Object formatValue = TransValueUtil.getFormatData(value);
this.row.put(columnName, formatValue);
}
}
/**
* Returns the uuid-name member of insert operation.
* @return the uuid-name member of insert operation
*/
public String getUuidName() {
return uuidName;
}
/**
* Returns the row member of insert operation.
* @return the row member of insert operation
*/
public Map<String, Object> getRow() {
return row;
}
@Override
public String getOp() {
return op;
}
@Override
public TableSchema getTableSchema() {
return tableSchema;
}
/**
* For the use of serialization.
* @return the table member of update operation
*/
@JsonProperty
public String getTable() {
return tableSchema.name();
}
}
......
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.operations;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List;
import org.onosproject.ovsdb.rfc.notation.Condition;
import org.onosproject.ovsdb.rfc.notation.Mutation;
import org.onosproject.ovsdb.rfc.schema.TableSchema;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* mutate operation.Refer to RFC 7047 Section 5.2.
*/
public final class Mutate implements Operation {
@JsonIgnore
private final TableSchema tableSchema;
private final String op;
private final List<Condition> where;
private final List<Mutation> mutations;
/**
* Constructs a Mutate object.
* @param schema TableSchema entity
* @param where the List of Condition entity
* @param mutations the List of Mutation entity
*/
public Mutate(TableSchema schema, List<Condition> where,
List<Mutation> mutations) {
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(mutations, "mutations cannot be null");
checkNotNull(where, "where cannot be null");
this.tableSchema = schema;
this.op = Operations.MUTATE.op();
this.where = where;
this.mutations = mutations;
}
/**
* Returns the mutations member of mutate operation.
* @return the mutations member of mutate operation
*/
public List<Mutation> getMutations() {
return mutations;
}
/**
* Returns the where member of mutate operation.
* @return the where member of mutate operation
*/
public List<Condition> getWhere() {
return where;
}
@Override
public String getOp() {
return op;
}
@Override
public TableSchema getTableSchema() {
return tableSchema;
}
/**
* For the use of serialization.
* @return the table member of update operation
*/
@JsonProperty
public String getTable() {
return tableSchema.name();
}
}
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.operations;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List;
import org.onosproject.ovsdb.rfc.notation.Condition;
import org.onosproject.ovsdb.rfc.notation.Mutation;
import org.onosproject.ovsdb.rfc.schema.TableSchema;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* mutate operation.Refer to RFC 7047 Section 5.2.
*/
public final class Mutate implements Operation {
@JsonIgnore
private final TableSchema tableSchema;
private final String op;
private final List<Condition> where;
private final List<Mutation> mutations;
/**
* Constructs a Mutate object.
* @param schema TableSchema entity
* @param where the List of Condition entity
* @param mutations the List of Mutation entity
*/
public Mutate(TableSchema schema, List<Condition> where,
List<Mutation> mutations) {
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(mutations, "mutations cannot be null");
checkNotNull(where, "where cannot be null");
this.tableSchema = schema;
this.op = Operations.MUTATE.op();
this.where = where;
this.mutations = mutations;
}
/**
* Returns the mutations member of mutate operation.
* @return the mutations member of mutate operation
*/
public List<Mutation> getMutations() {
return mutations;
}
/**
* Returns the where member of mutate operation.
* @return the where member of mutate operation
*/
public List<Condition> getWhere() {
return where;
}
@Override
public String getOp() {
return op;
}
@Override
public TableSchema getTableSchema() {
return tableSchema;
}
/**
* For the use of serialization.
* @return the table member of update operation
*/
@JsonProperty
public String getTable() {
return tableSchema.name();
}
}
......
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.operations;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List;
import org.onosproject.ovsdb.rfc.notation.Condition;
import org.onosproject.ovsdb.rfc.schema.TableSchema;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* select operation.Refer to RFC 7047 Section 5.2.
*/
public final class Select implements Operation {
@JsonIgnore
private final TableSchema tableSchema;
private final String op;
private final List<Condition> where;
private final List<String> columns;
/**
* Constructs a Select object.
* @param schema TableSchema entity
* @param where the List of Condition entity
* @param columns the List of column name
*/
public Select(TableSchema schema, List<Condition> where, List<String> columns) {
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(where, "where cannot be null");
checkNotNull(columns, "columns cannot be null");
this.tableSchema = schema;
this.op = Operations.SELECT.op();
this.where = where;
this.columns = columns;
}
/**
* Returns the columns member of select operation.
* @return the columns member of select operation
*/
public List<String> getColumns() {
return columns;
}
/**
* Returns the where member of select operation.
* @return the where member of select operation
*/
public List<Condition> getWhere() {
return where;
}
@Override
public String getOp() {
return op;
}
@Override
public TableSchema getTableSchema() {
return tableSchema;
}
/**
* For the use of serialization.
* @return the table member of update operation
*/
@JsonProperty
public String getTable() {
return tableSchema.name();
}
}
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.operations;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List;
import org.onosproject.ovsdb.rfc.notation.Condition;
import org.onosproject.ovsdb.rfc.schema.TableSchema;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* select operation.Refer to RFC 7047 Section 5.2.
*/
public final class Select implements Operation {
@JsonIgnore
private final TableSchema tableSchema;
private final String op;
private final List<Condition> where;
private final List<String> columns;
/**
* Constructs a Select object.
* @param schema TableSchema entity
* @param where the List of Condition entity
* @param columns the List of column name
*/
public Select(TableSchema schema, List<Condition> where, List<String> columns) {
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(where, "where cannot be null");
checkNotNull(columns, "columns cannot be null");
this.tableSchema = schema;
this.op = Operations.SELECT.op();
this.where = where;
this.columns = columns;
}
/**
* Returns the columns member of select operation.
* @return the columns member of select operation
*/
public List<String> getColumns() {
return columns;
}
/**
* Returns the where member of select operation.
* @return the where member of select operation
*/
public List<Condition> getWhere() {
return where;
}
@Override
public String getOp() {
return op;
}
@Override
public TableSchema getTableSchema() {
return tableSchema;
}
/**
* For the use of serialization.
* @return the table member of update operation
*/
@JsonProperty
public String getTable() {
return tableSchema.name();
}
}
......
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.operations;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.onosproject.ovsdb.rfc.notation.Column;
import org.onosproject.ovsdb.rfc.notation.Condition;
import org.onosproject.ovsdb.rfc.notation.Row;
import org.onosproject.ovsdb.rfc.schema.TableSchema;
import org.onosproject.ovsdb.rfc.utils.TransValueUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Maps;
/**
* update operation.Refer to RFC 7047 Section 5.2.
*/
public final class Update implements Operation {
@JsonIgnore
private final TableSchema tableSchema;
private final String op;
private final Map<String, Object> row;
private final List<Condition> where;
/**
* Constructs a Update object.
* @param schema TableSchema entity
* @param row Row entity
* @param where the List of Condition entity
*/
public Update(TableSchema schema, Row row, List<Condition> where) {
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(row, "row cannot be null");
checkNotNull(where, "where cannot be null");
this.tableSchema = schema;
this.op = Operations.UPDATE.op();
this.row = Maps.newHashMap();
this.where = where;
generateOperationRow(row);
}
/**
* Row entity convert into the row format of update operation. Refer to RFC
* 7047 Section 5.2.
* @param row Row entity
*/
private void generateOperationRow(Row row) {
Collection<Column> columns = row.getColumns();
for (Column column : columns) {
String columnName = column.columnName();
Object value = column.data();
Object formatValue = TransValueUtil.getFormatData(value);
this.row.put(columnName, formatValue);
}
}
/**
* Returns the row member of update operation.
* @return the row member of update operation
*/
public Map<String, Object> getRow() {
return row;
}
/**
* Returns the where member of update operation.
* @return the where member of update operation
*/
public List<Condition> getWhere() {
return where;
}
@Override
public String getOp() {
return op;
}
@Override
public TableSchema getTableSchema() {
return tableSchema;
}
/**
* For the use of serialization.
* @return the table member of update operation
*/
@JsonProperty
public String getTable() {
return tableSchema.name();
}
}
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.operations;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.onosproject.ovsdb.rfc.notation.Column;
import org.onosproject.ovsdb.rfc.notation.Condition;
import org.onosproject.ovsdb.rfc.notation.Row;
import org.onosproject.ovsdb.rfc.schema.TableSchema;
import org.onosproject.ovsdb.rfc.utils.TransValueUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Maps;
/**
* update operation.Refer to RFC 7047 Section 5.2.
*/
public final class Update implements Operation {
@JsonIgnore
private final TableSchema tableSchema;
private final String op;
private final Map<String, Object> row;
private final List<Condition> where;
/**
* Constructs a Update object.
* @param schema TableSchema entity
* @param row Row entity
* @param where the List of Condition entity
*/
public Update(TableSchema schema, Row row, List<Condition> where) {
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(row, "row cannot be null");
checkNotNull(where, "where cannot be null");
this.tableSchema = schema;
this.op = Operations.UPDATE.op();
this.row = Maps.newHashMap();
this.where = where;
generateOperationRow(row);
}
/**
* Row entity convert into the row format of update operation. Refer to RFC
* 7047 Section 5.2.
* @param row Row entity
*/
private void generateOperationRow(Row row) {
Collection<Column> columns = row.getColumns();
for (Column column : columns) {
String columnName = column.columnName();
Object value = column.data();
Object formatValue = TransValueUtil.getFormatData(value);
this.row.put(columnName, formatValue);
}
}
/**
* Returns the row member of update operation.
* @return the row member of update operation
*/
public Map<String, Object> getRow() {
return row;
}
/**
* Returns the where member of update operation.
* @return the where member of update operation
*/
public List<Condition> getWhere() {
return where;
}
@Override
public String getOp() {
return op;
}
@Override
public TableSchema getTableSchema() {
return tableSchema;
}
/**
* For the use of serialization.
* @return the table member of update operation
*/
@JsonProperty
public String getTable() {
return tableSchema.name();
}
}
......
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.schema.type;
import org.onosproject.ovsdb.rfc.error.AbnormalJsonNodeException;
import org.onosproject.ovsdb.rfc.utils.ObjectMapperUtil;
import com.fasterxml.jackson.databind.JsonNode;
/**
* ColumnType Factory class.
*/
public final class ColumnTypeFactory {
/**
* Constructs a ColumnTypeFactory object. This class should not be
* instantiated.
*/
private ColumnTypeFactory() {
}
/**
* Those Json's key/value pairs.
*/
public enum Type {
KEY("key"), VALUE("value");
private final String type;
private Type(String type) {
this.type = type;
}
/**
* Returns the type for Type.
* @return the type
*/
public String type() {
return type;
}
}
/**
* JsonNode like
* "flow_tables":{"type":{"key":{"maxInteger":254,"minInteger":0,"type":
* "integer"},"min":0,"value":{"type":"uuid","refTable":"Flow_Table"},"max":
* "unlimited"}}.
* @param columnTypeJson the ColumnType JsonNode
* @return ColumnType
*/
public static ColumnType getColumnTypeFromJson(JsonNode columnTypeJson) {
if (!columnTypeJson.isObject() || !columnTypeJson.has(Type.VALUE.type())) {
return createAtomicColumnType(columnTypeJson);
} else if (!columnTypeJson.isValueNode() && columnTypeJson.has(Type.VALUE.type())) {
return createKeyValuedColumnType(columnTypeJson);
}
String message = "Abnormal ColumnType JsonNode, it should be AtomicColumnType or KeyValuedColumnType"
+ ObjectMapperUtil.convertToString(columnTypeJson);
throw new AbnormalJsonNodeException(message);
}
/**
* Create AtomicColumnType entity.
* @param json JsonNode
* @return AtomicColumnType entity
*/
private static AtomicColumnType createAtomicColumnType(JsonNode json) {
BaseType baseType = BaseTypeFactory.getBaseTypeFromJson(json, Type.KEY.type());
int min = 1;
int max = 1;
JsonNode node = json.get("min");
if (node != null && node.isNumber()) {
min = node.asInt();
}
node = json.get("max");
if (node != null) {
if (node.isNumber()) {
max = node.asInt();
} else if (node.isTextual() && "unlimited".equals(node.asText())) {
max = Integer.MAX_VALUE;
}
}
return new AtomicColumnType(baseType, min, max);
}
/**
* Create KeyValuedColumnType entity.
* @param json JsonNode
* @return KeyValuedColumnType entity
*/
private static KeyValuedColumnType createKeyValuedColumnType(JsonNode json) {
BaseType keyType = BaseTypeFactory.getBaseTypeFromJson(json, Type.KEY.type());
BaseType valueType = BaseTypeFactory.getBaseTypeFromJson(json, Type.VALUE.type());
int min = 1;
int max = 1;
JsonNode node = json.get("min");
if (node != null && node.isNumber()) {
min = node.asInt();
}
node = json.get("max");
if (node != null) {
if (node.isNumber()) {
max = node.asInt();
} else if (node.isTextual() && "unlimited".equals(node.asText())) {
max = Integer.MAX_VALUE;
}
}
return new KeyValuedColumnType(keyType, valueType, min, max);
}
}
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.schema.type;
import org.onosproject.ovsdb.rfc.error.AbnormalJsonNodeException;
import org.onosproject.ovsdb.rfc.utils.ObjectMapperUtil;
import com.fasterxml.jackson.databind.JsonNode;
/**
* ColumnType Factory class.
*/
public final class ColumnTypeFactory {
/**
* Constructs a ColumnTypeFactory object. This class should not be
* instantiated.
*/
private ColumnTypeFactory() {
}
/**
* Those Json's key/value pairs.
*/
public enum Type {
KEY("key"), VALUE("value");
private final String type;
private Type(String type) {
this.type = type;
}
/**
* Returns the type for Type.
* @return the type
*/
public String type() {
return type;
}
}
/**
* JsonNode like
* "flow_tables":{"type":{"key":{"maxInteger":254,"minInteger":0,"type":
* "integer"},"min":0,"value":{"type":"uuid","refTable":"Flow_Table"},"max":
* "unlimited"}}.
* @param columnTypeJson the ColumnType JsonNode
* @return ColumnType
*/
public static ColumnType getColumnTypeFromJson(JsonNode columnTypeJson) {
if (!columnTypeJson.isObject() || !columnTypeJson.has(Type.VALUE.type())) {
return createAtomicColumnType(columnTypeJson);
} else if (!columnTypeJson.isValueNode() && columnTypeJson.has(Type.VALUE.type())) {
return createKeyValuedColumnType(columnTypeJson);
}
String message = "Abnormal ColumnType JsonNode, it should be AtomicColumnType or KeyValuedColumnType"
+ ObjectMapperUtil.convertToString(columnTypeJson);
throw new AbnormalJsonNodeException(message);
}
/**
* Create AtomicColumnType entity.
* @param json JsonNode
* @return AtomicColumnType entity
*/
private static AtomicColumnType createAtomicColumnType(JsonNode json) {
BaseType baseType = BaseTypeFactory.getBaseTypeFromJson(json, Type.KEY.type());
int min = 1;
int max = 1;
JsonNode node = json.get("min");
if (node != null && node.isNumber()) {
min = node.asInt();
}
node = json.get("max");
if (node != null) {
if (node.isNumber()) {
max = node.asInt();
} else if (node.isTextual() && "unlimited".equals(node.asText())) {
max = Integer.MAX_VALUE;
}
}
return new AtomicColumnType(baseType, min, max);
}
/**
* Create KeyValuedColumnType entity.
* @param json JsonNode
* @return KeyValuedColumnType entity
*/
private static KeyValuedColumnType createKeyValuedColumnType(JsonNode json) {
BaseType keyType = BaseTypeFactory.getBaseTypeFromJson(json, Type.KEY.type());
BaseType valueType = BaseTypeFactory.getBaseTypeFromJson(json, Type.VALUE.type());
int min = 1;
int max = 1;
JsonNode node = json.get("min");
if (node != null && node.isNumber()) {
min = node.asInt();
}
node = json.get("max");
if (node != null) {
if (node.isNumber()) {
max = node.asInt();
} else if (node.isTextual() && "unlimited".equals(node.asText())) {
max = Integer.MAX_VALUE;
}
}
return new KeyValuedColumnType(keyType, valueType, min, max);
}
}
......
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.table;
/**
* Ovsdb table name. Refer to RFC7047's Section 9.2.
*/
public enum OvsdbTable {
INTERFACE("Interface"), BRIDGE("Bridge"), CONTROLLER("Controller"),
PORT("Port"), OPENVSWITCH("Open_vSwitch"), FLWTABLE("Flow_Table"),
QOS("Qos"), QUEUE("Queue"), MIRROR("Mirror"), MANAGER("Manager"),
NETFLOW("NetFlow"), SSL("SSL"), SFLOW("sFlow"), IPFIX("IPFIX"),
FLOWSAMPLECOLLECTORSET("Flow_Sample_Collector_Set");
private final String tableName;
private OvsdbTable(String tableName) {
this.tableName = tableName;
}
/**
* Returns the table name for OvsdbTable.
* @return the table name
*/
public String tableName() {
return tableName;
}
}
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.table;
/**
* Ovsdb table name. Refer to RFC7047's Section 9.2.
*/
public enum OvsdbTable {
INTERFACE("Interface"), BRIDGE("Bridge"), CONTROLLER("Controller"),
PORT("Port"), OPENVSWITCH("Open_vSwitch"), FLWTABLE("Flow_Table"),
QOS("Qos"), QUEUE("Queue"), MIRROR("Mirror"), MANAGER("Manager"),
NETFLOW("NetFlow"), SSL("SSL"), SFLOW("sFlow"), IPFIX("IPFIX"),
FLOWSAMPLECOLLECTORSET("Flow_Sample_Collector_Set");
private final String tableName;
private OvsdbTable(String tableName) {
this.tableName = tableName;
}
/**
* Returns the table name for OvsdbTable.
* @return the table name
*/
public String tableName() {
return tableName;
}
}
......
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.table;
/**
* The version number of tables and columns.
*/
public enum VersionNum {
VERSION100("1.0.0"), VERSION102("1.0.2"), VERSION103("1.0.3"),
VERSION104("1.0.4"), VERSION106("1.0.6"), VERSION110("1.1.0"),
VERSION130("1.3.0"), VERSION200("2.0.0"), VERSION300("3.0.0"),
VERSION330("3.3.0"), VERSION350("3.5.0"), VERSION400("4.0.0"),
VERSION510("5.1.0"), VERSION520("5.2.0"), VERSION600("6.0.0"),
VERSION610("6.1.0"), VERSION620("6.2.0"), VERSION630("6.3.0"),
VERSION640("6.4.0"), VERSION650("6.5.0"), VERSION660("6.6.0"),
VERSION670("6.7.0"), VERSION680("6.8.0"), VERSION690("6.9.0"),
VERSION6100("6.10.0"), VERSION6111("6.11.1"), VERSION710("7.1.0"),
VERSION720("7.2.0"), VERSION721("7.2.1"), VERSION730("7.3.0"),
VERSION740("7.4.0"), VERSION750("7.5.0"), VERSION770("7.7.0");
private final String versionNum;
private VersionNum(String versionNum) {
this.versionNum = versionNum;
}
/**
* Returns the version number for VersionNum.
* @return the version number
*/
public String versionNum() {
return versionNum;
}
}
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.table;
/**
* The version number of tables and columns.
*/
public enum VersionNum {
VERSION100("1.0.0"), VERSION102("1.0.2"), VERSION103("1.0.3"),
VERSION104("1.0.4"), VERSION106("1.0.6"), VERSION110("1.1.0"),
VERSION130("1.3.0"), VERSION200("2.0.0"), VERSION300("3.0.0"),
VERSION330("3.3.0"), VERSION350("3.5.0"), VERSION400("4.0.0"),
VERSION510("5.1.0"), VERSION520("5.2.0"), VERSION600("6.0.0"),
VERSION610("6.1.0"), VERSION620("6.2.0"), VERSION630("6.3.0"),
VERSION640("6.4.0"), VERSION650("6.5.0"), VERSION660("6.6.0"),
VERSION670("6.7.0"), VERSION680("6.8.0"), VERSION690("6.9.0"),
VERSION6100("6.10.0"), VERSION6111("6.11.1"), VERSION710("7.1.0"),
VERSION720("7.2.0"), VERSION721("7.2.1"), VERSION730("7.3.0"),
VERSION740("7.4.0"), VERSION750("7.5.0"), VERSION770("7.7.0");
private final String versionNum;
private VersionNum(String versionNum) {
this.versionNum = versionNum;
}
/**
* Returns the version number for VersionNum.
* @return the version number
*/
public String versionNum() {
return versionNum;
}
}
......
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.tableservice;
import org.onosproject.ovsdb.rfc.notation.Column;
import org.onosproject.ovsdb.rfc.notation.UUID;
/**
* Representation of conversion between Ovsdb table and Row.
*/
public interface OvsdbTableService {
/**
* Get Column from row.
* @param columndesc Column description
* @return Column
*/
public Column getColumnHandler(ColumnDescription columndesc);
/**
* Get Data from row.
* @param columndesc Column description
* @return Object column data
*/
public Object getDataHandler(ColumnDescription columndesc);
/**
* Set column data of row.
* @param columndesc Column description
* @param obj column data
*/
public void setDataHandler(ColumnDescription columndesc, Object obj);
/**
* Returns UUID which column name is _uuid.
* @return UUID
*/
public UUID getTableUuid();
/**
* Returns UUID Column which column name is _uuid.
* @return UUID Column
*/
public Column getTableUuidColumn();
/**
* Returns UUID which column name is _version.
* @return UUID
*/
public UUID getTableVersion();
/**
* Returns UUID Column which column name is _version.
* @return UUID Column
*/
public Column getTableVersionColumn();
}
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.tableservice;
import org.onosproject.ovsdb.rfc.notation.Column;
import org.onosproject.ovsdb.rfc.notation.UUID;
/**
* Representation of conversion between Ovsdb table and Row.
*/
public interface OvsdbTableService {
/**
* Get Column from row.
* @param columndesc Column description
* @return Column
*/
public Column getColumnHandler(ColumnDescription columndesc);
/**
* Get Data from row.
* @param columndesc Column description
* @return Object column data
*/
public Object getDataHandler(ColumnDescription columndesc);
/**
* Set column data of row.
* @param columndesc Column description
* @param obj column data
*/
public void setDataHandler(ColumnDescription columndesc, Object obj);
/**
* Returns UUID which column name is _uuid.
* @return UUID
*/
public UUID getTableUuid();
/**
* Returns UUID Column which column name is _uuid.
* @return UUID Column
*/
public Column getTableUuidColumn();
/**
* Returns UUID which column name is _version.
* @return UUID
*/
public UUID getTableVersion();
/**
* Returns UUID Column which column name is _version.
* @return UUID Column
*/
public Column getTableVersionColumn();
}
......
package org.onosproject.ovsdb.rfc.utils;
import org.onosproject.ovsdb.rfc.notation.Mutation;
import org.onosproject.ovsdb.rfc.notation.Mutation.Mutator;
public final class MutationUtil {
/**
* Constructs a MutationUtil object. Utility classes should not have a
* public or default constructor, otherwise IDE will compile unsuccessfully. This
* class should not be instantiated.
*/
private MutationUtil() {
}
/**
* Returns a Mutation that means += .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation sum(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.SUM, value);
}
/**
* Returns a Mutation that means -= .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation difference(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.DIFFERENCE, value);
}
/**
* Returns a Mutation that means *= .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation product(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.PRODUCT, value);
}
/**
* Returns a Mutation that means /= .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation quotient(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.QUOTIENT, value);
}
/**
* Returns a Mutation that means %= .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation remainder(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.REMAINDER, value);
}
/**
* Returns a Mutation that means insert .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation insert(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.INSERT, value);
}
/**
* Returns a Mutation that means delete .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation delete(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.DELETE, value);
}
}
package org.onosproject.ovsdb.rfc.utils;
import org.onosproject.ovsdb.rfc.notation.Mutation;
import org.onosproject.ovsdb.rfc.notation.Mutation.Mutator;
public final class MutationUtil {
/**
* Constructs a MutationUtil object. Utility classes should not have a
* public or default constructor, otherwise IDE will compile unsuccessfully. This
* class should not be instantiated.
*/
private MutationUtil() {
}
/**
* Returns a Mutation that means += .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation sum(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.SUM, value);
}
/**
* Returns a Mutation that means -= .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation difference(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.DIFFERENCE, value);
}
/**
* Returns a Mutation that means *= .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation product(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.PRODUCT, value);
}
/**
* Returns a Mutation that means /= .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation quotient(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.QUOTIENT, value);
}
/**
* Returns a Mutation that means %= .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation remainder(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.REMAINDER, value);
}
/**
* Returns a Mutation that means insert .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation insert(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.INSERT, value);
}
/**
* Returns a Mutation that means delete .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation delete(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.DELETE, value);
}
}
......
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.utils;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.onosproject.ovsdb.rfc.message.MonitorRequest;
import org.onosproject.ovsdb.rfc.message.MonitorSelect;
import org.onosproject.ovsdb.rfc.operations.Operation;
import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
import org.onosproject.ovsdb.rfc.schema.TableSchema;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
/**
* Params utility class. Params of the request object, refer to RFC7047's
* Section 4.1.
*/
public final class ParamUtil {
/**
* Constructs a ParamUtil object. Utility classes should not have a public
* or default constructor, otherwise IDE will compile unsuccessfully. This
* class should not be instantiated.
*/
private ParamUtil() {
}
/**
* Returns MonitorRequest, refer to RFC7047's Section 4.1.5.
* @param tableSchema entity
* @return MonitorRequest
*/
private static MonitorRequest getAllColumnsMonitorRequest(TableSchema tableSchema) {
String tableName = tableSchema.name();
Set<String> columns = tableSchema.getColumnNames();
MonitorSelect select = new MonitorSelect(true, true, true, true);
MonitorRequest monitorRequest = new MonitorRequest(tableName, columns, select);
return monitorRequest;
}
/**
* Returns params of monitor method, refer to RFC7047's Section 4.1.5.
* @param monotorId json-value, refer to RFC7047's Section 4.1.5.
* @param dbSchema DatabaseSchema entity
* @return List of Object, the params of monitor request
*/
public static List<Object> getMonitorParams(String monotorId, DatabaseSchema dbSchema) {
Set<String> tables = dbSchema.getTableNames();
Map<String, MonitorRequest> mrMap = Maps.newHashMap();
for (String tableName : tables) {
TableSchema tableSchema = dbSchema.getTableSchema(tableName);
MonitorRequest monitorRequest = getAllColumnsMonitorRequest(tableSchema);
mrMap.put(tableName, monitorRequest);
}
return Lists.newArrayList(dbSchema.name(), monotorId, mrMap);
}
/**
* Returns params of transact method, refer to RFC7047's Section 4.1.3.
* @param dbSchema DatabaseSchema entity
* @param operations operation*, refer to RFC7047's Section 4.1.3.
* @return List of Object, the params of transact request
*/
public static List<Object> getTransactParams(DatabaseSchema dbSchema, List<Operation> operations) {
List<Object> lists = Lists.newArrayList(dbSchema.name());
lists.addAll(operations);
return lists;
}
}
/*
* Copyright 2015 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.
*/
package org.onosproject.ovsdb.rfc.utils;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.onosproject.ovsdb.rfc.message.MonitorRequest;
import org.onosproject.ovsdb.rfc.message.MonitorSelect;
import org.onosproject.ovsdb.rfc.operations.Operation;
import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
import org.onosproject.ovsdb.rfc.schema.TableSchema;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
/**
* Params utility class. Params of the request object, refer to RFC7047's
* Section 4.1.
*/
public final class ParamUtil {
/**
* Constructs a ParamUtil object. Utility classes should not have a public
* or default constructor, otherwise IDE will compile unsuccessfully. This
* class should not be instantiated.
*/
private ParamUtil() {
}
/**
* Returns MonitorRequest, refer to RFC7047's Section 4.1.5.
* @param tableSchema entity
* @return MonitorRequest
*/
private static MonitorRequest getAllColumnsMonitorRequest(TableSchema tableSchema) {
String tableName = tableSchema.name();
Set<String> columns = tableSchema.getColumnNames();
MonitorSelect select = new MonitorSelect(true, true, true, true);
MonitorRequest monitorRequest = new MonitorRequest(tableName, columns, select);
return monitorRequest;
}
/**
* Returns params of monitor method, refer to RFC7047's Section 4.1.5.
* @param monotorId json-value, refer to RFC7047's Section 4.1.5.
* @param dbSchema DatabaseSchema entity
* @return List of Object, the params of monitor request
*/
public static List<Object> getMonitorParams(String monotorId, DatabaseSchema dbSchema) {
Set<String> tables = dbSchema.getTableNames();
Map<String, MonitorRequest> mrMap = Maps.newHashMap();
for (String tableName : tables) {
TableSchema tableSchema = dbSchema.getTableSchema(tableName);
MonitorRequest monitorRequest = getAllColumnsMonitorRequest(tableSchema);
mrMap.put(tableName, monitorRequest);
}
return Lists.newArrayList(dbSchema.name(), monotorId, mrMap);
}
/**
* Returns params of transact method, refer to RFC7047's Section 4.1.3.
* @param dbSchema DatabaseSchema entity
* @param operations operation*, refer to RFC7047's Section 4.1.3.
* @return List of Object, the params of transact request
*/
public static List<Object> getTransactParams(DatabaseSchema dbSchema, List<Operation> operations) {
List<Object> lists = Lists.newArrayList(dbSchema.name());
lists.addAll(operations);
return lists;
}
}
......